ff$ddlmZddlmZmZddlmZddlmZm Z m Z m Z m Z m Z mZeddZGddeZd Zd S) ) unhexlify)bordtobytes)get_random_bytes)load_pycryptodome_raw_lib VoidPointer SmartPointercreate_string_bufferget_raw_bufferc_size_t c_uint8_ptrzCrypto.Hash._BLAKE2ba int blake2b_init(void **state, const uint8_t *key, size_t key_size, size_t digest_size); int blake2b_destroy(void *state); int blake2b_update(void *state, const uint8_t *buf, size_t len); int blake2b_digest(const void *state, uint8_t digest[64]); int blake2b_copy(const void *src, void *dst); c@eZdZdZdZdZdZdZdZdZ dZ d Z d S) BLAKE2b_HashaA BLAKE2b hash object. 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 @c ||_||_d|_|dvr|sdt|z|_t }t |t|tt|t|}|rtd|zt|t j|_|r||dSdS)NF) 0rz1.3.6.1.4.1.1722.12.2.1.z$Error %d while instantiating BLAKE2b) digest_size_update_after_digest _digest_donestroidr_raw_blake2b_lib blake2b_init address_ofr r len ValueErrorr getblake2b_destroy_stateupdate)selfdatakey digest_bytesupdate_after_digeststateresults u/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Hash/BLAKE2b.py__init__zBLAKE2b_Hash.__init__Ls($7!! + + +C +1C 4E4EEDH !..u/?/?/A/A/:3/?/?/7C/A/A/7 /E/E11  NCfLMM M"599;;#3#CEE   KK       c |jr|jstdt|jt|tt|}|rtd|z|S)zContinue hashing of a message by consuming the next chunk of data. Args: data (bytes/bytearray/memoryview): The next chunk of the message being hashed. z8You can only call 'digest' or 'hexdigest' on this objectz#Error %d while hashing BLAKE2b data) rr TypeErrorrblake2b_updater!rr r rr)r#r$r)s r*r"zBLAKE2b_Hash.updatefs   XT%> XVWW W!001B1B1z*BLAKE2b_Hash.hexdigest..s#GGGQa(GGGr,)jointupler3)r#s r* hexdigestzBLAKE2b_Hash.hexdigests5wwGG% 2F2FGGGHHHr,ctd}td||}td||}||krtddS)a`Verify that a given **binary** MAC (computed by another party) is valid. Args: mac_tag (bytes/bytearray/memoryview): the expected MAC of the message. Raises: ValueError: if the MAC does not match. It means that the message has been tampered with or that the MAC key is incorrect. ) digest_bitsr%r$zMAC check failedN)rnewr3r)r#mac_tagsecretmac1mac2s r*verifyzBLAKE2b_Hash.verifyss""%%sW===sT[[]]CCC ;;==DKKMM ) )/00 0 * )r,cd|tt|dS)anVerify that a given **printable** MAC (computed by another party) is valid. Args: hex_mac_tag (string): the expected MAC of the message, as a hexadecimal string. Raises: ValueError: if the MAC does not match. It means that the message has been tampered with or that the MAC key is incorrect. N)rFrr)r# hex_mac_tags r* hexverifyzBLAKE2b_Hash.hexverifys, Igk223344444r,c >d|vrd|vr |j|d<tdi|S)zQReturn a new instance of a BLAKE2b hash object. See :func:`new`. r&r@)rrA)r#kwargss r*rAzBLAKE2b_Hash.news6  ' 'M,G,G%)%5F> "}}V}}r,N) __name__ __module__ __qualname____doc__ block_sizer+r"r3r<rFrIrArKr,r*rr:s  J4$666&III111* 5 5 5r,rc Z|dd}|dd}|dd}|dd}d||fvrtdd||fkrd }|d |cxkrd ksntd n)d |cxkrd krnn|d zrtd|d z}|dd}t|d krtd|rtdt |zt ||||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:`BLAKE2b_Hash.update`. digest_bytes (integer): Optional. The size of the digest, in bytes (1 to 64). Default is 64. digest_bits (integer): Optional and alternative to ``digest_bytes``. The size of the digest, in bits (8 to 512, in steps of 8). Default is 512. key (bytes/bytearray/memoryview): Optional. The key to use to compute the MAC (1 to 64 bytes). If not specified, no key will be used. update_after_digest (boolean): Optional. By default, a hash object cannot be updated anymore after the digest is computed. When this flag is ``True``, such check is no longer enforced. Returns: A :class:`BLAKE2b_Hash` hash object r$Nr'Fr&r@z*Only one digest parameter must be provided)NNrz!'digest_bytes' not in range 1..64iz2'digest_bits' not in range 8..512, with steps of 8r%r,z"BLAKE2b key cannot exceed 64 byteszUnknown parameters: )popr.rrrr)rLr$r'r&r@r%s r*rArAsu2 ::fd # #D **%:EBB::nd33L**]D11K L+...DEEE k222 \''''R''''@AA A([''''C'''''[1_'/00 0"a' **UC C 3xx"}}=>>> >.V<=== c<1D E EEr,N)binasciirCrypto.Util.py3compatrr Crypto.RandomrCrypto.Util._raw_apirrr r r r r robjectrrArKr,r*r[s >////////******////////////////// -,-C    HHHHH6HHHV2F2F2F2F2Fr,