aboutsummaryrefslogtreecommitdiffstats
path: root/checks
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-06-27 18:30:07 +0000
committerlloyd <[email protected]>2008-06-27 18:30:07 +0000
commite2a465b75d8baeac912e3f4d428ebc5e03fd76f1 (patch)
tree7490308782cbac8b0ec9ca0cc23d73ec8a0a7b68 /checks
parentd84a769cc563aebeae3893f952cba1659562e430 (diff)
New structure for entropy sources + RNGs. The entropy sources are owned by
Randpool, it will query them as needed (or if asked to do so). New function make_rng() that creates an RNG (X9.31 backed by a Randpool) and seeds it. Remove the entropy source related code from the Modules/Builtin_Modules classes.
Diffstat (limited to 'checks')
-rw-r--r--checks/dolook2.cpp25
-rw-r--r--checks/rng.cpp12
2 files changed, 15 insertions, 22 deletions
diff --git a/checks/dolook2.cpp b/checks/dolook2.cpp
index f52d1fc09..a47efaff9 100644
--- a/checks/dolook2.cpp
+++ b/checks/dolook2.cpp
@@ -113,28 +113,31 @@ Filter* lookup_rng(const std::string& algname,
RandomNumberGenerator* prng = 0;
if(algname == "X9.31-RNG(TripleDES)")
- prng = new ANSI_X931_RNG("TripleDES", new Fixed_Output_RNG);
+ prng = new ANSI_X931_RNG("TripleDES", new Fixed_Output_RNG(decode_hex(key)));
else if(algname == "X9.31-RNG(AES-128)")
- prng = new ANSI_X931_RNG("AES-128", new Fixed_Output_RNG);
+ prng = new ANSI_X931_RNG("AES-128", new Fixed_Output_RNG(decode_hex(key)));
else if(algname == "X9.31-RNG(AES-192)")
- prng = new ANSI_X931_RNG("AES-192", new Fixed_Output_RNG);
+ prng = new ANSI_X931_RNG("AES-192", new Fixed_Output_RNG(decode_hex(key)));
else if(algname == "X9.31-RNG(AES-256)")
- prng = new ANSI_X931_RNG("AES-256", new Fixed_Output_RNG);
+ prng = new ANSI_X931_RNG("AES-256", new Fixed_Output_RNG(decode_hex(key)));
// these are used for benchmarking: AES-256/SHA-256 matches library
// defaults, so benchmark reflects real-world performance (maybe)
else if(algname == "Randpool")
- prng = new Randpool("AES-256", "HMAC(SHA-256)");
+ {
+ Randpool* randpool = new Randpool("AES-256", "HMAC(SHA-256)");
+ randpool->add_entropy((const byte*)key.c_str(), key.length());
+ prng = randpool;
+ }
else if(algname == "X9.31-RNG")
- prng = new ANSI_X931_RNG("AES-256",
- new Randpool("AES-256", "HMAC(SHA-256)"));
+ {
+ Randpool* randpool = new Randpool("AES-256", "HMAC(SHA-256)");
+ randpool->add_entropy((const byte*)key.c_str(), key.length());
+ prng = new ANSI_X931_RNG("AES-256", randpool);
+ }
if(prng)
- {
- SecureVector<byte> seed = decode_hex(key);
- prng->add_entropy(seed.begin(), seed.size());
return new RNG_Filter(prng);
- }
return 0;
}
diff --git a/checks/rng.cpp b/checks/rng.cpp
index 03c4d9990..05cd4da8e 100644
--- a/checks/rng.cpp
+++ b/checks/rng.cpp
@@ -1,9 +1,5 @@
#include "common.h"
-#include <botan/x931_rng.h>
-#include <botan/randpool.h>
-#include <botan/es_dev.h>
-#include <botan/parsing.h>
using namespace Botan;
@@ -12,13 +8,7 @@ RandomNumberGenerator& global_rng()
static RandomNumberGenerator* rng = 0;
if(!rng)
- {
- rng = new ANSI_X931_RNG("AES-256", new Randpool("AES-256", "HMAC(SHA-256)"));
-
- Device_EntropySource dev(split_on("/dev/random:/dev/srandom:/dev/urandom", ':'));
-
- rng->add_entropy(dev);
- }
+ rng = make_rng();
return *rng;
}