Your IP : 18.222.161.57


Current Path : /opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Hash/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Hash/__pycache__/HMAC.cpython-311.pyc

�

O�Dgp��~�ddlmZmZddlmZddlmZddlmZddlm	Z	ddl
mZddgZGd	�de
��Zd
d�ZdS)�)�bord�tobytes)�	unhexlify)�MD5)�BLAKE2s)�strxor)�get_random_bytes�new�HMACc�D�eZdZdZdd�Zd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�ZdS)
rz�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
    �Nc���|�t}|�d}|j|_||_t|t��r|���}	t
|��|jkr|d|jt
|��z
zz}nD|�|���	��}|d|jt
|��z
zz}n#t$rtd���wxYwt|dt
|��z��}|�|��|_
|j
�|��t|dt
|��z��}|�|��|_dS)Nr
�zHash type incompatible to HMAC�6�\)r�digest_size�
_digestmod�
isinstance�
memoryviewr�len�
block_sizer
�digest�AttributeError�
ValueErrorr�_inner�update�_outer)�self�key�msg�	digestmod�key_0�hash_k�
key_0_ipad�
key_0_opads        �r/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Hash/HMAC.py�__init__z
HMAC.__init__6se�����I��;��C�%�0���#����c�:�&�&�	 ��+�+�-�-�C�
	?��3�x�x�9�/�/�/��g��)=��C���)H�I�I���#���s�+�+�2�2�4�4����I�,@�3�v�;�;�,N�!O�O�����	?�	?�	?��=�>�>�>�	?����
�E�7�S��Z�Z�#7�8�8�
� �m�m�J�/�/�������3�����E�7�S��Z�Z�#7�8�8�
� �m�m�J�/�/����s
�A:C�C c�:�|j�|��|S)z�Authenticate the next chunk of message.

        Args:
            data (byte string/byte array/memoryview): The next chunk of data
        )rr)rr s  r&rzHMAC.update_s��	
����3�����r
c�T�|j�|j|j||��}|S)z2Carry out the expensive inner loop for PBKDF2-HMAC)r�_pbkdf2_hmac_assistrr)r�first_digest�
iterations�results    r&r*zHMAC._pbkdf2_hmac_assistis2����4�4�$(�K�$(�K�$0�$.�	0�0��
�
r
c��td|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`
        sfake key)r!)rrr�copyr)r�new_hmacs  r&r/z	HMAC.copyssI����t��?�?�?���+�*�*�,�,����+�*�*�,�,����r
c��|j���}|�|j�����|���S)z�Return 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
        )rr/rrr)r�frozen_outer_hashs  r&rzHMAC.digest�sL��!�K�,�,�.�.��� � ���!3�!3�!5�!5�6�6�6� �'�'�)�)�)r
c��td��}tjd||���}tjd||������}|���|���krt	d���dS)ahVerify 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�datazMAC check failedN)r	rr
rr)r�mac_tag�secret�mac1�mac2s     r&�verifyzHMAC.verify�sw��"�"�%�%���{�s��W�E�E�E���{�s��T�[�[�]�]�K�K�K���;�;�=�=�D�K�K�M�M�)�)��/�0�0�0�*�)r
c�~�d�d�t|�����D����S)z�Return 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
        �c�2�g|]}dt|��z��S)z%02x)r)�.0�xs  r&�
<listcomp>z"HMAC.hexdigest.<locals>.<listcomp>�s3��7�7�7����a���(�7�7�7r
)�join�tupler)rs r&�	hexdigestzHMAC.hexdigest�sF���w�w�7�7�!&�t�{�{�}�}�!5�!5�7�7�7�8�8�	8r
c�d�|�tt|������dS)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<rr)r�hex_mac_tags  r&�	hexverifyzHMAC.hexverify�s,��	
���I�g�k�2�2�3�3�4�4�4�4�4r
�r
N)�__name__�
__module__�__qualname__�__doc__r'rr*r/rr<rErH�r
r&rr.s���������'0�'0�'0�'0�R���������&*�*�*�1�1�1�(	8�	8�	8�
5�
5�
5�
5�
5r
r
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)rr r!s   r&r
r
�s��&��S�)�$�$�$r
rI)�Crypto.Util.py3compatrr�binasciir�Crypto.Hashrr�Crypto.Util.strxorr�
Crypto.Randomr	�__all__�objectrr
rNr
r&�<module>rWs���D0�/�/�/�/�/�/�/�������������������%�%�%�%�%�%�*�*�*�*�*�*��&�/��Q5�Q5�Q5�Q5�Q5�6�Q5�Q5�Q5�h%�%�%�%�%�%r

?>