aboutsummaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-09-30 06:20:10 +0000
committerlloyd <[email protected]>2008-09-30 06:20:10 +0000
commit33bb3dca54ecef2599b756d27b66781e14d06ae3 (patch)
tree4c7b07a1b1b3f40e82202570c7aec298a672339c /src/core
parentc9749d5d4693b5d93171f6085b29fc72c1e12ba0 (diff)
Remove lookup from Randpool, HMAC, CMAC, CBC-MAC, TLS-PRF, and PBKDF2
Diffstat (limited to 'src/core')
-rw-r--r--src/core/libstate/def_alg.cpp27
-rw-r--r--src/core/rng.cpp4
2 files changed, 21 insertions, 10 deletions
diff --git a/src/core/libstate/def_alg.cpp b/src/core/libstate/def_alg.cpp
index ade7e8d08..ea58bd06f 100644
--- a/src/core/libstate/def_alg.cpp
+++ b/src/core/libstate/def_alg.cpp
@@ -538,9 +538,12 @@ Default_Engine::find_mac(const std::string& algo_spec) const
return 0;
const std::string algo_name = global_state().deref_alias(name[0]);
-#if defined(BOTAN_HAS_CBC_MAC)
- HANDLE_TYPE_ONE_STRING("CBC-MAC", CBC_MAC);
-#endif
+ if(algo_name == "CBC-MAC")
+ {
+ if(name.size() == 2)
+ return new CBC_MAC(find_block_cipher(name[1]));
+ throw Invalid_Algorithm_Name(algo_spec);
+ }
if(algo_name == "CMAC")
{
@@ -549,9 +552,12 @@ Default_Engine::find_mac(const std::string& algo_spec) const
throw Invalid_Algorithm_Name(algo_spec);
}
-#if defined(BOTAN_HAS_HMAC)
- HANDLE_TYPE_ONE_STRING("HMAC", HMAC);
-#endif
+ if(algo_name == "HMAC")
+ {
+ if(name.size() == 2)
+ return new HMAC(find_hash(name[1]));
+ throw Invalid_Algorithm_Name(algo_spec);
+ }
#if defined(BOTAN_HAS_SSL3_MAC)
HANDLE_TYPE_ONE_STRING("SSL3-MAC", SSL3_MAC);
@@ -579,9 +585,12 @@ S2K* Default_Engine::find_s2k(const std::string& algo_spec) const
HANDLE_TYPE_ONE_STRING("PBKDF1", PKCS5_PBKDF1);
#endif
-#if defined(BOTAN_HAS_PBKDF2)
- HANDLE_TYPE_ONE_STRING("PBKDF2", PKCS5_PBKDF2);
-#endif
+ if(algo_spec == "PBKDF2")
+ {
+ if(name.size() == 2)
+ return new PKCS5_PBKDF2(find_mac("HMAC(" + name[1] + ")"));
+ throw Invalid_Algorithm_Name(algo_spec);
+ }
#if defined(BOTAN_HAS_PGPS2K)
HANDLE_TYPE_ONE_STRING("OpenPGP-S2K", OpenPGP_S2K);
diff --git a/src/core/rng.cpp b/src/core/rng.cpp
index 9bed40dc1..37b03684c 100644
--- a/src/core/rng.cpp
+++ b/src/core/rng.cpp
@@ -4,6 +4,7 @@
*************************************************/
#include <botan/rng.h>
+#include <botan/lookup.h>
#include <botan/util.h>
#include <botan/parsing.h>
#include <botan/timers.h>
@@ -82,7 +83,8 @@ RandomNumberGenerator* RandomNumberGenerator::make_rng()
RandomNumberGenerator* rng = 0;
#if defined(BOTAN_HAS_RANDPOOL)
- rng = new Randpool("AES-256", "HMAC(SHA-256)");
+ rng = new Randpool(get_block_cipher("AES-256"),
+ get_mac("HMAC(SHA-256)"));
#if defined(BOTAN_HAS_X931_RNG)
rng = new ANSI_X931_RNG("AES-256", rng);