
    i                     ^    S SK Jr  S SKJr  SSKJr  S rSrSrSr	Sr
 " S	 S
\5      rSS jrg)    )long_to_bytes)bchr   )TurboSHAKE128c                 T    U S:X  a  g[        U 5      nU[        [        U5      5      -   $ )Nr       )r   r   len)xSs     U/var/www/html/trading/venv/lib/python3.13/site-packages/Crypto/Hash/KangarooTwelve.py_length_encoder   $   s)    AvaAtCF|             c                   4    \ rS rSrSrS rS rS rS	S jrSr	g)
K12_XOF3   zYA KangarooTwelve hash object.
Do not instantiate directly.
Use the :func:`new` function.
c                    US :X  a  SnU[        [        U5      5      -   U l        [        U l        S U l        [        R                  " SS9U l        SU l	        S U l
        SU l        SU l        U(       a  U R                  U5        g g )Nr   r   domainr   )r   r	   _custom	SHORT_MSG_state_paddingr   new_hash1_length1_hash2_length2_ctrupdateselfdatacustoms      r   __init__K12_XOF.__init__9   sy    T>Fs6{ ;; $''q1  	KK r   c                    U R                   [        :X  a  [        S5      eU R                   [        :X  ab  U R                  [        U5      -   nU[        U R                  5      -   S::  a#  X l        U R                  R                  U5        U $ [        U l         U R                   [        :X  Ga  [        U5      nU R                  S:  d   e[        [        U5      SU R                  -
  5      nU R                  R                  USU 5        U =R                  U-  sl        U R                  S:  a  U $ U R                  S:X  d   eSnU R                  R                  U5        U =R                  S-  sl        [        R                  " SS9U l        SU l        S	U l        ["        U l         U R                  X4S 5      $ U R                   ["        :X  d   eSn[        U5      n[        U5      nXg:  a  [        US-   U R                  -
  U5      nU R                  R                  X6U 5        U =R                  X-
  -  sl        UnU R                  S:X  a  U R                  R%                  S
5      n	U R                  R                  U	5        U =R                  S
-  sl        U R                  R'                  5         SU l        U =R                   S	-  sl        Xg:  a  M  U $ )zHash 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%   next_lengthdata_memdtcdividerindexlen_data	new_indexcv_is
             r   r"   K12_XOF.updateQ   sM    ;;)#MNN;;)#--#d)3KS..$6 +""4( &DK;;+%!$'H==4'('c$i!56CKKx~.MMS M}}t# ==D()(+GKKw'MMQM'++48DKDMDI%DK;;x~.. {{k)*)t9 d#EDL4==8(CIKKxi89MMY..ME}}${{''+""4(#""$ !		Q	  r   c                    SnU R                   [        :X  a7  U R                  R                  U R                  5        SU l        [        U l         U R                   [        :X  a3  U R                  U R                  5        SnU R                   [        :X  d   eU R                   [        :X  a  U(       d  U R                  U R                  5        U R                  S:  a  U R                  R                  S5      nU R                  R                  U5        U =R                  S-  sl        U R                  R                  5         SU l	        U =R                  S-  sl        [        U R                  S-
  5      S-   nU R                  R                  U5        SU l        [        U l         U R
                  U R                  l        U R                  R                  U5      $ )	a  
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,   r   s      )r   r   r   r"   r   r   r-   r/   r2   r    r   r3   r   r4   r!   r   _domain)r$   lengthcustom_was_consumedr<   trailers        r   r3   K12_XOF.read   sO    $;;)#KKt||, DM#DK;;+%KK%"&;;+-.-;;+%&DLL) }}q {{''+""4(#""$ !		Q	$TYY]3kAGKKw' DM#DK"mm{{''r   Nc                 $    [        U 5      " X5      $ )N)typer#   s      r   r   K12_XOF.new   s    Dz$''r   )r!   r   r   r   r   r    r   r   )Nr   )
__name__
__module____qualname____firstlineno____doc__r'   r"   r3   r   __static_attributes__ r   r   r   r   3   s    
0GR/(b(r   r   Nc                     [        X5      $ )a?  Return a fresh instance of a KangarooTwelve object.

Args:
   data (bytes/bytearray/memoryview):
    Optional.
    The very first chunk of the message to hash.
    It is equivalent to an early call to :meth:`update`.
   custom (bytes):
    Optional.
    A customization byte string.

:Return: A :class:`K12_XOF` object
)r   )r%   r&   s     r   r   r      s     4  r   )NN)Crypto.Util.numberr   Crypto.Util.py3compatr    r   r   r   r/   r2   r-   objectr   r   rO   r   r   <module>rU      s?   > - &  		Y(f Y(x!r   