ffE#ddlmZmZmZmZmZmZmZddlm Z ddl m Z ddl m Z dZdZdZdZd ZGd d eZdd Zd S)) VoidPointer SmartPointercreate_string_bufferget_raw_bufferc_size_t c_uint8_ptrc_ubyte) long_to_bytes)bchr)_raw_keccak_libcn|dkrdSt|}|tt|zS)Nr)r r len)xSs |/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Hash/KangarooTwelve.py_length_encoder*s4AvvwaA tCFF|| cDeZdZdZdZdZdZdZdZdZ dZ d d Z d S) K12_XOFzeA KangarooTwelve hash object. Do not instantiate directly. Use the :func:`new` function. c |dkrd}|tt|z|_t|_d|_||_d|_d|_ d|_ d|_ |r| |dSdS)Nrr) rr_custom SHORT_MSG_state_padding_create_keccak_hash1_length1_hash2_length2_ctrupdateselfdatacustoms r__init__zK12_XOF.__init__?s T>>Fs6{{ ; ;;   ))++       KK       rc"t}tj|t dt d}|rt d|zt|tj S)N z+Error %d while instantiating KangarooTwelve) rr keccak_init address_ofrr ValueErrorrgetkeccak_destroy)r(stateresults rr zK12_XOF._create_keccakVs  ,U-=-=-?-?-5b\\-4R[[::  'J%&'' 'EIIKK)GHHHrc tj|t|t t |}|rt d|zdS)Nz,Error %d while updating KangarooTwelve state)r keccak_absorbr2rrrr1)r(r)hash_objr5s r_updatezK12_XOF._update`sm .x||~~/:4/@/@/7D /B/BDD  'K%&'' ' ' 'rct|}tj||t |t |}|rt d|zt|S)Nz-Error %d while extracting from KangarooTwelve)rr keccak_squeezer2rr r1r)r(r8lengthpaddingbfrr5s r_squeezezK12_XOF._squeezehs}"6** / 03080@0@070@0@BB  'L%&'' 'c"""rcztj|}|rtd|zdS)Nz-Error %d while resetting KangarooTwelve state)r keccak_resetr2r1)r(r8r5s r_resetzK12_XOF._resettsI -hllnn==  'L%&'' ' ' 'rc|jtkrtd|jtkrb|jt |z}|t |jzdkr$||_|||j|St|_|jtkr t|}|jdksJtt |d|jz }||d||j|xj|z c_|jdkr|S|jdksJd}|||j|xjdz c_| |_ d|_d|_t |_|||dS|jt ksJd}t |}t|}||krt|dz|jz |}|||||j |xj||z z c_|}|jdkrx||j dd } || |j|xjdz c_||j d|_|xjdz c_||k|S) aHash 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 Nsrr r- )r SQUEEZING TypeErrorrr"rrr9r! LONG_MSG_S0 memoryviewminr r#r$r% LONG_MSG_SXr&r?rB) r(r) next_lengthdata_memdtcdividerindexlen_data new_indexcv_is rr&zK12_XOF.updatezs ;) # #MNN N ;) # #-#d))3KS...$66 +  T4;/// &DK ;+ % %!$''H=4''''c$ii !566C LL$3$ 5 5 5 MMS MM}t## =D((((+G LL$+ . . . MMQ MM--//DKDMDI%DK;;x~.. .{k))))t99d##hEDL4=8(CCI LL% /2DK @ @ @ MMY. .MME}$$}}T["d;; T4;/// #  DK((( !  Q h rc8d}|jtkr3||j|jd|_t |_|jtkr.||jd}|jtksJ|jtkr|s||j|j dkrx| |j dd}|||j|xj dz c_ ||j d|_ |xjdz c_t!|jdz dz}|||jd |_t |_| |j||jS) ad 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 FTrr-rEr s)rrr9rr!rrFrHr&rKr$r?r#r"rBr%r)r(r<custom_was_consumedrStrailers rreadz K12_XOF.readsl$ ;) # # LLt{ 3 3 3 DM#DK ;+ % % KK % % %"& ;+---- ;+ % %& * DL)))}q  }}T["d;; T4;/// #  DK((( !  Q $TY]33kAG LL$+ . . . DM#DK}}T[&$-@@@rNrc4t|||S)N)typer's rnewz K12_XOF.newstDzz$'''r)Nr) __name__ __module__ __qualname____doc__r+r r9r?rBr&rYr\rrrr9s .III''' # # #''' GGGR.A.A.A`((((((rrNc"t||S)agReturn 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 rr\r\s 4  r)NN)Crypto.Util._raw_apirrrrrrr Crypto.Util.numberr Crypto.Util.py3compatr keccakr rrrHrKrFobjectrr\rarrrhs >888888888888888888 -,,,,,&&&&&&######    {({({({({(f{({({(|!!!!!!r