U +¥Mbwã@sZddlmZddlmZmZmZmZmZmZm Z m Z eddƒZ Gdd„de ƒZ dd„Zd S) é©Úbord)Úload_pycryptodome_raw_libÚ VoidPointerÚ SmartPointerÚcreate_string_bufferÚget_raw_bufferÚc_size_tÚ c_uint8_ptrÚc_ubytezCrypto.Hash._keccakaö int keccak_init(void **state, size_t capacity_bytes, uint8_t rounds); int keccak_destroy(void *state); int keccak_absorb(void *state, const uint8_t *in, size_t len); int keccak_squeeze(const void *state, uint8_t *out, size_t len, uint8_t padding); int keccak_digest(void *state, uint8_t *digest, size_t len, uint8_t padding); int keccak_copy(const void *src, void *dst); int keccak_reset(void *state); c@s8eZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd S) Ú Keccak_Hashz¿A Keccak hash object. Do not instantiate directly. Use the :func:`new` function. :ivar digest_size: the size in bytes of the resulting hash :vartype digest_size: integer cCsr||_||_d|_d|_tƒ}t | ¡t|jdƒt dƒ¡}|rNt d|ƒ‚t |  ¡tj ƒ|_|rn| |¡dS)NFéééz#Error %d while instantiating keccak)Ú digest_sizeÚ_update_after_digestÚ _digest_doneÚ_paddingrÚ_raw_keccak_libZ keccak_initZ address_ofr r Ú ValueErrorrÚgetZkeccak_destroyÚ_stateÚupdate)ÚselfÚdataÚ digest_bytesÚupdate_after_digestÚstateÚresult©rú9/tmp/pip-target-t616c12r/lib/python/Crypto/Hash/keccak.pyÚ__init__Es   þ ÿzKeccak_Hash.__init__cCsH|jr|jstdƒ‚t |j ¡t|ƒtt |ƒƒ¡}|rDt d|ƒ‚|S)z¼Continue 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. z8You can only call 'digest' or 'hexdigest' on this objectzError %d while updating keccak) rrÚ TypeErrorrZ keccak_absorbrrr r Úlenr)rrrrrr rXs   þ zKeccak_Hash.updatecCsJd|_t|jƒ}t |j ¡|t|jƒt|j ƒ¡}|rBt d|ƒ‚t |ƒS)zçReturn the **binary** (non-printable) digest of the message that has been hashed so far. :return: The hash digest, computed over the data processed so far. Binary form. :rtype: byte string TzError %d while squeezing keccak) rrrrZ keccak_digestrrr r rrr)rZbfrrrrr Údigestis  ý zKeccak_Hash.digestcCsd dd„| ¡Dƒ¡S)zÝReturn the **printable** digest of the message that has been hashed so far. :return: The hash digest, computed over the data processed so far. Hexadecimal encoded. :rtype: string ÚcSsg|]}dt|ƒ‘qS)z%02xr)Ú.0Úxrrr Ú „sz)Keccak_Hash.hexdigest..)Újoinr$)rrrr Ú hexdigest|szKeccak_Hash.hexdigestcKs$d|krd|kr|j|d<tf|ŽS)z"Create a fresh Keccak hash object.rÚ digest_bits)rÚnew)rÚkwargsrrr r,†s zKeccak_Hash.newN) Ú__name__Ú __module__Ú __qualname__Ú__doc__r!rr$r*r,rrrr r <s  r cKsª| dd¡}| dd¡}| dd¡}| dd¡}d||fkrDtdƒ‚d||fkrXtd ƒ‚|dk rr|d krŠtd ƒ‚n|d kr‚td ƒ‚|d}|ržtdt|ƒƒ‚t|||ƒS)aoCreate a new hash object. Args: data (bytes/bytearray/memoryview): The very first chunk of the message to hash. It is equivalent to an early call to :meth:`Keccak_Hash.update`. digest_bytes (integer): The size of the digest, in bytes (28, 32, 48, 64). digest_bits (integer): The size of the digest, in bits (224, 256, 384, 512). update_after_digest (boolean): Whether :meth:`Keccak.digest` can be followed by another :meth:`Keccak.update` (default: ``False``). :Return: A :class:`Keccak_Hash` hash object rNrFrr+z*Only one digest parameter must be provided)NNz&Digest size (bits, bytes) not provided)éé é0é@z('digest_bytes' must be: 28, 32, 48 or 64)éàéi€iz,'digest_bytes' must be: 224, 256, 384 or 512ézUnknown parameters: )Úpopr"rÚstrr )r-rrrr+rrr r,s"       r,N)ZCrypto.Util.py3compatrZCrypto.Util._raw_apirrrrrr r r rÚobjectr r,rrrr Ús (ÿS