o
    Ìn~bæ  ã                   @   sd   d dl T d dlmZmZmZmZmZmZmZ eddƒZ	G dd„ de
ƒZddd	„Zd
ZdZdd„ ZdS )é    )Ú*)Úload_pycryptodome_raw_libÚVoidPointerÚSmartPointerÚcreate_string_bufferÚget_raw_bufferÚc_size_tÚc_uint8_ptrzCryptodome.Hash._MD5a   
                        #define MD5_DIGEST_SIZE 16

                        int MD5_init(void **shaState);
                        int MD5_destroy(void *shaState);
                        int MD5_update(void *hs,
                                          const uint8_t *buf,
                                          size_t len);
                        int MD5_digest(const void *shaState,
                                          uint8_t digest[MD5_DIGEST_SIZE]);
                        int MD5_copy(const void *src, void *dst);

                        int MD5_pbkdf2_hmac_assist(const void *inner,
                                            const void *outer,
                                            const uint8_t first_digest[MD5_DIGEST_SIZE],
                                            uint8_t final_digest[MD5_DIGEST_SIZE],
                                            size_t iterations);
                        c                   @   sP   e Zd ZdZdZdZdZddd„Zdd	„ Zd
d„ Z	dd„ Z
dd„ Zddd„ZdS )ÚMD5Hasha–  A MD5 hash object.
    Do not instantiate directly.
    Use the :func:`new` function.

    :ivar oid: ASN.1 Object ID
    :vartype oid: string

    :ivar block_size: the size in bytes of the internal message block,
                      input to the compression function
    :vartype block_size: integer

    :ivar digest_size: the size in bytes of the resulting hash
    :vartype digest_size: integer
    é   é@   z1.2.840.113549.2.5Nc                 C   sL   t ƒ }t | ¡ ¡}|rtd| ƒ‚t| ¡ tjƒ| _|r$|  	|¡ d S d S )Nú Error %d while instantiating MD5)
r   Ú_raw_md5_libZMD5_initZ
address_ofÚ
ValueErrorr   ÚgetZMD5_destroyÚ_stateÚupdate)ÚselfÚdataÚstateÚresult© r   ú>/usr/local/lib/python3.10/dist-packages/Cryptodome/Hash/MD5.pyÚ__init__H   s   ÿÿÿzMD5Hash.__init__c                 C   s4   t  | j ¡ t|ƒtt|ƒƒ¡}|rtd| ƒ‚dS )z¼Continue hashing of a message by consuming the next chunk of data.

        Args:
            data (byte string/byte array/memoryview): The next chunk of the message being hashed.
        r   N)r   Z
MD5_updater   r   r	   r   Úlenr   )r   r   r   r   r   r   r   S   s   
þÿÿzMD5Hash.updatec                 C   s4   t | jƒ}t | j ¡ |¡}|rtd| ƒ‚t|ƒS )zçReturn the **binary** (non-printable) digest of the message that has been hashed so far.

        :return: The hash digest, computed over the data processed so far.
                 Binary form.
        :rtype: byte string
        r   )r   Údigest_sizer   Z
MD5_digestr   r   r   r   )r   Úbfrr   r   r   r   Údigesta   s   
ÿÿzMD5Hash.digestc                 C   s   d  dd„ |  ¡ D ƒ¡S )zÝReturn the **printable** digest of the message that has been hashed so far.

        :return: The hash digest, computed over the data processed so far.
                 Hexadecimal encoded.
        :rtype: string
        Ú c                 S   s   g | ]}d t |ƒ ‘qS )z%02x)Zbord)Ú.0Úxr   r   r   Ú
<listcomp>z   s    z%MD5Hash.hexdigest.<locals>.<listcomp>)Újoinr   )r   r   r   r   Ú	hexdigestr   s   zMD5Hash.hexdigestc                 C   s2   t ƒ }t | j ¡ |j ¡ ¡}|rtd| ƒ‚|S )a4  Return a copy ("clone") of the hash object.

        The copy will have the same internal state as the original hash
        object.
        This can be used to efficiently compute the digests of strings that
        share a common initial substring.

        :return: A hash object of the same type
        zError %d while copying MD5)r
   r   ZMD5_copyr   r   r   )r   Úcloner   r   r   r   Úcopy|   s   ÿzMD5Hash.copyc                 C   s   t |ƒS )z!Create a fresh SHA-1 hash object.)r
   )r   r   r   r   r   ÚnewŽ   s   zMD5Hash.new©N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú
block_sizeÚoidr   r   r   r#   r%   r&   r   r   r   r   r
   1   s    

r
   Nc                 C   s   t ƒ  | ¡S )a  Create a new hash object.

    :parameter data:
        Optional. The very first chunk of the message to hash.
        It is equivalent to an early call to :meth:`MD5Hash.update`.
    :type data: byte string/byte array/memoryview

    :Return: A :class:`MD5Hash` hash object
    )r
   r&   )r   r   r   r   r&   ”   s   
r&   r   r   c                 C   s^   t |ƒtksJ ‚|dksJ ‚ttƒ}t | j ¡ |j ¡ ||t|ƒ¡}|r+td| ƒ‚t	|ƒS )z/Compute the expensive inner loop in PBKDF-HMAC.r   z'Error %d with PBKDF2-HMAC assis for MD5)
r   r   r   r   ZMD5_pbkdf2_hmac_assistr   r   r   r   r   )ÚinnerÚouterZfirst_digestZ
iterationsr   r   r   r   r   Ú_pbkdf2_hmac_assist§   s   ûr0   r'   )ZCryptodome.Util.py3compatZCryptodome.Util._raw_apir   r   r   r   r   r   r	   r   Úobjectr
   r&   r   r,   r0   r   r   r   r   Ú<module>   s   $ÿ
c