aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-10-28 16:57:58 +0000
committerlloyd <[email protected]>2008-10-28 16:57:58 +0000
commitb4bdc13ec063e99480a5aec7d1f68923541e9390 (patch)
treeb121ee97916c6128278ec9cf6bb8a9381df28f76
parent2c58bfffa5833bfce7dfecf829cc877010db489f (diff)
In ANSI_X931_RNG::reseed, only attempt to reseed the X9.31 state if
the underlying PRNG's reseed was a success.
-rw-r--r--src/rng/x931_rng/x931_rng.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/rng/x931_rng/x931_rng.cpp b/src/rng/x931_rng/x931_rng.cpp
index 72ddb51c5..619c37e57 100644
--- a/src/rng/x931_rng/x931_rng.cpp
+++ b/src/rng/x931_rng/x931_rng.cpp
@@ -57,15 +57,18 @@ void ANSI_X931_RNG::reseed()
{
prng->reseed();
- 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();
+ }
}
/*************************************************