surtur
a1cbbb209e
All checks were successful
continuous-integration/drone/push Build is passing
* handle the PRNG state with R_state nested class * add a private property R holding PRNG state to Fortuna * add R_state properties as defined in Cryptography Engineering: * a generator instance * a reseed counter * 32 pools that the collected entropy is to be distributed over * add initial definition of the Pool object and its initialization * attempt to initialize PRNG in Fortuna constructor. wrap the initialization call in a try-catch block like a cultured person * erase the string used to print data from random_data() after it's been used
35 lines
749 B
C++
35 lines
749 B
C++
#ifndef FORTUNA_FORTUNA_CPP
|
|
#define FORTUNA_FORTUNA_CPP
|
|
|
|
#include "fortuna.h"
|
|
|
|
#include <cryptopp/cryptlib.h>
|
|
#include <cryptopp/osrng.h>
|
|
#include <cryptopp/hex.h>
|
|
#include <cryptopp/filters.h>
|
|
#include <cryptopp/serpent.h>
|
|
#include <cryptopp/ccm.h>
|
|
#include <fmt/core.h>
|
|
|
|
|
|
namespace fortuna {
|
|
Fortuna::Fortuna(){
|
|
try {
|
|
initialize_prng();
|
|
} catch(CryptoPP::Exception& e) {
|
|
fmt::print(stderr, "{}\n", e.what());
|
|
}
|
|
}
|
|
Fortuna::~Fortuna() = default;
|
|
|
|
auto Fortuna::random_data(unsigned int n_bytes) -> void {
|
|
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.erase();
|
|
} //random_data
|
|
|
|
} // namespace fortuna
|
|
|
|
#endif//FORTUNA_FORTUNA_CPP
|