aboutsummaryrefslogtreecommitdiffstats
path: root/src/x931_rng.cpp
diff options
context:
space:
mode:
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();
}
/*************************************************