| Server IP : 35.80.110.71 / Your IP : 216.73.216.221 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /lib/python3/dist-packages/Cryptodome/Cipher/__pycache__/ |
Upload File : |
�
��e* � � � d dl mZ d dlmZ d dlmZmZmZmZm Z m
Z
mZmZm
Z
edd� Zd� Z G d� de� Zd � Zd
� ZdZdZy
)� )�get_random_bytes)�_copy_bytes) �load_pycryptodome_raw_lib�create_string_buffer�get_raw_buffer�VoidPointer�SmartPointer�c_size_t�c_uint8_ptr�c_ulong�is_writeable_bufferzCryptodome.Cipher._chacha20a�
int chacha20_init(void **pState,
const uint8_t *key,
size_t keySize,
const uint8_t *nonce,
size_t nonceSize);
int chacha20_destroy(void *state);
int chacha20_encrypt(void *state,
const uint8_t in[],
uint8_t out[],
size_t len);
int chacha20_seek(void *state,
unsigned long block_high,
unsigned long block_low,
unsigned offset);
int hchacha20( const uint8_t key[32],
const uint8_t nonce16[16],
uint8_t subkey[32]);
c �� � t | � dk( sJ �t |� dk( sJ �t d� }t j t | � t |� t |� � }|rt d|z � �|S )N� � z,Error %d when deriving subkey with HChaCha20)�len� bytearray�_raw_chacha20_lib� hchacha20r �
ValueError)�key�nonce�subkey�results �</usr/lib/python3/dist-packages/Cryptodome/Cipher/ChaCha20.py�
_HChaCha20r B sp � ��s�8�r�>��>��u�:�����
�r�]�F�
�
(�
(��C� ��E�"��F�#�%�F� ��G�&�P�Q�Q��M� c �6 � e Zd ZdZdZd� Zd d�Zd� Zd d�Zd� Z y)
�ChaCha20Cipherz�ChaCha20 (or XChaCha20) 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: bytes
� c �6 � t dd|� | _ t |� dk( rt ||dd � }d|dd z }d| _ nd| _ | j }d| _ t
� | _ t j | j j � t |� t t |� � |t t |� � � }|rt d|| j fz � �t | j j � t j � | _ y) z\Initialize a ChaCha20/XChaCha20 cipher object
See also `new()` at the module level.N� r � � XChaCha20�ChaCha20)�encrypt�decryptz"Error %d instantiating a %s cipher)r r r r �_name�_nextr �_stater �
chacha20_init�
address_ofr r
r r �get�chacha20_destroy)�selfr r r s r �__init__zChaCha20Cipher.__init__\ s� � �
!��t�U�3��
� �u�:����S�%���*�-�C��%���*�,�E�$�D�J�#�D�J��J�J�E�+��
�!�m���"�0�0����.�.�0�#�C�(� ��S��*�� ��U��,�.�� ��A�V�EI�Z�Z�EQ� Q� R�
R�"�4�;�;�?�?�#4�#4�#E�#E�G��r Nc �f � d| j vrt d� �d| _ | 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-Cipher object can only be used for decryption)r% )r( � TypeError�_encrypt)r. � plaintext�outputs r r% zChaCha20Cipher.encrypt| s4 � � �D�J�J�&��K�L�L�!��
��}�}�Y��/�/r c
� � |�t t |� � }nF|}t |� st d� �t |� t |� k7 rt dt |� z � �t
j
| j j � t |� t |� t t |� � � }|rt d|| j fz � �|�t |� S y)zEncrypt without FSM checksNz4output must be a bytearray or a writeable memoryviewz9output must have the same length as the input (%d bytes)z!Error %d while encrypting with %s)
r r r
r1 r r �chacha20_encryptr) r, r r
r'