o
    Ìn~bë  ã                   @   sd   d dl mZ 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ejZejZdS )é    ©Úbord)Úload_pycryptodome_raw_libÚVoidPointerÚSmartPointerÚcreate_string_bufferÚget_raw_bufferÚc_size_tÚc_uint8_ptrzCryptodome.Hash._MD2aí  
                        int md2_init(void **shaState);
                        int md2_destroy(void *shaState);
                        int md2_update(void *hs,
                                          const uint8_t *buf,
                                          size_t len);
                        int md2_digest(const void *shaState,
                                          uint8_t digest[20]);
                        int md2_copy(const void *src, void *dst);
                        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 )ÚMD2Hasha“  An MD2 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.2Nc                 C   sL   t ƒ }t | ¡ ¡}|rtd| ƒ‚t| ¡ tjƒ| _|r$|  	|¡ d S d S )Nú Error %d while instantiating MD2)
r   Ú_raw_md2_libZmd2_initZ
address_ofÚ
ValueErrorr   ÚgetZmd2_destroyÚ_stateÚupdate)ÚselfÚdataÚstateÚresult© r   ú>/usr/local/lib/python3.10/dist-packages/Cryptodome/Hash/MD2.pyÚ__init__K   s   ÿÿÿzMD2Hash.__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
md2_updater   r   r
   r	   Úlenr   )r   r   r   r   r   r   r   V   s   
þÿÿzMD2Hash.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
md2_digestr   r   r   r   )r   Zbfrr   r   r   r   Údigestd   s   
ÿÿzMD2Hash.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%02xr   )Ú.0Úxr   r   r   Ú
<listcomp>}   s    z%MD2Hash.hexdigest.<locals>.<listcomp>)Újoinr   )r   r   r   r   Ú	hexdigestu   s   zMD2Hash.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 MD2)r   r   Zmd2_copyr   r   r   )r   Úcloner   r   r   r   Úcopy   s   ÿzMD2Hash.copyc                 C   s   t |ƒS ©N)r   )r   r   r   r   r   Únew‘   s   zMD2Hash.newr%   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú
block_sizeÚoidr   r   r   r"   r$   r&   r   r   r   r   r   5   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:`MD2Hash.update`.
    :type data: bytes/bytearray/memoryview

    :Return: A :class:`MD2Hash` hash object
    )r   r&   )r   r   r   r   r&   •   s   r&   r%   )ZCryptodome.Util.py3compatr   ZCryptodome.Util._raw_apir   r   r   r   r   r	   r
   r   Úobjectr   r&   r   r+   r   r   r   r   Ú<module>   s   $þ
`
