ok

Mini Shell

Direktori : /opt/alt/python38/lib64/python3.8/site-packages/cryptography/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/site-packages/cryptography/__pycache__/fernet.cpython-38.pyc

U

e�_��@s�ddlmZmZmZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZmZddlmZmZmZddlmZGdd	�d	e�Zd
ZGdd�de�ZGd
d�de�ZdS)�)�absolute_import�division�print_functionN)�InvalidSignature)�default_backend)�hashes�padding)�Cipher�
algorithms�modes)�HMACc@seZdZdS)�InvalidTokenN)�__name__�
__module__�__qualname__�rr�
/fernet.pyr
sr
�<c@s`eZdZddd�Zedd��Zdd�Zdd	�Zdd
d�Zdd
�Z	e
dd��Zdd�Zdd�Z
dS)�FernetNcCsR|dkrt�}t�|�}t|�dkr,td��|dd�|_|dd�|_||_dS)N� z4Fernet key must be 32 url-safe base64-encoded bytes.�)r�base64�urlsafe_b64decode�len�
ValueError�_signing_key�_encryption_key�_backend)�self�key�backendrrr�__init__s
�zFernet.__init__cCst�t�d��S)Nr)r�urlsafe_b64encode�os�urandom)�clsrrr�generate_key,szFernet.generate_keycCs$tt���}t�d�}|�|||�S)Nr)�int�timer#r$�_encrypt_from_parts)r�data�current_time�ivrrr�encrypt0s
zFernet.encryptcCs�t|t�std��t�tjj���}|�	|�|�
�}tt�|j�t
�|�|j���}|�	|�|�
�}dt�d|�||}t|jt��|jd�}	|	�	|�|	�
�}
t�||
�S)Nzdata must be bytes.���>Q�r )�
isinstance�bytes�	TypeErrorr�PKCS7r
�AES�
block_size�padder�update�finalizer	rr�CBCr�	encryptor�struct�packrrr�SHA256rr")rr*r+r,r7Zpadded_datar;�
ciphertextZbasic_parts�hZhmacrrrr)5s 

��
zFernet._encrypt_from_partscCst�|�\}}|�|||�S�N)r�_get_unverified_token_data�
_decrypt_data)r�token�ttl�	timestampr*rrr�decryptIszFernet.decryptcCst�|�\}}|�|�|SrA)rrB�_verify_signature)rrDrFr*rrr�extract_timestampMs
zFernet.extract_timestampc	Cs�t|t�std��zt�|�}Wnttjfk
r>t�YnX|rTt�	|d�dkrXt�zt
�d|dd��\}Wnt
jk
r�t�YnX||fS)Nztoken must be bytes.r�r/��	)
r1r2r3rr�binascii�Errorr
�sixZ
indexbytesr<�unpack�error)rDr*rFrrrrBSs


z!Fernet._get_unverified_token_datacCs\t|jt��|jd�}|�|dd��z|�|dd��Wntk
rVt�YnXdS)Nr0���)	rrrr>rr8Zverifyrr
)rr*r@rrrrHfszFernet._verify_signaturecCs�tt���}|dk	r4|||kr$t�|t|kr4t�|�|�|dd�}|dd�}tt�|j�t	�
|�|j���}|�
|�}z||��7}Wntk
r�t�YnXt�tjj���}	|	�
|�}
z|
|	��7}
Wntk
r�t�YnX|
S)NrL�rR)r'r(r
�_MAX_CLOCK_SKEWrHr	r
r5rrr:r�	decryptorr8r9rrr4r6�unpadder)rr*rFrEr+r,r?rUZplaintext_paddedrVZunpaddedrrrrCns4

�



zFernet._decrypt_data)N)N)rrrr!�classmethodr&r-r)rGrI�staticmethodrBrHrCrrrrrs



rc@s.eZdZdd�Zdd�Zdd�Zd
dd	�ZdS)�MultiFernetcCst|�}|std��||_dS)Nz1MultiFernet requires at least one Fernet instance)�listr�_fernets)rZfernetsrrrr!�s�zMultiFernet.__init__cCs|jd�|�S)Nr)r[r-)r�msgrrrr-�szMultiFernet.encryptc	Csjt�|�\}}|jD]2}z|�||d�}WqLWqtk
rDYqXqt�t�d�}|jd�|||�S)Nrr)rrBr[rCr
r#r$r))rr\rFr*�f�pr,rrr�rotate�s


zMultiFernet.rotateNc	Cs<|jD],}z|�||�WStk
r0YqXqt�dSrA)r[rGr
)rr\rEr]rrrrG�s
zMultiFernet.decrypt)N)rrrr!r-r_rGrrrrrY�srY)Z
__future__rrrrrMr#r<r(rOZcryptography.exceptionsrZcryptography.hazmat.backendsrZcryptography.hazmat.primitivesrrZ&cryptography.hazmat.primitives.ciphersr	r
rZ#cryptography.hazmat.primitives.hmacr�	Exceptionr
rT�objectrrYrrrr�<module>sp

Zerion Mini Shell 1.0