aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-05-24 17:05:16 +0000
committerlloyd <[email protected]>2008-05-24 17:05:16 +0000
commitb8768fa4372eaeb0b816db7bc55813261bc35c2a (patch)
treedb3738a2aef71c5aaae37619889d0baf6cef13b9 /src
parent265ffd5c1aaa29c19a4feae5c54133ef7cf1d52d (diff)
Remove both default arguments to the constructor of ANSI_X931_RNG.
If the second argument was NULL, it would default to a new Randpool. But this introduces an annoying dependency: really it is the caller who is relying on Randpool. Make this explicit by passing a new Randpool pointer to the constructor in Library_State. This will break all callers using ANSI_X931_RNG's constructors with default arguments. To regain the previous behavior, change: ANSI_X931_RNG rng; ANSI_X931_RNG rng("/*cipher name*/"); to ANSI_X931_RNG rng(/*cipher name, default was AES-256 */, new Randpool); You are free to pass another PRNG object if you like. This make require inclusion of <botan/randpool.h>
Diffstat (limited to 'src')
-rw-r--r--src/libstate.cpp3
-rw-r--r--src/x931_rng.cpp11
2 files changed, 7 insertions, 7 deletions
diff --git a/src/libstate.cpp b/src/libstate.cpp
index db2d124a8..b988625ce 100644
--- a/src/libstate.cpp
+++ b/src/libstate.cpp
@@ -11,6 +11,7 @@
#include <botan/mutex.h>
#include <botan/charset.h>
#include <botan/x931_rng.h>
+#include <botan/randpool.h>
#include <botan/selftest.h>
#include <algorithm>
@@ -272,7 +273,7 @@ void Library_State::initialize(const InitializerOptions& args,
for(u32bit j = 0; j != sources.size(); ++j)
add_entropy_source(sources[j]);
- set_prng(new ANSI_X931_RNG);
+ set_prng(new ANSI_X931_RNG("AES-256", new Randpool));
if(args.seed_rng())
{
diff --git a/src/x931_rng.cpp b/src/x931_rng.cpp
index 01b8c33d2..94d5f9247 100644
--- a/src/x931_rng.cpp
+++ b/src/x931_rng.cpp
@@ -108,18 +108,17 @@ std::string ANSI_X931_RNG::name() const
ANSI_X931_RNG::ANSI_X931_RNG(const std::string& cipher_name,
RandomNumberGenerator* prng_ptr)
{
- if(cipher_name == "")
- cipher = get_block_cipher("AES-256");
- else
- cipher = get_block_cipher(cipher_name);
+ if(!prng_ptr)
+ throw Invalid_Argument("ANSI_X931_RNG constructor: NULL prng");
+
+ prng = prng_ptr;
+ cipher = get_block_cipher(cipher_name);
const u32bit BLOCK_SIZE = cipher->BLOCK_SIZE;
V.create(BLOCK_SIZE);
R.create(BLOCK_SIZE);
- prng = (prng_ptr ? prng_ptr : new Randpool);
-
position = 0;
}