
    i                         S SK Jr  S SKJrJrJr  S SKJr  S SKJ	r	  S SK
JrJrJrJrJrJrJr  \" SS5      r " S S	\5      rS
 rg)    )	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_ptrzCrypto.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                   F    \ rS rSrSrSrS rS rS rS r	S r
S	 rS
 rSrg)Poly1305_MAC5   zAn 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                    [        U5      S:w  a  [        S5      e[        U5      S:w  a  [        S5      eS U l        [        5       n[        R                  UR                  5       [        U5      [        [        U5      5      [        U5      [        [        U5      5      5      nU(       a  [        SU-  5      e[        UR                  5       [        R                  5      U l        U(       a  U R                  U5        g g )Nr   z 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_ofr   r   r   getpoly1305_destroy_stateupdate)selfrsdatastateresults         O/var/www/html/trading/venv/lib/python3.13/site-packages/Crypto/Hash/Poly1305.py__init__Poly1305_MAC.__init__?   s    q6R<?@@q6R<?@@,,U-=-=-?-8^-5c!f-=-8^-5c!f-=	/ DvMNN"599;#0#A#ACKK     c           	          U R                   (       a  [        S5      e[        R                  U R                  R                  5       [        U5      [        [        U5      5      5      nU(       a  [        SU-  5      eU $ )ztAuthenticate 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_updater   r   r   r   r   r   )r   r"   r$   s      r%   r   Poly1305_MAC.updateV   sd     ==VWW..t{{/@/:4/@/7D	/BD CfLMMr(   c                     [        5       e)N)NotImplementedError)r   s    r%   copyPoly1305_MAC.copyg   s    !##r(   c           	      6   U R                   (       a  U R                   $ [        S5      n[        R                  U R                  R                  5       U[        [        U5      5      5      nU(       a  [        SU-  5      e[        U5      U l         U R                   $ )zReturn 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
r   z'Error %d while creating Poly1305 digest)
r   r   r   poly1305_digestr   r   r   r   r   r   )r   bfrr$   s      r%   digestPoly1305_MAC.digestj   sx     ==== "2&..t{{/@/2/7C/AC FOPP&s+}}r(   c           	          SR                  [        U R                  5       5       Vs/ s H  nS[        U5      -  PM     sn5      $ s  snf )zReturn 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
 z%02x)jointupler4   r   )r   xs     r%   	hexdigestPoly1305_MAC.hexdigest   sI     ww!&t{{}!57!5A a(!57 8 	8 7s   Ac                     [        S5      n[        R                  " SX!S9n[        R                  " SX R                  5       S9nUR                  5       UR                  5       :w  a  [	        S5      eg)a0  Verify 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"   zMAC check failedN)r   r   newr4   r   )r   mac_tagsecretmac1mac2s        r%   verifyPoly1305_MAC.verify   sY     ""%{{sE{{s[[]K;;=DKKM)/00 *r(   c                 J    U R                  [        [        U5      5      5        g)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)rF   r   r   )r   hex_mac_tags     r%   	hexverifyPoly1305_MAC.hexverify   s     	Igk234r(   )r   r   N)__name__
__module____qualname____firstlineno____doc__digest_sizer&   r   r/   r4   r;   rF   rJ   __static_attributes__ r(   r%   r   r   5   s1     K."$,	81(5r(   r   c                     U R                  SS5      n[        US5      (       d  [        S5      eU R                  SS5      nUc  [        S5      eU R                  SS5      nU R                  SS5      nU (       a  [        S	[	        U 5      -   5      eUR                  X#5      u  pVn[        XVU5      n[        SSU5      Ul        U$ )
ah  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@   zYou must pass a parameter 'key'noncer"   zUnknown parameters: )	pophasattrr   r*   strrV   r   r   rW   )kwargsrU   
cipher_keyrW   r"   r    r!   new_macs           r%   rA   rA      s    . ZZ$'F6677EFFE4(J9::JJw%E::fd#D.V<==22:EKA%1&GdE2GMNr(   N)binasciir   Crypto.Util.py3compatr   r   r   Crypto.Hashr   Crypto.Randomr   Crypto.Util._raw_apir	   r
   r   r   r   r   r   r   objectr   rA   rS   r(   r%   <module>rd      sM   .  < <  */ / / **A"w56 w5v)r(   