ok

Mini Shell

Direktori : /lib64/python3.6/site-packages/cryptography/hazmat/primitives/__pycache__/
Upload File :
Current File : //lib64/python3.6/site-packages/cryptography/hazmat/primitives/__pycache__/keywrap.cpython-36.pyc

3

l�_b�@s�ddlmZmZmZddlZddlmZddlmZddl	m
Z
ddlmZddl
mZdd	�Zdd
d�Zdd
�Zddd�Zddd�Zddd�ZGdd�de�ZdS)�)�absolute_import�division�print_functionN)�_get_backend)�Cipher)�AES)�ECB)�bytes_eqc		Cs�tt|�t�|�j�}t|�}xttd�D]h}xbt|�D]V}|j|||�}tjdtj	d|dd��d|||dA�}|dd�||<q6Wq(W|j
�dks�t�|dj|�S)N�z>Q�r��i����)
rrr�	encryptor�len�range�update�struct�pack�unpack�finalize�AssertionError�join)	�wrapping_key�a�r�backendr�n�j�i�b�r �/usr/lib64/python3.6/keywrap.py�
_wrap_cores,r"csxt|�}t|�dkrtd��t��dkr0td��t��ddkrHtd��d	}�fd
d�tdt��d�D�}t||||�S)
N��� z/The wrapping key must be a valid AES key lengthz)The key to wrap must be at least 16 bytesrrz-The key to wrap must be a multiple of 8 bytess��������csg|]}�||d��qS)rr )�.0r)�key_to_wrapr r!�
<listcomp>1sz aes_key_wrap.<locals>.<listcomp>)r#r$r%)rr�
ValueErrorrr")rr'rrrr )r'r!�aes_key_wrap%sr*c
Cs�tt|�t�|�j�}t|�}x�ttd��D]p}xjtt|��D]Z}tjdtj	d|�d|||dA�||}|j
|�}	|	dd�}|	dd�||<q>Wq,W|j�dks�t�||fS)Nr
z>Qrrrr
i����)
rrr�	decryptorr�reversedrrrrrrr)
rrrrr+rrrZatrrr r r!�_unwrap_core5s"

r-cs�t|�}t|�d
krtd��dtjdt���}dt��dd}�d|�t��dkr�tt|�t�|�j�}|j	|��}|j
�d	ks�t�|S�fd
d�tdt��d�D�}t
||||�SdS)Nr#r$r%z/The wrapping key must be a valid AES key lengths�YY�z>ir�r
csg|]}�||d��qS)rr )r&r)r'r r!r(\sz-aes_key_wrap_with_padding.<locals>.<listcomp>r)r#r$r%)rrr)rrrrrrrrrrr")rr'r�aivZpadrrrr )r'r!�aes_key_wrap_with_paddingLsr0cs�t|�}t��dkrtd��t|�dkr0td��t��dkr�tt|�t�|�j�}|j��}|j	�dkslt
�|dd�}|dd�}d}nL�fd	d
�tdt��d�D�}|jd�}	t|�}t
||	||�\}}dj|�}tjd|d
d��\}
d||
}t|dd
�d��s^d|d|
k�o.d|kn�s^|dk�rdt||d�d|��rdt��|dk�rr|S|d|�SdS)Nr#zMust be at least 16 bytesr$r%z/The wrapping key must be a valid AES key lengthr
rrcsg|]}�||d��qS)rr )r&r)�wrapped_keyr r!r(qsz/aes_key_unwrap_with_padding.<locals>.<listcomp>rz>I�s�YY�r.)r#r$r%)rr�
InvalidUnwrapr)rrrr+rrrr�popr-rrrr	)rr1rr+rr�datarrZ
encrypted_aivZmlir )r1r!�aes_key_unwrap_with_padding`s4


*&
r6cs�t|�}t��dkrtd��t��ddkr4td��t|�d
krHtd��d	}�fd
d�tdt��d�D�}|jd�}t||||�\}}t||�s�t��dj|�S)Nr$zMust be at least 24 bytesrrz-The wrapped key must be a multiple of 8 bytesr#r%z/The wrapping key must be a valid AES key lengths��������csg|]}�||d��qS)rr )r&r)r1r r!r(�sz"aes_key_unwrap.<locals>.<listcomp>r
)r#r$r%)	rrr3r)rr4r-r	r)rr1rr/rrr )r1r!�aes_key_unwrap�s

r7c@seZdZdS)r3N)�__name__�
__module__�__qualname__r r r r!r3�sr3)N)N)N)N)Z
__future__rrrrZcryptography.hazmat.backendsrZ&cryptography.hazmat.primitives.ciphersrZ1cryptography.hazmat.primitives.ciphers.algorithmsrZ,cryptography.hazmat.primitives.ciphers.modesrZ,cryptography.hazmat.primitives.constant_timer	r"r*r-r0r6r7�	Exceptionr3r r r r!�<module>s


+


Zerion Mini Shell 1.0