diff options
author | René Korthaus <[email protected]> | 2019-10-23 19:01:28 +0200 |
---|---|---|
committer | René Korthaus <[email protected]> | 2019-10-23 19:12:01 +0200 |
commit | 8493c63f4b7b92797c5a5c9f10c3fbef3ed27eee (patch) | |
tree | 597594223aa0c4c83cd6f1894a6349ec06936dff /src/tests/test_rng.cpp | |
parent | 7f084620e9c2c5ac82b4c71b23e098dd25a636db (diff) |
Add check for upper bound of reseed_interval
Diffstat (limited to 'src/tests/test_rng.cpp')
-rw-r--r-- | src/tests/test_rng.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/tests/test_rng.cpp b/src/tests/test_rng.cpp index 3751ac5ca..e0c929ac1 100644 --- a/src/tests/test_rng.cpp +++ b/src/tests/test_rng.cpp @@ -55,6 +55,7 @@ class Stateful_RNG_Tests : public Test std::vector<Test::Result> results; results.push_back(test_reseed_kat()); results.push_back(test_reseed()); + results.push_back(test_reseed_interval_limits()); results.push_back(test_max_number_of_bytes_per_request()); results.push_back(test_broken_entropy_input()); results.push_back(test_check_nonce()); @@ -107,6 +108,8 @@ class Stateful_RNG_Tests : public Test virtual Test::Result test_security_level() = 0; virtual Test::Result test_max_number_of_bytes_per_request() = 0; + + virtual Test::Result test_reseed_interval_limits() = 0; private: Test::Result test_reseed() { @@ -489,6 +492,29 @@ class HMAC_DRBG_Unit_Tests final : public Stateful_RNG_Tests return result; } + Test::Result test_reseed_interval_limits() override + { + Test::Result result("HMAC_DRBG reseed_interval"); + + const std::string mac_string = "HMAC(SHA-256)"; + + Request_Counting_RNG counting_rng; + + result.test_throws("HMAC_DRBG does not accept 0 for reseed_interval", + [&mac_string, &counting_rng]() + { + Botan::HMAC_DRBG failing_rng(Botan::MessageAuthenticationCode::create(mac_string), counting_rng, 0); + }); + + result.test_throws("HMAC_DRBG does not accept values higher than 2^48 for reseed_interval", + [&mac_string, &counting_rng]() + { + Botan::HMAC_DRBG failing_rng(Botan::MessageAuthenticationCode::create(mac_string), counting_rng, (static_cast<size_t>(1) << 48) + 1); + }); + + return result; + } + Test::Result test_security_level() override { Test::Result result("HMAC_DRBG Security Level"); @@ -590,6 +616,13 @@ class ChaCha_RNG_Unit_Tests final : public Stateful_RNG_Tests return result; } + Test::Result test_reseed_interval_limits() override + { + Test::Result result("ChaCha_RNG reseed_interval"); + // ChaCha_RNG doesn't apply any limits to reseed_interval + return result; + } + Test::Result test_reseed_kat() override { Test::Result result("ChaCha_RNG Reseed KAT"); |