3 L]k@sddlmZmZmZddlZddlmZddlmZm Z m Z m Z ddl m Z ddlmZddlmZejdZejeGd d d eZdS) )absolute_importdivisionprint_functionN)utils)AlreadyFinalized InvalidKeyUnsupportedAlgorithm_Reasons) ScryptBackend) constant_time)KeyDerivationFunctionc@s$eZdZddZddZddZdS)ScryptcCst|tstdtj||_tjd||dks@||d@dkrHtd|dkrXtd|dkrhtdd |_ ||_ ||_ ||_ ||_ ||_dS) Nz0Backend object does not implement ScryptBackend.saltr rz-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) isinstancer rr ZBACKEND_MISSING_INTERFACE_lengthr _check_bytes ValueError_used_salt_n_r_p_backend)selfrlengthnrpbackendr!S/tmp/pip-install-wfra5znf/cryptography/cryptography/hazmat/primitives/kdf/scrypt.py__init__s$  zScrypt.__init__cCs@|jrtdd|_tjd||jj||j|j|j|j |j S)Nz'Scrypt instances can only be used once.T key_material) rrrZ_check_byteslikerZ derive_scryptrrrrr)rr$r!r!r"derive2s  z Scrypt.derivecCs"|j|}tj||stddS)NzKeys do not match.)r%r Zbytes_eqr)rr$Z expected_keyZ derived_keyr!r!r"verify<s  z Scrypt.verifyN)__name__ __module__ __qualname__r#r%r&r!r!r!r"rs r) __future__rrrsysZ cryptographyrZcryptography.exceptionsrrrr Z'cryptography.hazmat.backends.interfacesr Zcryptography.hazmat.primitivesr Z"cryptography.hazmat.primitives.kdfr maxsizeZ _MEM_LIMITZregister_interfaceobjectrr!r!r!r"s