2021-11-15 22:13:00 +01:00
|
|
|
#ifndef FORTUNA_FORTUNA_CPP
|
|
|
|
#define FORTUNA_FORTUNA_CPP
|
|
|
|
|
2021-11-10 23:55:58 +01:00
|
|
|
#include "fortuna.h"
|
|
|
|
|
2021-12-04 00:19:22 +01:00
|
|
|
#include <cryptopp/cryptlib.h>
|
2021-11-15 23:27:17 +01:00
|
|
|
#include <cryptopp/osrng.h>
|
|
|
|
#include <cryptopp/hex.h>
|
|
|
|
#include <cryptopp/filters.h>
|
|
|
|
#include <cryptopp/serpent.h>
|
|
|
|
#include <cryptopp/ccm.h>
|
2021-11-18 22:05:05 +01:00
|
|
|
#include <fmt/core.h>
|
2021-11-15 23:27:17 +01:00
|
|
|
|
2021-11-10 23:55:58 +01:00
|
|
|
|
|
|
|
namespace fortuna {
|
|
|
|
Fortuna::Fortuna(){
|
2021-12-04 00:19:22 +01:00
|
|
|
try {
|
|
|
|
initialize_prng();
|
|
|
|
} catch(CryptoPP::Exception& e) {
|
|
|
|
fmt::print(stderr, "{}\n", e.what());
|
|
|
|
}
|
2021-11-10 23:55:58 +01:00
|
|
|
}
|
|
|
|
Fortuna::~Fortuna() = default;
|
|
|
|
|
2021-11-30 14:09:39 +01:00
|
|
|
auto Fortuna::random_data(unsigned int n_bytes) -> void {
|
2021-12-07 15:46:01 +01:00
|
|
|
incr_reseed_ctr();
|
|
|
|
|
2021-12-04 00:19:22 +01:00
|
|
|
std::string n{R.Gen.generate_random_data(n_bytes)};
|
2021-11-30 14:09:39 +01:00
|
|
|
fmt::print("got you {} proper bytes from generate_random_data -> {}\n",
|
|
|
|
n_bytes, n);
|
2021-12-04 00:19:22 +01:00
|
|
|
n.erase();
|
2021-11-15 23:27:17 +01:00
|
|
|
} //random_data
|
2021-11-10 23:55:58 +01:00
|
|
|
|
|
|
|
} // namespace fortuna
|
|
|
|
|
|
|
|
#endif//FORTUNA_FORTUNA_CPP
|