aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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();
}
/*************************************************