File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/Cryptodome/Hash/__pycache__/KangarooTwelve.cpython-310.pyc
Back
o ;j � @ sZ d dl mZ d dlmZ ddlmZ dd� ZdZdZdZ d Z G d d� de�Zdd d�Z dS )� )� long_to_bytes)�bchr� )� TurboSHAKE128c C s$ | dkrdS t | �}|tt|�� S )Nr � )r r �len)�x�S� r �R/opt/saltstack/salt/lib/python3.10/site-packages/Cryptodome/Hash/KangarooTwelve.py�_length_encode$ s r � � � c @ s2 e Zd ZdZdd� Zdd� Zdd� Zdd d�ZdS ) �K12_XOFzeA KangarooTwelve hash object. Do not instantiate directly. Use the :func:`new` function. c C sf |d krd}|t t|�� | _t| _d | _tjdd�| _d| _ d | _ d| _d| _|r1| � |� d S d S )N� r ��domainr )r r �_custom� SHORT_MSG�_state�_paddingr �new�_hash1�_length1�_hash2�_length2�_ctr�update��self�data�customr r r �__init__9 s �zK12_XOF.__init__c C s� | j tkr td��| j tkr,| jt|� }|t| j� dkr)|| _| j�|� | S t | _ | j t kr�t |�}| jdk s<J �tt|�d| j �}| j�|d|� � | j|7 _| jdk r^| S | jdkseJ �d}| j�|� | jd7 _tj dd�| _d| _d | _t| _ | �||d� �S | j tks�J �d}t|�}t |�}||k r�t|d | j |�}| j�|||� � | j|| 7 _|}| jdkr�| j�d �} | j�| � | jd 7 _| j�� d| _| jd 7 _||k s�| S )a Hash the next piece of data. .. note:: For better performance, submit chunks with a length multiple of 8192 bytes. Args: data (byte string/byte array/memoryview): The next chunk of the message to hash. z/You cannot call 'update' after the first 'read'i Ns � � r r r � )r � SQUEEZING� TypeErrorr r r r r r �LONG_MSG_S0� memoryview�minr r r r r �LONG_MSG_SX�read�_reset) r r! Znext_lengthZdata_memZdtcZdivider�indexZlen_dataZ new_index�cv_ir r r r Q sX �zK12_XOF.updatec C s� d}| j tkr| j�| j� d| _t| _ | j tkr(| �| j� d}| j tks(J �| j tkrq|s5| �| j� | j dkr\| j �d�}| j�|� | jd7 _| j � � d| _ | jd7 _t| jd �d }| j�|� d| _t| _ | j| j_| j�|�S ) ad Produce more bytes of the digest. .. 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 F� Tr r&