
    +h2	                        d dl mZ d dlZd dlZd dlmZ d dlmZmZm	Z	 d dl
mZ d dlmZ d dlmZ ej"                  dz  Z G d	 d
e      Zy)    )annotationsN)utils)AlreadyFinalized
InvalidKeyUnsupportedAlgorithm)openssl)constant_time)KeyDerivationFunction   c                  >    e Zd Z	 d	 	 	 	 	 	 	 	 	 	 	 ddZddZddZy)	ScryptNc                <   ddl m} |j                         st        d      || _        t        j                  d|       |dk  s||dz
  z  dk7  rt        d      |dk  rt        d      |dk  rt        d	      d
| _        || _	        || _
        || _        || _        y )Nr   )backendz/This version of OpenSSL does not support scryptsaltr      z-n must be greater than 1 and be a power of 2.z%r must be greater than or equal to 1.z%p must be greater than or equal to 1.F),cryptography.hazmat.backends.openssl.backendr   scrypt_supportedr   _lengthr   _check_bytes
ValueError_used_salt_n_r_p)selfr   lengthnrpr   ossls           \/var/www/html/venv/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/scrypt.py__init__zScrypt.__init__   s    	
 $$&&A  64(q5Q!a%[Q&LMMq5DEEq5DEE

    c           	         | j                   rt        d      d| _         t        j                  d|       t        j
                  j                  || j                  | j                  | j                  | j                  t        | j                        S )Nz'Scrypt instances can only be used once.Tkey_material)r   r   r   _check_byteslikerust_opensslkdfderive_scryptr   r   r   r   
_MEM_LIMITr   )r   r&   s     r"   derivezScrypt.derive<   sn    ::"#LMM
~|<--JJGGGGGGLL
 	
r$   c                h    | j                  |      }t        j                  ||      st        d      y )NzKeys do not match.)r,   r	   bytes_eqr   )r   r&   expected_keyderived_keys       r"   verifyzScrypt.verifyM   s2    kk,/%%k<@122 Ar$   )N)r   bytesr   intr   r3   r   r3   r    r3   r   z
typing.Any)r&   r2   returnr2   )r&   r2   r/   r2   r4   None)__name__
__module____qualname__r#   r,   r1    r$   r"   r   r      sQ     #     	 
      D
"3r$   r   )
__future__r   systypingcryptographyr   cryptography.exceptionsr   r   r   "cryptography.hazmat.bindings._rustr   r(   cryptography.hazmat.primitivesr	   "cryptography.hazmat.primitives.kdfr
   maxsizer+   r   r9   r$   r"   <module>rC      sF   
 # 
   
 G 8 D [[A
73" 73r$   