ok

Mini Shell

Direktori : /opt/imunify360/venv/lib/python3.11/site-packages/Crypto/Hash/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib/python3.11/site-packages/Crypto/Hash/__pycache__/Poly1305.cpython-311.pyc

�

f��f����ddlmZddlmZmZmZddlmZddlm	Z	ddl
mZmZm
Z
mZmZmZmZedd��ZGd�d	e��Zd
�ZdS)�)�	unhexlify)�bord�tobytes�_copy_bytes)�BLAKE2s)�get_random_bytes)�load_pycryptodome_raw_lib�VoidPointer�SmartPointer�create_string_buffer�get_raw_buffer�c_size_t�c_uint8_ptrzCrypto.Hash._poly1305a�
                        int poly1305_init(void **state,
                                          const uint8_t *r,
                                          size_t r_len,
                                          const uint8_t *s,
                                          size_t s_len);
                        int poly1305_destroy(void *state);
                        int poly1305_update(void *state,
                                            const uint8_t *in,
                                            size_t len);
                        int poly1305_digest(const void *state,
                                            uint8_t *digest,
                                            size_t len);
                        c�@�eZdZdZdZd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
S)�Poly1305_MACz�An Poly1305 MAC object.
    Do not instantiate directly. Use the :func:`new` function.

    :ivar digest_size: the size in bytes of the resulting MAC tag
    :vartype digest_size: integer
    �c�p�t|��dkrtd���t|��dkrtd���d|_t��}t�|���t|��tt|����t|��tt|������}|rtd|z���t|�
��tj��|_|r|�
|��dSdS)Nrz Parameter r is not 16 bytes longz Parameter s is not 16 bytes longz%Error %d while instantiating Poly1305)�len�
ValueError�_mac_tagr
�
_raw_poly1305�
poly1305_init�
address_ofrrr�get�poly1305_destroy�_state�update)�self�r�s�data�state�results      �v/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Hash/Poly1305.py�__init__zPoly1305_MAC.__init__?s���q�6�6�R�<�<��?�@�@�@��q�6�6�R�<�<��?�@�@�@���
��
�
���,�,�U�-=�-=�-?�-?�-8��^�^�-5�c�!�f�f�-=�-=�-8��^�^�-5�c�!�f�f�-=�-=�	/�/���	O��D�v�M�N�N�N�"�5�9�9�;�;�#0�#A�C�C����	��K�K�������	�	�c	��|jrtd���t�|j���t
|��tt|������}|rtd|z���|S)z�Authenticate the next chunk of message.

        Args:
            data (byte string/byte array/memoryview): The next chunk of data
        z8You can only call 'digest' or 'hexdigest' on this objectz$Error %d while hashing Poly1305 data)
r�	TypeErrorr�poly1305_updaterrrrrr)rr!r#s   r$rzPoly1305_MAC.updateVs����=�	X��V�W�W�W��.�.�t�{���/@�/@�/:�4�/@�/@�/7��D�	�	�/B�/B�D�D���	N��C�f�L�M�M�M��r&c��t���)N)�NotImplementedError�rs r$�copyzPoly1305_MAC.copygs��!�#�#�#r&c	�4�|jr|jStd��}t�|j���|t
t|������}|rtd|z���t|��|_|jS)z�Return the **binary** (non-printable) MAC tag of the message
        authenticated so far.

        :return: The MAC tag digest, computed over the data processed so far.
                 Binary form.
        :rtype: byte string
        rz'Error %d while creating Poly1305 digest)
rrr�poly1305_digestrrrrrr
)r�bfrr#s   r$�digestzPoly1305_MAC.digestjs����=�	!��=� �"�2�&�&���.�.�t�{���/@�/@�/2�/7��C���/A�/A�C�C���	Q��F��O�P�P�P�&�s�+�+��
��}�r&c�~�d�d�t|�����D����S)z�Return the **printable** MAC tag of the message authenticated so far.

        :return: The MAC tag, computed over the data processed so far.
                 Hexadecimal encoded.
        :rtype: string
        �c�2�g|]}dt|��z��S)z%02x)r)�.0�xs  r$�
<listcomp>z*Poly1305_MAC.hexdigest.<locals>.<listcomp>�s3��7�7�7����a���(�7�7�7r&)�join�tupler1r,s r$�	hexdigestzPoly1305_MAC.hexdigest�sF���w�w�7�7�!&�t�{�{�}�}�!5�!5�7�7�7�8�8�	8r&c��td��}tjd||���}tjd||������}|���|���krt	d���dS)ahVerify that a given **binary** MAC (computed by another party)
        is valid.

        Args:
          mac_tag (byte string/byte string/memoryview): the expected MAC of the message.

        Raises:
            ValueError: if the MAC does not match. It means that the message
                has been tampered with or that the MAC key is incorrect.
        r�)�digest_bits�keyr!zMAC check failedN)rr�newr1r)r�mac_tag�secret�mac1�mac2s     r$�verifyzPoly1305_MAC.verify�sw��"�"�%�%���{�s��W�E�E�E���{�s��T�[�[�]�]�K�K�K���;�;�=�=�D�K�K�M�M�)�)��/�0�0�0�*�)r&c�d�|�tt|������dS)a~Verify that a given **printable** MAC (computed by another party)
        is valid.

        Args:
            hex_mac_tag (string): the expected MAC of the message,
                as a hexadecimal string.

        Raises:
            ValueError: if the MAC does not match. It means that the message
                has been tampered with or that the MAC key is incorrect.
        N)rDrr)r�hex_mac_tags  r$�	hexverifyzPoly1305_MAC.hexverify�s,��	
���I�g�k�2�2�3�3�4�4�4�4�4r&N)�__name__�
__module__�__qualname__�__doc__�digest_sizer%rr-r1r:rDrG�r&r$rr5s����������K����.���"$�$�$����,	8�	8�	8�1�1�1�(
5�
5�
5�
5�
5r&rc���|�dd��}t|d��std���|�dd��}|�td���|�dd��}|�dd��}|rtd	t	|��z���|�||��\}}}t
|||��}tdd|��|_|S)
a�Create a new Poly1305 MAC object.

    Args:
        key (bytes/bytearray/memoryview):
            The 32-byte key for the Poly1305 object.
        cipher (module from ``Crypto.Cipher``):
            The cipher algorithm to use for deriving the Poly1305
            key pair *(r, s)*.
            It can only be ``Crypto.Cipher.AES`` or ``Crypto.Cipher.ChaCha20``.
        nonce (bytes/bytearray/memoryview):
            Optional. The non-repeatable value to use for the MAC of this message.
            It must be 16 bytes long for ``AES`` and 8 or 12 bytes for ``ChaCha20``.
            If not passed, a random nonce is created; you will find it in the
            ``nonce`` attribute of the new object.
        data (bytes/bytearray/memoryview):
            Optional. The very first chunk of the message to authenticate.
            It is equivalent to an early call to ``update()``.

    Returns:
        A :class:`Poly1305_MAC` object
    �cipherN�_derive_Poly1305_key_pairz*Parameter 'cipher' must be AES or ChaCha20r>zYou must pass a parameter 'key'�noncer!zUnknown parameters: )	�pop�hasattrrr(�strrPrrrQ)�kwargsrO�
cipher_keyrQr!rr �new_macs        r$r?r?�s���.�Z�Z��$�
'�
'�F��6�6�7�7�G��E�F�F�F����E�4�(�(�J����9�:�:�:��J�J�w��%�%�E��:�:�f�d�#�#�D�
�>��.��V���<�=�=�=��2�2�:�u�E�E�K�A�q�%��1�a��&�&�G���d�E�2�2�G�M��Nr&N)�binasciir�Crypto.Util.py3compatrrr�Crypto.Hashr�
Crypto.Randomr�Crypto.Util._raw_apir	r
rrr
rrr�objectrr?rMr&r$�<module>r^s��.������<�<�<�<�<�<�<�<�<�<�������*�*�*�*�*�*�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�*�)�*A�
���
�"w5�w5�w5�w5�w5�6�w5�w5�w5�v)�)�)�)�)r&

Zerion Mini Shell 1.0