diff options
author | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2003-03-20 01:24:12 +0000 |
---|---|---|
committer | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2003-03-20 01:24:12 +0000 |
commit | d23a489940499bd6c634a1cb0a9875f094f8a850 (patch) | |
tree | f85b3bed971083e90e5f3dbb84539ea4ba0359e9 /osrng.h | |
parent | b3517523a738277cfe22428bd757833e69abb66e (diff) | |
download | cryptopp-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.h | 32 |
1 files changed, 14 insertions, 18 deletions
@@ -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; |