summaryrefslogtreecommitdiff
path: root/osrng.h
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2003-03-20 01:24:12 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2003-03-20 01:24:12 +0000
commitd23a489940499bd6c634a1cb0a9875f094f8a850 (patch)
treef85b3bed971083e90e5f3dbb84539ea4ba0359e9 /osrng.h
parentb3517523a738277cfe22428bd757833e69abb66e (diff)
downloadcryptopp-d23a489940499bd6c634a1cb0a9875f094f8a850.tar.gz
various changes for 5.1
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@38 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'osrng.h')
-rw-r--r--osrng.h32
1 files changed, 14 insertions, 18 deletions
diff --git a/osrng.h b/osrng.h
index c5814a5..902b2ee 100644
--- a/osrng.h
+++ b/osrng.h
@@ -113,13 +113,11 @@ void AutoSeededX917RNG<BLOCK_CIPHER>::Reseed(const byte *key, unsigned int keyle
{
m_rng.reset(new X917RNG(new typename BLOCK_CIPHER::Encryption(key, keylength), seed, timeVector));
- if (FIPS_140_2_ComplianceEnabled())
- {
- m_lastBlock.resize(16);
- m_rng->GenerateBlock(m_lastBlock, m_lastBlock.size());
- m_counter = 0;
- m_isDifferent = false;
- }
+ // for FIPS 140-2
+ m_lastBlock.resize(16);
+ m_rng->GenerateBlock(m_lastBlock, m_lastBlock.size());
+ m_counter = 0;
+ m_isDifferent = false;
}
template <class BLOCK_CIPHER>
@@ -142,18 +140,16 @@ byte AutoSeededX917RNG<BLOCK_CIPHER>::GenerateByte()
{
byte b = m_rng->GenerateByte();
- if (FIPS_140_2_ComplianceEnabled())
+ // for FIPS 140-2
+ m_isDifferent = m_isDifferent || b != m_lastBlock[m_counter];
+ m_lastBlock[m_counter] = b;
+ ++m_counter;
+ if (m_counter == m_lastBlock.size())
{
- m_isDifferent = m_isDifferent || b != m_lastBlock[m_counter];
- m_lastBlock[m_counter] = b;
- ++m_counter;
- if (m_counter == m_lastBlock.size())
- {
- if (!m_isDifferent)
- throw SelfTestFailure("AutoSeededX917RNG: Continuous random number generator test failed.");
- m_counter = 0;
- m_isDifferent = false;
- }
+ if (!m_isDifferent)
+ throw SelfTestFailure("AutoSeededX917RNG: Continuous random number generator test failed.");
+ m_counter = 0;
+ m_isDifferent = false;
}
return b;