
    2i                    p   d dl mZ d dlZd dlmZ d dlmZmZ d dlm	Z	m
Z
  G d dej                        Z G d	 d
eej                        Z G d deej                        Z G d deej                        Z G d deej                        ZddZ	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 ddZy)    )annotationsN)utils)UnsupportedAlgorithm_Reasons)BlockCipherAlgorithmCipherAlgorithmc                  b    e Zd Zeej
                  dd              Zej
                  dd       Zy)Modec                     y)z@
        A string naming this mode (e.g. "ECB", "CBC").
        N selfs    [/var/www/html/qr/venv/lib/python3.12/site-packages/cryptography/hazmat/primitives/_modes.pynamez	Mode.name           c                     y)zq
        Checks that all the necessary invariants of this (mode, algorithm)
        combination are met.
        Nr   r   	algorithms     r   validate_for_algorithmzMode.validate_for_algorithm   r   r   N)returnstr)r   r   r   None)__name__
__module____qualname__propertyabcabstractmethodr   r   r   r   r   r
   r
      s<      
 	 r   r
   )	metaclassc                  <    e Zd Zeej
                  dd              Zy)ModeWithInitializationVectorc                     y)zP
        The value of the initialization vector for this mode as bytes.
        Nr   r   s    r   initialization_vectorz2ModeWithInitializationVector.initialization_vector"   r   r   Nr   utils.Buffer)r   r   r   r   r   r   r$   r   r   r   r"   r"   !   "      r   r"   c                  <    e Zd Zeej
                  dd              Zy)ModeWithTweakc                     y)z@
        The value of the tweak for this mode as bytes.
        Nr   r   s    r   tweakzModeWithTweak.tweak+   r   r   Nr%   )r   r   r   r   r   r   r+   r   r   r   r)   r)   *   r'   r   r)   c                  <    e Zd Zeej
                  dd              Zy)ModeWithNoncec                     y)z@
        The value of the nonce for this mode as bytes.
        Nr   r   s    r   noncezModeWithNonce.nonce4   r   r   Nr%   )r   r   r   r   r   r   r/   r   r   r   r-   r-   3   r'   r   r-   c                  <    e Zd Zeej
                  dd              Zy)ModeWithAuthenticationTagc                     y)zP
        The value of the tag supplied to the constructor of this mode.
        Nr   r   s    r   tagzModeWithAuthenticationTag.tag=   r   r   N)r   zbytes | None)r   r   r   r   r   r   r3   r   r   r   r1   r1   <   r'   r   r1   c                X    |j                   dkD  r|j                  dk(  rt        d      y y )N   AESz=Only 128, 192, and 256 bit keys are allowed for this AES mode)key_sizer   
ValueErrorr   s     r   _check_aes_key_lengthr9   E   s3    CINNe$;K
 	
 %<r   c                    t        | j                        }|dz  |j                  k7  rt        d| d| j                   d      y )N   zInvalid IV size () for .)lenr$   
block_sizer8   r   )r   r   iv_lens      r   _check_iv_lengthrA   L   sJ     ++,FzY))),VHF499+QGHH *r   c                    t        |t              st        | dt        j                        t        |       dz  |j                  k7  rt        dt        |        d| d      y )N" requires a block cipher algorithmr;   zInvalid nonce size (r<   r=   )
isinstancer   r   r   UNSUPPORTED_CIPHERr>   r?   r8   )r/   r   r   s      r   _check_nonce_lengthrF   T   sl     i!56"f67''
 	
 5zA~---/E
|6$qIJJ .r   c                    t        |t              st        |  dt        j                        t        | |       t        | |       y )NrC   )rD   r   r   r   rE   r9   rA   r   s     r   _check_iv_and_key_lengthrH   `   sF     i!56"f67''
 	
 $	*T9%r   )r   r
   r   r   r   r   )r   r"   r   r   r   r   )r/   r&   r   r   r   r   r   r   )r   r"   r   r   r   r   )
__future__r   r   cryptographyr   cryptography.exceptionsr   r   /cryptography.hazmat.primitives._cipheralgorithmr   r   ABCMetar
   r"   r)   r-   r1   r9   rA   rF   rH   r   r   r   <module>rN      s   
 # 
  BS[[  43;; DCKK DCKK  
I
&I3GI	I	K	K"	K/>	K		K	&
&	&3B	&		&r   