U +Mb@s^ddlmZddlmZmZmZmZmZmZm Z m Z ddl m Z Gddde Zd ddZdS) )bord)load_pycryptodome_raw_lib VoidPointer SmartPointercreate_string_bufferget_raw_bufferc_size_t c_uint8_ptrc_ubyte)_raw_keccak_libc@s8eZdZdZdZd ddZddZdd Zd d d ZdS) SHAKE256_XOFzA SHAKE256 hash object. Do not instantiate directly. Use the :func:`new` function. :ivar oid: ASN.1 Object ID :vartype oid: string z2.16.840.1.101.3.4.2.12NcCs`t}t|tdtd}|r0td|t|tj |_ d|_ d|_ |r\| |dS)N@z%Error %d while instantiating SHAKE256F)rr Z keccak_initZ address_ofrr ValueErrorrgetZkeccak_destroy_state _is_squeezing_paddingupdate)selfdatastateresultr;/tmp/pip-target-t616c12r/lib/python/Crypto/Hash/SHAKE256.py__init__5s  zSHAKE256_XOF.__init__cCsB|jrtdt|jt|tt|}|r>t d||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 SHAKE256 state) r TypeErrorr Z keccak_absorbrrr rlenr)rrrrrrrEs  zSHAKE256_XOF.updatecCsFd|_t|}t|j|t|t|j}|r>t d|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 SHAKE256) rrr Zkeccak_squeezerrrr rrr)rlengthZbfrrrrrreadWs zSHAKE256_XOF.readcCst||dS)Nr)type)rrrrrnewrszSHAKE256_XOF.new)N)N) __name__ __module__ __qualname____doc__oidrrr r#rrrrr )s   r NcCs t|dS)aReturn a fresh instance of a SHAKE256 object. Args: data (bytes/bytearray/memoryview): The very first chunk of the message to hash. It is equivalent to an early call to :meth:`update`. Optional. :Return: A :class:`SHAKE256_XOF` object r!)r r!rrrr#vs r#)N)ZCrypto.Util.py3compatrZCrypto.Util._raw_apirrrrrrr r ZCrypto.Hash.keccakr objectr r#rrrrs ( M