HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/cryptography/hazmat/primitives/ciphers/__pycache__/base.cpython-38.pyc
U

�)%a��@sBddlZddlZddlmZddlmZmZmZmZm	Z	ddl
mZddlm
Z
ddlmZddlmZGdd	�d	ejd
�ZGdd�dejd
�ZGd
d�dejd
�ZGdd�dejd
�ZGdd�dejd
�ZGdd�de�Ze�e�Gdd�de��Ze�e�e�e�e�e�Gdd�de����Ze�e�Gdd�de��ZdS)�N)�utils)�AlreadyFinalized�AlreadyUpdated�NotYetFinalized�UnsupportedAlgorithm�_Reasons)�_get_backend)�
CipherBackend)�CipherAlgorithm)�modesc@s eZdZejed�dd��ZdS)�BlockCipherAlgorithm��returncCsdS)zK
        The size of a block as an integer in bits (e.g. 64, 128).
        N���selfrr�M/usr/lib/python3/dist-packages/cryptography/hazmat/primitives/ciphers/base.py�
block_sizeszBlockCipherAlgorithm.block_sizeN)�__name__�
__module__�__qualname__�abc�abstractproperty�intrrrrrrsr)�	metaclassc@sLeZdZejeed�dd��Zejeed�dd��Zejed�dd��Z	d	S)
�
CipherContext��datarcCsdS)zk
        Processes the provided bytes through the cipher and returns the results
        as bytes.
        Nr�rrrrr�update szCipherContext.updatecCsdS)z�
        Processes the provided bytes and writes the resulting data into the
        provided buffer. Returns the number of bytes written.
        Nr�rr�bufrrr�update_into'szCipherContext.update_intor
cCsdS)zM
        Returns the results of processing the final block as bytes.
        Nrrrrr�finalize.szCipherContext.finalizeN)
rrrr�abstractmethod�bytesrrr"r#rrrrrsrc@s"eZdZejedd�dd��ZdS)�AEADCipherContextNrcCsdS)z3
        Authenticates the provided bytes.
        Nrrrrr�authenticate_additional_data6sz.AEADCipherContext.authenticate_additional_data)rrrrr$r%r'rrrrr&5sr&c@s"eZdZejeed�dd��ZdS)�AEADDecryptionContext��tagrcCsdS)z�
        Returns the results of processing the final block as bytes and allows
        delayed passing of the authentication tag.
        Nr)rr*rrr�finalize_with_tag>sz'AEADDecryptionContext.finalize_with_tagN)rrrrr$r%r+rrrrr(=sr(c@s eZdZejed�dd��ZdS)�AEADEncryptionContextr
cCsdS)zb
        Returns tag bytes. This is only available after encryption is
        finalized.
        Nrrrrrr*GszAEADEncryptionContext.tagN)rrrrrr%r*rrrrr,Fsr,c@s>eZdZdeejejd�dd�Zdd�Z	dd�Z
d	d
�ZdS)�CipherN)�	algorithm�modecCsXt|�}t|t�stdtj��t|t�s0td��|dk	rB|�|�||_	||_
||_dS)Nz0Backend object does not implement CipherBackend.z&Expected interface of CipherAlgorithm.)r�
isinstancer	rr�BACKEND_MISSING_INTERFACEr
�	TypeErrorZvalidate_for_algorithmr.r/�_backend)rr.r/�backendrrr�__init__Ps
�

zCipher.__init__cCsBt|jtj�r"|jjdk	r"td��|j�|j|j�}|j	|dd�S)Nz0Authentication tag must be None when encrypting.T��encrypt)
r0r/r�ModeWithAuthenticationTagr*�
ValueErrorr3�create_symmetric_encryption_ctxr.�	_wrap_ctx�r�ctxrrr�	encryptorgs��zCipher.encryptorcCs |j�|j|j�}|j|dd�S)NFr6)r3�create_symmetric_decryption_ctxr.r/r;r<rrr�	decryptorrs
�zCipher.decryptorcCs0t|jtj�r$|rt|�St|�Snt|�SdS�N)r0r/rr8�_AEADEncryptionContext�_AEADCipherContext�_CipherContext)rr=r7rrrr;xs

zCipher._wrap_ctx)N)rrrr
�typing�OptionalrZModer5r>r@r;rrrrr-Os�
�r-c@sBeZdZdd�Zeed�dd�Zeed�dd�Zed�d	d
�ZdS)rDcCs
||_dSrA)�_ctxr<rrrr5�sz_CipherContext.__init__rcCs|jdkrtd��|j�|�S�N�Context was already finalized.)rGrrrrrrr�s
z_CipherContext.updatecCs |jdkrtd��|j�||�SrH)rGrr"r rrrr"�s
z_CipherContext.update_intor
cCs&|jdkrtd��|j��}d|_|SrH)rGrr#rrrrr#�s


z_CipherContext.finalizeN)	rrrr5r%rrr"r#rrrrrD�srDc@speZdZdd�Zed�dd�Zeed�dd�Zeed�d	d
�Zed�dd
�Z	eed�dd�Z
edd�dd�ZdS)rCcCs"||_d|_d|_d|_d|_dS)NrF)rG�_bytes_processed�_aad_bytes_processed�_tag�_updatedr<rrrr5�s
z_AEADCipherContext.__init__)�	data_sizecCsV|jdkrtd��d|_|j|7_|j|jjjkrRtd�|jjj|jjj���dS)NrITz+{} has a maximum encrypted byte limit of {})	rGrrMrJ�_modeZ_MAX_ENCRYPTED_BYTESr9�format�name)rrNrrr�_check_limit�s
��z_AEADCipherContext._check_limitrcCs|�t|��|j�|�SrA)rR�lenrGrrrrrr�sz_AEADCipherContext.updatecCs|�t|��|j�||�SrA)rRrSrGr"r rrrr"�sz_AEADCipherContext.update_intor
cCs0|jdkrtd��|j��}|jj|_d|_|SrH)rGrr#r*rLrrrrr#�s


z_AEADCipherContext.finalizer)cCs2|jdkrtd��|j�|�}|jj|_d|_|SrH)rGrr+r*rL)rr*rrrrr+�s

z$_AEADCipherContext.finalize_with_tagNcCsn|jdkrtd��|jr td��|jt|�7_|j|jjjkr^td�	|jjj
|jjj���|j�|�dS)NrIz'Update has been called on this context.z%{} has a maximum AAD byte limit of {})rGrrMrrKrSrOZ_MAX_AAD_BYTESr9rPrQr'rrrrr'�s
��z/_AEADCipherContext.authenticate_additional_data)rrrr5rrRr%rr"r#r+r'rrrrrC�srCc@seZdZeed�dd��ZdS)rBr
cCs&|jdk	rtd��|jdk	s t�|jS)Nz4You must finalize encryption before getting the tag.)rGrrL�AssertionErrorrrrrr*�s
�z_AEADEncryptionContext.tagN)rrr�propertyr%r*rrrrrB�srB)rrE�cryptographyr�cryptography.exceptionsrrrrr�cryptography.hazmat.backendsr�'cryptography.hazmat.backends.interfacesr	Z/cryptography.hazmat.primitives._cipheralgorithmr
�&cryptography.hazmat.primitives.ciphersr�ABCMetarrr&r(r,�objectr-�register_interfacerDrCrBrrrr�<module>s*		3=