
    Wwgs                       d dl mZ d dlZd dlZd dlmZ d dlmZ d dl	m
Z
  G d dej                        Z G d	 d
eej                        Z G d deej                        Z G d deej                        Z ej                   dej"                  e
j$                     d      Z G d dej&                  e         Zeej*                  e
j,                  e
j.                  de
j0                  e
j2                  f      Zej7                  ej8                  j                         ej7                  ej8                  j                         ej7                  ej8                  j                         y)    )annotationsN)openssl)CipherAlgorithm)modesc                      e Zd Zej                  dd       Zej                  dd       Zej                  dd       Zej                  d	d       Zy)
CipherContextc                     y)zk
        Processes the provided bytes through the cipher and returns the results
        as bytes.
        N selfdatas     b/var/www/horilla/myenv/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/base.pyupdatezCipherContext.update           c                     y)z
        Processes the provided bytes and writes the resulting data into the
        provided buffer. Returns the number of bytes written.
        Nr
   )r   r   bufs      r   update_intozCipherContext.update_into   r   r   c                     y)zM
        Returns the results of processing the final block as bytes.
        Nr
   r   s    r   finalizezCipherContext.finalize   r   r   c                     y)z
        Resets the nonce for the cipher context to the provided value.
        Raises an exception if it does not support reset or if the
        provided nonce does not have a valid length.
        Nr
   )r   nonces     r   reset_noncezCipherContext.reset_nonce$   r   r   N)r   bytesreturnr   )r   r   r   r   r   intr   r   )r   r   r   None)	__name__
__module____qualname__abcabstractmethodr   r   r   r   r
   r   r   r   r      sh      	  	 
 	 r   r   )	metaclassc                  2    e Zd Zej                  dd       Zy)AEADCipherContextc                     y)z3
        Authenticates the provided bytes.
        Nr
   r   s     r   authenticate_additional_dataz.AEADCipherContext.authenticate_additional_data.   r   r   N)r   r   r   r   )r    r!   r"   r#   r$   r)   r
   r   r   r'   r'   -   s     r   r'   c                  2    e Zd Zej                  dd       Zy)AEADDecryptionContextc                     y)z
        Returns the results of processing the final block as bytes and allows
        delayed passing of the authentication tag.
        Nr
   )r   tags     r   finalize_with_tagz'AEADDecryptionContext.finalize_with_tag6   r   r   N)r-   r   r   r   )r    r!   r"   r#   r$   r.   r
   r   r   r+   r+   5   s     r   r+   c                  <    e Zd Zeej
                  dd              Zy)AEADEncryptionContextc                     y)zb
        Returns tag bytes. This is only available after encryption is
        finalized.
        Nr
   r   s    r   r-   zAEADEncryptionContext.tag?   r   r   Nr   )r    r!   r"   propertyr#   r$   r-   r
   r   r   r0   r0   >   s"      r   r0   ModeT)bound	covariantc                      e Zd Z	 d		 	 	 	 	 	 	 d
dZej
                  	 	 	 	 dd       Zej
                  	 	 	 	 dd       Zd Zej
                  	 	 	 	 dd       Zej
                  	 	 	 	 dd       Zd Zy)CipherNc                    t        |t              st        d      |-t        |t        j                        sJ |j                  |       || _        || _        y )Nz&Expected interface of CipherAlgorithm.)
isinstancer   	TypeErrorr   r3   validate_for_algorithm	algorithmmode)r   r<   r=   backends       r   __init__zCipher.__init__N   sR     )_5DEE dEJJ///''	2"	r   c                     y Nr
   r   s    r   	encryptorzCipher.encryptor`        !$r   c                     y rA   r
   r   s    r   rB   zCipher.encryptore        r   c                    t        | j                  t        j                        r!| j                  j                  t        d      t        j                  j                  | j                  | j                        S )Nz0Authentication tag must be None when encrypting.)
r9   r=   r   ModeWithAuthenticationTagr-   
ValueErrorrust_opensslcipherscreate_encryption_ctxr<   r   s    r   rB   zCipher.encryptorj   s\    dii!@!@Ayy}}( F  ##99NNDII
 	
r   c                     y rA   r
   r   s    r   	decryptorzCipher.decryptoru   rC   r   c                     y rA   r
   r   s    r   rM   zCipher.decryptorz   rE   r   c                j    t         j                  j                  | j                  | j                        S rA   )rI   rJ   create_decryption_ctxr<   r=   r   s    r   rM   zCipher.decryptor   s(    ##99NNDII
 	
r   rA   )r<   r   r=   r3   r>   z
typing.Anyr   r   )r   'Cipher[modes.ModeWithAuthenticationTag]r   r0   )r   _CIPHER_TYPEr   r   )r   rQ   r   r+   )r    r!   r"   r?   typingoverloadrB   rM   r
   r   r   r7   r7   M   s    
 #	"  	
 
$ __$5$	$ $ __	 	
 __$5$	$ $ __	 
r   r7   )
__future__r   r#   rS   "cryptography.hazmat.bindings._rustr   rI   /cryptography.hazmat.primitives._cipheralgorithmr   &cryptography.hazmat.primitives.ciphersr   ABCMetar   r'   r+   r0   TypeVarOptionalr3   Genericr7   UnionModeWithNonceModeWithTweakECBModeWithInitializationVectorrR   registerrJ   r
   r   r   <module>rc      s/  
 # 
  F K 8ckk < - -  v~~
&//%**-
5
V^^D! 5
p 
LL		**		,   |++99 :   |33II J   |33II Jr   