wec@sddlmZddlmZmZddlmZddlmZm Z m Z m Z m Z m Z mZeddZdefdYZd Zd S( i(t unhexlify(tbordttobytes(tget_random_bytes(tload_pycryptodome_raw_libt VoidPointert SmartPointertcreate_string_buffertget_raw_buffertc_size_tt c_uint8_ptrsCrypto.Hash._BLAKE2bs 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); t BLAKE2b_HashcBsSeZdZdZdZdZdZdZdZdZ dZ RS( sA 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 i@cCs||_||_t|_|dkrD| rDdt||_nt}tj|j t |t t |t |}|rt d|nt|jtj|_|r|j|ndS(Nii i0i@s1.3.6.1.4.1.1722.12.2.1.s$Error %d while instantiating BLAKE2b(ii i0i@(t digest_sizet_update_after_digesttFalset _digest_donetstrtoidRt_raw_blake2b_libt blake2b_initt address_ofR R tlent ValueErrorRtgettblake2b_destroyt_statetupdate(tselftdatatkeyt digest_bytestupdate_after_digesttstatetresult((s9/usr/lib64/python2.7/site-packages/Crypto/Hash/BLAKE2b.pyt__init__Ls       cCso|jr"|j r"tdntj|jjt|tt |}|rkt d|n|S(sContinue hashing of a message by consuming the next chunk of data. Args: data (bytes/bytearray/memoryview): The next chunk of the message being hashed. s8You can only call 'digest' or 'hexdigest' on this objects#Error %d while hashing BLAKE2b data( RR t TypeErrorRtblake2b_updateRRR R RR(RRR!((s9/usr/lib64/python2.7/site-packages/Crypto/Hash/BLAKE2b.pyRfs cCsZtd}tj|jj|}|r@td|nt|_t||j S(sReturn 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 i@s&Error %d while creating BLAKE2b digest( RRtblake2b_digestRRRtTrueRRR (RtbfrR!((s9/usr/lib64/python2.7/site-packages/Crypto/Hash/BLAKE2b.pytdigestxs   cCs6djgt|jD]}dt|^qS(sReturn 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 ts%02x(tjointtupleR(R(Rtx((s9/usr/lib64/python2.7/site-packages/Crypto/Hash/BLAKE2b.pyt hexdigestscCsstd}tddd|d|}tddd|d|j}|j|jkrotdndS(s`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. it digest_bitsiRRsMAC check failedN(RtnewR(R(Rtmac_tagtsecrettmac1tmac2((s9/usr/lib64/python2.7/site-packages/Crypto/Hash/BLAKE2b.pytverifys !cCs|jtt|dS(snVerify 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(R4RR(Rt hex_mac_tag((s9/usr/lib64/python2.7/site-packages/Crypto/Hash/BLAKE2b.pyt hexverifys cKs2d|kr(d|kr(|j|ds4