ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib/python3.11/site-packages/cryptography/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/cryptography/__pycache__/fernet.cpython-311.pyc

�

�܋f�����ddlmZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZm
Z
ddlmZmZmZddlmZGd�d	e��Zd
ZGd�d��ZGd
�d��ZdS)�)�annotationsN)�utils)�InvalidSignature)�hashes�padding)�Cipher�
algorithms�modes)�HMACc��eZdZdS)�InvalidTokenN)�__name__�
__module__�__qualname__���f/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib64/python3.11/site-packages/cryptography/fernet.pyr
r
s�������Drr
�<c��eZdZ	dd d�Zed!d
���Zd"d�Zd#d�Zd$d�Z	dd%d�Z	d&d�Z
d'd�Zed(d���Z
d)d�Zd*d�ZdS)+�FernetN�key�typing.Union[bytes, str]�backend�
typing.Any�return�Nonec��	tj|��}n'#tj$r}t	d��|�d}~wwxYwt|��dkrt	d���|dd�|_|dd�|_dS)Nz4Fernet key must be 32 url-safe base64-encoded bytes.� �)�base64�urlsafe_b64decode�binascii�Error�
ValueError�len�_signing_key�_encryption_key)�selfrr�excs    r�__init__zFernet.__init__s���
	��*�3�/�/�C�C���~�	�	�	��F����
�����	�����s�8�8�r�>�>��F���
� ����H���"�2�3�3�x����s��;�6�;�bytesc�N�tjtjd����S)Nr)r �urlsafe_b64encode�os�urandom)�clss r�generate_keyzFernet.generate_key/s���'��
�2���7�7�7r�datac�j�|�|ttj������S�N��encrypt_at_time�int�time)r(r2s  r�encryptzFernet.encrypt3s&���#�#�D�#�d�i�k�k�*:�*:�;�;�;r�current_timer7c�X�tjd��}|�|||��S)Nr)r.r/�_encrypt_from_parts)r(r2r:�ivs    rr6zFernet.encrypt_at_time6s'��
�Z��^�^���'�'��l�B�?�?�?rr=c���tjd|��tjtjj�����}|�|��|�	��z}tt	j|j��tj
|�������}|�|��|�	��z}d|�dd���z|z|z}t!|jt%j����}	|	�|��|	�	��}
t)j||
z��S)Nr2����big)�length�	byteorder)r�_check_bytesr�PKCS7r	�AES�
block_size�padder�update�finalizerr'r
�CBC�	encryptor�to_bytesrr&r�SHA256r r-)r(r2r:r=rH�padded_datarL�
ciphertext�basic_parts�h�hmacs           rr<zFernet._encrypt_from_parts:s;��	��6�4�(�(�(���z�~�8�9�9�@�@�B�B���m�m�D�)�)�F�O�O�,=�,=�=����N�4�/�0�0��I�b�M�M�
�
��)�+�+�	��%�%�k�2�2�Y�5G�5G�5I�5I�I�
�
��#�#�1��#�>�>�
?��
��
�	�
��"�F�M�O�O�4�4��	��������z�z�|�|���'��d�(:�;�;�;r�token�ttl�typing.Optional[int]c��t�|��\}}|�d}n"|ttj����f}|�|||��Sr4)r�_get_unverified_token_datar7r8�
_decrypt_data)r(rTrU�	timestampr2�	time_infos      r�decryptzFernet.decryptSsW��!�;�;�E�B�B��	�4��;��I�I��c�$�)�+�+�.�.�/�I��!�!�$�	�9�=�=�=rc��|�td���t�|��\}}|�||||f��S)Nz6decrypt_at_time() can only be used with a non-None ttl)r$rrXrY)r(rTrUr:rZr2s      r�decrypt_at_timezFernet.decrypt_at_time]sT���;��H���
�!�;�;�E�B�B��	�4��!�!�$�	�C��3F�G�G�Grc�j�t�|��\}}|�|��|Sr4)rrX�_verify_signature)r(rTrZr2s    r�extract_timestampzFernet.extract_timestampgs3�� �;�;�E�B�B��	�4����t�$�$�$��r�typing.Tuple[int, bytes]c�t�t|ttf��std���	t	j|��}n!#ttjf$rt�wxYw|r|ddkrt�t|��dkrt�t�|dd�d���}||fS)Nztoken must be bytes or strr��	�rA)rC)�
isinstance�strr+�	TypeErrorr r!r"r#r
r%r7�
from_bytes)rTr2rZs   rrXz!Fernet._get_unverified_token_datams����%�#�u��.�.�	:��8�9�9�9�	��+�E�2�2�D�D���8�>�*�	�	�	���	�����	�t�A�w�$������t�9�9�q�=�=����N�N�4��!��9��N�>�>�	��$��s�A�A c���t|jtj����}|�|dd���	|�|dd���dS#t$rt�wxYw)N���)rr&rrNrI�verifyrr
)r(r2rRs   rr`zFernet._verify_signature�sz����"�F�M�O�O�4�4��	����d�s�d�����	�
�H�H�T�#�$�$�Z� � � � � ���	�	�	���	���s�A$�$A6rZr[�'typing.Optional[typing.Tuple[int, int]]c��|�*|\}}||z|krt�|tz|krt�|�|��|dd�}|dd�}tt	j|j��tj|�����	��}|�
|��}		|	|���z
}	n#t$rt�wxYwtjtjj�����}
|
�
|	��}	||
���z
}n#t$rt�wxYw|S)Nre�rl)r
�_MAX_CLOCK_SKEWr`rr	rFr'r
rK�	decryptorrIrJr$rrErG�unpadder)r(r2rZr[rUr:r=rPrr�plaintext_paddedrs�unpaddeds            rrYzFernet._decrypt_data�sm��� � )��C���3���-�-�"�"��o�-�	�9�9�"�"����t�$�$�$�
�!�B�$�Z���"�S�&�\�
���N�4�/�0�0�%�)�B�-�-�
�
�
�)�+�+�	�%�+�+�J�7�7��	��	� 2� 2� 4� 4�4�����	�	�	���	�����=���!:�;�;�D�D�F�F���?�?�#3�4�4��	���)�)�+�+�+�H�H���	�	�	���	�����s�7C�C!�/E�Er4)rrrrrr)rr+)r2r+rr+)r2r+r:r7rr+)r2r+r:r7r=r+rr+)rTrrUrVrr+)rTrrUr7r:r7rr+)rTrrr7)rTrrrb)r2r+rr)r2r+rZr7r[rnrr+)rrrr*�classmethodr1r9r6r<r\r^ra�staticmethodrXr`rYrrrrrs&������#�(�(�(�(�(�&�8�8�8��[�8�<�<�<�<�@�@�@�@�<�<�<�<�4LP�>�>�>�>�>�H�H�H�H����������\��(����!�!�!�!�!�!rrc�B�eZdZdd�Zdd�Zdd
�Zdd�Z	ddd�Zdd�Zd
S)�MultiFernet�fernets�typing.Iterable[Fernet]c�T�t|��}|std���||_dS)Nz1MultiFernet requires at least one Fernet instance)�listr$�_fernets)r(rzs  rr*zMultiFernet.__init__�s7���w�-�-���	��C���
� ��
�
�
r�msgr+rc�j�|�|ttj������Sr4r5)r(rs  rr9zMultiFernet.encrypt�s&���#�#�C��T�Y�[�[�)9�)9�:�:�:rr:r7c�D�|jd�||��S)Nr)r~r6)r(rr:s   rr6zMultiFernet.encrypt_at_time�s���}�Q��/�/��\�B�B�Brrc��t�|��\}}|jD]+}	|�||d��}n#t$rY�(wxYwt�tjd��}|jd�|||��S)Nrr)rrXr~rYr
r.r/r<)r(rrZr2�f�pr=s       r�rotatezMultiFernet.rotate�s��� �;�;�C�@�@��	�4���	�	�A�
��O�O�D�)�T�:�:������
�
�
���
������
�Z��^�^���}�Q��3�3�A�y�"�E�E�Es�A�
A�
ANrUrVc�t�|jD]*}	|�||��cS#t$rY�'wxYwt�r4)r~r\r
)r(rrUr�s    rr\zMultiFernet.decrypt�sZ����	�	�A�
��y�y��c�*�*�*�*�*���
�
�
���
�����s�#�
0�0c�v�|jD]+}	|�|||��cS#t$rY�(wxYwt�r4)r~r^r
)r(rrUr:r�s     rr^zMultiFernet.decrypt_at_time�s^����	�	�A�
��(�(��c�<�@�@�@�@�@���
�
�
���
�����s�$�
1�1)rzr{)rr+rr+)rr+r:r7rr+)rrrr+r4)rrrUrVrr+)rrrUr7r:r7rr+)	rrrr*r9r6r�r\r^rrrryry�s������� � � � �;�;�;�;�C�C�C�C�F�F�F�F�JN�����������rry)�
__future__rr r"r.r8�typing�cryptographyr�cryptography.exceptionsr�cryptography.hazmat.primitivesrr�&cryptography.hazmat.primitives.ciphersrr	r
�#cryptography.hazmat.primitives.hmacr�	Exceptionr
rqrryrrr�<module>r�sF��
#�"�"�"�"�"�
�
�
�
�����	�	�	�	�����
�
�
�
�������4�4�4�4�4�4�:�:�:�:�:�:�:�:�L�L�L�L�L�L�L�L�L�L�4�4�4�4�4�4�	�	�	�	�	�9�	�	�	���P�P�P�P�P�P�P�P�f/�/�/�/�/�/�/�/�/�/r

Zerion Mini Shell 1.0