
    ,h                         d dl mZmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 ddgZdd	d
dddddddddZej                         D  ci c]  \  } }|| 
 c}} Z G d de      ZddZyc c}} w )    )bordtobytes)	unhexlify)BLAKE2s)strxor)get_random_bytesnewHMACz1.2.840.113549.2.7z1.2.840.113549.2.8z1.2.840.113549.2.9z1.2.840.113549.2.10z1.2.840.113549.2.11z1.2.840.113549.2.12z1.2.840.113549.2.13z2.16.840.1.101.3.4.2.13z2.16.840.1.101.3.4.2.14z2.16.840.1.101.3.4.2.15z2.16.840.1.101.3.4.2.16)z1.3.14.3.2.26z2.16.840.1.101.3.4.2.4z2.16.840.1.101.3.4.2.1z2.16.840.1.101.3.4.2.2z2.16.840.1.101.3.4.2.3z2.16.840.1.101.3.4.2.5z2.16.840.1.101.3.4.2.6z2.16.840.1.101.3.4.2.7z2.16.840.1.101.3.4.2.8z2.16.840.1.101.3.4.2.9z2.16.840.1.101.3.4.2.10c                   B    e Zd ZdZddZd Zd Zd Zd Zd Z	d	 Z
d
 Zy)r
   aB  An HMAC hash 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

    :ivar oid: the ASN.1 object ID of the HMAC algorithm.
               Only present if the algorithm was officially assigned one.
    Nc                    |ddl m} |}|d}|j                  | _        || _        	 t        |j
                     | _        t        |t              r|j                         }	 t        |      |j                  k  r|d|j                  t        |      z
  z  z   }n=|j                  |      j                         }|d|j                  t        |      z
  z  z   }t!        |dt        |      z        }|j                  |      | _        | j"                  j%                  |       t!        |dt        |      z        }|j                  |      | _        y # t        t        f$ r Y w xY w# t        $ r t        d      w xY w)Nr   )MD5        zHash type incompatible to HMAC   6   \)Crypto.Hashr   digest_size
_digestmod_hash2hmac_oidoidKeyErrorAttributeError
isinstance
memoryviewr   len
block_sizer	   digest
ValueErrorr   _innerupdate_outer)	selfkeymsg	digestmodr   key_0hash_k
key_0_ipad
key_0_opads	            R/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/Crypto/Hash/HMAC.py__init__zHMAC.__init__H   sb   'I;C %00#	%imm4DH c:&++-C
	?3x9///g)=)=C)HII #s+224I,@,@3v;,N!OO E7SZ#78
  mmJ/3 E7SZ#78
  mmJ/; .) 		  	?=>>	?s   E !A4E# E E #E8c                 <    | j                   j                  |       | S )zAuthenticate the next chunk of message.

        Args:
            data (byte string/byte array/memoryview): The next chunk of data
        )r   r    )r"   r$   s     r*   r    zHMAC.updatex   s     	3r   c                 j    | j                   j                  | j                  | j                  ||      }|S )z2Carry out the expensive inner loop for PBKDF2-HMAC)r   _pbkdf2_hmac_assistr   r!   )r"   first_digest
iterationsresults       r*   r.   zHMAC._pbkdf2_hmac_assist   s3     44$(KK$(KK$0$.	0
 r   c                     t        d| j                        }| j                  j                         |_        | j                  j                         |_        |S )a+  Return a copy ("clone") of the HMAC object.

        The copy will have the same internal state as the original HMAC
        object.
        This can be used to efficiently compute the MAC tag of byte
        strings that share a common initial substring.

        :return: An :class:`HMAC`
        s   fake key)r%   )r
   r   r   copyr!   )r"   new_hmacs     r*   r3   z	HMAC.copy   sC     t? ++**,++**,r   c                     | j                   j                         }|j                  | j                  j	                                |j	                         S )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!   r3   r    r   r   )r"   frozen_outer_hashs     r*   r   zHMAC.digest   sA     !KK,,.  !3!3!56 ''))r   c                     t        d      }t        j                  d||      }t        j                  d|| j                               }|j                         |j                         k7  rt	        d      y)ah  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.
              )digest_bitsr#   datazMAC check failedN)r   r   r	   r   r   )r"   mac_tagsecretmac1mac2s        r*   verifyzHMAC.verify   s]     ""%{{sWE{{sT[[]K;;=DKKM)/00 *r   c           	          dj                  t        | j                               D cg c]  }dt        |      z   c}      S c c}w )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tupler   r   )r"   xs     r*   	hexdigestzHMAC.hexdigest   sD     ww!&t{{}!57 a( 7 8 	8 7s   Ac                 J    | j                  t        t        |                   y)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)r@   r   r   )r"   hex_mac_tags     r*   	hexverifyzHMAC.hexverify   s     	Igk234r   r   N)__name__
__module____qualname____doc__r+   r    r.   r3   r   r@   rF   rI    r   r*   r
   r
   =   s0    .0`&*1(	85r   Nc                     t        | ||      S )a=  Create a new MAC object.

    Args:
        key (bytes/bytearray/memoryview):
            key for the MAC object.
            It must be long enough to match the expected security level of the
            MAC.
        msg (bytes/bytearray/memoryview):
            Optional. The very first chunk of the message to authenticate.
            It is equivalent to an early call to :meth:`HMAC.update`.
        digestmod (module):
            The hash to use to implement the HMAC.
            Default is :mod:`Crypto.Hash.MD5`.

    Returns:
        An :class:`HMAC` object
    )r
   )r#   r$   r%   s      r*   r	   r	      s    & S)$$r   rJ   )Crypto.Util.py3compatr   r   binasciir   r   r   Crypto.Util.strxorr   Crypto.Randomr   __all__r   items_hmac2hash_oidobjectr
   r	   )kvs   00r*   <module>r[      s   D 0   % *&/ *2233337778 $2#7#7#9:41a!Q$:[56 [5|%C ;s   A'