Hacked By AnonymousFox

Current Path : /usr/lib64/python3.6/site-packages/cryptography/hazmat/primitives/ciphers/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/cryptography/hazmat/primitives/ciphers/__pycache__/aead.cpython-36.pyc

3

l�_��@sxddlmZmZmZddlZddlmZmZddlm	Z	ddl
mZGdd�de�Z
Gdd	�d	e�ZGd
d�de�ZdS)�)�absolute_import�division�print_functionN)�
exceptions�utils)�aead)�backendc@s<eZdZdZdd�Zedd��Zdd�Zd	d
�Zdd�Z	d
S)�ChaCha20Poly1305�� cCsDtj|�stjdtjj��tjd|�t|�dkr:t	d��||_
dS)Nz<ChaCha20Poly1305 is not supported by this version of OpenSSL�keyrz&ChaCha20Poly1305 key must be 32 bytes.)rZaead_cipher_supportedrZUnsupportedAlgorithmZ_ReasonsZUNSUPPORTED_CIPHERr�_check_byteslike�len�
ValueError�_key)�selfr�r�/usr/lib64/python3.6/aead.py�__init__s

zChaCha20Poly1305.__init__cCs
tjd�S)Nr)�os�urandom)�clsrrr�generate_keyszChaCha20Poly1305.generate_keycCsR|dkrd}t|�|jks(t|�|jkr0td��|j|||�tjt||||d�S)N�z1Data or associated data too long. Max 2**32 bytes�)r�	_MAX_SIZE�
OverflowError�
_check_paramsr�_encryptr)r�nonce�data�associated_datarrr�encrypt"szChaCha20Poly1305.encryptcCs.|dkrd}|j|||�tjt||||d�S)Nrr)rr�_decryptr)rrr r!rrr�decrypt/szChaCha20Poly1305.decryptcCs<tjd|�tjd|�tjd|�t|�dkr8td��dS)Nrr r!�zNonce must be 12 bytes)rr
�_check_bytesrr)rrr r!rrrr6s
zChaCha20Poly1305._check_paramsNl)
�__name__�
__module__�__qualname__rr�classmethodrr"r$rrrrrr	s

r	c@sFeZdZdZddd�Zedd��Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�AESCCMr
rrcCsRtjd|�t|�dkr td��||_t|t�s8td��|dkrHtd
��||_dS)Nrr�rz)AESCCM key must be 128, 192, or 256 bits.ztag_length must be an integer����
r%�zInvalid tag_length)rr,r)r-r.r/r0r%r1r)	rr
rrr�
isinstance�int�	TypeError�_tag_length)rrZ
tag_lengthrrrrAs
zAESCCM.__init__cCs0t|t�std��|dkr"td��tj|d�S)Nzbit_length must be an integer���z#bit_length must be 128, 192, or 256r/)r6r7r8)r2r3r4rrr)r�
bit_lengthrrrrOs

zAESCCM.generate_keycCsd|dkrd}t|�|jks(t|�|jkr0td��|j|||�|j|t|��tjt|||||j�S)Nrz1Data or associated data too long. Max 2**32 bytes)	rrrr�_validate_lengthsrrrr5)rrr r!rrrr"YszAESCCM.encryptcCs0|dkrd}|j|||�tjt|||||j�S)Nr)rrr#rr5)rrr r!rrrr$is
zAESCCM.decryptcCs(dt|�}dd||kr$td��dS)N�r
r/zData too long for nonce)rr)rrZdata_lenZl_valrrrr:rszAESCCM._validate_lengthscCsLtjd|�tjd|�tjd|�dt|�ko:dknsHtd��dS)Nrr r!��
z$Nonce must be between 7 and 13 bytes)rr
r&rr)rrr r!rrrrys
zAESCCM._check_paramsNl)r)r'r(r)rrr*rr"r$r:rrrrrr+>s

	r+c@s<eZdZdZdd�Zedd��Zdd�Zd	d
�Zdd�Z	d
S)�AESGCMr
rcCs*tjd|�t|�dkr td��||_dS)Nrrr,rz)AESGCM key must be 128, 192, or 256 bits.)rr,r)rr
rrr)rrrrrr�szAESGCM.__init__cCs0t|t�std��|dkr"td��tj|d�S)Nzbit_length must be an integerr6r7r8z#bit_length must be 128, 192, or 256r/)r6r7r8)r2r3r4rrr)rr9rrrr�s

zAESGCM.generate_keycCsR|dkrd}t|�|jks(t|�|jkr0td��|j|||�tjt||||d�S)Nrz1Data or associated data too long. Max 2**32 bytesr)rrrrrrr)rrr r!rrrr"�szAESGCM.encryptcCs.|dkrd}|j|||�tjt||||d�S)Nrr)rrr#r)rrr r!rrrr$�szAESGCM.decryptcCs<tjd|�tjd|�tjd|�t|�dkr8td��dS)Nrr r!rzNonce must be at least 1 byte)rr
r&rr)rrr r!rrrr�s
zAESGCM._check_paramsNl)
r'r(r)rrr*rr"r$rrrrrr>�s

r>)Z
__future__rrrrZcryptographyrrZ$cryptography.hazmat.backends.opensslrZ,cryptography.hazmat.backends.openssl.backendr�objectr	r+r>rrrr�<module>s0C

Hacked By AnonymousFox1.0, Coded By AnonymousFox