Your IP : 18.118.0.93


Current Path : /lib64/python3.8/__pycache__/
Upload File :
Current File : //lib64/python3.8/__pycache__/hmac.cpython-38.opt-1.pyc

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�	<genexpr>sr	�ccs|]}|dAVqdS)�6Nrrrrrr	sc@sReZdZdZdZddd�Zedd��Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�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<td��t	��rL�|_
n,t�t�rhd�fdd�	|_
nd�fdd�	|_
|�
�|_|�
�|_
|j
j|_t|j
d�r�|j
j}|d	kr�t�d
||jftd�|j}nt�d|jtd�|j}||_t|�|k�r|�
|���}|�|d
�}|j�|�t��|j
�|�t��|dk	�rR|�|�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.
        z9This class is not available in FIPS mode. Use hmac.new().�,key: expected bytes or bytearray, but got %rz'Missing required parameter 'digestmod'.�cst��|�S�N��_hashlib�new��d��	digestmodrr�<lambda>?rzHMAC.__init__.<locals>.<lambda>cs
��|�Sr�rrrrrrAr�
block_size�z:block_size of %d seems too small; using our default of %d.�z<No block_size attribute on given digest object; Assuming %d.�N)r)r)�_hashlibopenssl�
get_fips_mode�
ValueError�
isinstance�bytes�	bytearray�	TypeError�type�__name__�callable�digest_cons�str�outer�inner�digest_size�hasattrr�	_warnings�warn�	blocksize�RuntimeWarning�len�digest�ljust�update�	translate�trans_5C�trans_36)�self�key�msgrr1rrr�__init__#sR
�



����
z
HMAC.__init__cCsd|jjS)Nzhmac-)r,�name)r:rrrr>asz	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<rrrr6eszHMAC.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�szHMAC.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.<locals>.<lambda>cs
��|�SrrrrTrrr�rrr
r)r)r)
�_hashopensslr"r*�_openssl_md_methsZhmac_digestr(�getattrr3r4r6r7r9r8)r;r<r4r)r,r+r1rrTrr4�s,	��

r4)Nr)rI�warningsr/�	_operatorrZcompare_digestrrU�ImportErrorrV�	frozensetZopenssl_md_meth_namesZhashlibrrQr#�ranger8r9r-rrOrPr rr4rrrr�<module>s*

u


?>