Your IP : 216.73.217.117


Current Path : /lib/python3/dist-packages/cryptography/hazmat/primitives/ciphers/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/cryptography/hazmat/primitives/ciphers/__pycache__/base.cpython-311.pyc

�

p�g; ��F�ddlZddlZddlmZmZmZddlmZddlm	Z	ej
rddlmZ
Gd�dej���ZGd	�d
eej���ZGd�deej���ZGd
�deej���Zejdeje	jd���ZGd�deje��Zeeje	je	jde	je	jfZGd�de��ZGd�de��ZGd�dee��ZGd�dee��Z dS)�N)�AlreadyFinalized�AlreadyUpdated�NotYetFinalized)�CipherAlgorithm)�modes)�_CipherContextc��eZdZejdedefd���Zejdededefd���Zejdefd���Z	dS)�
CipherContext�data�returnc��dS)zk
        Processes the provided bytes through the cipher and returns the results
        as bytes.
        N���selfrs  �M/usr/lib/python3/dist-packages/cryptography/hazmat/primitives/ciphers/base.py�updatezCipherContext.update������bufc��dS)z�
        Processes the provided bytes and writes the resulting data into the
        provided buffer. Returns the number of bytes written.
        Nr�rrrs   r�update_intozCipherContext.update_into rrc��dS)zM
        Returns the results of processing the final block as bytes.
        Nr�rs r�finalizezCipherContext.finalize'rrN)
�__name__�
__module__�__qualname__�abc�abstractmethod�bytesr�intrrrrrr
r
s����������5��U�������	�����E��c�������	���%��������rr
)�	metaclassc�8�eZdZejdeddfd���ZdS)�AEADCipherContextrrNc��dS)z3
        Authenticates the provided bytes.
        Nrrs  r�authenticate_additional_dataz.AEADCipherContext.authenticate_additional_data/rr)rrrrr r!r'rrrr%r%.sD�����������4��������rr%c�8�eZdZejdedefd���ZdS)�AEADDecryptionContext�tagrc��dS)z�
        Returns the results of processing the final block as bytes and allows
        delayed passing of the authentication tag.
        Nr)rr*s  r�finalize_with_tagz'AEADDecryptionContext.finalize_with_tag7rrN)rrrrr r!r,rrrr)r)6sD���������U��u��������rr)c�4�eZdZejdefd���ZdS)�AEADEncryptionContextrc��dS)zb
        Returns tag bytes. This is only available after encryption is
        finalized.
        Nrrs rr*zAEADEncryptionContext.tag@rrN)rrrr�abstractpropertyr!r*rrrr.r.?s=���������U��������rr.�ModeT)�bound�	covariantc	��eZdZ	ddededejfd�Zejddde	fd	���Z
ejdd
defd���Z
d�Z
ejdddefd
���Z
ejdd
defd���Z
d�Z
dddedeje	eeffd�ZdS)�CipherN�	algorithm�mode�backendc���t|t��std���|�1t|tj��sJ�|�|��||_||_dS)Nz&Expected interface of CipherAlgorithm.)�
isinstancer�	TypeErrorrr1�validate_for_algorithmr6r7)rr6r7r8s    r�__init__zCipher.__init__Nsl���)�_�5�5�	F��D�E�E�E����d�E�J�/�/�/�/�/��'�'�	�2�2�2�"�����	�	�	rrz'Cipher[modes.ModeWithAuthenticationTag]rc��dS�Nrrs r�	encryptorzCipher.encryptora�	��	�r�_CIPHER_TYPEc��dSr?rrs rr@zCipher.encryptorgrArc���t|jtj��r|jj�td���ddlm}|�|j	|j��}|�
|d���S)Nz0Authentication tag must be None when encrypting.r�r8T��encrypt)r:r7r�ModeWithAuthenticationTagr*�
ValueError�,cryptography.hazmat.backends.openssl.backendr8�create_symmetric_encryption_ctxr6�	_wrap_ctx�rr8�ctxs   rr@zCipher.encryptorms����d�i��!@�A�A�	��y�}�(� �F����	I�H�H�H�H�H��5�5��N�D�I�
�
���~�~�c�4�~�0�0�0rc��dSr?rrs r�	decryptorzCipher.decryptorzrArc��dSr?rrs rrPzCipher.decryptor�rArc�|�ddlm}|�|j|j��}|�|d���S)NrrEFrF)rJr8�create_symmetric_decryption_ctxr6r7rLrMs   rrPzCipher.decryptor�sJ��H�H�H�H�H�H��5�5��N�D�I�
�
���~�~�c�5�~�1�1�1rrN�_BackendCipherContextrGc��t|jtj��r |rt	|��St|��St
|��Sr?)r:r7rrH�_AEADEncryptionContext�_AEADDecryptionContextr)rrNrGs   rrLzCipher._wrap_ctx�sM��
�d�i��!@�A�A�	'��
3�-�c�2�2�2�-�c�2�2�2�!�#�&�&�&rr?)rrrrr1�typing�Anyr=�overloadr.r@r
r)rP�bool�UnionrLrrrr5r5Mst������
#�	��"������	����&�_��7��	�����_��
�_����	�����_��
1�1�1��_��7��	�����_��
�_����	�����_��
2�2�2�'�*�'�59�'�	���4�m�C�
�'�'�'�'�'�'rr5c�h�eZdZUejded<dd�Zdedefd�Zded	ede	fd
�Z
defd�ZdS)
rrT�_ctxrNrNc��||_dSr?)r^�rrNs  rr=z_CipherContext.__init__�s
����	�	�	rrc�b�|j�td���|j�|��S�N�Context was already finalized.)r^rrrs  rrz_CipherContext.update�s/���9��"�#C�D�D�D��y����%�%�%rrc�d�|j�td���|j�||��Srb)r^rrrs   rrz_CipherContext.update_into�s1���9��"�#C�D�D�D��y�$�$�T�3�/�/�/rc�r�|j�td���|j���}d|_|Srb)r^rrrs  rrz_CipherContext.finalize�s8���9��"�#C�D�D�D��y�!�!�#�#����	��r�rNrTrN)rrrrX�Optional�__annotations__r=r!rr"rrrrrrr�s��������
�/�1�
2�2�2�2�����&�5�&�U�&�&�&�&�
0��0�E�0�c�0�0�0�0�
�%������rrc��eZdZUejded<ejeed<dd�Zdeddfd	�Z	d
edefd�Z
d
ededefd
�Zdefd�Zd
eddfd�Z
dS)�_AEADCipherContextrTr^�_tagrNrNc�L�||_d|_d|_d|_d|_dS)NrF)r^�_bytes_processed�_aad_bytes_processedrk�_updatedr`s  rr=z_AEADCipherContext.__init__�s+����	� !���$%��!���	���
�
�
r�	data_sizec��|j�td���d|_|xj|z
c_|j|jjjkrAt
d�|jjj|jjj�����dS)NrcTz+{} has a maximum encrypted byte limit of {})	r^rrorm�_mode�_MAX_ENCRYPTED_BYTESrI�format�name)rrps  r�_check_limitz_AEADCipherContext._check_limit�s����9��"�#C�D�D�D���
�����*���� �4�9�?�#G�G�G��=�D�D��I�O�(�$�)�/�*N�����
�H�Grrc��|�t|����|j�J�|j�|��Sr?)rv�lenr^rrs  rrz_AEADCipherContext.update�s@�����#�d�)�)�$�$�$��y�$�$�$��y����%�%�%rrc��|�t|����|j�J�|j�||��Sr?)rvrxr^rrs   rrz_AEADCipherContext.update_into�sB�����#�d�)�)�$�$�$��y�$�$�$��y�$�$�T�3�/�/�/rc��|j�td���|j���}|jj|_d|_|Srb)r^rrr*rkrs  rrz_AEADCipherContext.finalize�sC���9��"�#C�D�D�D��y�!�!�#�#���I�M��	���	��rc��|j�td���|jrtd���|xjt|��z
c_|j|jjjkrAtd�	|jjj
|jjj�����|j�|��dS)Nrcz'Update has been called on this context.z%{} has a maximum AAD byte limit of {})r^rrorrnrxrr�_MAX_AAD_BYTESrIrtrur'rs  rr'z/_AEADCipherContext.authenticate_additional_data�s����9��"�#C�D�D�D��=�	L� �!J�K�K�K��!�!�S��Y�Y�.�!�!��$�t�y��'E�E�E��7�>�>��I�O�(�$�)�/�*H�����
�	
�	�.�.�t�4�4�4�4�4rrf)rrrrXrgrhr!r=r"rvrrrr'rrrrjrj�s��������
�/�1�
2�2�2�2�
�/�%�
 � � � �����
�c�
�d�
�
�
�
�&�5�&�U�&�&�&�&�0��0�E�0�c�0�0�0�0��%�����5��5�4�5�5�5�5�5�5rrjc��eZdZdedefd�ZdS)rWr*rc��|j�td���|j�|��}|jj|_d|_|Srb)r^rr,r*rk)rr*rs   rr,z(_AEADDecryptionContext.finalize_with_tag�sE���9��"�#C�D�D�D��y�*�*�3�/�/���I�M��	���	��rN)rrrr!r,rrrrWrW�s6�������U��u������rrWc�*�eZdZedefd���ZdS)rVrc�N�|j�td���|j�J�|jS)Nz4You must finalize encryption before getting the tag.)r^rrkrs rr*z_AEADEncryptionContext.tags7���9� �!�I���
��y�$�$�$��y�rN)rrr�propertyr!r*rrrrVrVs9������
��U�����X���rrV)!rrX�cryptography.exceptionsrrr�/cryptography.hazmat.primitives._cipheralgorithmr�&cryptography.hazmat.primitives.ciphersr�
TYPE_CHECKING�,cryptography.hazmat.backends.openssl.ciphersrrT�ABCMetar
r%r)r.�TypeVarrgr1�Genericr5r\�
ModeWithNonce�
ModeWithTweak�ECB�ModeWithInitializationVectorrBrjrWrVrrr�<module>r�s����
�
�
�
�
�
�
�����������
L�K�K�K�K�K�8�8�8�8�8�8�
���������
�����c�k�����,�����
������������-������������-��������v�~�
�&�/�%�*�-������
L'�L'�L'�L'�L'�V�^�D�
!�L'�L'�L'�^�
�L�
��
���
�	�
�*�		,���������]����095�95�95�95�95�*�95�95�95�x�����/�1F���������/�1F�����r