U &.e@sddlZddlmZz ddlZWnek r<dZdZYn Xe ej Zddl ZddlZ ddl Z eddedDZeddedDZdZGdddZd d ZGd d d e jZe reZdddZddZdS)N)_compare_digestccs|]}|dAVqdS)\N.0xrr/usr/lib64/python3.8/hmac.py sr ccs|]}|dAVqdS)6Nrrrrrr sc@sNeZdZdZdddZeddZdd Zd d Zd d Z ddZ ddZ dS)HMAC@NcsVtrtdt|ttfs0tdt|js?rzHMAC.__init__..cs |SrrrrrrrAr block_sizez:block_size of %d seems too small; using our default of %d.zasz HMAC.namecCs trtd|j|dS)Nz'hmac.HMAC is not available in FIPS mode)rr r!r,r6)r:r<rrrr6esz HMAC.updatecCs:|j|j}|j|_|j|_|j|_|j|_|Sr) __class____new__r)r-r,copyr+)r:otherrrrrAks   z HMAC.copycCs|j}||j|Sr)r+rAr6r,r4r:hrrr_currentxs z HMAC._currentcCs|}|Sr)rEr4rCrrrr4sz HMAC.digestcCs|}|Sr)rE hexdigestrCrrrrFszHMAC.hexdigest)Nr) r' __module__ __qualname__r1r=propertyr>r6rArEr4rFrrrrr s >    r cCsHt|tr|St|r"|d}t|tjs6td|jddS)Nrz6Only OpenSSL hashlib hashes are accepted in FIPS mode._-) r"r*lowerr(rZHASHr%r>replacerrrr_get_openssl_names  rNc@seZdZdddZdS) HMAC_opensslNcCsLt|ttfs tdt|jt|}tjj |||d}|rH| ||S)Nrr) r"r#r$r%r&r'rN _hmacopensslr r@r6)clsr;r<rr>resultrrrr@s zHMAC_openssl.__new__)NN)r'rGrHr@rrrrrOsrOrcCs t|||Sr)r )r;r<rrrrrsrcstdk r(ttr(tkr(t||Str6}n(ttrPdfdd }nd fdd }|}|}t|dd}t||kr||}|d|t|}| | t | | t | || ||S) Nrcs t|Srrrr4rrrrzdigest..cs |SrrrrSrrrrrr r)r)r) _hashopensslr"r*_openssl_md_methsZ hmac_digestr(getattrr3r4r6r7r9r8)r;r<r4r)r,r+r1rrSrr4s,      r4)Nr)warningsr/ _operatorrZcompare_digestrrT ImportErrorrU frozensetZopenssl_md_meth_namesZhashlibrrPr#ranger8r9r-r rNrOr rr4rrrrs(    u