o
    ™¨Êh‰  ã                   @   sz   d dl mZmZm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 e e¡G dd„ deƒƒZd	S )
é    )Úabsolute_importÚdivisionÚprint_function)Úutils)ÚAlreadyFinalizedÚ
InvalidKeyÚUnsupportedAlgorithmÚ_Reasons)ÚPBKDF2HMACBackend)Úconstant_time)ÚKeyDerivationFunctionc                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )Ú
PBKDF2HMACc                 C   sn   t |tƒstdtjƒ‚| |¡std |j¡tjƒ‚d| _	|| _
|| _t |tƒs,tdƒ‚|| _|| _|| _d S )Nz4Backend object does not implement PBKDF2HMACBackend.z0{0} is not supported for PBKDF2 by this backend.Fzsalt must be bytes.)Ú
isinstancer
   r   r	   ÚBACKEND_MISSING_INTERFACEÚpbkdf2_hmac_supportedÚformatÚnameÚUNSUPPORTED_HASHÚ_usedÚ
_algorithmÚ_lengthÚbytesÚ	TypeErrorÚ_saltÚ_iterationsÚ_backend)ÚselfÚ	algorithmÚlengthÚsaltÚ
iterationsÚbackend© r"   ú[/var/www/html/env/lib/python3.10/site-packages/cryptography/hazmat/primitives/kdf/pbkdf2.pyÚ__init__   s(   
þ
ÿý

zPBKDF2HMAC.__init__c                 C   sB   | j rtdƒ‚d| _ t|tƒstdƒ‚| j | j| j| j	| j
|¡S )Nz'PBKDF2 instances can only be used once.Tzkey_material must be bytes.)r   r   r   r   r   r   Úderive_pbkdf2_hmacr   r   r   r   )r   Úkey_materialr"   r"   r#   Úderive(   s   
ûzPBKDF2HMAC.derivec                 C   s"   |   |¡}t ||¡stdƒ‚d S )NzKeys do not match.)r'   r   Úbytes_eqr   )r   r&   Úexpected_keyÚderived_keyr"   r"   r#   Úverify7   s   
ÿzPBKDF2HMAC.verifyN)Ú__name__Ú
__module__Ú__qualname__r$   r'   r+   r"   r"   r"   r#   r      s    r   N)Ú
__future__r   r   r   Úcryptographyr   Úcryptography.exceptionsr   r   r   r	   Ú'cryptography.hazmat.backends.interfacesr
   Úcryptography.hazmat.primitivesr   Ú"cryptography.hazmat.primitives.kdfr   Úregister_interfaceÚobjectr   r"   r"   r"   r#   Ú<module>   s   