관리-도구
편집 파일: ciphers.cpython-36.pyc
3 T��e�! � @ s� d dl mZmZmZ d dlmZ d dlmZmZm Z d dl mZ d dlm Z ejej�ejej�ejej�ejej�G dd� de�����ZdS ) � )�absolute_import�division�print_function)�utils)� InvalidTag�UnsupportedAlgorithm�_Reasons)�ciphers)�modesc @ sR e Zd ZdZdZdZdd� Zdd� Zd d � Zdd� Z d d� Z dd� Zej d�ZdS )�_CipherContext� r � � c C s� || _ || _|| _|| _d | _t| jtj�r<| jjd | _ nd| _ | j j j� }| j jj || j j j�}| j j}y|t|�t|�f }W n4 tk r� tdj|j|r�|jn|�tj��Y nX || j ||�}|| j jjk�rdj|�} |d k r�| dj|�7 } | dj| j j� �7 } t| tj��t|tj��r8| j jj|j�} njt|tj��rX| j jj|j�} nJt|tj��rx| j jj|j �} n*t|tj��r�| j jj|j �} n | j jj} | j j j!||| j jj| j jj| j jj|�}| j j"|dk� | j j j#|t$|j%��}| j j"|dk� t|tj&��r�| j j j'|| j j j(t$| �| j jj�}| j j"|dk� |j)d k �r�| j j j'|| j j j*t$|j)�|j)�}| j j"|dk� |j)| _| j j j!|| j jj| j jj| j jj|j%�| |�}| j j"|dk� | j j j+|d� || _,d S )N� r z6cipher {} in {} mode is not supported by this backend.zcipher {0.name} zin {0.name} mode z_is not supported by this backend (Your version of OpenSSL may be too old. Current version: {}.)r )-�_backendZ_cipher�_mode� _operation�_tag� isinstancer ZBlockCipherAlgorithmZ block_size�_block_size_bytes�_libZEVP_CIPHER_CTX_new�_ffi�gcZEVP_CIPHER_CTX_freeZ_cipher_registry�type�KeyErrorr �format�namer ZUNSUPPORTED_CIPHER�NULLZopenssl_version_textr ZModeWithInitializationVector�from_bufferZinitialization_vectorZ ModeWithTweakZtweakZ ModeWithNonceZnonceZEVP_CipherInit_ex�openssl_assertZEVP_CIPHER_CTX_set_key_length�len�key�GCM�EVP_CIPHER_CTX_ctrlZEVP_CTRL_AEAD_SET_IVLEN�tag�EVP_CTRL_AEAD_SET_TAGZEVP_CIPHER_CTX_set_padding�_ctx)�selfZbackendZcipher�modeZ operationZctx�registryZadapterZ evp_cipher�msgZiv_nonce�res� r, �/usr/lib64/python3.6/ciphers.py�__init__ s� z_CipherContext.__init__c C s2 t t|�| j d �}| j||�}t|d |� �S )Nr )� bytearrayr r �update_into�bytes)r'