aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_rng.h
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-07-03 14:36:55 -0400
committerJack Lloyd <[email protected]>2016-07-17 10:43:41 -0400
commitcae7a66072905bc264ecf0805a8738a674ff2986 (patch)
treef10d8a79a6ce4be3992da74c6bd1e66a10709d0f /src/tests/test_rng.h
parentee1b5c7e8513b3b97efa87720154d8ca24774eba (diff)
Revamp entropy polling
Remove Entropy_Accumulator, instead have entropy sources directly add entropy to the RNG.
Diffstat (limited to 'src/tests/test_rng.h')
-rw-r--r--src/tests/test_rng.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/tests/test_rng.h b/src/tests/test_rng.h
index c14ed7fb7..6c29b1d55 100644
--- a/src/tests/test_rng.h
+++ b/src/tests/test_rng.h
@@ -155,6 +155,31 @@ class Fixed_Output_Position_RNG : public Fixed_Output_RNG
std::unique_ptr<RandomNumberGenerator> m_rng;
};
+class SeedCapturing_RNG : public Botan::RandomNumberGenerator
+ {
+ public:
+ void randomize(uint8_t[], size_t) override
+ { throw Botan::Exception("SeedCapturing_RNG has no output"); }
+
+ void add_entropy(const byte input[], size_t len) override
+ {
+ m_samples++;
+ m_seed.insert(m_seed.end(), input, input + len);
+ }
+
+ void clear() override {}
+ bool is_seeded() const override { return false; }
+ std::string name() const override { return "SeedCapturing"; }
+
+ size_t samples() const { return m_samples; }
+
+ const std::vector<uint8_t>& seed_material() const { return m_seed; }
+
+ private:
+ std::vector<uint8_t> m_seed;
+ size_t m_samples = 0;
+ };
+
}
#endif