U
    ¶[Öex  ã                   @   sx   d dl 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mZ d dlmZ G d	d
„ d
eƒZdS )é    N)ÚUnsupportedAlgorithmÚ_Reasons)Ú_get_backend)ÚHMACBackend)Úconstant_time)ÚInvalidToken)ÚHOTPÚ_ALLOWED_HASH_TYPES)Ú_generate_uric                   @   sh   e Zd Zdeeeeedœdd„Zej	ee
f edœdd„Zeedd	œd
d„Zeeje edœdd„ZdS )ÚTOTPNT)ÚkeyÚlengthÚ	algorithmÚ	time_stepÚenforce_key_lengthc                 C   s:   t |ƒ}t|tƒstdtjƒ‚|| _t|||||ƒ| _d S )Nz.Backend object does not implement HMACBackend.)	r   Ú
isinstancer   r   r   ZBACKEND_MISSING_INTERFACEÚ
_time_stepr   Ú_hotp)Úselfr   r   r   r   Úbackendr   © r   úo/var/www/html/services/stratfitenv/lib/python3.8/site-packages/cryptography/hazmat/primitives/twofactor/totp.pyÚ__init__   s    	
þzTOTP.__init__)ÚtimeÚreturnc                 C   s   t || j ƒ}| j |¡S )N)Úintr   r   Úgenerate)r   r   Úcounterr   r   r   r   '   s    zTOTP.generate)Útotpr   r   c                 C   s   t  |  |¡|¡stdƒ‚d S )Nz#Supplied TOTP value does not match.)r   Zbytes_eqr   r   )r   r   r   r   r   r   Úverify+   s    zTOTP.verify)Úaccount_nameÚissuerr   c                 C   s   t | jd||dt| jƒfgƒS )Nr   Zperiod)r
   r   r   r   )r   r    r!   r   r   r   Úget_provisioning_uri/   s    ûzTOTP.get_provisioning_uri)NT)Ú__name__Ú
__module__Ú__qualname__Úbytesr   r	   Úboolr   ÚtypingÚUnionÚfloatr   r   ÚstrÚOptionalr"   r   r   r   r   r      s     ùù þr   )r(   Zcryptography.exceptionsr   r   Zcryptography.hazmat.backendsr   Z'cryptography.hazmat.backends.interfacesr   Zcryptography.hazmat.primitivesr   Z(cryptography.hazmat.primitives.twofactorr   Z-cryptography.hazmat.primitives.twofactor.hotpr   r	   Z.cryptography.hazmat.primitives.twofactor.utilsr
   Úobjectr   r   r   r   r   Ú<module>   s   