Your IP : 216.73.216.85


Current Path : /opt/alt/python39/lib64/python3.9/test/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/__pycache__/test_crypt.cpython-39.opt-1.pyc

a

XC?h��
@s�ddlZddlZddlmZz&eddd�r4e�d��ddlZdZWnHey�Zz0ej	dkrje�e
e���dZe
e�ZWYdZ[n
dZ[00e�ej	dkd�e�ed�Gd	d
�d
ej
���Ze�ed�Gdd
�d
ej
��Zedkr�e��dS)�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�4/opt/alt/python39/lib64/python3.9/test/test_crypt.py�test_import_failure_messagesz4TestWhyCryptDidNotImport.test_import_failure_messageN)�__name__�
__module__�__qualname__r
rrrr	rsrzcrypt module is requiredc@s�eZdZdd�Zdd�Zdd�Zdd�Ze�e	oFe	j
e	jvpFe	je	jvd	�d
d��Z
e�e	ofe	je	jvd�d
d��Zdd�ZdS)�
CryptTestCasecCsRt�d�}t�d|�}|�||�t�dd�}|durNt�d|�}|�||�dS)N�
mypasswordZab)�crypt�assertEqual)r�cr�cr2rrr	�
test_crypts
zCryptTestCase.test_cryptcCsl|�ttj�d�tjD]N}t�|�}|�t|�|jhd��|jr|�|j|dt|�|j��qdS)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_saltedcryptcCsL|�ttj�dk�tj�d�r4|�tjtjg�n|�tjdtj	�dS)NrZopenbsd���)
�
assertTruerrr�sys�platform�
startswithr�METHOD_BLOWFISH�METHOD_CRYPTrrrr	�test_methods7szCryptTestCase.test_methodszrequires support of SHA-2c	Cs�tjtjfD]|}dD]r}tj||d�}|�d||�|�t|�|jdtt|���t�d|�}|�	|�t�d|�}|�||�qqdS)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]r}tjtjd|>d�}|�d||�|�t|�tjjddh�t�d|�}|�|�t�d|�}|�||�q
dS)	Nrr.rr,z$%02d$rrr)	�rangerrr(rrrr$r)rZ
log_roundsr rrrrr	�test_blowfish_roundsQs
z"CryptTestCase.test_blowfish_roundsc
CsdtjtjtjfD]�}|�t��tj|dd�Wd�n1sB0Y|�t��tj|dd�Wd�n1sz0Yddddd>fD]<}|�t��tj||d�Wd�q�1s�0Yq�q|�t�� tjtjdd�Wd�n1�s0Ytjtj	fD]B}|�
td	��tj|d
d�Wd�n1�sR0Y�qdS)NZ4096r,g�@rrr#i�r+Zsupporti)rr/r0r(ZassertRaises�	TypeErrorr�
ValueErrorr)Z
METHOD_MD5ZassertRaisesRegex)rrr-rrr	�test_invalid_rounds^s�,,00z!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