ffp~ddlmZmZddlmZddlmZddlmZddlm Z ddl m Z ddgZ Gd de Zd d Zd S))bordtobytes) unhexlify)MD5)BLAKE2s)strxor)get_random_bytesnewHMACcDeZdZdZd dZdZdZdZdZd Z d Z d Z dS) r zAn HMAC hash object. Do not instantiate directly. Use the :func:`new` function. :ivar digest_size: the size in bytes of the resulting MAC tag :vartype digest_size: integer Nc|t}|d}|j|_||_t|tr|} t ||jkr|d|jt |z zz}nD|| }|d|jt |z zz}n#t$rtdwxYwt|dt |z}|||_ |j |t|dt |z}|||_dS)Nr zHash type incompatible to HMAC6\)r digest_size _digestmod isinstance memoryviewrlen block_sizer digestAttributeError ValueErrorr_innerupdate_outer)selfkeymsg digestmodkey_0hash_k key_0_ipad key_0_opads r/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Hash/HMAC.py__init__z HMAC.__init__6se  I ;C%0# c: & & ++--C ?3xx9///g)=C)HII#s++2244I,@3v;;,N!OO ? ? ?=>> > ? E7SZZ#788  mmJ//  3E7SZZ#788  mmJ// s A:CC c:|j||S)zAuthenticate the next chunk of message. Args: data (byte string/byte array/memoryview): The next chunk of data )rr)rr s r&rz HMAC.update_s 3 r cT|j|j|j||}|S)z2Carry out the expensive inner loop for PBKDF2-HMAC)r_pbkdf2_hmac_assistrr)r first_digest iterationsresults r&r*zHMAC._pbkdf2_hmac_assistis244$(K$(K$0$. 00  r ctd|j}|j|_|j|_|S)a+Return a copy ("clone") of the HMAC object. The copy will have the same internal state as the original HMAC object. This can be used to efficiently compute the MAC tag of byte strings that share a common initial substring. :return: An :class:`HMAC` sfake key)r!)r rrcopyr)rnew_hmacs r&r/z HMAC.copyssI t???+**,,+**,,r c|j}||j|S)zReturn the **binary** (non-printable) MAC tag of the message authenticated so far. :return: The MAC tag digest, computed over the data processed so far. Binary form. :rtype: byte string )rr/rrr)rfrozen_outer_hashs r&rz HMAC.digestsL!K,,..  !3!3!5!5666 '')))r ctd}tjd||}tjd||}||krt ddS)ahVerify that a given **binary** MAC (computed by another party) is valid. Args: mac_tag (byte string/byte string/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_bitsrdatazMAC check failedN)r rr rr)rmac_tagsecretmac1mac2s r&verifyz HMAC.verifysw""%%{sWEEE{sT[[]]KKK ;;==DKKMM ) )/00 0 * )r c~ddt|DS)zReturn the **printable** MAC tag of the message authenticated so far. :return: The MAC tag, computed over the data processed so far. Hexadecimal encoded. :rtype: string c2g|]}dt|zS)z%02x)r).0xs r& z"HMAC.hexdigest..s3777a(777r )jointupler)rs r& hexdigestzHMAC.hexdigestsFww77!&t{{}}!5!577788 8r cd|tt|dS)a~Verify 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)r<rr)r hex_mac_tags r& hexverifyzHMAC.hexverifys, Igk223344444r r N) __name__ __module__ __qualname____doc__r'rr*r/rr<rErHr r&r r .s'0'0'0'0R& * * *111( 8 8 8 5 5 5 5 5r r Nc$t|||S)a=Create a new MAC object. Args: key (bytes/bytearray/memoryview): key for the MAC object. It must be long enough to match the expected security level of the MAC. msg (bytes/bytearray/memoryview): Optional. The very first chunk of the message to authenticate. It is equivalent to an early call to :meth:`HMAC.update`. digestmod (module): The hash to use to implement the HMAC. Default is :mod:`Crypto.Hash.MD5`. Returns: An :class:`HMAC` object )r )rr r!s r&r r s& S) $ $$r rI)Crypto.Util.py3compatrrbinasciir Crypto.HashrrCrypto.Util.strxorr Crypto.Randomr __all__objectr r rNr r&rWsD0///////%%%%%%****** &/Q5Q5Q5Q5Q56Q5Q5Q5h%%%%%%r