diff options
author | lloyd <[email protected]> | 2008-09-28 19:20:33 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-09-28 19:20:33 +0000 |
commit | 9822a701516396b7de4e41339faecd48ff8dc8ff (patch) | |
tree | 719574e03e1fc811530150d3d81486fd3e2cecfb | |
parent | 8534c9a67226ccffe7acbefbf3905aba10e88de3 (diff) |
Allow test suite to build even if RNG or DLIES is missing
-rw-r--r-- | checks/dolook2.cpp | 17 | ||||
-rw-r--r-- | checks/pk.cpp | 9 |
2 files changed, 22 insertions, 4 deletions
diff --git a/checks/dolook2.cpp b/checks/dolook2.cpp index 7493f4fe6..ed579ad67 100644 --- a/checks/dolook2.cpp +++ b/checks/dolook2.cpp @@ -6,8 +6,15 @@ #include <botan/lookup.h> #include <botan/look_pk.h> #include <botan/filters.h> -#include <botan/randpool.h> -#include <botan/x931_rng.h> + +#if defined(BOTAN_HAS_RANDPOOL) + #include <botan/randpool.h> +#endif + +#if defined(BOTAN_HAS_X931_RNG) + #include <botan/x931_rng.h> +#endif + #include "common.h" using namespace Botan; @@ -112,6 +119,7 @@ Filter* lookup_rng(const std::string& algname, { RandomNumberGenerator* prng = 0; +#if defined(BOTAN_HAS_X931_RNG) if(algname == "X9.31-RNG(TripleDES)") prng = new ANSI_X931_RNG("TripleDES", new Fixed_Output_RNG(decode_hex(key))); else if(algname == "X9.31-RNG(AES-128)") @@ -120,10 +128,12 @@ Filter* lookup_rng(const std::string& algname, prng = new ANSI_X931_RNG("AES-192", new Fixed_Output_RNG(decode_hex(key))); else if(algname == "X9.31-RNG(AES-256)") prng = new ANSI_X931_RNG("AES-256", new Fixed_Output_RNG(decode_hex(key))); +#endif +#if defined(BOTAN_HAS_X931_RNG) and defined(BOTAN_HAS_RANDPOOL) // these are used for benchmarking: AES-256/SHA-256 matches library // defaults, so benchmark reflects real-world performance (maybe) - else if(algname == "Randpool" || algname == "X9.31-RNG") + if(!prng && (algname == "Randpool" || algname == "X9.31-RNG")) { Randpool* randpool = new Randpool("AES-256", "HMAC(SHA-256)"); randpool->add_entropy(reinterpret_cast<const byte*>(key.c_str()), @@ -134,6 +144,7 @@ Filter* lookup_rng(const std::string& algname, else prng = new ANSI_X931_RNG("AES-256", randpool); } +#endif if(prng) return new RNG_Filter(prng); diff --git a/checks/pk.cpp b/checks/pk.cpp index 7a8f821fa..31c432033 100644 --- a/checks/pk.cpp +++ b/checks/pk.cpp @@ -13,7 +13,10 @@ #include <botan/nr.h> #include <botan/rw.h> #include <botan/elgamal.h> -#include <botan/dlies.h> + +#if defined(BOTAN_HAS_DLIES) + #include <botan/dlies.h> +#endif #include <botan/filters.h> #include <botan/look_pk.h> @@ -460,6 +463,7 @@ u32bit validate_dlies(const std::string& algo, if(str.size() != 6) throw Exception("Invalid input from pk_valid.dat"); +#if defined(BOTAN_HAS_DLIES) DL_Group domain(to_bigint(str[0]), to_bigint(str[1])); DH_PrivateKey from(rng, domain, to_bigint(str[2])); @@ -484,6 +488,9 @@ u32bit validate_dlies(const std::string& algo, bool failure = false; validate_encryption(e, d, algo, str[4], empty, str[5], failure); return (failure ? 1 : 0); +#else + return 0; +#endif } void do_pk_keygen_tests(RandomNumberGenerator& rng) |