aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pbkdf/pbkdf2
diff options
context:
space:
mode:
authorlloyd <[email protected]>2015-02-04 04:03:38 +0000
committerlloyd <[email protected]>2015-02-04 04:03:38 +0000
commit0dd060fed07b0060f94e3bae62e125a85c1bb877 (patch)
treeed4bc7a961e2b30f17ed5e80769c84b0c313c8b7 /src/lib/pbkdf/pbkdf2
parentf9a7c85b74be0f4a7273e8e0591703af83036e81 (diff)
Remove algo factory, engines, global RNG, global state, etc.
Convert all uses of Algorithm_Factory and the engines to using Algo_Registry The shared pool of entropy sources remains but is moved to EntropySource. With that and few remaining initializations (default OIDs and aliases) moved elsewhere, the global state is empty and init and shutdown are no-ops. Remove almost all of the headers and code for handling the global state, except LibraryInitializer which remains as a compatability stub. Update seeding for blinding so only one hacky almost-global RNG instance needs to be setup instead of across all pubkey uses (it uses either the system RNG or an AutoSeeded_RNG if the system RNG is not available).
Diffstat (limited to 'src/lib/pbkdf/pbkdf2')
-rw-r--r--src/lib/pbkdf/pbkdf2/info.txt2
-rw-r--r--src/lib/pbkdf/pbkdf2/pbkdf2.cpp15
-rw-r--r--src/lib/pbkdf/pbkdf2/pbkdf2.h3
3 files changed, 19 insertions, 1 deletions
diff --git a/src/lib/pbkdf/pbkdf2/info.txt b/src/lib/pbkdf/pbkdf2/info.txt
index b13168c53..9863532b7 100644
--- a/src/lib/pbkdf/pbkdf2/info.txt
+++ b/src/lib/pbkdf/pbkdf2/info.txt
@@ -1,5 +1,5 @@
define PBKDF2 20131128
<requires>
-mac
+hmac
</requires>
diff --git a/src/lib/pbkdf/pbkdf2/pbkdf2.cpp b/src/lib/pbkdf/pbkdf2/pbkdf2.cpp
index 8ca0cbb0c..fedf036a3 100644
--- a/src/lib/pbkdf/pbkdf2/pbkdf2.cpp
+++ b/src/lib/pbkdf/pbkdf2/pbkdf2.cpp
@@ -5,13 +5,28 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
+#include <botan/internal/pbkdf_utils.h>
#include <botan/pbkdf2.h>
#include <botan/get_byte.h>
+#include <botan/hmac.h>
#include <botan/internal/xor_buf.h>
#include <botan/internal/rounding.h>
namespace Botan {
+BOTAN_REGISTER_NAMED_T(PBKDF, "PBKDF2", PKCS5_PBKDF2, PKCS5_PBKDF2::make);
+
+PKCS5_PBKDF2* PKCS5_PBKDF2::make(const Spec& spec)
+ {
+ if(auto mac = make_a<MessageAuthenticationCode>(spec.arg(0)))
+ return new PKCS5_PBKDF2(mac);
+
+ if(auto hash = make_a<HashFunction>(spec.arg(0)))
+ return new PKCS5_PBKDF2(new HMAC(hash));
+
+ return nullptr;
+ }
+
/*
* Return a PKCS #5 PBKDF2 derived key
*/
diff --git a/src/lib/pbkdf/pbkdf2/pbkdf2.h b/src/lib/pbkdf/pbkdf2/pbkdf2.h
index d2ed6a08c..3d1a14fab 100644
--- a/src/lib/pbkdf/pbkdf2/pbkdf2.h
+++ b/src/lib/pbkdf/pbkdf2/pbkdf2.h
@@ -10,6 +10,7 @@
#include <botan/pbkdf.h>
#include <botan/mac.h>
+#include <botan/hash.h>
namespace Botan {
@@ -41,6 +42,8 @@ class BOTAN_DLL PKCS5_PBKDF2 : public PBKDF
* @param mac_fn the MAC object to use as PRF
*/
PKCS5_PBKDF2(MessageAuthenticationCode* mac_fn) : mac(mac_fn) {}
+
+ static PKCS5_PBKDF2* make(const Spec& spec);
private:
std::unique_ptr<MessageAuthenticationCode> mac;
};