aboutsummaryrefslogtreecommitdiffstats
path: root/src/x931_rng.cpp
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 /src/x931_rng.cpp
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 'src/x931_rng.cpp')
-rw-r--r--src/x931_rng.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/x931_rng.cpp b/src/x931_rng.cpp
index d9ac69296..24b5059f1 100644
--- a/src/x931_rng.cpp
+++ b/src/x931_rng.cpp
@@ -1,6 +1,6 @@
/*************************************************
* ANSI X9.31 RNG Source File *
-* (C) 1999-2007 Jack Lloyd *
+* (C) 1999-2008 Jack Lloyd *
*************************************************/
#include <botan/x931_rng.h>
@@ -16,7 +16,7 @@ namespace Botan {
void ANSI_X931_RNG::randomize(byte out[], u32bit length)
{
if(!is_seeded())
- throw PRNG_Unseeded(name());
+ reseed();
while(length)
{
@@ -52,24 +52,19 @@ void ANSI_X931_RNG::update_buffer()
}
/*************************************************
-* Add entropy to internal state *
+* Reseed the internal state *
*************************************************/
-void ANSI_X931_RNG::add_randomness(const byte data[], u32bit length)
+void ANSI_X931_RNG::reseed()
{
- prng->add_entropy(data, length);
+ SecureVector<byte> key(cipher->MAXIMUM_KEYLENGTH);
+ prng->randomize(key, key.size());
+ cipher->set_key(key, key.size());
- if(prng->is_seeded())
- {
- SecureVector<byte> key(cipher->MAXIMUM_KEYLENGTH);
- prng->randomize(key, key.size());
- cipher->set_key(key, key.size());
-
- if(V.size() != cipher->BLOCK_SIZE)
- V.create(cipher->BLOCK_SIZE);
- prng->randomize(V, V.size());
+ if(V.size() != cipher->BLOCK_SIZE)
+ V.create(cipher->BLOCK_SIZE);
+ prng->randomize(V, V.size());
- update_buffer();
- }
+ update_buffer();
}
/*************************************************