ffddlmZddlmZmZmZmZmZmZm Z ddl m Z ddl m Z dZdZdZdZGd d eZd Zdd Zd S))bchr) VoidPointer SmartPointercreate_string_bufferget_raw_bufferc_size_t c_uint8_ptrc_ubyte) long_to_bytes)_raw_keccak_libc|ddzkr|dksJ|dkrdn|dzdz}t|t|zS)z2Left encode function as defined in NIST SP 800-185r) bit_lengthrr xnums w/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Hash/cSHAKE128.py _left_encoder+s\ dOOQ &Avv!!ALLNNQ.14C 99}Q'' ''c|ddzkr|dksJ|dkrdn|dzdz}t|t|zS)z3Right encode function as defined in NIST SP 800-185rrrrr)rr rrs r _right_encoder6s\ dOOQ &Avv!!ALLNNQ.14C   d3ii ''rczt|dz}|ddzkrtdt||zS)z4Encode string function as defined in NIST SP 800-185rrrz$String too large to encode in cSHAKE)len ValueErrorr)rbitlens r _encode_strrAsDVVaZF !t)?@@@   ! ##rcft||z}|t||zz |z}|d|zzS)z2Zero pad byte string as defined in NIST SP 800-185)rr)rlengthto_padnpads r_bytepadr%KsA& ! !A %F S[[6) )V 3D GdN ""rc$eZdZdZdZdZdZdS) cSHAKE_XOFz]A cSHAKE hash object. Do not instantiate directly. Use the :func:`new` function. c8t}|s|r=t|t|z}t|d|z dz}d|_n d}d|_t j|t|dztd}|rtd|zt| tj |_ d|_|r|||r||dSdS)Ni@rz#Error %d while instantiating cSHAKEF)rrr%_paddingr keccak_init address_ofrr rrgetkeccak_destroy_state _is_squeezingupdate) selfdatacustomcapacityfunctionstate prefix_unpadprefixresults r__init__zcSHAKE_XOF.__init__]s/   !X !&x00;v3F3FFLlTH_q,@AAF DMMF DM ,U-=-=-?-?-5hk-B-B-4R[[::  'B%&'' '"599;;#2#ACC "  KK      KK       rc |jrtdtj|jt |tt|}|rtd||j fz|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 %s state) r2 TypeErrorr keccak_absorbr1r/r rrrname)r4r5r<s rr3zcSHAKE_XOF.updatexs   OMNN N .t{/@/@/:4/@/@/7D /B/BDD  4? & 2344 4 rcd|_t|}tj|j|t |t|j}|rtd||j fzt|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 %s) r2rr keccak_squeezer1r/rr r,rrAr)r4r"bfrr<s rreadzcSHAKE_XOF.reads""6** / 0A0A03080@0@07 0F0FHH  4@ & 2344 4c"""rN)__name__ __module__ __qualname____doc__r=r3rErrr'r'WsK 6$#####rr'c&t||d|S)Nr')r5r6r8s r_newrNs dFC 2 22rNc&t||ddS)azReturn a fresh instance of a cSHAKE128 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 bytestring (``S`` in SP 800-185). :Return: A :class:`cSHAKE_XOF` object rLrrM)r5r6s rnewrPs dFC - --r)NN)Crypto.Util.py3compatrCrypto.Util._raw_apirrrrrr r Crypto.Util.numberr Crypto.Hash.keccakr rrrr%objectr'rNrPrJrrrVs5>'&&&&&888888888888888888 -,,,,,......(((((($$$ # # #L#L#L#L#L#L#L#L#^333 ......r