diff options
Diffstat (limited to 'src/pbkdf')
-rw-r--r-- | src/pbkdf/pbkdf.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/pbkdf/pbkdf.h b/src/pbkdf/pbkdf.h index 2508dc6a3..65ad8e83a 100644 --- a/src/pbkdf/pbkdf.h +++ b/src/pbkdf/pbkdf.h @@ -48,6 +48,22 @@ class BOTAN_DLL PBKDF : public Algorithm * @param output_len the desired length of the key to produce * @param passphrase the password to derive the key from * @param salt a randomly chosen salt + * @param iterations the number of iterations to use (use 10K or more) + */ + template<typename Alloc> + OctetString derive_key(size_t output_len, + const std::string& passphrase, + const std::vector<byte, Alloc>& salt, + size_t iterations) const + { + return derive_key(output_len, passphrase, &salt[0], salt.size(), iterations); + } + + /** + * Derive a key from a passphrase + * @param output_len the desired length of the key to produce + * @param passphrase the password to derive the key from + * @param salt a randomly chosen salt * @param salt_len length of salt in bytes * @param msec is how long to run the PBKDF * @param iterations is set to the number of iterations used @@ -59,6 +75,24 @@ class BOTAN_DLL PBKDF : public Algorithm size_t& iterations) const; /** + * Derive a key from a passphrase using a certain amount of time + * @param output_len the desired length of the key to produce + * @param passphrase the password to derive the key from + * @param salt a randomly chosen salt + * @param msec is how long to run the PBKDF + * @param iterations is set to the number of iterations used + */ + template<typename Alloc> + OctetString derive_key(size_t output_len, + const std::string& passphrase, + const std::vector<byte, Alloc>& salt, + std::chrono::milliseconds msec, + size_t& iterations) const + { + return derive_key(output_len, passphrase, &salt[0], salt.size(), msec, iterations); + } + + /** * Derive a key from a passphrase for a number of iterations * specified by either iterations or if iterations == 0 then * running until seconds time has elapsed. |