o
    )%ax                     @   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                   @   s~   e Zd Z		ddededededef
dd	Zd
ej	ee
f defddZded
eddfddZdedeje def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   BACKEND_MISSING_INTERFACE
_time_stepr   _hotp)selfr   r   r   r   backendr    r   O/usr/lib/python3/dist-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totpc                 C   s   t | ||stdd S )Nz#Supplied TOTP value does not match.)r   bytes_eqr   r   )r   r   r   r   r   r   verify+   s   zTOTP.verifyaccount_nameissuerc                 C   s   t | jd||dt| jfgS )Nr   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+   cryptography.exceptionsr   r   cryptography.hazmat.backendsr   'cryptography.hazmat.backends.interfacesr   cryptography.hazmat.primitivesr   (cryptography.hazmat.primitives.twofactorr   -cryptography.hazmat.primitives.twofactor.hotpr   r	   .cryptography.hazmat.primitives.twofactor.utilsr
   objectr   r   r   r   r   <module>   s   