o
    ™¨Êh:  ã                   @   st   d dl mZmZmZ d dlmZmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZ G dd	„ d	eƒZd
S )é    )Úabsolute_importÚdivisionÚprint_function)ÚUnsupportedAlgorithmÚ_Reasons)ÚHMACBackend)Úconstant_time)ÚInvalidToken)ÚHOTP)Ú_generate_uric                   @   s0   e Zd Z	ddd„Zdd„ Zdd„ Zdd	„ Zd
S )ÚTOTPTc                 C   s2   t |tƒstdtjƒ‚|| _t|||||ƒ| _d S )Nz.Backend object does not implement HMACBackend.)Ú
isinstancer   r   r   ÚBACKEND_MISSING_INTERFACEÚ
_time_stepr
   Ú_hotp)ÚselfÚkeyÚlengthÚ	algorithmÚ	time_stepÚbackendÚenforce_key_length© r   ú_/var/www/html/env/lib/python3.10/site-packages/cryptography/hazmat/primitives/twofactor/totp.pyÚ__init__   s   
þzTOTP.__init__c                 C   s   t || j ƒ}| j |¡S )N)Úintr   r   Úgenerate)r   ÚtimeÚcounterr   r   r   r      s   zTOTP.generatec                 C   s   t  |  |¡|¡stdƒ‚d S )Nz#Supplied TOTP value does not match.)r   Úbytes_eqr   r	   )r   Útotpr   r   r   r   Úverify!   s   ÿzTOTP.verifyc                 C   s   t | jd||dt| jƒfgƒS )Nr    Úperiod)r   r   r   r   )r   Úaccount_nameÚissuerr   r   r   Úget_provisioning_uri%   s   ÿzTOTP.get_provisioning_uriN)T)Ú__name__Ú
__module__Ú__qualname__r   r   r!   r%   r   r   r   r   r      s    
ÿr   N)Ú
__future__r   r   r   Úcryptography.exceptionsr   r   Ú'cryptography.hazmat.backends.interfacesr   Úcryptography.hazmat.primitivesr   Ú(cryptography.hazmat.primitives.twofactorr	   Ú-cryptography.hazmat.primitives.twofactor.hotpr
   Ú.cryptography.hazmat.primitives.twofactor.utilsr   Úobjectr   r   r   r   r   Ú<module>   s   