HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/cryptography/hazmat/primitives/ciphers/__pycache__/base.cpython-38.pyc
U

�e�]��@s�ddlmZmZmZddlZddlZddlmZddlm	Z	m
Z
mZmZm
Z
ddlmZddlmZe�ej�Gdd�de��Ze�ej�Gd	d
�d
e��Ze�ej�Gdd�de��Ze�ej�Gd
d�de��Ze�ej�Gdd�de��Ze�ej�Gdd�de��ZGdd�de�Ze�e�Gdd�de��Ze�e�e�e�e�e�Gdd�de����Ze�e�Gdd�de��ZdS)�)�absolute_import�division�print_functionN)�utils)�AlreadyFinalized�AlreadyUpdated�NotYetFinalized�UnsupportedAlgorithm�_Reasons)�
CipherBackend)�modesc@s(eZdZejdd��Zejdd��ZdS)�CipherAlgorithmcCsdS)zE
        A string naming this mode (e.g. "AES", "Camellia").
        N���selfrr�M/usr/lib/python3/dist-packages/cryptography/hazmat/primitives/ciphers/base.py�nameszCipherAlgorithm.namecCsdS)zW
        The size of the key being used as an integer in bits (e.g. 128, 256).
        Nrrrrr�key_sizeszCipherAlgorithm.key_sizeN)�__name__�
__module__�__qualname__�abc�abstractpropertyrrrrrrr
s
r
c@seZdZejdd��ZdS)�BlockCipherAlgorithmcCsdS)zK
        The size of a block as an integer in bits (e.g. 64, 128).
        Nrrrrr�
block_size%szBlockCipherAlgorithm.block_sizeN)rrrrrrrrrrr#src@s6eZdZejdd��Zejdd��Zejdd��ZdS)�
CipherContextcCsdS)zk
        Processes the provided bytes through the cipher and returns the results
        as bytes.
        Nr�r�datarrr�update.szCipherContext.updatecCsdS)z�
        Processes the provided bytes and writes the resulting data into the
        provided buffer. Returns the number of bytes written.
        Nr�rrZbufrrr�update_into5szCipherContext.update_intocCsdS)zM
        Returns the results of processing the final block as bytes.
        Nrrrrr�finalize<szCipherContext.finalizeN)rrrr�abstractmethodrr r!rrrrr,s

rc@seZdZejdd��ZdS)�AEADCipherContextcCsdS)z3
        Authenticates the provided bytes.
        Nrrrrr�authenticate_additional_dataEsz.AEADCipherContext.authenticate_additional_dataN)rrrrr"r$rrrrr#Csr#c@seZdZejdd��ZdS)�AEADDecryptionContextcCsdS)z�
        Returns the results of processing the final block as bytes and allows
        delayed passing of the authentication tag.
        Nr)r�tagrrr�finalize_with_tagNsz'AEADDecryptionContext.finalize_with_tagN)rrrrr"r'rrrrr%Lsr%c@seZdZejdd��ZdS)�AEADEncryptionContextcCsdS)zb
        Returns tag bytes. This is only available after encryption is
        finalized.
        Nrrrrrr&XszAEADEncryptionContext.tagN)rrrrrr&rrrrr(Vsr(c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�CiphercCsPt|t�stdtj��t|t�s(td��|dk	r:|�|�||_||_	||_
dS)Nz0Backend object does not implement CipherBackend.z&Expected interface of CipherAlgorithm.)�
isinstancerr	r
ZBACKEND_MISSING_INTERFACEr
�	TypeErrorZvalidate_for_algorithm�	algorithm�mode�_backend)rr,r-Zbackendrrr�__init__as
�

zCipher.__init__cCsBt|jtj�r"|jjdk	r"td��|j�|j|j�}|j	|dd�S)Nz0Authentication tag must be None when encrypting.T��encrypt)
r*r-r�ModeWithAuthenticationTagr&�
ValueErrorr.Zcreate_symmetric_encryption_ctxr,�	_wrap_ctx�r�ctxrrr�	encryptorrs��zCipher.encryptorcCs |j�|j|j�}|j|dd�S)NFr0)r.Zcreate_symmetric_decryption_ctxr,r-r4r5rrr�	decryptor}s
�zCipher.decryptorcCs0t|jtj�r$|rt|�St|�Snt|�SdS�N)r*r-rr2�_AEADEncryptionContext�_AEADCipherContext�_CipherContext)rr6r1rrrr4�s

zCipher._wrap_ctxN)rrrr/r7r8r4rrrrr)`sr)c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
r<cCs
||_dSr9)�_ctxr5rrrr/�sz_CipherContext.__init__cCs|jdkrtd��|j�|�S�N�Context was already finalized.)r=rrrrrrr�s
z_CipherContext.updatecCs |jdkrtd��|j�||�Sr>)r=rr rrrrr �s
z_CipherContext.update_intocCs&|jdkrtd��|j��}d|_|Sr>)r=rr!rrrrr!�s


z_CipherContext.finalizeN)rrrr/rr r!rrrrr<�sr<c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)r;cCs"||_d|_d|_d|_d|_dS)NrF)r=�_bytes_processed�_aad_bytes_processed�_tag�_updatedr5rrrr/�s
z_AEADCipherContext.__init__cCsV|jdkrtd��d|_|j|7_|j|jjjkrRtd�|jjj|jjj���dS)Nr?Tz+{} has a maximum encrypted byte limit of {})	r=rrCr@�_modeZ_MAX_ENCRYPTED_BYTESr3�formatr)r�	data_sizerrr�_check_limit�s
��z_AEADCipherContext._check_limitcCs|�t|��|j�|�Sr9)rG�lenr=rrrrrr�sz_AEADCipherContext.updatecCs|�t|��|j�||�Sr9)rGrHr=r rrrrr �sz_AEADCipherContext.update_intocCs0|jdkrtd��|j��}|jj|_d|_|Sr>)r=rr!r&rBrrrrr!�s


z_AEADCipherContext.finalizecCs2|jdkrtd��|j�|�}|jj|_d|_|Sr>)r=rr'r&rB)rr&rrrrr'�s

z$_AEADCipherContext.finalize_with_tagcCsn|jdkrtd��|jr td��|jt|�7_|j|jjjkr^td�	|jjj
|jjj���|j�|�dS)Nr?z'Update has been called on this context.z%{} has a maximum AAD byte limit of {})r=rrCrrArHrDZ_MAX_AAD_BYTESr3rErr$rrrrr$�s
��z/_AEADCipherContext.authenticate_additional_dataN)
rrrr/rGrr r!r'r$rrrrr;�sr;c@seZdZedd��ZdS)r:cCs|jdk	rtd��|jS)Nz4You must finalize encryption before getting the tag.)r=rrBrrrrr&�s
z_AEADEncryptionContext.tagN)rrr�propertyr&rrrrr:�sr:) Z
__future__rrrrZsixZcryptographyrZcryptography.exceptionsrrrr	r
Z'cryptography.hazmat.backends.interfacesrZ&cryptography.hazmat.primitives.ciphersrZ
add_metaclass�ABCMeta�objectr
rrr#r%r(r)Zregister_interfacer<r;r:rrrr�<module>s6




	
	-=