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