
    : jw                       d dl mZ d dlmZ d dlmZmZ d dlmZ d dlm	Z	 d dlm
Z
 d dlmZmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZmZmZ d dlmZ  G d de          Z G d de          Z G d de          Z G d de          Z G d dee          Z ej        e
edej         d            ej        eedej         d            ej        e	edej         d           d S )!    )annotations)utils)UnsupportedAlgorithm_Reasons)CFB)CFB8)OFB)BlockCipherAlgorithmCipherAlgorithm)Mode)ModeWithAuthenticationTag)ModeWithInitializationVector)ModeWithNonce)ModeWithTweak)_check_aes_key_length_check_iv_and_key_length_check_nonce_length)
algorithmsc                  6    e Zd Zd ZddZedd            ZeZdS )	CBCinitialization_vectorutils.Bufferc                >    t          j        d|           || _        d S )Nr   )r   _check_byteslike_initialization_vector)selfr   s     C:\Users\Terasoftware\OneDrive\Desktop\faahhh\fyndo\fyndo\venv\Lib\site-packages\cryptography/hazmat/primitives/ciphers/modes.py__init__zCBC.__init__*   s%    68MNNN&;###    returnc                    | j         S Nr   r   s    r   r   zCBC.initialization_vector.       **r   N)r   r   r    r   )	__name__
__module____qualname__namer   propertyr   r   validate_for_algorithm r   r   r   r   '   sQ        D< < < < + + + X+ 6r   r   c                  :    e Zd Zd ZddZedd            Zdd	Zd
S )XTStweakr   c                    t          j        d|           t          |          dk    rt          d          || _        d S )Nr0      z!tweak must be 128-bits (16 bytes))r   r   len
ValueError_tweak)r   r0   s     r   r   zXTS.__init__8   sC    w...u:: 	B@AAAr   r    c                    | j         S r"   )r5   r$   s    r   r0   z	XTS.tweak@   
    {r   	algorithmr   Nonec                    t          |t          j        t          j        f          rt	          d          |j        dvrt          d          d S )Nz\The AES128 and AES256 classes do not support XTS, please use the standard AES class instead.)   i   z\The XTS specification requires a 256-bit key for AES-128-XTS and 512-bit key for AES-256-XTS)
isinstancer   AES128AES256	TypeErrorkey_sizer4   r   r8   s     r   r,   zXTS.validate_for_algorithmD   si    i*"3Z5F!GHH 	2  
 Z/ 	3  	 	r   N)r0   r   r&   r8   r   r    r9   )r'   r(   r)   r*   r   r+   r0   r,   r-   r   r   r/   r/   5   sa        D       X     r   r/   c                      e Zd Zd ZeZdS )ECBN)r'   r(   r)   r*   r   r,   r-   r   r   rD   rD   R   s        D2r   rD   c                  :    e Zd Zd ZddZedd            Zdd	Zd
S )CTRnoncer   c                >    t          j        d|           || _        d S )NrG   )r   r   _nonce)r   rG   s     r   r   zCTR.__init__[   s     w...r   r    c                    | j         S r"   )rI   r$   s    r   rG   z	CTR.nonce_   r7   r   r8   r   r9   c                \    t          | |           t          | j        | j        |           d S r"   )r   r   rG   r*   rA   s     r   r,   zCTR.validate_for_algorithmc   s.    dI...DJ	9=====r   N)rG   r   r&   rB   )r'   r(   r)   r*   r   r+   rG   r,   r-   r   r   rF   rF   X   sa        D       X> > > > > >r   rF   c                  `    e Zd Zd ZdZdZ	 	 dddZedd            Zedd            Z	ddZ
dS )GCMl   ? l            Nr2   r   r   tagbytes | Nonemin_tag_lengthintc                h   t          j        d|           t          |          dk     st          |          dk    rt          d          || _        |Pt          j        d|           |dk     rt          d          t          |          |k     rt          d| d	          || _        || _        d S )
Nr         zIinitialization_vector must be between 8 and 128 bytes (64 and 1024 bits).rN      zmin_tag_length must be >= 4zAuthentication tag must be z bytes or longer.)r   r   r3   r4   r   _check_bytes_tag_min_tag_length)r   r   rN   rP   s       r   r   zGCM.__init__m   s     	68MNNN$%%) 	S1F-G-G#-M 	"   '<# 	uc***! @ !>???3xx.(  .      	-r   r    c                    | j         S r"   )rW   r$   s    r   rN   zGCM.tag   s
    yr   c                    | j         S r"   r#   r$   s    r   r   zGCM.initialization_vector   r%   r   r8   r   r9   c                    t          | |           t          |t                    st          dt          j                  |j        dz  }| j        +t          | j                  |k    rt          d| d          d S d S )Nz%GCM requires a block cipher algorithmrS   z'Authentication tag cannot be more than z bytes.)
r   r<   r
   r   r   UNSUPPORTED_CIPHER
block_sizerW   r3   r4   )r   r8   block_size_bytess      r   r,   zGCM.validate_for_algorithm   s    dI...)%9:: 	&7+   %/149 	S^^6F%F 	:J     	 	 	 	r   )Nr2   )r   r   rN   rO   rP   rQ   )r    rO   r&   rB   )r'   r(   r)   r*   _MAX_ENCRYPTED_BYTES_MAX_AAD_BYTESr   r+   rN   r   r,   r-   r   r   rM   rM   h   s        D-!N
 ! 	. . . . .6    X + + + X+     r   rM   zOFB has been moved to cryptography.hazmat.decrepit.ciphers.modes.OFB and will be removed from cryptography.hazmat.primitives.ciphers.modes in 49.0.0.r	   )r*   zCFB has been moved to cryptography.hazmat.decrepit.ciphers.modes.CFB and will be removed from cryptography.hazmat.primitives.ciphers.modes in 49.0.0.r   zCFB8 has been moved to cryptography.hazmat.decrepit.ciphers.modes.CFB8 and will be removed from cryptography.hazmat.primitives.ciphers.modes in 49.0.0.r   N)!
__future__r   cryptographyr   cryptography.exceptionsr   r   *cryptography.hazmat.decrepit.ciphers.modesr   r   r	   /cryptography.hazmat.primitives._cipheralgorithmr
   r   %cryptography.hazmat.primitives._modesr   r   r   r   r   r   r   r   &cryptography.hazmat.primitives.ciphersr   r   r/   rD   rF   rM   
deprecatedr'   DeprecatedIn47r-   r   r   <module>rj      s  
 # " " " " "       B B B B B B B B A A A A A A C C C C C C A A A A A A                                         
 > = = = = =6 6 6 6 6
& 6 6 6    -   :3 3 3 3 3$ 3 3 3> > > > >- > > > 4 4 4 4 4
&(A 4 4 4n  > 
		 	 	 	  > 
		 	 	 	  > 
		 	 	 	 	 	r   