403Webshell
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/Cryptodome/Cipher/__pycache__/ChaCha20.cpython-312.pyc
�

��e*���ddlmZddlmZddlmZmZmZmZm	Z	m
Z
mZmZm
Z
edd�Zd�ZGd�de�Zd	�Zd
�ZdZdZy
)�)�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�td�}tjt	|�t	|�t	|��}|rtd|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�
_HChaCha20rBsp���s�8�r�>��>��u�:�����
�r�]�F�
�
(�
(��C� ��E�"��F�#�%�F���G�&�P�Q�Q��M�c�6�eZdZdZdZd�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�tdd|�|_t|�dk(rt||dd�}d|ddz}d|_nd|_|j}d|_t
�|_tj|jj�t|�tt|��|tt|���}|rtd||jfz��t|jj�tj �|_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)rrrr�_name�_nextr�_stater�
chacha20_init�
address_ofrr
rr	�get�chacha20_destroy)�selfrrrs    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��rNc�f�d|jvrtd��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   rr%zChaCha20Cipher.encrypt|s4���D�J�J�&��K�L�L�!��
��}�}�Y��/�/rc
��|�tt|��}nF|}t|�std��t|�t|�k7rt	dt|�z��t
j
|jj�t|�t|�tt|���}|rt	d||jfz��|�t|�Sy)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)
rrr
r1rr�chacha20_encryptr)r,rr
r'r)r.r3r4�
ciphertextrs     rr2zChaCha20Cipher._encrypt�s����>�-�c�)�n�=�J��J�&�v�.�� V�W�W��9�~��V��,� �"0�25�i�.�"A�B�B�#�3�3�)-�����):�)4�Y�)?�)4�Z�)@�)1�#�i�.�)A�	C��
��@�F�D�J�J�CW�W�X�X��>�!�*�-�-�rc���d|jvrtd��d|_	|j||�S#t$r)}tt	|�jdd���d}~wwxYw)a�Decrypt a piece of data.

        Args:
          ciphertext(bytes/bytearray/memoryview): The data to decrypt, of any size.
        Keyword Args:
          output(bytes/bytearray/memoryview): The location where the plaintext
            is written to. If ``None``, the plaintext is returned.
        Returns:
          If ``output`` is ``None``, the plaintext is returned as ``bytes``.
          Otherwise, ``None``.
        r&z-Cipher object can only be used for encryption)r&�enc�decN)r(r1r2r�str�replace)r.r7r4�es    rr&zChaCha20Cipher.decrypt�sc���D�J�J�&��K�L�L�!��
�	;��=�=��V�4�4���	;��S��V�^�^�E�5�9�:�:��	;�s�4�	A&�$A!�!A&c���t|d�\}}|dz}|dz	}tj|jj	�t|�t|�|�}|rt
d||jfz��y)z�Seek to a certain position in the key stream.

        Args:
          position (integer):
            The absolute position within the key stream, in bytes.
        �@l��rzError %d while seeking with %sN)�divmodr�
chacha20_seekr)r,rrr')r.�position�offset�	block_low�
block_highrs      r�seekzChaCha20Cipher.seek�s}��"�(�B�/���&��z�)�	���^�
�"�0�0�15�����1B�18��1D�18��1C�17�	3����=�����@T�T�U�U�r)N)
�__name__�
__module__�__qualname__�__doc__�
block_sizer/r%r2r&rF�rrrrRs*����J�G�@0�$�8;�,Vrrc��t|�dk7rtd��|�td�x}}n0t|�dk(rd|z}nt|�dk(r|}ntd��t||��j	d	�}|dd
|d
d|fS)zrDerive a tuple (r, s, nonce) for a Poly1305 MAC.

    If nonce is ``None``, a new 12-byte nonce is generated.
    rz-Poly1305 with ChaCha20 requires a 32-byte keyN��r"z6Poly1305 with ChaCha20 requires an 8- or 12-byte nonce)rrs r)rrr�newr%)rr�padded_nonce�rss    r�_derive_Poly1305_key_pairrS�s����3�x�2�~��H�I�I��}�/��3�3��u�	�U��q��+�U�2��	�U��r�	����Q�R�R�	��L�	)�	1�	1�,�	?�B�
�c�r�7�B�r�s�G�U�"�"rc�N�	|jd�}|jdd�}|�td�}t	|�dk7rtd��t	|�dvrtd	��|rtd
t
|�z��t||�S#t$r}td|z��d}~wwxYw)a�Create a new ChaCha20 or XChaCha20 cipher

    Keyword Args:
        key (bytes/bytearray/memoryview): The secret key to use.
            It must be 32 bytes long.
        nonce (bytes/bytearray/memoryview): A mandatory value that
            must never be reused for any other encryption
            done with this key.

            For ChaCha20, it must be 8 or 12 bytes long.

            For XChaCha20, it must be 24 bytes long.

            If not provided, 8 bytes will be randomly generated
            (you can find them back in the ``nonce`` attribute).

    :Return: a :class:`Cryptodome.Cipher.ChaCha20.ChaCha20Cipher` object
    rzMissing parameter %sNrrOrz,ChaCha20/XChaCha20 key must be 32 bytes long)rOrNr!z:Nonce must be 8/12 bytes(ChaCha20) or 24 bytes (XChaCha20)zUnknown parameters: )�pop�KeyErrorr1rrrr;r)�kwargsrr=rs    rrPrP�s���(4��j�j����
�J�J�w��%�E��}� ��#��
�3�x�2�~��G�H�H�
�5�z��$��U�V�V�
��.��V��<�=�=��#�u�%�%��!�4��.��2�3�3��4�s�B�	B$�B�B$rrN)�Cryptodome.Randomr�Cryptodome.Util.py3compatr�Cryptodome.Util._raw_apirrrrr	r
rrr
rr�objectrrSrPrK�key_sizerLrr�<module>r]s`��>/�1�7�7�7�.�.K����2
� AV�V�AV�H#�:&&�R�
��r

Youez - 2016 - github.com/yon3zu
LinuXploit