a
    `mgs                     @  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                   @  sd   e Zd ZejdddddZejddddddZejdd	d
dZejdddddZdS )CipherContextbytesdatareturnc                 C  s   dS )zk
        Processes the provided bytes through the cipher and returns the results
        as bytes.
        N selfr	   r   r   d/var/www/html/idle/venv/lib64/python3.9/site-packages/cryptography/hazmat/primitives/ciphers/base.pyupdate   s    zCipherContext.updateint)r	   bufr
   c                 C  s   dS )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   s    zCipherContext.update_intor
   c                 C  s   dS )zM
        Returns the results of processing the final block as bytes.
        Nr   r   r   r   r   finalize   s    zCipherContext.finalizeNone)noncer
   c                 C  s   dS )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$   s    zCipherContext.reset_nonceN)	__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ddZdS )AEADCipherContextr   r   r   c                 C  s   dS )z3
        Authenticates the provided bytes.
        Nr   r   r   r   r   authenticate_additional_data.   s    z.AEADCipherContext.authenticate_additional_dataN)r   r   r   r   r   r    r   r   r   r   r   -   s   r   c                   @  s"   e Zd ZejdddddZdS )AEADDecryptionContextr   )tagr
   c                 C  s   dS )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   s    z'AEADDecryptionContext.finalize_with_tagN)r   r   r   r   r   r#   r   r   r   r   r!   5   s   r!   c                   @  s$   e Zd ZeejddddZdS )AEADEncryptionContextr   r   c                 C  s   dS )zb
        Returns tag bytes. This is only available after encryption is
        finalized.
        Nr   r   r   r   r   r"   ?   s    zAEADEncryptionContext.tagN)r   r   r   propertyr   r   r"   r   r   r   r   r$   >   s   r$   ModeT)bound	covariantc                   @  s   e Zd ZddddddddZejd	d
dddZejdddddZdd Zejd	ddddZejdddddZdd ZdS )CipherNr   r&   z
typing.Anyr   )	algorithmmodebackendr
   c                 C  sD   t |tstd|d ur4t |tjs*J || || _|| _d S )Nz&Expected interface of CipherAlgorithm.)
isinstancer   	TypeErrorr   r&   Zvalidate_for_algorithmr*   r+   )r   r*   r+   r,   r   r   r   __init__N   s    

zCipher.__init__z'Cipher[modes.ModeWithAuthenticationTag]r$   )r   r
   c                 C  s   d S Nr   r   r   r   r   	encryptor`   s    zCipher.encryptor_CIPHER_TYPEr   c                 C  s   d S r0   r   r   r   r   r   r1   e   s    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.)
r-   r+   r   ZModeWithAuthenticationTagr"   
ValueErrorrust_opensslciphersZcreate_encryption_ctxr*   r   r   r   r   r1   j   s    r!   c                 C  s   d S r0   r   r   r   r   r   	decryptoru   s    zCipher.decryptorc                 C  s   d S r0   r   r   r   r   r   r6   z   s    c                 C  s   t j| j| jS r0   )r4   r5   Zcreate_decryption_ctxr*   r+   r   r   r   r   r6      s    )N)r   r   r   r/   typingoverloadr1   r6   r   r   r   r   r)   M   s    r)   )
__future__r   r   r7   Z"cryptography.hazmat.bindings._rustr   r4   Z/cryptography.hazmat.primitives._cipheralgorithmr   Z&cryptography.hazmat.primitives.ciphersr   ABCMetar   r   r!   r$   TypeVarOptionalr&   Genericr)   UnionZModeWithNonceZModeWithTweakZECBZModeWithInitializationVectorr2   registerr5   r   r   r   r   <module>   s4   	
8
