a oe2 @s~ddlmZddlZddlZddlmZddlmZmZm Z ddl m Z ddl mZddlmZejdZGd d d eZdS) ) annotationsN)utils)AlreadyFinalized InvalidKeyUnsupportedAlgorithm)openssl) constant_time)KeyDerivationFunctionc@sHeZdZddddddddddZdddd d Zddd d d dZdS)ScryptNbytesintz typing.Any)saltlengthnrpbackendcCsddlm}|std||_td||dksF||d@dkrNtd|dkr^td|dkrntd d |_||_ ||_ ||_ ||_ dS) Nr)rz/This version of OpenSSL does not support scryptrr 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) Z,cryptography.hazmat.backends.openssl.backendrZscrypt_supportedr_lengthrZ _check_bytes ValueError_used_salt_n_r_p)selfrrrrrrZosslrJC:\Program Files\Certbot\pkgs\cryptography\hazmat\primitives\kdf\scrypt.py__init__s$  zScrypt.__init__) key_materialreturnc CsB|jrtdd|_td|tj||j|j|j |j t |j S)Nz'Scrypt instances can only be used once.Tr ) rrrZ_check_byteslike rust_opensslZkdfZ derive_scryptrrrr _MEM_LIMITr)rr rrrderive<s z Scrypt.deriveNone)r expected_keyr!cCs"||}t||stddS)NzKeys do not match.)r$rZbytes_eqr)rr r&Z derived_keyrrrverifyMs  z Scrypt.verify)N)__name__ __module__ __qualname__rr$r'rrrrr s"r )Z __future__rsystypingZ cryptographyrZcryptography.exceptionsrrrZ"cryptography.hazmat.bindings._rustrr"Zcryptography.hazmat.primitivesrZ"cryptography.hazmat.primitives.kdfr maxsizer#r rrrrs