o )%a@slddlmZddlmZmZmZmZddlmZddl m Z ddl m Z m Z ddlmZGdddeZd S) )utils)AlreadyFinalized InvalidKeyUnsupportedAlgorithm_Reasons) _get_backend)PBKDF2HMACBackend) constant_timehashes)KeyDerivationFunctionc @sTeZdZ ddejdededefddZded efd d Zded ed dfd dZ dS) PBKDF2HMACN algorithmlengthsalt iterationscCspt|}t|tstdtj||std|jtj d|_ ||_ ||_ t d|||_||_||_dS)Nz4Backend object does not implement PBKDF2HMACBackend.z/{} is not supported for PBKDF2 by this backend.Fr)r isinstancerrrBACKEND_MISSING_INTERFACEpbkdf2_hmac_supportedformatnameUNSUPPORTED_HASH_used _algorithm_lengthr _check_bytes_salt _iterations_backend)selfr rrrbackendr K/usr/lib/python3/dist-packages/cryptography/hazmat/primitives/kdf/pbkdf2.py__init__s(    zPBKDF2HMAC.__init__ key_materialreturncCs<|jrtdd|_td||j|j|j|j|j |S)Nz'PBKDF2 instances can only be used once.Tr#) rrr_check_byteslikerderive_pbkdf2_hmacrrrr)rr#r r r!derive2s zPBKDF2HMAC.derive expected_keycCs"||}t||stddS)NzKeys do not match.)r'r bytes_eqr)rr#r( derived_keyr r r!verify@s  zPBKDF2HMAC.verify)N) __name__ __module__ __qualname__r HashAlgorithmintbytesr"r'r+r r r r!r s r N) cryptographyrcryptography.exceptionsrrrrcryptography.hazmat.backendsr'cryptography.hazmat.backends.interfacesrcryptography.hazmat.primitivesr r "cryptography.hazmat.primitives.kdfr r r r r r!s