Your IP : 3.135.215.149


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/hmac.cpython-310.pyc

o

6��f%�@s�dZddlZzddlZWneydZdZddlmZ	Yn	wej	Z	e
ej�ZddlZe
dd�ed�D��Ze
dd�ed�D��ZdZGdd	�d	�Zddd�Zd
d�ZdS)zqHMAC (Keyed-Hashing for Message Authentication) module.

Implements the HMAC algorithm as described by RFC 2104.
�N)�_compare_digestcc��|]}|dAVqdS)�\N���.0�xrr�+/opt/alt/python310/lib64/python3.10/hmac.py�	<genexpr>��r
�ccr)�6Nrrrrr	r
rc@sfeZdZdZdZdZddd�Zdd	�Zd
d�Ze	dd
��Z
dd�Zdd�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�stdt|�j��|std��tr<t|ttf�r<z
|�	|||�WdStj
y;|�|||�YdSw|�|||�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�str�	_functype�
_init_hmac�UnsupportedDigestmodError�	_init_old��self�key�msg�	digestmodrrr	�__init__&s�z
HMAC.__init__cCs*tj|||d�|_|jj|_|jj|_dS)N�r&)rZhmac_newrrrr"rrr	rBs
zHMAC._init_hmaccst��r�}nt�t�rd�fdd�	}nd�fdd�	}d|_|�|_|�|_|jj|_t|jd�rI|jj}|dkrHt	�
d||jftd�|j}n
t	�
d	|jtd�|j}t
|�|krb||���}||_|�|d
�}|j�|�t��|j�|�t��|dur�|�|�dSdS)N�c�t��|�S�N��_hashlib�new��dr(rr	�<lambda>K�z HMAC._init_old.<locals>.<lambda>c�
��|�Sr+�r.r/r(rr	r1M�
r�z:block_size of %d seems too small; using our default of %d.�z<No block_size attribute on given digest object; Assuming %d.��r))�callablerrrrrr�hasattrr�	_warnings�warn�	blocksize�RuntimeWarning�len�digest�ljust�update�	translate�trans_5C�trans_36)r#r$r%r&�digest_consr>rr(r	r!GsD

������zHMAC._init_oldcCs|jr|jjSd|jj��S)Nzhmac-)r�namer)r#rrr	rHnsz	HMAC.namecCs|jp|j}|�|�dS)z,Feed data from msg into this hashing object.N)rrrC)r#r%�instrrr	rCuszHMAC.updatecCsZ|j�|j�}|j|_|jr|j��|_d|_|_|Sd|_|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#�otherrrr	rLzs�z	HMAC.copycCs*|jr|jS|j��}|�|j���|S)zwReturn a hash object for the current state.

        To be used only internally with digest() and hexdigest().
        )rrrLrCrrA�r#�hrrr	�_current�s

z
HMAC._currentcC�|��}|��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.
        )rPrArNrrr	rA�szHMAC.digestcCrQ)zKLike digest(), but returns a string of hexadecimal digits instead.
        )rP�	hexdigestrNrrr	rR�szHMAC.hexdigest�Nr)r�
__module__�__qualname__�__doc__r>�	__slots__r'rr!�propertyrHrCrLrPrArRrrrr	rs
'

rrcCs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&rrr	r.�sr.cs�tdurt�ttf�rzt�||��WStjyYnwt��r%�}nt�t�r2d	�fdd�	}nd	�fdd�	}|�}|�}t|dd�}t|�|krQ||��	�}|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.
    Nr)cr*r+r,r/�rArr	r1�r2zdigest.<locals>.<lambda>cr3r+r4r/rYrr	r1�r5rrr8r9)rrrrZhmac_digestr r:�getattrr@rArCrDrFrE)r$r%rArG�innerZouterr>rrYr	rA�s,	�

rArS)rV�warningsr<r-r�ImportErrorr�	_operatorrZcompare_digestrZopenssl_sha256Zhashlibr�rangerErFrrr.rArrrr	�<module>s&�




?>