diff options
Diffstat (limited to 'src/rng')
-rw-r--r-- | src/rng/auto_rng/auto_rng.h | 3 | ||||
-rw-r--r-- | src/rng/hmac_rng/hmac_rng.cpp | 16 | ||||
-rw-r--r-- | src/rng/hmac_rng/hmac_rng.h | 4 | ||||
-rw-r--r-- | src/rng/randpool/randpool.cpp | 22 | ||||
-rw-r--r-- | src/rng/randpool/randpool.h | 10 | ||||
-rw-r--r-- | src/rng/rng.h | 4 | ||||
-rw-r--r-- | src/rng/x931_rng/x931_rng.cpp | 22 | ||||
-rw-r--r-- | src/rng/x931_rng/x931_rng.h | 8 |
8 files changed, 55 insertions, 34 deletions
diff --git a/src/rng/auto_rng/auto_rng.h b/src/rng/auto_rng/auto_rng.h index 90f342a50..28a603feb 100644 --- a/src/rng/auto_rng/auto_rng.h +++ b/src/rng/auto_rng/auto_rng.h @@ -14,6 +14,9 @@ namespace Botan { +/** +* An automatically seeded PRNG +*/ class BOTAN_DLL AutoSeeded_RNG : public RandomNumberGenerator { public: diff --git a/src/rng/hmac_rng/hmac_rng.cpp b/src/rng/hmac_rng/hmac_rng.cpp index c185a5643..d8c031f6b 100644 --- a/src/rng/hmac_rng/hmac_rng.cpp +++ b/src/rng/hmac_rng/hmac_rng.cpp @@ -30,7 +30,7 @@ void hmac_prf(MessageAuthenticationCode* prf, } -/** +/* * Generate a buffer of random bytes */ void HMAC_RNG::randomize(byte out[], u32bit length) @@ -53,7 +53,7 @@ void HMAC_RNG::randomize(byte out[], u32bit length) } } -/** +/* * Poll for entropy and reset the internal keys */ void HMAC_RNG::reseed(u32bit poll_bits) @@ -114,7 +114,7 @@ void HMAC_RNG::reseed(u32bit poll_bits) seeded = true; } -/** +/* * Add user-supplied entropy to the extractor input */ void HMAC_RNG::add_entropy(const byte input[], u32bit length) @@ -131,7 +131,7 @@ void HMAC_RNG::add_entropy(const byte input[], u32bit length) reseed(128); } -/** +/* * Add another entropy source to the list */ void HMAC_RNG::add_entropy_source(EntropySource* src) @@ -139,7 +139,7 @@ void HMAC_RNG::add_entropy_source(EntropySource* src) entropy_sources.push_back(src); } -/** +/* * Clear memory of sensitive data */ void HMAC_RNG::clear() @@ -152,7 +152,7 @@ void HMAC_RNG::clear() seeded = false; } -/** +/* * Return the name of this type */ std::string HMAC_RNG::name() const @@ -160,7 +160,7 @@ std::string HMAC_RNG::name() const return "HMAC_RNG(" + extractor->name() + "," + prf->name() + ")"; } -/** +/* * HMAC_RNG Constructor */ HMAC_RNG::HMAC_RNG(MessageAuthenticationCode* extractor_mac, @@ -208,7 +208,7 @@ HMAC_RNG::HMAC_RNG(MessageAuthenticationCode* extractor_mac, extractor->set_key(prf->process("Botan HMAC_RNG XTS")); } -/** +/* * HMAC_RNG Destructor */ HMAC_RNG::~HMAC_RNG() diff --git a/src/rng/hmac_rng/hmac_rng.h b/src/rng/hmac_rng/hmac_rng.h index 452357130..fc712b3ec 100644 --- a/src/rng/hmac_rng/hmac_rng.h +++ b/src/rng/hmac_rng/hmac_rng.h @@ -36,6 +36,10 @@ class BOTAN_DLL HMAC_RNG : public RandomNumberGenerator void add_entropy_source(EntropySource* es); void add_entropy(const byte[], u32bit); + /** + * @param extractor a MAC used for extracting the entropy + * @param prf a MAC used as a PRF using HKDF construction + */ HMAC_RNG(MessageAuthenticationCode* extractor, MessageAuthenticationCode* prf); diff --git a/src/rng/randpool/randpool.cpp b/src/rng/randpool/randpool.cpp index c58378b32..d75885a76 100644 --- a/src/rng/randpool/randpool.cpp +++ b/src/rng/randpool/randpool.cpp @@ -15,7 +15,7 @@ namespace Botan { namespace { -/** +/* * PRF based on a MAC */ enum RANDPOOL_PRF_TAG { @@ -26,7 +26,7 @@ enum RANDPOOL_PRF_TAG { } -/** +/* * Generate a buffer of random bytes */ void Randpool::randomize(byte out[], u32bit length) @@ -45,7 +45,7 @@ void Randpool::randomize(byte out[], u32bit length) } } -/** +/* * Refill the output buffer */ void Randpool::update_buffer() @@ -66,7 +66,7 @@ void Randpool::update_buffer() mix_pool(); } -/** +/* * Mix the entropy pool */ void Randpool::mix_pool() @@ -94,7 +94,7 @@ void Randpool::mix_pool() update_buffer(); } -/** +/* * Reseed the internal state */ void Randpool::reseed(u32bit poll_bits) @@ -121,7 +121,7 @@ void Randpool::reseed(u32bit poll_bits) seeded = true; } -/** +/* * Add user-supplied entropy */ void Randpool::add_entropy(const byte input[], u32bit length) @@ -134,7 +134,7 @@ void Randpool::add_entropy(const byte input[], u32bit length) seeded = true; } -/** +/* * Add another entropy source to the list */ void Randpool::add_entropy_source(EntropySource* src) @@ -142,7 +142,7 @@ void Randpool::add_entropy_source(EntropySource* src) entropy_sources.push_back(src); } -/** +/* * Clear memory of sensitive data */ void Randpool::clear() @@ -155,7 +155,7 @@ void Randpool::clear() seeded = false; } -/** +/* * Return the name of this type */ std::string Randpool::name() const @@ -163,7 +163,7 @@ std::string Randpool::name() const return "Randpool(" + cipher->name() + "," + mac->name() + ")"; } -/** +/* * Randpool Constructor */ Randpool::Randpool(BlockCipher* cipher_in, @@ -194,7 +194,7 @@ Randpool::Randpool(BlockCipher* cipher_in, seeded = false; } -/** +/* * Randpool Destructor */ Randpool::~Randpool() diff --git a/src/rng/randpool/randpool.h b/src/rng/randpool/randpool.h index ab6ed6748..471bb791a 100644 --- a/src/rng/randpool/randpool.h +++ b/src/rng/randpool/randpool.h @@ -30,7 +30,15 @@ class BOTAN_DLL Randpool : public RandomNumberGenerator void add_entropy_source(EntropySource* es); void add_entropy(const byte input[], u32bit length); - Randpool(BlockCipher* cipher, MessageAuthenticationCode* mac, + /** + * @param cipher a block cipher to use + * @param mac a message authentication code to use + * @param pool_blocks how many cipher blocks to use for the pool + * @param iterations_before_reseed how many times we'll use the + * internal state to generate output before reseeding + */ + Randpool(BlockCipher* cipher, + MessageAuthenticationCode* mac, u32bit pool_blocks = 32, u32bit iterations_before_reseed = 128); diff --git a/src/rng/rng.h b/src/rng/rng.h index c53d8e22d..687f98d13 100644 --- a/src/rng/rng.h +++ b/src/rng/rng.h @@ -82,8 +82,8 @@ class BOTAN_DLL RandomNumberGenerator { return (*this); } }; -/* -* Null Random Number Generator +/** +* Null/stub RNG - fails if you try to use it for anything */ class BOTAN_DLL Null_RNG : public RandomNumberGenerator { diff --git a/src/rng/x931_rng/x931_rng.cpp b/src/rng/x931_rng/x931_rng.cpp index 3ff180898..f812377ed 100644 --- a/src/rng/x931_rng/x931_rng.cpp +++ b/src/rng/x931_rng/x931_rng.cpp @@ -11,7 +11,7 @@ namespace Botan { -/** +/* * Generate a buffer of random bytes */ void ANSI_X931_RNG::randomize(byte out[], u32bit length) @@ -33,7 +33,7 @@ void ANSI_X931_RNG::randomize(byte out[], u32bit length) } } -/** +/* * Refill the internal state */ void ANSI_X931_RNG::update_buffer() @@ -52,7 +52,7 @@ void ANSI_X931_RNG::update_buffer() position = 0; } -/** +/* * Reset V and the cipher key with new values */ void ANSI_X931_RNG::rekey() @@ -71,7 +71,7 @@ void ANSI_X931_RNG::rekey() } } -/** +/* * Reseed the internal state */ void ANSI_X931_RNG::reseed(u32bit poll_bits) @@ -80,7 +80,7 @@ void ANSI_X931_RNG::reseed(u32bit poll_bits) rekey(); } -/** +/* * Add a entropy source to the underlying PRNG */ void ANSI_X931_RNG::add_entropy_source(EntropySource* src) @@ -88,7 +88,7 @@ void ANSI_X931_RNG::add_entropy_source(EntropySource* src) prng->add_entropy_source(src); } -/** +/* * Add some entropy to the underlying PRNG */ void ANSI_X931_RNG::add_entropy(const byte input[], u32bit length) @@ -97,7 +97,7 @@ void ANSI_X931_RNG::add_entropy(const byte input[], u32bit length) rekey(); } -/** +/* * Check if the the PRNG is seeded */ bool ANSI_X931_RNG::is_seeded() const @@ -105,7 +105,7 @@ bool ANSI_X931_RNG::is_seeded() const return (V.size() > 0); } -/** +/* * Clear memory of sensitive data */ void ANSI_X931_RNG::clear() @@ -118,7 +118,7 @@ void ANSI_X931_RNG::clear() position = 0; } -/** +/* * Return the name of this type */ std::string ANSI_X931_RNG::name() const @@ -126,7 +126,7 @@ std::string ANSI_X931_RNG::name() const return "X9.31(" + cipher->name() + ")"; } -/** +/* * ANSI X931 RNG Constructor */ ANSI_X931_RNG::ANSI_X931_RNG(BlockCipher* cipher_in, @@ -142,7 +142,7 @@ ANSI_X931_RNG::ANSI_X931_RNG(BlockCipher* cipher_in, position = 0; } -/** +/* * ANSI X931 RNG Destructor */ ANSI_X931_RNG::~ANSI_X931_RNG() diff --git a/src/rng/x931_rng/x931_rng.h b/src/rng/x931_rng/x931_rng.h index d5ba2e9eb..345ee3ca9 100644 --- a/src/rng/x931_rng/x931_rng.h +++ b/src/rng/x931_rng/x931_rng.h @@ -28,7 +28,13 @@ class BOTAN_DLL ANSI_X931_RNG : public RandomNumberGenerator void add_entropy_source(EntropySource*); void add_entropy(const byte[], u32bit); - ANSI_X931_RNG(BlockCipher*, RandomNumberGenerator*); + /** + * @param cipher the block cipher to use in this PRNG + * @param rng the underlying PRNG for generating inputs + * (eg, an HMAC_RNG) + */ + ANSI_X931_RNG(BlockCipher* cipher, + RandomNumberGenerator* rng); ~ANSI_X931_RNG(); private: void rekey(); |