diff options
Diffstat (limited to 'src/tests/test_rng.h')
-rw-r--r-- | src/tests/test_rng.h | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/tests/test_rng.h b/src/tests/test_rng.h index 3016707dd..343356550 100644 --- a/src/tests/test_rng.h +++ b/src/tests/test_rng.h @@ -7,25 +7,25 @@ #ifndef BOTAN_TESTS_FIXED_RNG_H__ #define BOTAN_TESTS_FIXED_RNG_H__ +#include "tests.h" #include <deque> #include <string> -#include <stdexcept> #include <botan/rng.h> #include <botan/hex.h> -using Botan::byte; +namespace Botan_Tests { class Fixed_Output_RNG : public Botan::RandomNumberGenerator { public: bool is_seeded() const override { return !buf.empty(); } - byte random() + uint8_t random() { if(!is_seeded()) - throw Test_Error("Out of bytes"); + throw Test_Error("Fixed output RNG ran out of bytes, test bug?"); - byte out = buf.front(); + uint8_t out = buf.front(); buf.pop_front(); return out; } @@ -34,13 +34,13 @@ class Fixed_Output_RNG : public Botan::RandomNumberGenerator size_t, std::chrono::milliseconds) { return 0; } - void randomize(byte out[], size_t len) override + void randomize(uint8_t out[], size_t len) override { for(size_t j = 0; j != len; j++) out[j] = random(); } - void add_entropy(const byte b[], size_t s) override + void add_entropy(const uint8_t b[], size_t s) override { buf.insert(buf.end(), b, b + s); } @@ -49,14 +49,14 @@ class Fixed_Output_RNG : public Botan::RandomNumberGenerator void clear() throw() override {} - Fixed_Output_RNG(const std::vector<byte>& in) + Fixed_Output_RNG(const std::vector<uint8_t>& in) { buf.insert(buf.end(), in.begin(), in.end()); } Fixed_Output_RNG(const std::string& in_str) { - std::vector<byte> in = Botan::hex_decode(in_str); + std::vector<uint8_t> in = Botan::hex_decode(in_str); buf.insert(buf.end(), in.begin(), in.end()); } @@ -64,7 +64,9 @@ class Fixed_Output_RNG : public Botan::RandomNumberGenerator protected: size_t remaining() const { return buf.size(); } private: - std::deque<byte> buf; + std::deque<uint8_t> buf; }; +} + #endif |