a
    còfs  ã                   @  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   úh/home/httpd/docs/test/DocsMgr/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_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üÿÿ
