관리-도구
편집 파일: kbkdf.cpython-36.pyc
3 l�_� � @ s� d dl mZmZmZ d dlmZ d dlmZ d dlm Z d dl mZmZm Z mZ d dlmZ d dlmZ d dlmZmZmZ d d lmZ G d d� de�ZG dd � d e�Ze je�G dd� de��ZdS )� )�absolute_import�division�print_function)�Enum)�range)�utils)�AlreadyFinalized� InvalidKey�UnsupportedAlgorithm�_Reasons)�_get_backend)�HMACBackend)� constant_time�hashes�hmac)�KeyDerivationFunctionc @ s e Zd ZdZdS )�ModeZctrN)�__name__� __module__�__qualname__ZCounterMode� r r �/usr/lib64/python3.6/kbkdf.pyr s r c @ s e Zd ZdZdZdS )�CounterLocationZbefore_fixedZafter_fixedN)r r r �BeforeFixed� AfterFixedr r r r r s r c @ s6 e Zd Zddd�Zdd� Zdd� Zdd � Zd d� ZdS ) � KBKDFHMACNc C sJ t | �} t| t�stdtj��t|tj�s6tdtj��| j |�sLtdtj��t|t �s^td��t|t�sptd��|sx|r�| r�t d��|d ks�| j|� r�t d��|d kr�| d kr�t d��|d k r�t|t� r�td ��|d kr�d }|d kr�d }tjd|� tjd|� || _|| _|| _|| _|| _|| _|| _|| _| | _d | _| | _d S )Nz.Backend object does not implement HMACBackend.z5Algorithm supplied is not a supported hash algorithm.z5Algorithm supplied is not a supported hmac algorithm.zmode must be of type Modez(location must be of type CounterLocationz9When supplying fixed data, label and context are ignored.zrlen must be between 1 and 4zPlease specify an llenzllen must be an integer� �label�contextF)r � isinstancer r r ZBACKEND_MISSING_INTERFACEr Z HashAlgorithmZUNSUPPORTED_HASHZhmac_supportedr � TypeErrorr � ValueError�_valid_byte_length�intr �_check_bytes� _algorithm�_mode�_length�_rlen�_llen� _location�_label�_context�_backend�_used�_fixed_data)�self� algorithm�modeZlengthZrlenZllen�locationr r Zfixed�backendr r r �__init__# sV zKBKDFHMAC.__init__c C sB t |t�std��tjd|�}dt|� ko4dkn s>dS dS )Nzvalue must be of type int� � FT)r r# r r �int_to_bytes�len)r0 �valueZ value_binr r r r"