U &�.e��@s�dZddlZddlmZz ddlZWnek r@dZdZ Yn Xe ej �Z ddl ZddlZ ddlZedd�ed�D��Zedd�ed�D��ZdZGdd �d �Zd d �ZGd d �d ej�Ze ��r�eZddd�Zdd�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.8/hmac.py� sr �ccs|]}|dAVqdS)�6Nrrrrrr sc@sReZdZdZdZddd�Zedd��Zd d �Zd d �Z d d�Z dd�Z dd�Z dS)�HMACz~RFC 2104 HMAC class. Also complies with RFC 4231. This supports the API for Cryptographic Hash Functions (PEP 247). �@N�csVt��rtd��t|ttf�s0tdt|�j���s?rzHMAC.__init__..cs ��|�Sr�rrrrrrAr� block_size�z:block_size of %d seems too small; using our default of %d.�zasz HMAC.namecCs t��rtd��|j�|�dS)z,Feed data from msg into this hashing object.z'hmac.HMAC is not available in FIPS modeN)rr r!r,r6)r:r<rrrr6esz HMAC.updatecCs:|j�|j�}|j|_|j|_|j��|_|j��|_|S)zyReturn a separate copy of this hashing object. An update to this copy won't affect the original object. )� __class__�__new__r)r-r,�copyr+)r:�otherrrrrAks   z HMAC.copycCs|j��}|�|j���|S)zwReturn a hash object for the current state. To be used only internally with digest() and hexdigest(). )r+rAr6r,r4�r:�hrrr�_currentxs 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. )rEr4rCrrrr4�sz HMAC.digestcCs|��}|��S)zKLike digest(), but returns a string of hexadecimal digits instead. )rE� hexdigestrCrrrrF�szHMAC.hexdigest)Nr) r'� __module__� __qualname__�__doc__r1r=�propertyr>r6rArEr4rFrrrrr s >    r cCsHt|t�r|��St|�r"|d�}t|tj�s6td��|j���dd�S)Nrz6Only OpenSSL hashlib hashes are accepted in FIPS mode.�_�-) r"r*�lowerr(rZHASHr%r>�replacerrrr�_get_openssl_name�s  �rOc@seZdZddd�ZdS)� HMAC_opensslNcCsLt|ttf�s tdt|�j��t|�}tjj |||d�}|rH|� |�|S)Nrr) r"r#r$r%r&r'rO� _hmacopensslr r@r6)�clsr;r<rr>�resultrrrr@�s zHMAC_openssl.__new__)NN)r'rGrHr@rrrrrP�srPrcCs 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<rrrrr�srcs�tdk r(t�t�r(�tkr(t�||��St��r6�}n(t�t�rPd �fdd� }nd �fdd� }|�}|�}t|dd�}t|�|kr�||���}|d|t|�}|� |� t ��|� |� t ��|� |�|� |���|��S) aJFast inline implementation of HMAC. key: bytes or buffer, The key for the keyed hash object. msg: bytes or buffer, Input message. digest: A hash name suitable for hashlib.new() for best performance. *OR* A hashlib constructor returning a new hash object. *OR* A module supporting PEP 247. Nrcs t��|�Srrr�r4rrr�rzdigest..cs ��|�SrrrrTrrr�rrr r)r)r) � _hashopensslr"r*�_openssl_md_methsZ hmac_digestr(�getattrr3r4r6r7r9r8)r;r<r4r)r,r+r1rrTrr4�s, ��     r4)Nr)rI�warningsr/� _operatorrZcompare_digestrrU� ImportErrorrV� frozensetZopenssl_md_meth_namesZhashlibrrQr#�ranger8r9r-r rOrPr rr4rrrr�s*    u