3 lá˜_ôã@s€ddlmZmZmZddlmZmZddlmZddl m Z ddl m Z ddl mZddlmZddlmZGd d „d eƒZd S) é)Úabsolute_importÚdivisionÚprint_function)ÚUnsupportedAlgorithmÚ_Reasons)Ú _get_backend)Ú HMACBackend)Ú constant_time)Ú InvalidToken)ÚHOTP)Ú _generate_uric@s.eZdZd dd„Zdd„Zdd„Zd d „ZdS) ÚTOTPNTcCs:t|ƒ}t|tƒstdtjƒ‚||_t|||||ƒ|_dS)Nz.Backend object does not implement HMACBackend.) rÚ isinstancerrrZBACKEND_MISSING_INTERFACEÚ _time_stepr Ú_hotp)ÚselfÚkeyZlengthÚ algorithmZ time_stepZbackendZenforce_key_length©rú/usr/lib64/python3.6/totp.pyÚ__init__s  z TOTP.__init__cCst||jƒ}|jj|ƒS)N)ÚintrrÚgenerate)rÚtimeZcounterrrrr$sz TOTP.generatecCstj|j|ƒ|ƒstdƒ‚dS)Nz#Supplied TOTP value does not match.)r Zbytes_eqrr )rÚtotprrrrÚverify(sz TOTP.verifycCst|jd||dt|jƒfgƒS)NrZperiod)r rrr)rZ account_nameZissuerrrrÚget_provisioning_uri,s zTOTP.get_provisioning_uri)NT)Ú__name__Ú __module__Ú __qualname__rrrrrrrrr s  r N)Z __future__rrrZcryptography.exceptionsrrZcryptography.hazmat.backendsrZ'cryptography.hazmat.backends.interfacesrZcryptography.hazmat.primitivesr Z(cryptography.hazmat.primitives.twofactorr Z-cryptography.hazmat.primitives.twofactor.hotpr Z.cryptography.hazmat.primitives.twofactor.utilsr Úobjectr rrrrÚs