j; Mo~G` d dl mZ d dlmZ d dlmZ d dlmZmZ d dl m Z d dlmZ d dl mZmZ d dlmZ d Z ed dd Z G d de Zd ZdZdS ) ) unhexlify)ChaCha20) _HChaCha20)Poly1305BLAKE2s)get_random_bytes) long_to_bytes)_copy_bytesbord) is_bufferc $ t dd| S )NEnum )type)enumss /builddir/build/BUILD/imunify360-venv-2.6.2/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Cipher/ChaCha20_Poly1305.py_enumr , s E""" )PROCESSING_AUTH_DATAPROCESSING_CIPHERTEXTPROCESSING_DONEc ^ e Zd ZdZd Zd Zd ZddZddZd Z d Z d Zd Zd Z d Zd ZdS )ChaCha20Poly1305CipherzChaCha20-Poly1305 and XChaCha20-Poly1305 cipher object. Do not create it directly. Use :py:func:`new` instead. :var nonce: The nonce with length 8, 12 or 24 bytes :vartype nonce: byte string c d| _ t j ||t | _ t j || | _ | j d d| _ d| _ d| _ t j | _ dS )z`Initialize a ChaCha20-Poly1305 AEAD cipher object See also `new()` at the module level.)updateencryptdecryptdigestverify)keynoncecipher)r# r$ @ r N) _nextr newr _authenticator_cipherseek_len_aad_len_ct_mac_tag _CipherStatusr _status)selfr# r$ s r __init__zChaCha20Poly1305Cipher.__init__= su 'ls%QQQ|5999" $9r c d| j vrt d | xj t | z c_ | j | dS )a Protect the associated data. Associated data (also known as *additional authenticated data* - AAD) is the piece of the message that must stay in the clear, while still allowing the receiver to verify its integrity. An example is packet headers. The associated data (possibly split into multiple segments) is fed into :meth:`update` before any call to :meth:`decrypt` or :meth:`encrypt`. If there is no associated data, :meth:`update` is not called. :param bytes/bytearray/memoryview assoc_data: A piece of associated data. There are no restrictions on its size. r z update() method cannot be calledN)r' TypeErrorr, lenr) r )r1 datas r r zChaCha20Poly1305Cipher.updateO sS 4:%%>??? T" ""4(((((r c | j t j k sJ | j dz r(| j dd| j dz z z t j | _ d S )N )r0 r/ r r, r) r r r1 s r _pad_aadzChaCha20Poly1305Cipher._pad_aade s^ |}AAAAA=4 P&&w" 8L2M'NOOO$:r Nc v d| j vrt d | j t j k r| d| _ | j || }| xj t | z c_ || j | n| j | |S )a Encrypt a piece of data. Args: plaintext(bytes/bytearray/memoryview): The data to encrypt, of any size. Keyword Args: output(bytes/bytearray/memoryview): The location where the ciphertext is written to. If ``None``, the ciphertext is returned. Returns: If ``output`` is ``None``, the ciphertext is returned as ``bytes``. Otherwise, ``None``. r z!encrypt() method cannot be calledr r! output)r' r4 r0 r/ r r<