o
    j                     @  s   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 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G dd deejdZd#ddZd$ddZd%dd Zd&d!d"ZdS )'    )annotationsN)utils)UnsupportedAlgorithm_Reasons)BlockCipherAlgorithmCipherAlgorithmc                   @  s0   e Zd ZeejdddZejddd	Zd
S )Modereturnstrc                 C     dS )z@
        A string naming this mode (e.g. "ECB", "CBC").
        N selfr   r   k/var/www/html/fyndo/pharma/fyndo/venv/lib/python3.10/site-packages/cryptography/hazmat/primitives/_modes.pyname       z	Mode.name	algorithmr   Nonec                 C  r   )zq
        Checks that all the necessary invariants of this (mode, algorithm)
        combination are met.
        Nr   r   r   r   r   r   validate_for_algorithm   r   zMode.validate_for_algorithmN)r	   r
   )r   r   r	   r   )__name__
__module____qualname__propertyabcabstractmethodr   r   r   r   r   r   r      s    r   )	metaclassc                   @      e Zd ZeejdddZdS )ModeWithInitializationVectorr	   utils.Bufferc                 C  r   )zP
        The value of the initialization vector for this mode as bytes.
        Nr   r   r   r   r   initialization_vector"   r   z2ModeWithInitializationVector.initialization_vectorNr	   r   )r   r   r   r   r   r   r    r   r   r   r   r   !       r   c                   @  r   )ModeWithTweakr	   r   c                 C  r   )z@
        The value of the tweak for this mode as bytes.
        Nr   r   r   r   r   tweak+   r   zModeWithTweak.tweakNr!   )r   r   r   r   r   r   r$   r   r   r   r   r#   *   r"   r#   c                   @  r   )ModeWithNoncer	   r   c                 C  r   )z@
        The value of the nonce for this mode as bytes.
        Nr   r   r   r   r   nonce4   r   zModeWithNonce.nonceNr!   )r   r   r   r   r   r   r&   r   r   r   r   r%   3   r"   r%   c                   @  r   )ModeWithAuthenticationTagr	   bytes | Nonec                 C  r   )zP
        The value of the tag supplied to the constructor of this mode.
        Nr   r   r   r   r   tag=   r   zModeWithAuthenticationTag.tagN)r	   r(   )r   r   r   r   r   r   r)   r   r   r   r   r'   <   r"   r'   r   r   r   r	   r   c                 C  s$   |j dkr|jdkrtdd S d S )N   AESz=Only 128, 192, and 256 bit keys are allowed for this AES mode)key_sizer   
ValueErrorr   r   r   r   _check_aes_key_lengthE   s
   r.   r   c                 C  s4   t | j}|d |jkrtd| d| j dd S )N   zInvalid IV size () for .)lenr    
block_sizer-   r   )r   r   iv_lenr   r   r   _check_iv_lengthL   s   
r5   r&   r   r   r
   c                 C  sL   t |tst| dtjt| d |jkr$tdt|  d| dd S )N" requires a block cipher algorithmr/   zInvalid nonce size (r0   r1   )
isinstancer   r   r   UNSUPPORTED_CIPHERr2   r3   r-   )r&   r   r   r   r   r   _check_nonce_lengthT   s   
r9   c                 C  s4   t |tst|  dtjt| | t| | d S )Nr6   )r7   r   r   r   r8   r.   r5   r   r   r   r   _check_iv_and_key_length`   s   

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%   r'   r.   r5   r9   r:   r   r   r   r   <module>   s   			
	

