a
    ž˜ëj�  ã                   @  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
 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e
je
jdf  Ze ejj¡ e ejj¡ e ejj¡ dS )é    )ÚannotationsN)Úopenssl)ÚCipherAlgorithm)Úmodes)ÚBufferc                   @  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 )ÚCipherContextr   Ú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   új/mnt/bigstor/www/usecases/.venv/lib/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_tag7   s    z'AEADDecryptionContext.finalize_with_tagN)r   r   r   r   r   r$   r   r   r   r   r"   6   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__O   s    

zCipher.__init__z'Cipher[modes.ModeWithAuthenticationTag]r%   )r   r   c                 C  s   d S ©Nr   r   r   r   r   Ú	encryptora   s    zCipher.encryptorÚ_CIPHER_TYPEr   c                 C  s   d S r1   r   r   r   r   r   r2   f   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   r2   k   s    ÿÿr"   c                 C  s   d S r1   r   r   r   r   r   Ú	decryptorv   s    zCipher.decryptorc                 C  s   d S r1   r   r   r   r   r   r7   {   s    c                 C  s   t j | j| j¡S r1   )r5   r6   Zcreate_decryption_ctxr+   r,   r   r   r   r   r7   €   s    ÿ)N)r   r   r   r0   ÚtypingÚoverloadr2   r7   r   r   r   r   r*   N   s    ür*   )Ú
__future__r   r   r8   Z"cryptography.hazmat.bindings._rustr   r5   Z/cryptography.hazmat.primitives._cipheralgorithmr   Z&cryptography.hazmat.primitives.ciphersr   Zcryptography.utilsr   ÚABCMetar   r    r"   r%   ÚTypeVarÚOptionalr'   ÚGenericr*   ÚUnionZModeWithNonceZModeWithTweakZECBZModeWithInitializationVectorr3   Úregisterr6   r   r   r   r   Ú<module>   s6   	
ÿ8üÿÿ
