File: //opt/saltstack/salt/lib/python3.10/site-packages/Cryptodome/Hash/__pycache__/MD5.cpython-310.pyc
o
�N�g� � @ sd d dl T d dlmZmZmZmZmZmZmZ edd�Z G dd� de
�Zddd �Zd
Z
dZdd
� ZdS )� )�*)�load_pycryptodome_raw_lib�VoidPointer�SmartPointer�create_string_buffer�get_raw_buffer�c_size_t�c_uint8_ptrzCryptodome.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 Zd ZdZdZdZdZddd�Zdd � Zd
d� Z dd
� Z
dd� Zddd�ZdS )�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
� �@ z1.2.840.113549.2.5Nc C sL t � }t�|�� �}|rtd| ��t|�� tj�| _|r$| � |� d S d S )N� Error %d while instantiating MD5)
r �_raw_md5_libZMD5_initZ
address_of�
ValueErrorr �getZMD5_destroy�_state�update)�self�data�state�result� r �G/opt/saltstack/salt/lib/python3.10/site-packages/Cryptodome/Hash/MD5.py�__init__H s ���zMD5Hash.__init__c C s4 t �| j�� t|�tt|���}|rtd| ��dS )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
���zMD5Hash.updatec C s4 t | j�}t�| j�� |�}|rtd| ��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
��zMD5Hash.digestc C s d� dd� | �� 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 |� �qS )z%02x)Zbord)�.0�xr r r �
<listcomp>z s z%MD5Hash.hexdigest.<locals>.<listcomp>)�joinr )r r r r � hexdigestr s zMD5Hash.hexdigestc C s2 t � }t�| j�� |j�� �}|rtd| ��|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
zError %d while copying MD5)r
r ZMD5_copyr r r )r �cloner r r r �copy| s �zMD5Hash.copyc C s t |�S )z!Create a fresh SHA-1 hash object.)r
)r r r r r �new� s zMD5Hash.new�N)
�__name__�
__module__�__qualname__�__doc__r �
block_size�oidr r r r# r% r&