o
    Z2h                     @  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                   @  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datar   returnbytesc                 C     dS )zk
        Processes the provided bytes through the cipher and returns the results
        as bytes.
        N selfr   r   r   |/home/skpark/git/infrasmart_work/infrasmart/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_tag7   r   z'AEADDecryptionContext.finalize_with_tagN)r%   r
   r	   r
   )r   r   r   r   r   r&   r   r   r   r   r$   6   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__O   s   


zCipher.__init__r   'Cipher[modes.ModeWithAuthenticationTag]r'   c                 C     d S Nr   r   r   r   r   	encryptora      zCipher.encryptor_CIPHER_TYPEr   c                 C  r6   r7   r   r   r   r   r   r8   f   r9   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.)
r1   r.   r   ModeWithAuthenticationTagr%   
ValueErrorrust_opensslcipherscreate_encryption_ctxr-   r   r   r   r   r8   k   s   r$   c                 C  r6   r7   r   r   r   r   r   	decryptorv   r9   zCipher.decryptorc                 C  r6   r7   r   r   r   r   r   r@   {   r9   c                 C  s   t j| j| jS r7   )r=   r>   create_decryption_ctxr-   r.   r   r   r   r   r@      s   r7   )r-   r   r.   r)   r/   r0   r	   r   )r   r5   r	   r'   )r   r:   r	   r   )r   r5   r	   r$   )r   r   r   r4   typingoverloadr8   r@   r   r   r   r   r,   N   s    r,   )
__future__r   r   rB   "cryptography.hazmat.bindings._rustr   r=   /cryptography.hazmat.primitives._cipheralgorithmr   &cryptography.hazmat.primitives.ciphersr   cryptography.utilsr   ABCMetar   r!   r$   r'   TypeVarOptionalr)   Genericr,   UnionModeWithNonceModeWithTweakECBModeWithInitializationVectorr:   registerr>   r   r   r   r   <module>   s8   	
8
