a ze[@sdZddlZz ddlZWn&ey>dZdZddlmZ Yn0e ej Zej Z ddl 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_digestccs|]}|dAVqdS)\N.0xrr8/opt/bitninja-python-dojo/embedded/lib/python3.9/hmac.py r ccs|]}|dAVqdS)6Nrrrrrr r c@szeZdZdZdZdZdddZedd Zed d Z ed d Z eddZ ddZ ddZ ddZddZddZdS)HMACz~RFC 2104 HMAC class. Also complies with RFC 4231. This supports the API for Cryptographic Hash Functions (PEP 247). @) _digest_cons_inner_outer block_size digest_sizeNcsFt|ttfs tdt|js,tdtr<|_n,ttrXdfdd |_ndfdd |_||_ ||_ |j j |_ t |j dr|j j }|dkrtd ||jftd |j}ntd |jtd |j}||_ t||kr||}||d }|j |t|j |t|d urB||d S)a?Create a new HMAC object. key: bytes or buffer, key for the keyed hash object. 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. z,key: expected bytes or bytearray, but got %rz'Missing required parameter 'digestmod'.r cs t|SN_hashlibnewd digestmodrr=r zHMAC.__init__..cs |Srrrrrrr?r rz:block_size of %d seems too small; using our default of %d.zr2rArEr0rFrrrrr s" 9       r rcCs 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 )r7r8rrrrrsrcstdur(ttr(tvr(t||Str6}n(ttrPd fdd }nd fdd }|}|}t|dd}t||kr||}|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 cs t|Srrrr0rrrr zdigest..cs |SrrrrLrrrr rrr!)r )r ) _hashopensslr"r)_openssl_md_methsZ hmac_digestr(getattrr/r0r2r3r5r4)r7r8r0r<r=r>r-rrLrr0s,      r0)Nr)rIwarningsr+rrM ImportErrorrN _operatorrZcompare_digest frozensetZopenssl_md_meth_namesZhashlibr#ranger4r5rr rr0rrrrs    ~