diff options
author | lloyd <[email protected]> | 2008-10-28 18:04:59 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-10-28 18:04:59 +0000 |
commit | 462ed4a4efe1a7470ac9b6dec55ebe6352b898e2 (patch) | |
tree | 32505934bef2316ff39038c1a94f1fc58f7a8d75 | |
parent | fd8817b742a483220965b3ca161347142303343e (diff) |
Add HMAC_RNG benchmarks. Change X9.31 PRNG to use HMAC_RNG as lower RNG
-rw-r--r-- | checks/algos.cpp | 1 | ||||
-rw-r--r-- | checks/dolook2.cpp | 45 |
2 files changed, 35 insertions, 11 deletions
diff --git a/checks/algos.cpp b/checks/algos.cpp index 2ed25a846..6d0b17b4c 100644 --- a/checks/algos.cpp +++ b/checks/algos.cpp @@ -90,6 +90,7 @@ std::vector<algorithm> get_algos() algos.push_back(algorithm("MAC", "HMAC(SHA-1)", 16)); algos.push_back(algorithm("MAC", "X9.19-MAC", 16)); + algos.push_back(algorithm("RNG", "HMAC_RNG", 4096)); algos.push_back(algorithm("RNG", "Randpool", 4096)); algos.push_back(algorithm("RNG", "X9.31-RNG", 4096)); diff --git a/checks/dolook2.cpp b/checks/dolook2.cpp index 9dc72cacb..ece8b261f 100644 --- a/checks/dolook2.cpp +++ b/checks/dolook2.cpp @@ -10,6 +10,13 @@ #include <botan/randpool.h> #endif +#if defined(BOTAN_HAS_HMAC_RNG) + #include <botan/hmac_rng.h> + #include <botan/hmac.h> + #include <botan/sha2_32.h> + #include <botan/sha2_64.h> +#endif + #if defined(BOTAN_HAS_X931_RNG) #include <botan/x931_rng.h> #endif @@ -133,25 +140,41 @@ Filter* lookup_rng(const std::string& algname, new Fixed_Output_RNG(decode_hex(key))); #endif -#if defined(BOTAN_HAS_X931_RNG) && defined(BOTAN_HAS_RANDPOOL) +#if defined(BOTAN_HAS_RANDPOOL) + if(algname == "Randpool") + { + prng = new Randpool(get_block_cipher("AES-256"), + get_mac("HMAC(SHA-256)")); + + prng->add_entropy(reinterpret_cast<const byte*>(key.c_str()), + key.length()); + } +#endif + +#if defined(BOTAN_HAS_X931_RNG) // these are used for benchmarking: AES-256/SHA-256 matches library // defaults, so benchmark reflects real-world performance (maybe) - if(!prng && (algname == "Randpool" || algname == "X9.31-RNG")) + if(algname == "X9.31-RNG") { - Randpool* randpool = new Randpool(get_block_cipher("AES-256"), - get_mac("HMAC(SHA-256)")); - randpool->add_entropy(reinterpret_cast<const byte*>(key.c_str()), - key.length()); - - if(algname == "Randpool") - prng = randpool; - else - prng = new ANSI_X931_RNG(get_block_cipher("AES-256"), randpool); + RandomNumberGenerator* hmac_rng = + new HMAC_RNG(new HMAC(new SHA_512), new HMAC(new SHA_256)); + prng = new ANSI_X931_RNG(get_block_cipher("AES-256"), hmac_rng); + } +#endif + +#if defined(BOTAN_HAS_HMAC_RNG) + if(algname == "HMAC_RNG") + { + prng = new HMAC_RNG(new HMAC(new SHA_512), new HMAC(new SHA_256)); } #endif if(prng) + { + prng->add_entropy(reinterpret_cast<const byte*>(key.c_str()), + key.length()); return new RNG_Filter(prng); + } return 0; } |