diff options
author | lloyd <[email protected]> | 2013-12-31 18:58:27 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2013-12-31 18:58:27 +0000 |
commit | 7ec00d6a7bfe94f628a6c5118f3a0e8ed7938f99 (patch) | |
tree | 1b8d098be5ffd4c7b18cdf02efd9e2a9a3feac0c | |
parent | c07aa8c37d016f5b8fa78a95b37093b3b8d991e3 (diff) |
Add PBKDF::derive_key taking vector salt
-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. |