Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/Cryptodome/Hash/__pycache__/BLAKE2s.cpython-39.pyc
Ðазад
a b�h�$ � @ sr d dl mZ d dlmZmZ d dlmZ d dlmZm Z m Z mZmZm Z mZ edd�ZG dd� de�Zd d � ZdS )� )� unhexlify)�bord�tobytes)�get_random_bytes)�load_pycryptodome_raw_lib�VoidPointer�SmartPointer�create_string_buffer�get_raw_buffer�c_size_t�c_uint8_ptrzCryptodome.Hash._BLAKE2sa� int blake2s_init(void **state, const uint8_t *key, size_t key_size, size_t digest_size); int blake2s_destroy(void *state); int blake2s_update(void *state, const uint8_t *buf, size_t len); int blake2s_digest(const void *state, uint8_t digest[32]); int blake2s_copy(const void *src, void *dst); c @ sL e Zd ZdZdZdd� Zdd� Zdd� Zd d � Zdd� Z d d� Z dd� ZdS )�BLAKE2s_Hasha� A BLAKE2s 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 � c C s� || _ || _d| _|dv r,|s,dt|� | _t� }t�|�� t |�t t|��t |��}|rftd| ��t |�� tj�| _|r�| �|� d S )NF)� � � r z1.3.6.1.4.1.1722.12.2.2.z$Error %d while instantiating BLAKE2s)�digest_size�_update_after_digest�_digest_done�str�oidr �_raw_blake2s_libZblake2s_initZ address_ofr r �len� ValueErrorr �getZblake2s_destroy�_state�update)�self�data�key�digest_bytes�update_after_digest�state�result� r$ ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/Cryptodome/Hash/BLAKE2s.py�__init__L s$ ��zBLAKE2s_Hash.__init__c C sH | j r| jstd��t�| j�� t|�tt |���}|rDt 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. z8You can only call 'digest' or 'hexdigest' on this objectz#Error %d while hashing BLAKE2s data)r r � TypeErrorr Zblake2s_updater r r r r r )r r r# r$ r$ r% r f s �zBLAKE2s_Hash.updatec C sB t d�}t�| j�� |�}|r*td| ��d| _t|�d| j� 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 z&Error %d while creating BLAKE2s digestTN) r r Zblake2s_digestr r r r r r )r Zbfrr# r$ r$ r% �digestx s �zBLAKE2s_Hash.digestc C s d� dd� t| �� �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)r )�.0�xr$ r$ r% � <listcomp>� � z*BLAKE2s_Hash.hexdigest.<locals>.<listcomp>)�join�tupler( )r r$ r$ r% � hexdigest� s zBLAKE2s_Hash.hexdigestc C sD t d�}td||d�}td|| �� d�}|�� |�� kr@td��dS )ag Verify that a given **binary** MAC (computed by another party) is valid. Args: mac_tag (byte string/byte array/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. r � )�digest_bitsr r zMAC check failedN)r �newr( r )r Zmac_tag�secretZmac1Zmac2r$ r$ r% �verify� s zBLAKE2s_Hash.verifyc C s | � tt|��� dS )an 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)r5 r r )r Zhex_mac_tagr$ r$ r% � hexverify� s zBLAKE2s_Hash.hexverifyc K s( d|vrd|vr| j |d<