Your IP : 216.73.216.196


Current Path : /opt/alt/python310/lib64/python3.10/test/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/__pycache__/test_crypt.cpython-310.opt-1.pyc

o

0�i��
@s�ddlZddlZddlmZzeddd�re�d��ddlZdZWn$eyEZzej	dkr5e�e
e���dZe
e�ZWYdZ[ndZ[wwe�ej	dkd�e�ed�Gd	d
�d
ej
���Ze�ed�Gdd
�d
ej
��Zedkrwe��dSdS)�N)�check_sanitizerT)ZaddressZmemoryz.The crypt module SEGFAULTs on ASAN/MSAN buildsZwin32zThis should only run on windowszimport succeededc@seZdZdd�ZdS)�TestWhyCryptDidNotImportcCs|�dt�dS)Nz
not supported)�assertIn�IMPORT_ERROR��self�r�6/opt/alt/python310/lib64/python3.10/test/test_crypt.py�test_import_failure_messagesz4TestWhyCryptDidNotImport.test_import_failure_messageN)�__name__�
__module__�__qualname__r
rrrr	rsrzcrypt module is requiredc@s�eZdZdd�Zdd�Zdd�Zdd�Ze�e	o#e	j
e	jvp#e	je	jvd	�d
d��Z
e�e	o3e	je	jvd�d
d��Zdd�ZdS)�
CryptTestCasecCsVt�d�}t�d|�}|�||�t�dd�}|dur)t�d|�}|�||�dSdS)N�
mypasswordZab)�crypt�assertEqual)r�cr�cr2rrr	�
test_crypts
�zCryptTestCase.test_cryptcCsl|�ttj�d�tjD]'}t�|�}|�t|�|jhd��|jr3|�|j|dt|�|j��qdS)N�@>r�����)	r�lenrZ
_saltchars�methods�mksaltr�
salt_charsZident)r�method�saltrrr	�	test_salt&s

 ��zCryptTestCase.test_saltcCsjtjD]/}t�d|�}|�t|�|j�t�d|�}|�||�t�dt�|��}|�t|�|j�qdS)NZassword)rrrrZ
total_sizer)rrrrrrr	�test_saltedcrypt.s
�zCryptTestCase.test_saltedcryptcCsN|�ttj�dk�tj�d�r|�tjtjg�dS|�tjdtj	�dS)NrZopenbsd���)
�
assertTruerrr�sys�platform�
startswithr�METHOD_BLOWFISH�METHOD_CRYPTrrrr	�test_methods7szCryptTestCase.test_methodszrequires support of SHA-2c	Cs�tjtjfD]>}dD]9}tj||d�}|�d||�|�t|�|jdtt|���t�d|�}|�	|�t�d|�}|�||�q
qdS)N)��i'i����roundsz$rounds=%d$�r)
r�
METHOD_SHA256�
METHOD_SHA512rrrrr�strr$)rrr-r rrrrr	�test_sha2_rounds>s�
��zCryptTestCase.test_sha2_roundszrequires support of BlowfishcCs�tdd�D]9}tjtjd|>d�}|�d||�|�t|�tjjddh�t�d|�}|�|�t�d|�}|�||�qdS)	Nrr.rr,z$%02d$rrr)	�rangerrr(rrrr$r)rZ
log_roundsr rrrrr	�test_blowfish_roundsQs
�z"CryptTestCase.test_blowfish_roundsc
Cs^tjtjtjfD]a}|�t��tj|dd�Wd�n1s!wY|�t��tj|dd�Wd�n1s=wYddddd>fD]}|�t��tj||d�Wd�n1scwYqJq|�t��tjtjdd�Wd�n1s�wYtjtj	fD]}|�
td	��tj|d
d�Wd�n1s�wYq�dS)NZ4096r,g�@rrr#i�r+Zsupporti)rr/r0r(ZassertRaises�	TypeErrorr�
ValueErrorr)Z
METHOD_MD5ZassertRaisesRegex)rrr-rrr	�test_invalid_rounds^s0����������z!CryptTestCase.test_invalid_roundsN)rrr
rr!r"r*�unittest�
skipUnlessrr/rr0r2r(r4r7rrrr	rs 		�
�

r�__main__)r%r8Ztest.supportrZSkipTestrr�ImportErrorZexr&r1r9ZskipIfZTestCaserrr�mainrrrr	�<module>s.

��

T�