관리-도구
편집 파일: KangarooTwelve.cpython-311.pyc
� O�DgE# � � � d dl mZmZmZmZmZmZmZ d dlm Z d dl mZ ddlm Z d� ZdZdZdZd Z G d � de� � Zdd �ZdS )� )�VoidPointer�SmartPointer�create_string_buffer�get_raw_buffer�c_size_t�c_uint8_ptr�c_ubyte)� long_to_bytes)�bchr� )�_raw_keccak_libc �n � | dk rdS t | � � }|t t |� � � � z S )Nr � )r r �len)�x�Ss �|/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Hash/KangarooTwelve.py�_length_encoder * s4 � ��A�v�v��w��a���A��t�C��F�F�|�|��� � � � c �D � e Zd ZdZd� Zd� Zd� Zd� Zd� Zd� Z d� Z dd�Zd S ) �K12_XOFzeA KangarooTwelve hash object. Do not instantiate directly. Use the :func:`new` function. c � � |d k rd}|t t |� � � � z | _ t | _ d | _ | � � � | _ d| _ d | _ d| _ d| _ |r| � |� � d S d S )Nr r ) r r �_custom� SHORT_MSG�_state�_padding�_create_keccak�_hash1�_length1�_hash2�_length2�_ctr�update��self�data�customs r �__init__zK12_XOF.__init__? s� � ��T�>�>��F���s�6�{�{� ;� ;�;�������� � �)�)�+�+����� � ����� � �� �� ��K�K������� � r c �" � t � � }t j |� � � t d� � t d� � � � }|rt d|z � � �t |� � � t j � � S )N� � z+Error %d while instantiating KangarooTwelve) r r �keccak_init� address_ofr r � ValueErrorr �get�keccak_destroy)r( �state�results r r zK12_XOF._create_keccakV s � �� � �� �,�U�-=�-=�-?�-?�-5�b�\�\�-4�R�[�[�:� :�� � '��J�%�&� '� '� '��E�I�I�K�K��)G�H�H�Hr c �� � t j |� � � t |� � t t |� � � � � � }|rt d|z � � �d S )Nz,Error %d while updating KangarooTwelve state)r � keccak_absorbr2 r r r r1 )r( r) �hash_objr5 s r �_updatezK12_XOF._update` sm � � �.�x�|�|�~�~�/:�4�/@�/@�/7��D� � �/B�/B�D� D�� � '��K�%�&� '� '� '� '� 'r c �� � t |� � }t j |� � � |t |� � t |� � � � }|rt d|z � � �t |� � S )Nz-Error %d while extracting from KangarooTwelve)r r �keccak_squeezer2 r r r1 r )r( r8 �length�padding�bfrr5 s r �_squeezezK12_XOF._squeezeh s} � �"�6�*�*�� �/������03�08��0@�0@�07��0@�0@�B� B�� � '��L�%�&� '� '� '� �c�"�"�"r c �z � t j |� � � � � }|rt d|z � � �d S )Nz-Error %d while resetting KangarooTwelve state)r �keccak_resetr2 r1 )r( r8 r5 s r �_resetzK12_XOF._resett sI � � �-�h�l�l�n�n�=�=��� '��L�%�&� '� '� '� '� 'r c � � | j t k rt d� � �| j t k rb| j t |� � z }|t | j � � z dk r$|| _ | � || j � � | S t | _ | j t k �rt |� � }| j dk sJ �t t |� � d| j z � � }| � |d|� | j � � | xj |z c_ | j dk r| S | j dk sJ �d}| � || j � � | xj dz c_ | � � � | _ d| _ d| _ t | _ | � ||d� � � S | j t k sJ �d}t |� � }t |� � }||k r�t |dz | j z |� � }| � |||� | j � � | xj ||z z c_ |}| j dk rx| � | j dd � � } | � | | j � � | xj dz c_ | � | j � � d| _ | xj dz c_ ||k ��| 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"