fortuna: add const and casts where appropriate
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2022-01-20 05:58:36 +01:00
parent 5da8023bd3
commit 4f28612f3f
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D

@ -75,12 +75,13 @@ auto Fortuna::random_data(unsigned int n_bytes) -> void {
R.Gen.reseed_interval)) {
for (int i = 0; i < static_cast<int>(pools_to_use); ++i) {
if (this->R.reseed_ctr %
static_cast<int>(pow(2, static_cast<double>(i))) ==
static_cast<uint64_t>(pow(2, static_cast<double>(i))) ==
0) {
try {
s.append(
fortuna::Util::do_sha(this->R._p_pools->at(i).get_s()));
this->R._p_pools->at(i).clear_pool();
s.append(fortuna::Util::do_sha(
this->R._p_pools->at(static_cast<uint64_t>(i))
.get_s()));
this->R._p_pools->at(static_cast<uint64_t>(i)).clear_pool();
}
catch (std::exception& e) {
fmt::print("{}\n", e.what());
@ -99,15 +100,14 @@ auto Fortuna::random_data(unsigned int n_bytes) -> void {
throw std::runtime_error("illegal state, PRNG not seeded");
}
else {
std::string n{R.Gen.generate_random_data(n_bytes)};
const std::string n{R.Gen.generate_random_data(n_bytes)};
fmt::print("got you {} proper bytes from generate_random_data -> {}\n",
n_bytes,
n);
n.clear();
}
const auto end{std::chrono::system_clock::now()};
std::chrono::duration<float> diff = end - start;
const std::chrono::duration<float> diff = end - start;
fmt::print("random_data done - {}\n", end);
fmt::print("getting random data took {:.{}f}s\n", diff.count(), 12);
} // random_data