<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
lá˜_g	  ã               @   sš   d dl mZmZmZ d dlZd dlmZ d dlmZm	Z	m
Z
mZ d dlmZ d dlmZ d dlmZmZ d dlmZ d	d
„ ZejeƒG dd„ deƒƒZdS )é    )Úabsolute_importÚdivisionÚprint_functionN)Úutils)ÚAlreadyFinalizedÚ
InvalidKeyÚUnsupportedAlgorithmÚ_Reasons)Ú_get_backend)ÚHashBackend)Úconstant_timeÚhashes)ÚKeyDerivationFunctionc             C   s   t jd| ƒS )Nz>I)ÚstructÚpack)Ún© r   ú/usr/lib64/python3.6/x963kdf.pyÚ_int_to_u32be   s    r   c               @   s&   e Zd Zddd„Zdd„ Zdd„ ZdS )	ÚX963KDFNc             C   st   t |ƒ}|jd	 }||kr(tdj|ƒƒ‚|d k	r<tjd|ƒ || _|| _|| _t	|t
ƒsdtdtjƒ‚|| _d| _d S )
Né   é    é   z(Can not derive keys larger than {} bits.Ú
sharedinfoz.Backend object does not implement HashBackend.Fl        l   ÿÿ )r
   Zdigest_sizeÚ
ValueErrorÚformatr   Ú_check_bytesÚ
_algorithmÚ_lengthÚ_sharedinfoÚ
isinstancer   r   r	   ZBACKEND_MISSING_INTERFACEÚ_backendÚ_used)ÚselfÚ	algorithmZlengthr   ZbackendZmax_lenr   r   r   Ú__init__   s     

zX963KDF.__init__c             C   s²   | j r
t‚d| _ tjd|ƒ dg}d}d}xr| j|krœtj| j| jƒ}|j	|ƒ |j	t
|ƒƒ | jd k	rt|j	| jƒ |j|jƒ ƒ |t|d ƒ7 }|d7 }q,W dj|ƒd | j… S )NTÚkey_materialó    r   r   éÿÿÿÿ)r"   r   r   Z_check_bytesliker   r   ZHashr   r!   Úupdater   r   ÚappendÚfinalizeÚlenÚjoin)r#   r&   ÚoutputZoutlenZcounterÚhr   r   r   Úderive3   s"    

zX963KDF.derivec             C   s   t j| j|ƒ|ƒst‚d S )N)r   Zbytes_eqr0   r   )r#   r&   Zexpected_keyr   r   r   ÚverifyH   s    zX963KDF.verify)N)Ú__name__Ú
__module__Ú__qualname__r%   r0   r1   r   r   r   r   r      s   
r   )Z
__future__r   r   r   r   Zcryptographyr   Zcryptography.exceptionsr   r   r   r	   Zcryptography.hazmat.backendsr
   Z'cryptography.hazmat.backends.interfacesr   Zcryptography.hazmat.primitivesr   r   Z"cryptography.hazmat.primitives.kdfr   r   Zregister_interfaceÚobjectr   r   r   r   r   Ú<module>   s   