o
    <‘ði  ã                   @  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   úd/root/parts/websockify/install/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   			
	

