관리-도구
편집 파일: aead.cpython-36.pyc
3 l�_� � @ sd d dl mZmZmZ d dlmZ dZd Zdd� Zdd� Z dd � Z d d� Zdd � Zdd� Z dd� ZdS )� )�absolute_import�division�print_function)� InvalidTag� c C sr ddl m}m}m} t| |�r"dS t| |�rFdjt| j�d �jd�S t| |�sTt �djt| j�d �jd�S d S )Nr )�AESCCM�AESGCM�ChaCha20Poly1305s chacha20-poly1305z aes-{}-ccm� �asciiz aes-{}-gcm) �+cryptography.hazmat.primitives.ciphers.aeadr r r � isinstance�format�len�_key�encode�AssertionError)�cipherr r r � r �/usr/lib64/python3.6/aead.py�_aead_cipher_name s r c C st | j j|�}| j|| jjk� | j j� }| jj|| j j�}| j j||| jj| jj| jjt |t k��} | j| dk� | j j|t|��} | j| dk� | j j || j jt|�| jj�} | j| dk� |tkr�| j j || j jt|�|�} | j| dk� n4|jd��r$| j j || j j|| jj�} | j| dk� | jj|�} | jj|�}| j j|| jj| jj|| t |t k��} | j| dk� |S )Nr s -ccm)�_libZEVP_get_cipherbyname�openssl_assert�_ffi�NULLZEVP_CIPHER_CTX_new�gcZEVP_CIPHER_CTX_freeZEVP_CipherInit_ex�int�_ENCRYPTZEVP_CIPHER_CTX_set_key_lengthr �EVP_CIPHER_CTX_ctrlZEVP_CTRL_AEAD_SET_IVLEN�_DECRYPTZEVP_CTRL_AEAD_SET_TAG�endswithZfrom_buffer)�backend�cipher_name�key�nonce�tagZtag_lenZ operationZ evp_cipher�ctx�resZ nonce_ptrZkey_ptrr r r �_aead_setup sN r( c C s: | j jd�}| jj|| j j|| j j|�}| j|dk� d S )Nzint *r )r �newr �EVP_CipherUpdater r )r! r&