%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core20/2379/lib/python3/dist-packages/cryptography/__pycache__/
Upload File :
Create Path :
Current File : //snap/core20/2379/lib/python3/dist-packages/cryptography/__pycache__/fernet.cpython-38.pyc

U

�e�]d�@s�ddlmZmZmZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZddlmZmZddlmZmZmZddlmZGd	d
�d
e�ZdZGdd
�d
e�ZGdd�de�ZdS)�)�absolute_import�division�print_functionN)�utils)�InvalidSignature)�default_backend)�hashes�padding)�Cipher�
algorithms�modes)�HMACc@seZdZdS)�InvalidTokenN)�__name__�
__module__�__qualname__�rr�5/usr/lib/python3/dist-packages/cryptography/fernet.pyrsr�<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�encrypt1s
zFernet.encryptcCs�t�d|�t�tjj���}|�|�|�	�}t
t�|j�t�
|�|j���}|�|�|�	�}dt�d|�||}t|jt��|jd�}	|	�|�|	�	�}
t�||
�S)Nr+���>Q�r!)r�_check_bytesr	�PKCS7r�AES�
block_size�padder�update�finalizer
rr�CBCr�	encryptor�structZpackr
rr�SHA256rr#)rr+r,r-r6Zpadded_datar:�
ciphertextZbasic_parts�hZhmacrrrr*6s
��
zFernet._encrypt_from_partscCst�|�\}}|�|||�S�N)r�_get_unverified_token_data�
_decrypt_data)r�token�ttl�	timestampr+rrr�decryptIszFernet.decryptcCst�|�\}}|�|�|Sr?)rr@�_verify_signature)rrBrDr+rrr�extract_timestampMs
zFernet.extract_timestampc	Cs�t�d|�zt�|�}Wnttjfk
r8t�YnX|rNt�	|d�dkrRt�zt
�d|dd��\}Wnt
jk
r�t�YnX||fS)NrBr�r0��	)
rr2rr�	TypeError�binascii�Errorr�sixZ
indexbytesr;Zunpack�error)rBr+rDrrrr@Ss

z!Fernet._get_unverified_token_datacCs\t|jt��|jd�}|�|dd��z|�|dd��Wntk
rVt�YnXdS)Nr1���)	r
rrr<rr7Zverifyrr)rr+r>rrrrFds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)NrJ�rP)r(r)r�_MAX_CLOCK_SKEWrFr
rr4rrr9r�	decryptorr7r8rr	r3r5�unpadder)rr+rDrCr,r-r=rSZplaintext_paddedrTZunpaddedrrrrAls4

�



zFernet._decrypt_data)N)N)rrrr"�classmethodr'r.r*rErG�staticmethodr@rFrArrrrrs



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)rYr.)r�msgrrrr.�szMultiFernet.encryptc	Csjt�|�\}}|jD]2}z|�||d�}WqLWqtk
rDYqXqt�t�d�}|jd�|||�S)Nrr)rr@rYrArr$r%r*)rrZrDr+�f�pr-rrr�rotate�s


zMultiFernet.rotateNc	Cs<|jD],}z|�||�WStk
r0YqXqt�dSr?)rYrEr)rrZrCr[rrrrE�s
zMultiFernet.decrypt)N)rrrr"r.r]rErrrrrW�srW)Z
__future__rrrrrLr$r;r)rNZcryptographyrZcryptography.exceptionsrZcryptography.hazmat.backendsrZcryptography.hazmat.primitivesrr	Z&cryptography.hazmat.primitives.ciphersr
rrZ#cryptography.hazmat.primitives.hmacr
�	ExceptionrrR�objectrrWrrrr�<module>s m

Zerion Mini Shell 1.0