관리-도구
편집 파일: totp.cpython-36.pyc
3 l�_� � @ s� d dl mZmZmZ d dlmZmZ d dlmZ d dl m Z d dlmZ d dl mZ d dlmZ d dlmZ G d d � d e�ZdS )� )�absolute_import�division�print_function)�UnsupportedAlgorithm�_Reasons)�_get_backend)�HMACBackend)� constant_time)�InvalidToken)�HOTP)� _generate_uric @ s. e Zd Zddd�Zdd� Zdd� Zd d � ZdS )�TOTPNTc C s: t |�}t|t�stdtj��|| _t|||||�| _d S )Nz.Backend object does not implement HMACBackend.) r � isinstancer r r ZBACKEND_MISSING_INTERFACE� _time_stepr �_hotp)�self�keyZlength� algorithmZ time_stepZbackendZenforce_key_length� r �/usr/lib64/python3.6/totp.py�__init__ s z TOTP.__init__c C s t || j �}| jj|�S )N)�intr r �generate)r �timeZcounterr r r r $ s z TOTP.generatec C s t j| j|�|�std��d S )Nz#Supplied TOTP value does not match.)r Zbytes_eqr r )r �totpr r r r �verify( s zTOTP.verifyc C s t | jd||dt| j�fg�S )Nr Zperiod)r r r r )r Zaccount_nameZissuerr r r �get_provisioning_uri, s zTOTP.get_provisioning_uri)NT)�__name__� __module__�__qualname__r r r r r r r r r s r N)Z __future__r r r Zcryptography.exceptionsr r Zcryptography.hazmat.backendsr Z'cryptography.hazmat.backends.interfacesr Zcryptography.hazmat.primitivesr Z(cryptography.hazmat.primitives.twofactorr Z-cryptography.hazmat.primitives.twofactor.hotpr Z.cryptography.hazmat.primitives.twofactor.utilsr �objectr r r r r �<module> s