a X�Zgk�@s�dZddlZz ddlZWn&ey>dZdZddlmZ Yn0ej Z e ej �Zddl Ze� �s�edd�ed�D��Zedd�ed�D��ZdZGdd �d �Zdd d �Zd d�ZdS)zqHMAC (Keyed-Hashing for Message Authentication) module. Implements the HMAC algorithm as described by RFC 2104. �N)�_compare_digestccs|]}|dAVqdS)�\N���.0�xrr�/usr/lib64/python3.9/hmac.py� �r �ccs|]}|dAVqdS)�6Nrrrrrr r c@sfeZdZdZdZdZddd�Zdd �Zd d �Ze d d ��Z dd�Z dd�Z dd�Z dd�Zdd�ZdS)�HMACz~RFC 2104 HMAC class. Also complies with RFC 4231. This supports the API for Cryptographic Hash Functions (PEP 247). �@)�_hmac�_inner�_outer� block_size� digest_sizeN�cCs�t|ttf�s tdt|�j��|s,td��t��sFtr�t|tt f�r�z|� |||�Wq�tj y�t��rr�|� |||�Yq�0n|� |||�dS)a?Create a new HMAC object. key: bytes or buffer, key for the keyed hash object. msg: bytes or buffer, Initial input for the hash or None. digestmod: A hash name suitable for hashlib.new(). *OR* A hashlib constructor returning a new hash object. *OR* A module supporting PEP 247. Required as of 3.8, despite its position after the optional msg argument. Passing it as a keyword argument is recommended, though not required for legacy API reasons. z,key: expected bytes or bytearray, but got %rz'Missing required parameter 'digestmod'.N) � isinstance�bytes� bytearray� TypeError�type�__name__� _hashopenssl� get_fips_mode�str� _functype� _init_hmac�UnsupportedDigestmodError� _init_old��self�key�msg� digestmodrrr�__init__'s z HMAC.__init__cCs*tj|||d�|_|jj|_|jj|_dS)N�r&)r�hmac_newrrrr"rrrrDs zHMAC._init_hmaccs(t��r|�||��St��r$�}n(t�t�r>d �fdd� }nd �fdd� }d|_|�|_|�|_|jj |_ t |jd�r�|jj }|dkr�t � d||jftd�|j}nt � d |jtd�|j}t|�|kr�||���}||_ |�|d �}|j�|�t��|j�|�t��|du�r$|�|�dS) Nr cs t��|�S�N��_hashlib�new��dr(rr�Pr z HMAC._init_old..cs ��|�Sr*�r-r.r(rrr0Rr r�z:block_size of %d seems too small; using our default of %d.�z)r#r%�instrrrr>zs z HMAC.updatecCsX|j�|j�}|j|_|jr6|j��|_d|_|_nd|_|j��|_|j��|_|S)zyReturn a separate copy of this hashing object. An update to this copy won't affect the original object. N)� __class__�__new__rr�copyrr)r#�otherrrrrGs   z HMAC.copycCs.|jr |jS|j��}|�|j���|SdS)zwReturn a hash object for the current state. To be used only internally with digest() and hexdigest(). N)rrrGr>rr<�r#�hrrr�_current�s  z HMAC._currentcCs|��}|��S)z�Return the hash value of this hashing object. This returns the hmac value as bytes. The object is not altered in any way by this function; you can continue updating the object after calling this function. )rKr<rIrrrr<�sz HMAC.digestcCs|��}|��S)zKLike digest(), but returns a string of hexadecimal digits instead. )rK� hexdigestrIrrrrL�szHMAC.hexdigest)Nr)r� __module__� __qualname__�__doc__r9� __slots__r'rr!�propertyrCr>rGrKr<rLrrrrr s *   r rcCs t|||�S)a�Create a new hashing object and return it. key: bytes or buffer, The starting key for the hash. msg: bytes or buffer, Initial input for the hash, or None. digestmod: A hash name suitable for hashlib.new(). *OR* A hashlib constructor returning a new hash object. *OR* A module supporting PEP 247. Required as of 3.8, despite its position after the optional msg argument. Passing it as a keyword argument is recommended, though not required for legacy API reasons. You can now feed arbitrary bytes into the object using its update() method, and can ask for the hash value at any time by calling its digest() or hexdigest() methods. )r )r$r%r&rrrr-�sr-cs�tdur.cs ��|�Sr*r1r.rRrrr0�r rrr4)r )r )rrrr� hmac_digestr r5�getattrr;r<r>r?rAr@)r$r%r<rB�innerZouterr9rrRrr<�s*      r<)Nr)rO�warningsr7r,r� ImportErrorr� _operatorr�compare_digestr�openssl_sha256�hashlibrr�ranger@rArr r-r<rrrr�s$