diff options
author | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2002-10-17 16:32:28 +0000 |
---|---|---|
committer | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2002-10-17 16:32:28 +0000 |
commit | 68bd19cb320b2023aa892c2de15b419edf3f3086 (patch) | |
tree | e508ea100a61e22b1f3d56c3aa2b4479e93da51e /osrng.h | |
parent | 9242d66857d0199765f58148ea33821438f864e2 (diff) | |
download | cryptopp-68bd19cb320b2023aa892c2de15b419edf3f3086.tar.gz |
bug fixes and KAT for X9.17 RNG
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@11 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'osrng.h')
-rw-r--r-- | osrng.h | 25 |
1 files changed, 17 insertions, 8 deletions
@@ -96,6 +96,8 @@ public: explicit AutoSeededX917RNG(bool blocking = false) {Reseed(blocking);} void Reseed(bool blocking = false); + // exposed for testing + void Reseed(const byte *key, unsigned int keylength, const byte *seed, unsigned long timeVector); byte GenerateByte(); @@ -107,6 +109,20 @@ private: }; template <class BLOCK_CIPHER> +void AutoSeededX917RNG<BLOCK_CIPHER>::Reseed(const byte *key, unsigned int keylength, const byte *seed, unsigned long timeVector) +{ + 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; + } +} + +template <class BLOCK_CIPHER> void AutoSeededX917RNG<BLOCK_CIPHER>::Reseed(bool blocking) { SecByteBlock seed(BLOCK_CIPHER::BLOCKSIZE + BLOCK_CIPHER::DEFAULT_KEYLENGTH); @@ -117,15 +133,8 @@ void AutoSeededX917RNG<BLOCK_CIPHER>::Reseed(bool blocking) key = seed + BLOCK_CIPHER::BLOCKSIZE; } // check that seed and key don't have same value while (memcmp(key, seed, STDMIN((unsigned int)BLOCK_CIPHER::BLOCKSIZE, (unsigned int)BLOCK_CIPHER::DEFAULT_KEYLENGTH)) == 0); - m_rng.reset(new X917RNG(new typename BLOCK_CIPHER::Encryption(key, BLOCK_CIPHER::DEFAULT_KEYLENGTH), seed)); - if (FIPS_140_2_ComplianceEnabled()) - { - m_lastBlock.resize(16); - m_rng->GenerateBlock(m_lastBlock, m_lastBlock.size()); - m_counter = 0; - m_isDifferent = false; - } + Reseed(key, BLOCK_CIPHER::DEFAULT_KEYLENGTH, seed, 0); } template <class BLOCK_CIPHER> |