o
    Vhs                     @  s  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 dejdZG d	d
 d
eejdZG dd deejdZG dd deejdZejdeje
j ddZG dd deje Zeeje
je
jde
je
jf  Zeejj eejj eejj dS )    )annotationsN)openssl)CipherAlgorithm)modesc                   @  sL   e Zd ZejdddZejddd	Zejdd
dZejdddZdS )CipherContextdatabytesreturnc                 C     dS )zk
        Processes the provided bytes through the cipher and returns the results
        as bytes.
        N selfr   r   r   /var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/cryptography/hazmat/primitives/ciphers/base.pyupdate       zCipherContext.updatebufintc                 C  r
   )z
        Processes the provided bytes and writes the resulting data into the
        provided buffer. Returns the number of bytes written.
        Nr   )r   r   r   r   r   r   update_into   r   zCipherContext.update_intoc                 C  r
   )zM
        Returns the results of processing the final block as bytes.
        Nr   r   r   r   r   finalize   r   zCipherContext.finalizenonceNonec                 C  r
   )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   r   r   r   r   reset_nonce$   r   zCipherContext.reset_nonceN)r   r   r	   r   )r   r   r   r   r	   r   r	   r   )r   r   r	   r   )	__name__
__module____qualname__abcabstractmethodr   r   r   r   r   r   r   r   r      s    r   )	metaclassc                   @  s   e Zd ZejdddZdS )	AEADCipherContextr   r   r	   r   c                 C  r
   )z3
        Authenticates the provided bytes.
        Nr   r   r   r   r   authenticate_additional_data.   r   z.AEADCipherContext.authenticate_additional_dataN)r   r   r	   r   )r   r   r   r   r   r!   r   r   r   r   r    -       r    c                   @  s   e Zd ZejdddZdS )AEADDecryptionContexttagr   r	   c                 C  r
   )z
        Returns the results of processing the final block as bytes and allows
        delayed passing of the authentication tag.
        Nr   )r   r$   r   r   r   finalize_with_tag6   r   z'AEADDecryptionContext.finalize_with_tagN)r$   r   r	   r   )r   r   r   r   r   r%   r   r   r   r   r#   5   r"   r#   c                   @  s    e Zd ZeejdddZdS )AEADEncryptionContextr	   r   c                 C  r
   )zb
        Returns tag bytes. This is only available after encryption is
        finalized.
        Nr   r   r   r   r   r$   ?   r   zAEADEncryptionContext.tagNr   )r   r   r   propertyr   r   r$   r   r   r   r   r&   >   s    r&   ModeT)bound	covariantc                   @  sj   e Zd Z	ddd
dZejdddZejdddZdd ZejdddZejdddZdd ZdS )CipherN	algorithmr   moder(   backend
typing.Anyr	   r   c                 C  sD   t |ts	td|d urt |tjsJ || || _|| _d S )Nz&Expected interface of CipherAlgorithm.)
isinstancer   	TypeErrorr   r(   validate_for_algorithmr,   r-   )r   r,   r-   r.   r   r   r   __init__N   s   


zCipher.__init__r   'Cipher[modes.ModeWithAuthenticationTag]r&   c                 C     d S Nr   r   r   r   r   	encryptor`      zCipher.encryptor_CIPHER_TYPEr   c                 C  r5   r6   r   r   r   r   r   r7   e   r8   c                 C  s4   t | jtjr| jjd urtdtj| j	| jS )Nz0Authentication tag must be None when encrypting.)
r0   r-   r   ModeWithAuthenticationTagr$   
ValueErrorrust_opensslcipherscreate_encryption_ctxr,   r   r   r   r   r7   j   s   r#   c                 C  r5   r6   r   r   r   r   r   	decryptoru   r8   zCipher.decryptorc                 C  r5   r6   r   r   r   r   r   r?   z   r8   c                 C  s   t j| j| jS r6   )r<   r=   create_decryption_ctxr,   r-   r   r   r   r   r?      s   r6   )r,   r   r-   r(   r.   r/   r	   r   )r   r4   r	   r&   )r   r9   r	   r   )r   r4   r	   r#   )r   r   r   r3   typingoverloadr7   r?   r   r   r   r   r+   M   s    r+   )
__future__r   r   rA   "cryptography.hazmat.bindings._rustr   r<   /cryptography.hazmat.primitives._cipheralgorithmr   &cryptography.hazmat.primitives.ciphersr   ABCMetar   r    r#   r&   TypeVarOptionalr(   Genericr+   UnionModeWithNonceModeWithTweakECBModeWithInitializationVectorr9   registerr=   r   r   r   r   <module>   s6   	
8
