Your IP : 216.73.216.213


Current Path : /opt/alt/python38/lib64/python3.8/test/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/test/__pycache__/test_crypt.cpython-38.opt-1.pyc

U

i�f��
@s�ddlZddlZzddlZdZWnFek
rfZz(ejdkrJe�ee���dZee�ZW5dZ[XYnXe�	ejdkd�e�
ed�Gdd�dej���Ze�	ed�Gdd	�d	ej��Z
ed
kr�e��dS)�NZwin32zThis should only run on windowszimport succeededc@seZdZdd�ZdS)�TestWhyCryptDidNotImportcCs|�dt�dS)Nz
not supported)�assertIn�IMPORT_ERROR��self�r�4/opt/alt/python38/lib64/python3.8/test/test_crypt.py�test_import_failure_messagesz4TestWhyCryptDidNotImport.test_import_failure_messageN)�__name__�
__module__�__qualname__r	rrrrrsrzcrypt module is requiredc@s�eZdZdd�Zdd�Zdd�Zdd�Ze�e	oFe	j
e	jkpFe	je	jkd	�d
d��Z
e�e	ofe	je	jkd�d
d��Zdd�ZdS)�
CryptTestCasecCsRt�d�}t�d|�}|�||�t�dd�}|dk	rNt�d|�}|�||�dS)N�
mypasswordZab)�crypt�assertEqual)r�cr�cr2rrr�
test_crypts
zCryptTestCase.test_cryptc
Cst|�ttj�d�tjD]V}t�|�}|�t|�|jddddddh�|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_methods4s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,rrrrrr�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_roundsrrrrrr�test_blowfish_roundsNs
z"CryptTestCase.test_blowfish_roundscCs�tjtjtjfD]�}|�t��tj|dd�W5QRX|�t��tj|dd�W5QRXddddd>fD](}|�t��tj||d�W5QRXqlq|�t��tjtjdd�W5QRXtjtj	fD]*}|�
td	��tj|d
d�W5QRXq�dS)NZ4096r+g�@rrr"i�r*Zsupporti)rr.r/r'ZassertRaises�	TypeErrorr�
ValueErrorr(Z
METHOD_MD5ZassertRaisesRegex)rrr,rrr�test_invalid_rounds[s�z!CryptTestCase.test_invalid_roundsN)r
rrrr r!r)�unittest�
skipUnlessrr.rr/r1r'r3r6rrrrr
s 		�
�

r
�__main__)r$r7rr�ImportErrorZexr%ZSkipTestr0r8ZskipIfZTestCaserr
r
�mainrrrr�<module>s 


T