diff options
author | Jack Lloyd <[email protected]> | 2017-05-22 17:52:37 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-05-22 17:52:37 -0400 |
commit | 464a51e823b08ab953570645fc804c0bce87fdf4 (patch) | |
tree | a731b87e95f5244355f450871c1ef779c9d47c7d | |
parent | 1da4a72b281ec25b8fc6c7d55d32c3f7558c63fb (diff) | |
parent | 1f0aa5fc418a76e9c244f7ba35c8d29b98257c5f (diff) |
Merge GH #1055 Add fallback RNG for the tests
-rw-r--r-- | src/tests/main.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/tests/main.cpp b/src/tests/main.cpp index bdd751e48..e30c268c0 100644 --- a/src/tests/main.cpp +++ b/src/tests/main.cpp @@ -13,6 +13,7 @@ #include <deque> #include <thread> #include <future> +#include <cstdlib> #include <botan/version.h> #include <botan/loadstor.h> @@ -206,9 +207,45 @@ class Test_Runner : public Botan_CLI::Command #elif defined(BOTAN_HAS_AUTO_SEEDING_RNG) output() << " rng:autoseeded"; rng.reset(new Botan::Serialized_RNG(new Botan::AutoSeeded_RNG)); +#else + // last ditch fallback for RNG-less build + class Bogus_Fallback_RNG : public Botan::RandomNumberGenerator + { + public: + std::string name() const override + { + return "Bogus_Fallback_RNG"; + } + + void clear() override + { + /* ignored */ + } + + void randomize(uint8_t out[], size_t len) override + { + for(size_t i = 0; i != len; ++i) + { + out[i] = std::rand(); + } + } + + bool is_seeded() const override + { + return true; + } + + void add_entropy(const uint8_t[], size_t) override + { + /* ignored */ + } + }; + + rng.reset(new Bogus_Fallback_RNG); #endif #endif + output() << "\n"; Botan_Tests::Test::setup_tests(log_success, run_online_tests, run_long_tests, |