OwlCyberSecurity - MANAGER
Edit File: crypto_aead.cpython-38.pyc
U �֫[�C � @ s d dl mZmZmZ d dlmZ d dlmZm Z d dl mZ e �� Z e �� Ze �� Ze �� Ze �� Zee Ze �� Ze �� Ze �� Ze �� Ze �� Z e e Z!e �"� Z#e �$� Z%e �&� Z'e �(� Z)e �*� Z+e+e) Z,dd� Z-dd� Z.d d � Z/dd� Z0d d� Z1dd� Z2dS )� )�absolute_import�division�print_function)� exceptions)�ffi�lib)�ensurec C s( t t| t�dtjd� t| �}t |tkd�t�tjd� t t|t�pJ|dkdtjd� t t|t�olt|�t kd�t �tjd� t t|t�o�t|�t kd�t �tjd� |r�|}t|�}n tj}d}|t }t�d �}t�d |�} t�| || |||tj||� } t | dkdtjd� t�| |d �dd� S )aP Encrypt the given ``message`` using the IETF ratified chacha20poly1305 construction described in RFC7539. :param message: :type message: bytes :param aad: :type aad: bytes :param nonce: :type nonce: bytes :param key: :type key: bytes :return: authenticated ciphertext :rtype: bytes � Input message type must be bytes�Zraising�&Message must be at most {0} bytes longN�%Additional data must be bytes or None�-Nonce must be a {0} bytes long bytes sequence�+Key must be a {0} bytes long bytes sequencer �unsigned long long *�unsigned char[]�Encryption failed.)r � isinstance�bytes�exc� TypeError�len�2crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX�format� ValueError�+crypto_aead_chacha20poly1305_ietf_NPUBBYTES�*crypto_aead_chacha20poly1305_ietf_KEYBYTESr �NULL�(crypto_aead_chacha20poly1305_ietf_ABYTES�newr �)crypto_aead_chacha20poly1305_ietf_encrypt�CryptoError�buffer��message�aad�nonce�key�mlen�_aad�aalen�mxout�clen� ciphertext�res� r. �;/usr/lib/python3/dist-packages/nacl/bindings/crypto_aead.pyr F s` ���� �� �� � r c C s( t t| t�dtjd� t| �}t |tkd�t�tjd� t t|t�pJ|dkdtjd� t t|t�olt|�t kd�t �tjd� t t|t�o�t|�t kd�t �tjd� |t }t� d�}t� d |�}|r�|}t|�} n tj}d } t�||tj| ||| ||� } t | d kdtjd� t�||d �dd� S )aH Decrypt the given ``ciphertext`` using the IETF ratified chacha20poly1305 construction described in RFC7539. :param ciphertext: :type ciphertext: bytes :param aad: :type aad: bytes :param nonce: :type nonce: bytes :param key: :type key: bytes :return: message :rtype: bytes �#Input ciphertext type must be bytesr �)Ciphertext must be at most {0} bytes longNr r r r r r �Decryption failed.)r r r r r r �*_aead_chacha20poly1305_ietf_CRYPTBYTES_MAXr r r r r r r r r �)crypto_aead_chacha20poly1305_ietf_decryptr r! �r, r$ r% r&