aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-09-22 18:09:10 -0400
committerJack Lloyd <[email protected]>2017-09-22 18:09:10 -0400
commita91f507e6a9d94244d56385bc5f17bb8c6bcf31e (patch)
treedd36dcc3b0aee34e41c5aabdd29d74aea0dafcad /src
parent034a12e6361be524823d8701b66c3ca5c78e6243 (diff)
Slight improvements to RNG tests
Diffstat (limited to 'src')
-rw-r--r--src/lib/rng/system_rng/system_rng.h4
-rw-r--r--src/tests/test_rng.cpp6
2 files changed, 5 insertions, 5 deletions
diff --git a/src/lib/rng/system_rng/system_rng.h b/src/lib/rng/system_rng/system_rng.h
index 491c4d1b3..4e3beaf9f 100644
--- a/src/lib/rng/system_rng/system_rng.h
+++ b/src/lib/rng/system_rng/system_rng.h
@@ -31,9 +31,9 @@ class BOTAN_PUBLIC_API(2,0) System_RNG final : public RandomNumberGenerator
void add_entropy(const uint8_t in[], size_t length) override { system_rng().add_entropy(in, length); }
- bool is_seeded() const override { return true; }
+ bool is_seeded() const override { return system_rng().is_seeded(); }
- void clear() override {}
+ void clear() override { system_rng().clear(); }
};
}
diff --git a/src/tests/test_rng.cpp b/src/tests/test_rng.cpp
index 82804d1b9..51d636693 100644
--- a/src/tests/test_rng.cpp
+++ b/src/tests/test_rng.cpp
@@ -168,6 +168,7 @@ class Stateful_RNG_Tests : public Test
// underlying_rng throws exception
Botan::Null_RNG broken_entropy_input_rng;
+ result.test_eq("Null_RNG not seeded", broken_entropy_input_rng.is_seeded(), false);
std::unique_ptr<Botan::Stateful_RNG> rng_with_broken_rng = make_rng(broken_entropy_input_rng);
result.test_throws("broken underlying rng", [&rng_with_broken_rng]() { rng_with_broken_rng->random_vec(16); });
@@ -703,9 +704,7 @@ class System_RNG_Tests final : public Test
Botan::System_RNG rng;
- const std::string name = rng.name();
-
- result.confirm("Some non-empty name is returned", name.empty() == false);
+ result.test_gte("Some non-empty name is returned", rng.name().size(), 1);
result.confirm("System RNG always seeded", rng.is_seeded());
rng.clear(); // clear is a noop for system rng
@@ -719,6 +718,7 @@ class System_RNG_Tests final : public Test
{
std::vector<uint8_t> out_buf(i);
rng.randomize(out_buf.data(), out_buf.size());
+ rng.add_entropy(out_buf.data(), out_buf.size());
}
return std::vector<Test::Result>{result};