HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/asyncssh/crypto/__pycache__/chacha.cpython-310.pyc
o

�h��
@s�dZddlmZmZddlmZmZddlmZddl	m
Z
ddlmZddl
mZddlmZd	d
lmZe
��r�d�dd�Zd	�dd�Zd
Zdededededef
dd�Zdededefdd�Zdedededefdd�Zdededededef
dd�ZdZnczTddl m!Z!e!j"Z#e!j$Z%e!�&�Z'e!�(�Ze!j)Z*e!j+Z,dededededef
dd�Zdededefdd�Zdedededefd d�Zdededededef
d!d�ZdZWne-e.e/fy�d"ZYnwGd#d$�d$�Z0er�ed%d&dd	�d'Sd'S)(z.Chacha20-Poly1305 symmetric encryption handler�)�c_ulonglong�create_string_buffer)�Optional�Tuple)�InvalidSignature)�backend)�Cipher)�ChaCha20)�Poly1305�)�register_cipher��little� �key�data�nonce�ctr�returncCs(tt||rtnt|�dd����|�S)�8Encrypt/decrypt a block of data with the ChaCha20 cipherN)�mode)rr	�_CTR_1�_CTR_0�	encryptor�update)rrrr�r�I/usr/local/CyberCP/lib/python3.10/site-packages/asyncssh/crypto/chacha.py�chacha20)s
�
�rcCst|td|d�S)�Derive a Poly1305 key�r)r�_POLY1305_KEYBYTES)rrrrr�poly1305_key/�r!cCst�t||�|�S�z*Compute a Poly1305 tag for a block of data)r
�generate_tagr!)rrrrrr�poly13054r"r%�tagcCs0z
t�t||�||�WdStyYdSw)�)Verify a Poly1305 tag for a block of dataTF)r
�
verify_tagr!r)rrrr&rrr�poly1305_verify9s�r)T)�naclcCs8t|�}t|�}t|�}t|�}t||||||�|jS)r)�lenrr�_chacha20_xor_ic�raw)rrrr�datalen�result�ull_datalen�ull_ctrrrrrQscCs$tt�}tt�}t||||�|jS)r)rr r�	_chacha20r-)rr�polykey�ull_polykeylenrrrr!]scCs2tt�}tt|��}t||�}t||||�|jSr#)r�_POLY1305_BYTESrr+r!�	_poly1305r-�rrrr&r0r3rrrr%gs

cCs(tt|��}t||�}t||||�dkS)r'r)rr+r!�_poly1305_verifyr7rrrr)rs
Fc@sxeZdZdZdefdd�Zdedededeeeffd	d
�Zdededefdd�Zdededed
ede	ef
dd�Z
dS)�ChachaCipherz/Shim for Chacha20-Poly1305 symmetric encryptionrcCs,t|�d}|d|�|_||d�|_dS)N�)r+�_key�_adkey)�selfr�keylenrrr�__init__�szChachaCipher.__init__�headerrrrcCs>t|j||d�}t|j||d�}t|j|||�}|||fS)z Encrypt and sign a block of datarr)rr<r;r%�r=r@rrr&rrr�encrypt_and_sign�szChachaCipher.encrypt_and_signcCst|j||d�S)zDecrypt header datar)rr<)r=r@rrrr�decrypt_header�szChachaCipher.decrypt_headerr&cCs(t|j||||�rt|j||d�SdS)z3Verify the signature of and decrypt a block of datarN)r)r;rrArrr�verify_and_decrypt�szChachaCipher.verify_and_decryptN)�__name__�
__module__�__qualname__�__doc__�bytesr?rrBrCrrDrrrrr9�s 
�

�

���r9zchacha20-poly1305�@N)1rH�ctypesrr�typingrr�cryptography.exceptionsr�$cryptography.hazmat.backends.opensslr�&cryptography.hazmat.primitives.ciphersr�1cryptography.hazmat.primitives.ciphers.algorithmsr	�'cryptography.hazmat.primitives.poly1305r
�cipherr�poly1305_supported�to_bytesrrr rI�intrr!r%�boolr)�chacha_available�libnaclr*�crypto_stream_chacha20r2�crypto_stream_chacha20_xor_icr,�!crypto_onetimeauth_poly1305_bytesr5�$crypto_onetimeauth_poly1305_keybytes�crypto_onetimeauth_poly1305r6�"crypto_onetimeauth_poly1305_verifyr8�ImportError�OSError�AttributeErrorr9rrrr�<module>sd
��
�


��
�	�!�