diff options
author | lloyd <[email protected]> | 2008-10-28 17:15:24 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-10-28 17:15:24 +0000 |
commit | 5f35fe7bd6f1a94585447763150d0b4fe772e1bd (patch) | |
tree | abd6b4b0b9d260f97368a430f869ca5cc3578c38 | |
parent | aea4b082f42a314fdf19376963e20ae5a90fd6d7 (diff) |
Modify AutoSeeded_RNG to use HMAC_RNG instead of Randpool, if HMAC_RNG is
available in the build. If neither is avilable, the constructor will
throw an exception.
As before, the underlying RNG will be wrapped in an X9.31 PRNG using
AES-256 as the block cipher (if X9.31 is enabled in the build).
-rw-r--r-- | src/rng/auto_rng/auto_rng.cpp | 24 | ||||
-rw-r--r-- | src/rng/auto_rng/info.txt | 1 |
2 files changed, 20 insertions, 5 deletions
diff --git a/src/rng/auto_rng/auto_rng.cpp b/src/rng/auto_rng/auto_rng.cpp index 51d71f7d0..2389df8d7 100644 --- a/src/rng/auto_rng/auto_rng.cpp +++ b/src/rng/auto_rng/auto_rng.cpp @@ -4,12 +4,20 @@ *************************************************/ #include <botan/auto_rng.h> -#include <botan/randpool.h> #include <botan/parsing.h> #include <botan/timers.h> -#include <botan/aes.h> #include <botan/hmac.h> #include <botan/sha2_32.h> +#include <botan/sha2_64.h> +#include <botan/aes.h> + +#if defined(BOTAN_HAS_RANDPOOL) + #include <botan/randpool.h> +#endif + +#if defined(BOTAN_HAS_HMAC_RNG) + #include <botan/hmac_rng.h> +#endif #if defined(BOTAN_HAS_X931_RNG) #include <botan/x931_rng.h> @@ -126,10 +134,18 @@ void add_entropy_sources(RandomNumberGenerator* rng) AutoSeeded_RNG::AutoSeeded_RNG() { - /* Randpool is required for make_rng to work */ + rng = 0; + +#if defined(BOTAN_HAS_HMAC_RNG) + rng = new HMAC_RNG(new HMAC(new SHA_512), new HMAC(new SHA_256)); +#elif defined(BOTAN_HAS_RANDPOOL) rng = new Randpool(new AES_256, new HMAC(new SHA_256)); +#endif + + if(!rng) + throw Algorithm_Not_Found("No usable RNG found enabled in build"); - /* If X9.31 is available, wrap the Randpool algorithm in it */ + /* If X9.31 is available, use it to wrap the other RNG as a failsafe */ #if defined(BOTAN_HAS_X931_RNG) rng = new ANSI_X931_RNG(new AES_256, rng); #endif diff --git a/src/rng/auto_rng/info.txt b/src/rng/auto_rng/info.txt index c2b653220..aa316367e 100644 --- a/src/rng/auto_rng/info.txt +++ b/src/rng/auto_rng/info.txt @@ -5,7 +5,6 @@ define AUTO_SEEDING_RNG load_on auto <requires> -randpool aes sha2 hmac |