o )%a@szddlZddlmZddlmZmZmZmZddlm Z ddl m Z ddl m Z ddlmZejdZGd d d eZdS) N)utils)AlreadyFinalized InvalidKeyUnsupportedAlgorithm_Reasons) _get_backend) ScryptBackend) constant_time)KeyDerivationFunctionc @sVeZdZ ddededededef ddZd ed efd d Zd ed ed dfddZdS)ScryptNsaltlengthnrpcCst|}t|tstdtj||_td||dks$||d@dkr(t d|dkr0t d|dkr8t dd |_ ||_ ||_ ||_ ||_||_dS) Nz0Backend object does not implement ScryptBackend.r r 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)r isinstancerrrBACKEND_MISSING_INTERFACE_lengthr _check_bytes ValueError_used_salt_n_r_p_backend)selfr rrrrbackendr K/usr/lib/python3/dist-packages/cryptography/hazmat/primitives/kdf/scrypt.py__init__s(   zScrypt.__init__ key_materialreturncCs@|jrtdd|_td||j||j|j|j|j |j S)Nz'Scrypt instances can only be used once.Tr#) rrr_check_bytesliker derive_scryptrrrrr)rr#r r r!derive7s z Scrypt.derive expected_keycCs"||}t||stddS)NzKeys do not match.)r'r bytes_eqr)rr#r( derived_keyr r r!verifyAs  z Scrypt.verify)N)__name__ __module__ __qualname__bytesintr"r'r+r r r r!r s  r )sys cryptographyrcryptography.exceptionsrrrrcryptography.hazmat.backendsr'cryptography.hazmat.backends.interfacesrcryptography.hazmat.primitivesr "cryptography.hazmat.primitives.kdfr maxsize _MEM_LIMITr r r r r!s