Skip to content

Commit

Permalink
Test jitter entropy source
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkz committed Sep 8, 2024
1 parent 1f03c40 commit a3158c6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/tests/test_jitter_rng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@

#ifdef BOTAN_HAS_JITTER_RNG

#include <botan/auto_rng.h>
#include <botan/entropy_src.h>
#include <botan/jitter_rng.h>
#include <botan/system_rng.h>

#include "tests.h"

Expand All @@ -30,9 +33,22 @@ class Jitter_RNG_Tests final : public Test {
return result;
}

Test::Result test_entropy_source() {
Botan::Entropy_Sources entropy_sources;
entropy_sources.add_source(Botan::Entropy_Source::create("jitter"));
Botan::AutoSeeded_RNG rng{Botan::system_rng(), entropy_sources};
std::vector<uint8_t> buf(512);
rng.randomize(buf.data(), buf.size());

Test::Result result{"JitterRNG as entropy source"};
result.test_success();
return result;
}

std::vector<Test::Result> run() override {
std::vector<Test::Result> results;
results.push_back(test_basic_rng());
results.push_back(test_entropy_source());
return results;
}
};
Expand Down

0 comments on commit a3158c6

Please sign in to comment.