
    ,h                     h    d dl mZmZmZmZmZmZmZ d dlm	Z	 d dl
mZ ddlmZ  G d de      Zd Zy	)
    )VoidPointerSmartPointercreate_string_bufferget_raw_bufferc_size_tc_uint8_ptrc_ubyte)long_to_bytes)bchr   )_raw_keccak_libc                   0    e Zd ZdZd Zd Zd ZddZd Zy)	
TurboSHAKEzaA TurboSHAKE hash object.
    Do not instantiate directly.
    Use the :func:`new` function.
    c                 R   t               }t        j                  |j                         t	        |      t        d            }|rt        d|z        t        |j                         t        j                        | _
        d| _        || _        || _        |r| j                  |       y y )N   z'Error %d while instantiating TurboSHAKEF)r   r   keccak_init
address_ofr   r	   
ValueErrorr   getkeccak_destroy_state_is_squeezing	_capacity_domainupdate)selfcapacitydomain_separationdatastateresults         [/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/Crypto/Hash/TurboSHAKE128.py__init__zTurboSHAKE.__init__   s     ,,U-=-=-?-5h-?-4R[: F%& ' '"599;0N0NO"!(KK     c           	          | j                   rt        d      t        j                  | j                  j                         t        |      t        t        |                  }|rt        d|z        | S )zContinue 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   keccak_absorbr   r   r   r   lenr   )r   r   r!   s      r"   r   zTurboSHAKE.update%   sm     MNN ..t{{/@/:4/@/7D	/BD G%& ' 'r$   c                     d| _         t        |      }t        j                  | j                  j                         |t        |      t        | j                              }|rt        d|z        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   keccak_squeezer   r   r   r	   r   r   r   )r   lengthbfrr!   s       r"   readzTurboSHAKE.read7   su     ""6* //0A03080@070EG H%& ' ' c""r$   Nc                 P     t        |       | j                  | j                  |      S N)typer   r   )r   r   s     r"   newzTurboSHAKE.newR   s    tDz$..$,,==r$   c                     t        j                  | j                  j                               }|rt	        d|z        d| _        y )Nz)Error %d while resetting TurboSHAKE stateF)r   keccak_resetr   r   r   r   )r   r!   s     r"   _resetzTurboSHAKE._resetU   s@     --dkkoo.?@H%& ' '"r$   r/   )	__name__
__module____qualname____doc__r#   r   r-   r1   r4    r$   r"   r   r      s     
&$#6>#r$   r   c                      | j                  dd      }d|cxk  rdk  sn t        d|z        | j                  d      }t        d||      S )	a  Create a new TurboSHAKE128 object.

    Args:
       domain (integer):
         Optional - A domain separation byte, between 0x01 and 0x7F.
         The default value is 0x1F.
       data (bytes/bytearray/memoryview):
        Optional - The very first chunk of the message to hash.
        It is equivalent to an early call to :meth:`update`.

    :Return: A :class:`TurboSHAKE` object
    domain   r      z&Incorrect domain separation value (%d)r       )r   )r   r   r   )kwargsr   r   s      r"   r1   r1   ]   sY     

8T2%--A*+ , 	,::fDb+$77r$   N)Crypto.Util._raw_apir   r   r   r   r   r   r	   Crypto.Util.numberr
   Crypto.Util.py3compatr   keccakr   objectr   r1   r9   r$   r"   <module>rE      s3   8 8 8
 - & #N# N#b8r$   