
    ,h$                     ~    d dl mZ d dlmZmZ d dlmZ d dlmZm	Z	m
Z
mZmZmZmZ  edd      Z G d de      Zd	 Zy
)    )	unhexlify)bordtobytes)get_random_bytes)load_pycryptodome_raw_libVoidPointerSmartPointercreate_string_bufferget_raw_bufferc_size_tc_uint8_ptrzCrypto.Hash._BLAKE2ba  
                        int blake2b_init(void **state,
                                         const uint8_t *key,
                                         size_t key_size,
                                         size_t digest_size);
                        int blake2b_destroy(void *state);
                        int blake2b_update(void *state,
                                           const uint8_t *buf,
                                           size_t len);
                        int blake2b_digest(const void *state,
                                           uint8_t digest[64]);
                        int blake2b_copy(const void *src, void *dst);
                        c                   >    e Zd ZdZdZd Zd Zd Zd Zd Z	d Z
d	 Zy
)BLAKE2b_Hasha  A BLAKE2b hash object.
    Do not instantiate directly. Use the :func:`new` function.

    :ivar oid: ASN.1 Object ID
    :vartype oid: string

    :ivar block_size: the size in bytes of the internal message block,
                      input to the compression function
    :vartype block_size: integer

    :ivar digest_size: the size in bytes of the resulting hash
    :vartype digest_size: integer
    @   c           	         || _         || _        d| _        |dv r|sdt        |      z   | _        t               }t        j                  |j                         t        |      t        t        |            t        |            }|rt        d|z        t        |j                         t        j                        | _        |r| j#                  |       y y )NF)       0   r   z1.3.6.1.4.1.1722.12.2.1.z$Error %d while instantiating BLAKE2b)digest_size_update_after_digest_digest_donestroidr   _raw_blake2b_libblake2b_init
address_ofr   r   len
ValueErrorr	   getblake2b_destroy_stateupdate)selfdatakeydigest_bytesupdate_after_digeststateresults          U/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/Crypto/Hash/BLAKE2b.py__init__zBLAKE2b_Hash.__init__L   s     ($7!! ++C1C4EEDH!..u/?/?/A/:3/?/7C/A/7/E1
 CfLMM"599;#3#C#CEKK     c           	          | j                   r| j                  st        d      t        j	                  | j
                  j                         t        |      t        t        |                  }|rt        d|z        | S )zContinue hashing of a message by consuming the next chunk of data.

        Args:
            data (bytes/bytearray/memoryview): The next chunk of the message being hashed.
        z8You can only call 'digest' or 'hexdigest' on this objectz#Error %d while hashing BLAKE2b data)r   r   	TypeErrorr   blake2b_updater!   r   r   r   r   r   )r#   r$   r)   s      r*   r"   zBLAKE2b_Hash.updatef   sn     T%>%>VWW!001B1<T1B19#d)1DF BVKLLr,   c                     t        d      }t        j                  | j                  j	                         |      }|rt        d|z        d| _        t        |      d| j                   S )zReturn the **binary** (non-printable) digest of the message that has been hashed so far.

        :return: The hash digest, computed over the data processed so far.
                 Binary form.
        :rtype: byte string
        r   z&Error %d while creating BLAKE2b digestTN)	r
   r   blake2b_digestr!   r   r   r   r   r   )r#   bfrr)   s      r*   digestzBLAKE2b_Hash.digestx   sc     #2&!001B146ENOO c"#4D$4$455r,   c           	          dj                  t        | j                               D cg c]  }dt        |      z   c}      S c c}w )zReturn the **printable** digest of the message that has been hashed so far.

        :return: The hash digest, computed over the data processed so far.
                 Hexadecimal encoded.
        :rtype: string
         z%02x)jointupler3   r   )r#   xs     r*   	hexdigestzBLAKE2b_Hash.hexdigest   s5     ww%2FGQa(GHHGs   Ac                     t        d      }t        d||      }t        d|| j                               }|j                         |j                         k7  rt        d      y)a`  Verify that a given **binary** MAC (computed by another party)
        is valid.

        Args:
          mac_tag (bytes/bytearray/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.
              )digest_bitsr%   r$   zMAC check failedN)r   newr3   r   )r#   mac_tagsecretmac1mac2s        r*   verifyzBLAKE2b_Hash.verify   sU     ""%sW=sT[[]C;;=DKKM)/00 *r,   c                 J    | j                  t        t        |                   y)an  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)rC   r   r   )r#   hex_mac_tags     r*   	hexverifyzBLAKE2b_Hash.hexverify   s     	Igk234r,   c                 F    d|vrd|vr| j                   |d<   t        di |S )zQReturn a new instance of a BLAKE2b hash object.
        See :func:`new`.
        r&   r=    )r   r>   )r#   kwargss     r*   r>   zBLAKE2b_Hash.new   s/    
 'M,G%)%5%5F>"}V}r,   N)__name__
__module____qualname____doc__
block_sizer+   r"   r3   r9   rC   rF   r>   rH   r,   r*   r   r   :   s2     J4$6&I1*5r,   r   c                     | j                  dd      }| j                  dd      }| j                  dd      }| j                  dd      }d||fvrt        d      d||fk(  rd	}|"d
|cxk  rd	k  sDt        d       t        d      d|cxk  rdk  rn t        d      |dz  rt        d      |dz  }| j                  dd      }t        |      d	kD  rt        d      | rt        dt	        |       z         t        ||||      S )a  Create a new hash object.

    Args:
        data (bytes/bytearray/memoryview):
            Optional. The very first chunk of the message to hash.
            It is equivalent to an early call to :meth:`BLAKE2b_Hash.update`.
        digest_bytes (integer):
            Optional. The size of the digest, in bytes (1 to 64). Default is 64.
        digest_bits (integer):
            Optional and alternative to ``digest_bytes``.
            The size of the digest, in bits (8 to 512, in steps of 8).
            Default is 512.
        key (bytes/bytearray/memoryview):
            Optional. The key to use to compute the MAC (1 to 64 bytes).
            If not specified, no key will be used.
        update_after_digest (boolean):
            Optional. By default, a hash object cannot be updated anymore after
            the digest is computed. When this flag is ``True``, such check
            is no longer enforced.

    Returns:
        A :class:`BLAKE2b_Hash` hash object
    r$   Nr'   Fr&   r=   z*Only one digest parameter must be provided)NNr      z!'digest_bytes' not in range 1..64   i   z2'digest_bits' not in range 8..512, with steps of 8r%   r,   z"BLAKE2b key cannot exceed 64 byteszUnknown parameters: )popr.   r   r   r   r   )rI   r$   r'   r&   r=   r%   s         r*   r>   r>      s6   2 ::fd#D **%:EB::nd3L**]D1KL+..DEEk22\'R'@AA (@AA['C' / 0 0 .91_ / 0 0"a'
**UC
 C
3x"}=>>.V<==c<1DEEr,   N)binasciir   Crypto.Util.py3compatr   r   Crypto.Randomr   Crypto.Util._raw_apir   r   r	   r
   r   r   r   r   objectr   r>   rH   r,   r*   <module>rX      sI   >  / */ / / --C  H6 HV2Fr,   