o
    )%a                     @   sz   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 d dlmZ e jd ZG d	d
 d
eZdS )    N)utils)AlreadyFinalized
InvalidKeyUnsupportedAlgorithm_Reasons)_get_backend)ScryptBackend)constant_time)KeyDerivationFunction   c                   @   sV   e Zd Z	ddededededef
ddZd	ed
efddZd	eded
dfddZdS )ScryptNsaltlengthnrpc                 C   s   t |}t|tstdtj|| _td| |dk s$||d @ dkr(t	d|dk r0t	d|dk r8t	dd	| _
|| _|| _|| _|| _|| _d S )
Nz0Backend object does not implement ScryptBackend.r   r      r   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)r   
isinstancer   r   r   BACKEND_MISSING_INTERFACE_lengthr   _check_bytes
ValueError_used_salt_n_r_p_backend)selfr   r   r   r   r   backend r    K/usr/lib/python3/dist-packages/cryptography/hazmat/primitives/kdf/scrypt.py__init__   s(   

zScrypt.__init__key_materialreturnc                 C   s@   | j rtdd| _ td| | j|| j| j| j| j	| j
S )Nz'Scrypt instances can only be used once.Tr#   )r   r   r   _check_bytesliker   derive_scryptr   r   r   r   r   )r   r#   r    r    r!   derive7   s   zScrypt.deriveexpected_keyc                 C   s"   |  |}t||stdd S )NzKeys do not match.)r'   r	   bytes_eqr   )r   r#   r(   derived_keyr    r    r!   verifyA   s   
zScrypt.verify)N)__name__
__module____qualname__bytesintr"   r'   r+   r    r    r    r!   r      s    

r   )syscryptographyr   cryptography.exceptionsr   r   r   r   cryptography.hazmat.backendsr   'cryptography.hazmat.backends.interfacesr   cryptography.hazmat.primitivesr	   "cryptography.hazmat.primitives.kdfr
   maxsize
_MEM_LIMITr   r    r    r    r!   <module>   s   
