File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/Cryptodome/Hash/__pycache__/TurboSHAKE128.cpython-310.pyc
Back
o ;j � @ sd d dl mZmZmZmZmZmZmZ d dlm Z d dl mZ ddlm Z G dd� de�Zdd � Zd S )� )�VoidPointer�SmartPointer�create_string_buffer�get_raw_buffer�c_size_t�c_uint8_ptr�c_ubyte)� long_to_bytes)�bchr� )�_raw_keccak_libc @ s: e Zd ZdZdd� Zdd� Zdd� Zd d d �Zdd� ZdS )� TurboSHAKEzaA TurboSHAKE hash object. Do not instantiate directly. Use the :func:`new` function. c C sj t � }t�|�� t|�td��}|rtd| ��t|�� tj �| _ d| _|| _|| _ |r3| �|� d S d S )N� z'Error %d while instantiating TurboSHAKEF)r r Zkeccak_initZ address_ofr r � ValueErrorr �getZkeccak_destroy�_state� _is_squeezing� _capacity�_domain�update)�selfZcapacity�domain_separation�data�state�result� r �Q/opt/saltstack/salt/lib/python3.10/site-packages/Cryptodome/Hash/TurboSHAKE128.py�__init__ s ���zTurboSHAKE.__init__c C sB | j rtd��t�| j�� t|�tt|���}|rt 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. z/You cannot call 'update' after the first 'read'z(Error %d while updating TurboSHAKE state) r � TypeErrorr Z keccak_absorbr r r r �lenr )r r r r r r r % s ��zTurboSHAKE.updatec C sF d| _ t|�}t�| j�� |t|�t| j��}|rt d| ��t |�S )ah Compute the next piece of XOF output. .. note:: You cannot use :meth:`update` anymore after the first call to :meth:`read`. Args: length (integer): the amount of bytes this method must return :return: the next piece of XOF output (of the given length) :rtype: byte string Tz)Error %d while extracting from TurboSHAKE)r r r Zkeccak_squeezer r r r r r r )r �lengthZbfrr r r r �read7 s ��zTurboSHAKE.readNc C s t | �| j| j|�S �N)�typer r )r r r r r �newR s zTurboSHAKE.newc C s* t �| j�� �}|rtd| ��d| _d S )Nz)Error %d while resetting TurboSHAKE stateF)r Zkeccak_resetr r r r )r r r r r �_resetU s � zTurboSHAKE._resetr"