fortuna: add moar_random_data() fun
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2022-02-03 02:10:06 +01:00
parent fab8e72975
commit 3fe5c06c49
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
2 changed files with 24 additions and 0 deletions

@ -118,6 +118,28 @@ auto Fortuna::random_data(const uint64_t n_bytes) -> void {
fmt::print(stderr, "getting random data took {:.{}f}s\n", diff.count(), 12);
} // random_data
auto Fortuna::moar_random_data(const uint64_t& n_bytes) -> void {
// used for requests of more than 2^20 bytes
// modus operandi: calculate how many consecutive requests to
// "random_data(2^20)" are needed, call random_data() until done
if (n_bytes > Fortuna::two_pow_twenty) {
uint64_t how_many_ops{n_bytes / Fortuna::two_pow_twenty};
uint64_t remaining{n_bytes};
fmt::print(stderr, "[i] fortuna: remaining {} bytes\n", remaining);
while (--how_many_ops > 0) {
this->random_data(Fortuna::two_pow_twenty);
remaining -= Fortuna::two_pow_twenty;
fmt::print(stderr, "[i] fortuna: remaining {} bytes\n", remaining);
}
this->random_data(remaining);
}
else {
this->random_data(n_bytes);
}
} // moar_random_data
auto Fortuna::seed_file_manager_service() -> void {
static constexpr const std::chrono::seconds checkup_interval{7};

@ -36,6 +36,8 @@ public:
~Fortuna() noexcept;
[[optimize_for_synchronized]] auto random_data(const uint64_t) -> void;
[[optimize_for_synchronized]] auto moar_random_data(const uint64_t&)
-> void;
auto set_reseed_ctr_to_null() -> void {
std::scoped_lock sl(mtx_accu, print_mtx);