���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /home/ukubnwwtacc0unt/chapelbellstudios.com/uploads/cover/twofactor.tar
���ѧ٧ѧ�
__init__.py 0000644 00000000440 15204267724 0006664 0 ustar 00 # This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function class InvalidToken(Exception): pass totp.py 0000644 00000003364 15204267724 0006123 0 ustar 00 # This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function from cryptography.exceptions import UnsupportedAlgorithm, _Reasons from cryptography.hazmat.backends import _get_backend from cryptography.hazmat.backends.interfaces import HMACBackend from cryptography.hazmat.primitives import constant_time from cryptography.hazmat.primitives.twofactor import InvalidToken from cryptography.hazmat.primitives.twofactor.hotp import HOTP from cryptography.hazmat.primitives.twofactor.utils import _generate_uri class TOTP(object): def __init__( self, key, length, algorithm, time_step, backend=None, enforce_key_length=True, ): backend = _get_backend(backend) if not isinstance(backend, HMACBackend): raise UnsupportedAlgorithm( "Backend object does not implement HMACBackend.", _Reasons.BACKEND_MISSING_INTERFACE, ) self._time_step = time_step self._hotp = HOTP(key, length, algorithm, backend, enforce_key_length) def generate(self, time): counter = int(time / self._time_step) return self._hotp.generate(counter) def verify(self, totp, time): if not constant_time.bytes_eq(self.generate(time), totp): raise InvalidToken("Supplied TOTP value does not match.") def get_provisioning_uri(self, account_name, issuer): return _generate_uri( self._hotp, "totp", account_name, issuer, [("period", int(self._time_step))], ) __pycache__/totp.cpython-36.opt-1.pyc 0000644 00000003510 15204267724 0013337 0 ustar 00 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 __pycache__/hotp.cpython-36.pyc 0000644 00000005246 15204267724 0012374 0 ustar 00 3 l�_w � @ s� d dl mZmZmZ d dlZd dlZd dlmZmZ d dl m Z d dlmZ d dl mZmZ d dlmZmZmZ d dlmZ d d lmZ G d d� de�ZdS )� )�absolute_import�division�print_functionN)�UnsupportedAlgorithm�_Reasons)�_get_backend)�HMACBackend)� constant_time�hmac)�SHA1�SHA256�SHA512)�InvalidToken)� _generate_uric @ s6 e Zd Zd dd�Zdd� Zdd� Zd d � Zdd� ZdS )�HOTPNTc C s� t |�}t|t�stdtj��t|�dk r:|dkr:td��t|tj �sNt d��|dk s^|dkrftd��t|ttt f�s~t d ��|| _|| _|| _|| _d S ) Nz.Backend object does not implement HMACBackend.� Tz'Key length has to be at least 128 bits.z)Length parameter must be an integer type.� � z(Length of HOTP has to be between 6 to 8.z)Algorithm must be SHA1, SHA256 or SHA512.)r � isinstancer r r ZBACKEND_MISSING_INTERFACE�len� ValueError�sixZ integer_types� TypeErrorr r r �_key�_length� _algorithm�_backend)�self�keyZlength� algorithmZbackendZenforce_key_length� r �/usr/lib64/python3.6/hotp.py�__init__ s"