o ?Og%@sdZddlZzddlZWneydZdZddlmZ Yn wej Z e ej Zddl Ze ddedDZe ddedDZdZGdd d Zdd d Zd dZdS)zqHMAC (Keyed-Hashing for Message Authentication) module. Implements the HMAC algorithm as described by RFC 2104. N)_compare_digestcc|]}|dAVqdS)\N.0xrr+/opt/alt/python310/lib64/python3.10/hmac.py r ccr)6Nrrrrr r r c@sfeZdZdZdZdZdddZdd Zd d Ze d d Z ddZ ddZ ddZ ddZddZdS)HMACz~RFC 2104 HMAC class. Also complies with RFC 4231. This supports the API for Cryptographic Hash Functions (PEP 247). @)_hmac_inner_outer block_size digest_sizeNcCst|ttfstdt|j|stdtrK z HMAC._init_old..c |Sr+r.r/r(rr r1M rz:block_size of %d seems too small; using our default of %d.zrr(r r!GsD      zHMAC._init_oldcCs|jr|jjSd|jjS)Nzhmac-)rnamer)r#rrr rHnsz HMAC.namecCs|jp|j}||dS)z,Feed data from msg into this hashing object.N)rrrC)r#r%instrrr rCus z HMAC.updatecCsZ|j|j}|j|_|jr|j|_d|_|_|Sd|_|j|_|j|_|S)zyReturn a separate copy of this hashing object. An update to this copy won't affect the original object. N) __class____new__rrcopyrr)r#otherrrr rLzs    z HMAC.copycCs*|jr|jS|j}||j|S)zwReturn a hash object for the current state. To be used only internally with digest() and hexdigest(). )rrrLrCrrAr#hrrr _currents  z HMAC._currentcC|}|S)zReturn the hash value of this hashing object. This returns the hmac value as bytes. The object is not altered in any way by this function; you can continue updating the object after calling this function. )rPrArNrrr rAsz HMAC.digestcCrQ)zKLike digest(), but returns a string of hexadecimal digits instead. )rP hexdigestrNrrr rRszHMAC.hexdigestNr)r __module__ __qualname____doc__r> __slots__r'rr!propertyrHrCrLrPrArRrrrr rs '  rrcCs t|||S)aCreate a new hashing object and return it. key: bytes or buffer, The starting key for the hash. msg: bytes or buffer, Initial input for the hash, or None. digestmod: A hash name suitable for hashlib.new(). *OR* A hashlib constructor returning a new hash object. *OR* A module supporting PEP 247. Required as of 3.8, despite its position after the optional msg argument. Passing it as a keyword argument is recommended, though not required for legacy API reasons. You can now feed arbitrary bytes into the object using its update() method, and can ask for the hash value at any time by calling its digest() or hexdigest() methods. )r)r$r%r&rrr r.s r.cstdurtttfrzt||WStjyYnwtr%}nttr2d fdd }nd fdd }|}|}t|dd}t||krQ|| }|d|t|}| | t | | t | || | | S) aJFast inline implementation of HMAC. key: bytes or buffer, The key for the keyed hash object. msg: bytes or buffer, Input message. digest: A hash name suitable for hashlib.new() for best performance. *OR* A hashlib constructor returning a new hash object. *OR* A module supporting PEP 247. Nr)cr*r+r,r/rArr r1r2zdigest..cr3r+r4r/rYrr r1r5rrr8r9)rrrrZ hmac_digestr r:getattrr@rArCrDrFrE)r$r%rArGinnerZouterr>rrYr rAs,      rArS)rVwarningsr<r-r ImportErrorr _operatorrZcompare_digestrZopenssl_sha256ZhashlibrrangerErFrrr.rArrrr s&