3 l�_J � @ s� d dl mZmZmZ d dlZd dlZd dlmZ ejej �G dd� de ��Zejej �G dd� de ��Zejej �G dd � d e ��Z ejej �G d d� de ��Zejej �G dd � d e ��Zdd� Zdd� Zdd� Zeje�eje�G dd� de ���Zeje�eje �G dd� de ���Zeje�G dd� de ��Zeje�eje�G dd� de ���Zeje�eje�G dd� de ���Zeje�eje�G dd� de ���Zeje�eje�G d d!� d!e ���Zeje�eje�eje�G d"d#� d#e ����ZdS )$� )�absolute_import�division�print_functionN)�utilsc @ s( e Zd Zejdd� �Zejdd� �ZdS )�Modec C s dS )z@ A string naming this mode (e.g. "ECB", "CBC"). N� )�selfr r �/usr/lib64/python3.6/modes.py�name s z Mode.namec C s dS )zq Checks that all the necessary invariants of this (mode, algorithm) combination are met. Nr )r � algorithmr r r �validate_for_algorithm s zMode.validate_for_algorithmN)�__name__� __module__�__qualname__�abc�abstractpropertyr �abstractmethodr r r r r r s r c @ s e Zd Zejdd� �ZdS )�ModeWithInitializationVectorc C s dS )zP The value of the initialization vector for this mode as bytes. Nr )r r r r �initialization_vector s z2ModeWithInitializationVector.initialization_vectorN)r r r r r r r r r r r s r c @ s e Zd Zejdd� �ZdS )� ModeWithTweakc C s dS )z@ The value of the tweak for this mode as bytes. Nr )r r r r �tweak) s zModeWithTweak.tweakN)r r r r r r r r r r r ' s r c @ s e Zd Zejdd� �ZdS )� ModeWithNoncec C s dS )z@ The value of the nonce for this mode as bytes. Nr )r r r r �nonce2 s zModeWithNonce.nonceN)r r r r r r r r r r r 0 s r c @ s e Zd Zejdd� �ZdS )�ModeWithAuthenticationTagc C s dS )zP The value of the tag supplied to the constructor of this mode. Nr )r r r r �tag; s zModeWithAuthenticationTag.tagN)r r r r r r r r r r r 9 s r c C s |j dkr|jdkrtd��d S )N� ZAESz=Only 128, 192, and 256 bit keys are allowed for this AES mode)�key_sizer � ValueError)r r r r r �_check_aes_key_lengthB s r c C s0 t | j�d |jkr,tdjt | j�| j���d S )N� zInvalid IV size ({}) for {}.)�lenr � block_sizer �formatr )r r r r r �_check_iv_lengthI s r# c C s t | |� t| |� d S )N)r r# )r r r r r �_check_iv_and_key_lengthR s r$ c @ s&