U +¥Mb(ã@shddlmZddlmZmZmZmZmZmZm Z eddƒZ Gdd„de ƒZ ddd „Z d Zd Zd d „ZdS)é©Úbord)Úload_pycryptodome_raw_libÚ VoidPointerÚ SmartPointerÚcreate_string_bufferÚget_raw_bufferÚc_size_tÚ c_uint8_ptrzCrypto.Hash._SHA512a int SHA512_init(void **shaState, size_t digest_size); int SHA512_destroy(void *shaState); int SHA512_update(void *hs, const uint8_t *buf, size_t len); int SHA512_digest(const void *shaState, uint8_t *digest, size_t digest_size); int SHA512_copy(const void *src, void *dst); int SHA512_pbkdf2_hmac_assist(const void *inner, const void *outer, const uint8_t *first_digest, uint8_t *final_digest, size_t iterations, size_t digest_size); c@sFeZdZdZdZdd„Zdd„Zdd„Zd d „Zd d „Z ddd„Z d S)Ú SHA512HashaØA SHA-512 hash object (possibly in its truncated version SHA-512/224 or SHA-512/256. Do not instantiate directly. Use the :func:`new` function. :ivar oid: ASN.1 Object ID :vartype oid: string :ivar block_size: the size in bytes of the internal message block, input to the compression function :vartype block_size: integer :ivar digest_size: the size in bytes of the resulting hash :vartype digest_size: integer é€cCs ||_|dkrd|_d|_n4|dkr2d|_d|_n|dkrHd|_d|_ntd ƒ‚tƒ}t | ¡t|jƒ¡}|r|td |ƒ‚t |  ¡tj ƒ|_ |rœ|  |¡dS) Nz2.16.840.1.101.3.4.2.3é@Z224z2.16.840.1.101.3.4.2.5éÚ256z2.16.840.1.101.3.4.2.6é z7Incorrect truncation length. It must be '224' or '256'.z$Error %d while instantiating SHA-512)Ú _truncateÚoidÚ digest_sizeÚ ValueErrorrÚ_raw_sha512_libZ SHA512_initZ address_ofr rÚgetZSHA512_destroyÚ_stateÚupdate)ÚselfÚdataÚtruncateÚstateÚresult©rú9/tmp/pip-target-t616c12r/lib/python/Crypto/Hash/SHA512.pyÚ__init__Es0 ÿÿÿzSHA512Hash.__init__cCs4t |j ¡t|ƒtt|ƒƒ¡}|r0td|ƒ‚dS)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. z'Error %d while hashing data with SHA512N)rZ SHA512_updaterrr r Úlenr)rrrrrrr_s  þÿzSHA512Hash.updatecCs<t|jƒ}t |j ¡|t|jƒ¡}|r4td|ƒ‚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 z#Error %d while making SHA512 digest) rrrZ SHA512_digestrrr rr)rÚbfrrrrrÚdigestms  þÿzSHA512Hash.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(SHA512Hash.hexdigest..)Újoinr#)rrrrÚ hexdigestszSHA512Hash.hexdigestcCs8td|jƒ}t |j ¡|j ¡¡}|r4td|ƒ‚|S)a4Return a copy ("clone") of the hash object. The copy will have the same internal state as the original hash object. This can be used to efficiently compute the digests of strings that share a common initial substring. :return: A hash object of the same type NzError %d while copying SHA512)r rrZ SHA512_copyrrr)rÚclonerrrrÚcopy‰s  ÿ zSHA512Hash.copyNcCs t||jƒS)z#Create a fresh SHA-512 hash object.)r r)rrrrrÚnew›szSHA512Hash.new)N) Ú__name__Ú __module__Ú __qualname__Ú__doc__Ú block_sizer rr#r)r+r,rrrrr 2s r NcCs t||ƒS)aCreate a new hash 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:`SHA512Hash.update`. truncate (string): Optional. The desired length of the digest. It can be either "224" or "256". If not present, the digest is 512 bits long. Passing this parameter is **not** equivalent to simply truncating the output digest. :Return: A :class:`SHA512Hash` hash object )r )rrrrrr,¡sr,r r c Cs\|dks t‚tt|ƒƒ}t |j ¡|j ¡||t|ƒtt|ƒƒ¡}|rTtd|ƒ‚t |ƒS)z/Compute the expensive inner loop in PBKDF-HMAC.rz+Error %d with PBKDF2-HMAC assist for SHA512) ÚAssertionErrorrr!rZSHA512_pbkdf2_hmac_assistrrr rr)ÚinnerÚouterZ first_digestÚ iterationsr"rrrrÚ_pbkdf2_hmac_assist»s   ú r6)NN)ZCrypto.Util.py3compatrZCrypto.Util._raw_apirrrrrr r rÚobjectr r,rr1r6rrrrÚs $ÿo