diff options
author | René Korthaus <[email protected]> | 2016-06-16 13:03:23 +0200 |
---|---|---|
committer | Daniel Neus <[email protected]> | 2016-06-17 14:36:16 +0200 |
commit | 960adccc86396f5d2ef9ec1a7374bcc9de70b85a (patch) | |
tree | d8891721e294437b3a2b510a41861925a95d7d13 /src/tests/test_rng.cpp | |
parent | 6816c9e71e01432792a997ad9a5d561b9cd94a48 (diff) |
fix test failures and seg faults when Botan is configured with --module-policy bsi
Diffstat (limited to 'src/tests/test_rng.cpp')
-rw-r--r-- | src/tests/test_rng.cpp | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/tests/test_rng.cpp b/src/tests/test_rng.cpp index 6a9580345..7f1c1f123 100644 --- a/src/tests/test_rng.cpp +++ b/src/tests/test_rng.cpp @@ -40,15 +40,31 @@ Botan::RandomNumberGenerator* get_rng(const std::string& algo_str, const std::ve #if defined(BOTAN_HAS_HMAC_DRBG) if(rng_name == "HMAC_DRBG") - return new Botan::HMAC_DRBG( - Botan::MessageAuthenticationCode::create("HMAC(" + algo_name[1] + ")").release(), - new AllOnce_RNG(ikm)); + { + auto mac = Botan::MessageAuthenticationCode::create("HMAC(" + algo_name[1] + ")"); + + if(!mac) + { + return nullptr; + } + + return new Botan::HMAC_DRBG(mac.release(), new AllOnce_RNG(ikm)); + } + #endif #if defined(BOTAN_HAS_X931_RNG) if(rng_name == "X9.31-RNG") - return new Botan::ANSI_X931_RNG(Botan::BlockCipher::create(algo_name[1]).release(), - new Fixed_Output_RNG(ikm)); + { + auto bc = Botan::BlockCipher::create(algo_name[1]); + + if(!bc) + { + return nullptr; + } + + return new Botan::ANSI_X931_RNG(bc.release(), new Fixed_Output_RNG(ikm)); + } #endif return nullptr; @@ -72,6 +88,11 @@ class X931_RNG_Tests : public Text_Based_Test result.test_eq("length", L, expected.size()); std::unique_ptr<Botan::RandomNumberGenerator> rng(get_rng(algo, ikm)); + if(!rng) + { + result.note_missing("RNG " + algo); + return result; + } result.test_eq("rng", rng->random_vec(L), expected); |