관리-도구
편집 파일: cSHAKE128.cpython-311.pyc
� O�Dg� � � � d dl mZ d dlmZmZmZmZmZmZm Z d dl mZ d dlm Z d� Zd� Zd� Zd� Z G d � d e� � Zd� Zdd �ZdS )� )�bchr)�VoidPointer�SmartPointer�create_string_buffer�get_raw_buffer�c_size_t�c_uint8_ptr�c_ubyte)� long_to_bytes)�_raw_keccak_libc � � | ddz k r| dk sJ �| dk rdn| � � � dz dz }t |� � t | � � z S )z2Left encode function as defined in NIST SP 800-185� � r � � )� bit_lengthr r ��x�nums �w/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Hash/cSHAKE128.py�_left_encoder + s\ � � ��d��O�O��Q����&� �A�v�v�!�!�A�L�L�N�N�Q�.�1�4�C���9�9�}�Q�'�'�'�'� c � � | ddz k r| dk sJ �| dk rdn| � � � dz dz }t | � � t |� � z S )z3Right encode function as defined in NIST SP 800-185r r r r r )r r r r s r � _right_encoder 6 s\ � � ��d��O�O��Q����&� �A�v�v�!�!�A�L�L�N�N�Q�.�1�4�C�����d�3�i�i�'�'r c �z � t | � � dz }|ddz k rt d� � �t |� � | z S )z4Encode string function as defined in NIST SP 800-185r r r z$String too large to encode in cSHAKE)�len� ValueErrorr )r �bitlens r �_encode_strr A sD � � ��V�V�a�Z�F� �!�t�)����?�@�@�@�����!�#�#r c �f � t |� � | z }|t |� � |z z |z }|d|z z S )z2Zero pad byte string as defined in NIST SP 800-185� )r r )r �length�to_pad�npads r �_bytepadr% K sA � � �&� !� !�A� %�F� �S��[�[�6�)�)�V�3�D��G�d�N�"�"r c �$ � e Zd ZdZd� Zd� Zd� ZdS )� cSHAKE_XOFz]A cSHAKE hash object. Do not instantiate directly. Use the :func:`new` function. c �8 � t � � }|s|r=t |� � t |� � z }t |d|z dz � � }d| _ n d }d| _ t j |� � � t |dz � � t d� � � � }|rt d|z � � �t |� � � t j � � | _ d| _ |r| � |� � |r| � |� � d S d S )Ni@ r � � � z#Error %d while instantiating cSHAKEF)r r r% �_paddingr �keccak_init� address_ofr r r r �get�keccak_destroy�_state� _is_squeezing�update) �self�data�custom�capacity�function�state�prefix_unpad�prefix�results r �__init__zcSHAKE_XOF.__init__] s/ � �� � ��� !�X� !�&�x�0�0�;�v�3F�3F�F�L��l�T�H�_�q�,@�A�A�F� �D�M�M��F� �D�M� �,�U�-=�-=�-?�-?�-5�h��k�-B�-B�-4�R�[�[�:� :�� � '��B�%�&� '� '� '�"�5�9�9�;�;�#2�#A�C� C���"���� ��K�K������ ��K�K������� � r c � � | j rt d� � �t j | j � � � t |� � t t |� � � � � � }|rt d|| j fz � � �| 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 %s state)r2 � TypeErrorr � keccak_absorbr1 r/ r r r r �name)r4 r5 r<