aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-11-09 17:48:47 +0000
committerlloyd <[email protected]>2008-11-09 17:48:47 +0000
commit8b12f78f1a1f9d861a0e0b7dd8f7f53b6f2d1459 (patch)
tree39fe575753dd4c1c5a50a3c644258ef77ade09dd
parent2dada64d07767d7794d0f325b2df99b090ecc758 (diff)
Remove use of get_s2k in PBES1 and PBES2, since they both always wanted
a particular algorithm (PBKDF1 or PBKDF2, resp), only variation is the has function to use.
-rw-r--r--src/pbe/pbes1/pbes1.cpp10
-rw-r--r--src/pbe/pbes2/pbes2.cpp13
2 files changed, 14 insertions, 9 deletions
diff --git a/src/pbe/pbes1/pbes1.cpp b/src/pbe/pbes1/pbes1.cpp
index cdcc78148..4119f1a1e 100644
--- a/src/pbe/pbes1/pbes1.cpp
+++ b/src/pbe/pbes1/pbes1.cpp
@@ -4,6 +4,7 @@
*************************************************/
#include <botan/pbes1.h>
+#include <botan/pbkdf1.h>
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
#include <botan/parsing.h>
@@ -70,10 +71,11 @@ void PBE_PKCS5v15::flush_pipe(bool safe_to_skip)
*************************************************/
void PBE_PKCS5v15::set_key(const std::string& passphrase)
{
- std::auto_ptr<S2K> pbkdf(get_s2k("PBKDF1(" + digest + ")"));
- pbkdf->set_iterations(iterations);
- pbkdf->change_salt(salt, salt.size());
- SymmetricKey key_and_iv = pbkdf->derive_key(16, passphrase);
+ PKCS5_PBKDF1 pbkdf(get_hash(digest));
+
+ pbkdf.set_iterations(iterations);
+ pbkdf.change_salt(salt, salt.size());
+ SymmetricKey key_and_iv = pbkdf.derive_key(16, passphrase);
key.set(key_and_iv.begin(), 8);
iv.set(key_and_iv.begin() + 8, 8);
diff --git a/src/pbe/pbes2/pbes2.cpp b/src/pbe/pbes2/pbes2.cpp
index 136ebc393..e4e4585fe 100644
--- a/src/pbe/pbes2/pbes2.cpp
+++ b/src/pbe/pbes2/pbes2.cpp
@@ -4,11 +4,13 @@
*************************************************/
#include <botan/pbes2.h>
+#include <botan/pbkdf2.h>
+#include <botan/hmac.h>
+#include <botan/lookup.h>
#include <botan/libstate.h>
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
#include <botan/parsing.h>
-#include <botan/lookup.h>
#include <botan/asn1_obj.h>
#include <botan/oids.h>
#include <algorithm>
@@ -72,10 +74,11 @@ void PBE_PKCS5v20::flush_pipe(bool safe_to_skip)
*************************************************/
void PBE_PKCS5v20::set_key(const std::string& passphrase)
{
- std::auto_ptr<S2K> pbkdf(get_s2k("PBKDF2(" + digest + ")"));
- pbkdf->set_iterations(iterations);
- pbkdf->change_salt(salt, salt.size());
- key = pbkdf->derive_key(key_length, passphrase).bits_of();
+ PKCS5_PBKDF2 pbkdf(new HMAC(get_hash(digest)));
+
+ pbkdf.set_iterations(iterations);
+ pbkdf.change_salt(salt, salt.size());
+ key = pbkdf.derive_key(key_length, passphrase).bits_of();
}
/*************************************************