diff options
author | lloyd <[email protected]> | 2010-08-17 16:54:30 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-08-17 16:54:30 +0000 |
commit | eca3acddef1659d2c014fde006e9834c54d5ccd7 (patch) | |
tree | 91ee9891e4f41d85270aeb54f46ed29b63be4320 | |
parent | ffc3ffbe172809c14546f8d1a5097192140fa043 (diff) |
Improve compatability with the S2K/PBKDF changes made in 1.9:
- Add PBKDF typedef
- Add get_pbkdf in lookup.h
- Add version of S2K::derive_key that takes the salt and iteration
count along with the output length and passphrase
-rw-r--r-- | doc/log.txt | 2 | ||||
-rw-r--r-- | src/libstate/lookup.h | 10 | ||||
-rw-r--r-- | src/s2k/s2k.cpp | 8 | ||||
-rw-r--r-- | src/s2k/s2k.h | 17 |
4 files changed, 37 insertions, 0 deletions
diff --git a/doc/log.txt b/doc/log.txt index fce6ad0d1..8c9c4f051 100644 --- a/doc/log.txt +++ b/doc/log.txt @@ -2,6 +2,8 @@ * 1.8.10-dev, ????-??-?? - Switch default PKCS #8 encryption algorithm from 3DES to AES-256 - Increase default hash iterations from 2048 to 10000 in PBES1 and PBES2 + - Add PBKDF typedef and get_pbkdf for better compatability with 1.9 + - Add version of S2K::derive_key taking salt and iteration count - Enable the /proc-walking entropy source on NetBSD - Fix the doxygen makefile target diff --git a/src/libstate/lookup.h b/src/libstate/lookup.h index 0f48dddfb..663cbee6f 100644 --- a/src/libstate/lookup.h +++ b/src/libstate/lookup.h @@ -82,6 +82,16 @@ BOTAN_DLL MessageAuthenticationCode* get_mac(const std::string& name); */ BOTAN_DLL S2K* get_s2k(const std::string& name); +/** +* String to key algorithm factory method. +* @param name the name of the desired PBKDF algorithm +* @return a pointer to the string to key algorithm object +*/ +BOTAN_DLL PBKDF* get_pbkdf(const std::string& name) + { + return get_s2k(name); + } + /* * Get an EMSA/EME/KDF/MGF function */ diff --git a/src/s2k/s2k.cpp b/src/s2k/s2k.cpp index b8a8ef719..bb86109eb 100644 --- a/src/s2k/s2k.cpp +++ b/src/s2k/s2k.cpp @@ -18,6 +18,14 @@ OctetString S2K::derive_key(u32bit key_len, return derive(key_len, passphrase, salt, salt.size(), iterations()); } +OctetString S2K::derive_key(u32bit output_len, + const std::string& passphrase, + const byte salt[], u32bit salt_len, + u32bit iterations) + { + return derive(output_len, passphrase, salt, salt_len, iterations); + } + /* * Set the number of iterations */ diff --git a/src/s2k/s2k.h b/src/s2k/s2k.h index 7af92519b..64505d4ce 100644 --- a/src/s2k/s2k.h +++ b/src/s2k/s2k.h @@ -45,6 +45,20 @@ class BOTAN_DLL S2K OctetString derive_key(u32bit key_len, const std::string& passphrase) const; + + /** + * 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 iterations the number of iterations to use (use 10K or more) + */ + OctetString derive_key(u32bit output_len, + const std::string& passphrase, + const byte salt[], u32bit salt_len, + u32bit iterations); + /** * Set the number of iterations for the one-way function during * key generation. @@ -97,6 +111,9 @@ class BOTAN_DLL S2K u32bit iter; }; +// More conventional name for this algorithm +typedef S2K PBKDF; + } #endif |