fortuna,generator: better printing
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ad71199e1a
commit
e0448d6d08
|
@ -50,13 +50,15 @@ auto Fortuna::random_data(unsigned int n_bytes) -> void {
|
|||
auto elapsed{std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now().time_since_epoch() -
|
||||
now.time_since_epoch())};
|
||||
fmt::print("last_reseed: {} ago\n", elapsed);
|
||||
fmt::print("[i] fortuna: last_reseed: {} ago\n", elapsed);
|
||||
now = std::chrono::steady_clock::now();
|
||||
std::string s;
|
||||
// synchronise reads and writes to the between
|
||||
// {generator,accumulator,fortuna} service threads -> in member functions
|
||||
const int pools_to_use{ffsll(static_cast<int>(get_reseed_ctr()))};
|
||||
|
||||
fmt::print("[*] fortuna: current p0 length: {}\n",
|
||||
R.pools[0].get_s_length());
|
||||
if (R.pools[0].get_s_length() >= min_pool_size &&
|
||||
elapsed > R.Gen.reseed_interval) {
|
||||
for (int i = 0; i < static_cast<int>(pools_to_use); ++i) {
|
||||
|
@ -76,8 +78,9 @@ auto Fortuna::random_data(unsigned int n_bytes) -> void {
|
|||
s.clear();
|
||||
}
|
||||
|
||||
fmt::print("[i] fortuna: reseed ctr {}\n", R.reseed_ctr);
|
||||
if (R.reseed_ctr == 0) {
|
||||
fmt::print("reseed ctr is 0, PRNG not seeded!\n");
|
||||
fmt::print("[!] ERROR: reseed ctr is 0, PRNG not seeded!\n");
|
||||
throw std::runtime_error("illegal state, PRNG not seeded");
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -138,11 +138,10 @@ auto Generator::generate_blocks(unsigned int k_blocks) -> std::string {
|
|||
|
||||
auto Generator::generate_random_data(uint n) -> std::string {
|
||||
std::lock_guard<std::mutex> lg(mtx);
|
||||
// fmt::print("n -> {}\n", n); // debugging
|
||||
if (n == 0) {
|
||||
// do not do this..?
|
||||
const std::string msg{"zero bytes requested, bailing\n"};
|
||||
fmt::print("[*] error: {}", msg);
|
||||
fmt::print("[*] g: error: {}", msg);
|
||||
throw std::invalid_argument(msg);
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue