| Server IP : 217.160.0.135 / Your IP : 216.73.217.25 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/python3/dist-packages/Cryptodome/Cipher/__pycache__/ |
Upload File : |
�
8�tc* � � � d dl mZ d dlmZ d dlmZmZmZmZm Z m
Z
mZmZm
Z
edd� � Zd� Z G d� de� � Zd � Zd
� ZdZdZd
S )� )�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 � 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 s� � ��s�8�8�r�>�>�>�>��u�:�:������
�r�]�]�F�
�
(�
(��C� � ��E�"�"��F�#�#�%� %�F� � R��G�&�P�Q�Q�Q��M� c �8 � e Zd ZdZdZd� Zd d�Zd� Zd d�Zd� Z dS )
�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 � � t dd|� � | _ t |� � dk r-t ||dd� � � }d|dd� z }d| _ nd| _ | j }| j | j f| _ t � � | _ t � | j � � � t |� � t t |� � � � |t t |� � � � � � }|rt d|| j fz � � �t! | j � � � t j � � | _ dS )z\Initialize a ChaCha20/XChaCha20 cipher object
See also `new()` at the module level.N� r � � XChaCha20�ChaCha20z"Error %d instantiating a %s cipher)r r r r �_name�encrypt�decrypt�_nextr �_stater �
chacha20_init�
address_ofr r
r r �get�chacha20_destroy)�selfr r r s r �__init__zChaCha20Cipher.__init__\ s= � �
!��t�U�3�3��
� �u�:�:�����S�%����*�-�-�C��%����*�,�E�$�D�J�J�#�D�J��J�E��|�T�\�3��
�!�m�m���"�0�0���.�.�0�0�#�C�(�(� ��S���*�*�� ��U���,�,�.� .�� � R��A�V�EI�Z�EQ� Q� R� R�
R�"�4�;�?�?�#4�#4�#4�#E�G� G����r Nc � � | j | j vrt d� � �| j f| _ | � ||� � 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``.
z-Cipher object can only be used for decryption)r&