%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/cryptography/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/cryptography/__pycache__/fernet.cpython-312.pyc

�

�3Tf�����ddlmZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZm
Z
ddlmZmZmZddlmZGd�d	e�Zd
ZGd�d�ZGd
�d�Zy)�)�annotationsN)�utils)�InvalidSignature)�hashes�padding)�Cipher�
algorithms�modes)�HMACc��eZdZy)�InvalidTokenN)�__name__�
__module__�__qualname__���5/usr/lib/python3/dist-packages/cryptography/fernet.pyr
r
s��rr
�<c���eZdZ	d
					dd�Zedd��Zdd�Zdd�Z								dd�Z	d
					dd�Z									dd�Z
dd	�Ze				dd
��Z
dd�Z								dd�Zy)�FernetNc���	tj|�}t|�dk7rt	d��|dd|_|dd|_y#tj$r}t	d�|�d}~wwxYw)Nz4Fernet key must be 32 url-safe base64-encoded bytes.� �)�base64�urlsafe_b64decode�binascii�Error�
ValueError�len�_signing_key�_encryption_key)�self�key�backend�excs    r�__init__zFernet.__init__s{��
	��*�*�3�/�C�
�s�8�r�>��F��
� ���H���"�2�3�x�����~�~�	��F���
��	�s�A�A)�A$�$A)c�R�tjtjd��S)Nr)r�urlsafe_b64encode�os�urandom)�clss r�generate_keyzFernet.generate_key/s���'�'��
�
�2��7�7rc�\�|j|ttj���S�N��encrypt_at_time�int�time)r"�datas  r�encryptzFernet.encrypt3s ���#�#�D�#�d�i�i�k�*:�;�;rc�R�tjd�}|j|||�S)Nr)r)r*�_encrypt_from_parts)r"r3�current_time�ivs    rr0zFernet.encrypt_at_time6s$��
�Z�Z��^���'�'��l�B�?�?rc��tjd|�tjtj
j�j�}|j|�|j�z}tt	j
|j�tj|��j�}|j|�|j�z}d|jdd��z|z|z}t!|j"t%j&��}	|	j|�|	j�}
t)j*||
z�S)Nr3����big)�length�	byteorder)r�_check_bytesr�PKCS7r	�AES�
block_size�padder�update�finalizerr!r
�CBC�	encryptor�to_bytesrr r�SHA256rr()r"r3r7r8rC�padded_datarG�
ciphertext�basic_parts�h�hmacs           rr6zFernet._encrypt_from_parts:s��	���6�4�(����z�~�~�8�8�9�@�@�B���m�m�D�)�F�O�O�,=�=����N�N�4�/�/�0��I�I�b�M�
��)�+�	��%�%�k�2�Y�5G�5G�5I�I�
�
��#�#�1��#�>�
?��
��
�	�
��"�"�F�M�M�O�4��	������z�z�|���'�'��d�(:�;�;rc��tj|�\}}|�d}n|ttj��f}|j	|||�Sr.)r�_get_unverified_token_datar1r2�
_decrypt_data)r"�token�ttl�	timestampr3�	time_infos      r�decryptzFernet.decryptSsL��!�;�;�E�B��	�4��;��I��c�$�)�)�+�.�/�I��!�!�$�	�9�=�=rc�v�|�td��tj|�\}}|j||||f�S)Nz6decrypt_at_time() can only be used with a non-None ttl)rrrPrQ)r"rRrSr7rTr3s      r�decrypt_at_timezFernet.decrypt_at_time]sI���;��H��
�!�;�;�E�B��	�4��!�!�$�	�C��3F�G�Grc�X�tj|�\}}|j|�|Sr.)rrP�_verify_signature)r"rRrTr3s    r�extract_timestampzFernet.extract_timestampgs*�� �;�;�E�B��	�4����t�$��rc�:�t|ttf�std��	t	j
|�}|r|ddk7rt�t|�dkrt�tj|ddd��}||fS#ttjf$rt�wxYw)Nztoken must be bytes or strr��	�r<)r>)�
isinstance�str�bytes�	TypeErrorrrrrr
rr1�
from_bytes)rRr3rTs   rrPz!Fernet._get_unverified_token_datams����%�#�u��.��8�9�9�	��+�+�E�2�D��t�A�w�$�����t�9�q�=����N�N�4��!�9��N�>�	��$�����8�>�>�*�	���	�s�A:�: Bc���t|jtj��}|j	|dd�	|j|dd�y#t$rt�wxYw)N���)rr rrIrD�verifyrr
)r"r3rMs   rrZzFernet._verify_signature�sX����"�"�F�M�M�O�4��	����d�s���	�
�H�H�T�#�$�Z� ���	���	�s�A�A#c�t�|�%|\}}||z|krt�|tz|krt�|j|�|dd}|dd}tt	j
|j�tj|��j�}|j|�}		|	|j�z
}	tjtj
j�j!�}
|
j|	�}	||
j�z
}|S#t$rt�wxYw#t$rt�wxYw)Nr^�rf)r
�_MAX_CLOCK_SKEWrZrr	rAr!r
rF�	decryptorrDrErrr@rB�unpadder)r"r3rTrUrSr7r8rKrk�plaintext_paddedrl�unpaddeds            rrQzFernet._decrypt_data�s7��� � )��C���3���-�"�"��o�-�	�9�"�"����t�$�
�!�B�Z���"�S�\�
���N�N�4�/�/�0�%�)�)�B�-�
�
�)�+�	�%�+�+�J�7��	��	� 2� 2� 4�4���=�=����!:�!:�;�D�D�F���?�?�#3�4��	���)�)�+�+�H�����	���	���	���	�s�D�?D'�D$�'D7r.)r#�typing.Union[bytes, str]r$z
typing.Any�return�None)rprb)r3rbrprb)r3rbr7r1rprb)r3rbr7r1r8rbrprb)rRrorS�typing.Optional[int]rprb)rRrorSr1r7r1rprb)rRrorpr1)rRrorpztyping.Tuple[int, bytes])r3rbrprq)r3rbrTr1rUz'typing.Optional[typing.Tuple[int, int]]rprb)rrrr&�classmethodr,r4r0r6rVrXr[�staticmethodrPrZrQrrrrrs��#�(�
%�(��(�
�	(�&�8��8�<�@�<��<�),�<�27�<�	�<�4LP�>�-�>�4H�>�	�>�H�-�H�47�H�GJ�H�	�H����'��	!����(�!��!��!�;�	!�

�!rrc�Z�eZdZdd�Zd	d�Zd
d�Zdd�Z	d					d
d�Z								dd�Zy)�MultiFernetc�B�t|�}|std��||_y)Nz1MultiFernet requires at least one Fernet instance)�listr�_fernets)r"�fernetss  rr&zMultiFernet.__init__�s'���w�-����C��
� ��
rc�\�|j|ttj���Sr.r/)r"�msgs  rr4zMultiFernet.encrypt�s ���#�#�C��T�Y�Y�[�)9�:�:rc�@�|jdj||�S)Nr)ryr0)r"r|r7s   rr0zMultiFernet.encrypt_at_time�s���}�}�Q��/�/��\�B�Brc��tj|�\}}|jD]}	|j||d�}nt�tjd�}|jdj|||�S#t$rY�`wxYw)Nrr)rrPryrQr
r)r*r6)r"r|rTr3�f�pr8s       r�rotatezMultiFernet.rotate�s��� �;�;�C�@��	�4����	�A�
��O�O�D�)�T�:���	���
�Z�Z��^���}�}�Q��3�3�A�y�"�E�E��
 �
��
�s�A:�:	B�BNc�v�|jD]}	|j||�cSt�#t$rY�*wxYwr.)ryrVr
)r"r|rSrs    rrVzMultiFernet.decrypt�sI�����	�A�
��y�y��c�*�*�	�
��� �
��
�s�,�	8�8c�x�|jD]}	|j|||�cSt�#t$rY�+wxYwr.)ryrXr
)r"r|rSr7rs     rrXzMultiFernet.decrypt_at_time�sM�����	�A�
��(�(��c�<�@�@�	�
��� �
��
�s�-�	9�9)rzztyping.Iterable[Fernet])r|rbrprb)r|rbr7r1rprb)r|rorprbr.)r|rorSrrrprb)r|rorSr1r7r1rprb)	rrrr&r4r0r�rVrXrrrrvrv�sa�� �;�C�F�JN��+��2F��	���+��25��EH��	�rrv)�
__future__rrrr)r2�typing�cryptographyr�cryptography.exceptionsr�cryptography.hazmat.primitivesrr�&cryptography.hazmat.primitives.ciphersrr	r
�#cryptography.hazmat.primitives.hmacr�	Exceptionr
rjrrvrrr�<module>r�sU��
#�
��	��
��4�:�L�L�4�	�9�	���P�P�f/�/r

Zerion Mini Shell 1.0