surtur
444660bf89
All checks were successful
continuous-integration/drone/push Build is passing
* initialize_generator() is now a private method * call initialize_generator() inside the constructor of the Generator * move full struct declaration to generator.h * have a private field named G of type G_state * remove explicit instantiation of Generator from fortuna constructor - Generator is a private field of fortuna * remove direct initialize_generator() call from fortuna constructor * remove get_state() calls as G_state G is now a private field * refactor get_state() to simply return the *private field G_state G* * refactor do_crypto() - I know, this should have been split to a separate commit - remove function parameters and useless assignments inside its body to reflect that once it accesses k and ctr (of the G_state G), it won't be necessary for them to be passed as parameters, since *G_state G is now a private field*...
44 lines
879 B
C++
44 lines
879 B
C++
#ifndef FORTUNA_GENERATOR_H
|
|
#define FORTUNA_GENERATOR_H
|
|
|
|
#include <string>
|
|
|
|
namespace fortuna {
|
|
namespace generator {
|
|
|
|
class Generator {
|
|
public:
|
|
Generator(); // ad noexcept: perhaps _do_ throw*
|
|
~Generator();
|
|
auto generate_blocks(unsigned int k_blocks) -> std::string;
|
|
|
|
private:
|
|
struct G_state {
|
|
int64_t k;
|
|
#pragma GCC diagnostic push
|
|
#pragma GCC diagnostic ignored "-Wpedantic"
|
|
unsigned __int128 ctr;
|
|
#pragma GCC diagnostic pop
|
|
};
|
|
G_state G;
|
|
|
|
void initialize_generator();
|
|
|
|
auto reseed(const std::string& s) -> void;
|
|
|
|
auto do_sha(const std::string& k_n_s) -> std::string;
|
|
|
|
auto do_crypto() -> std::string;
|
|
|
|
/* n is the number of random bytes to generate */
|
|
auto generate_random_data(uint n) -> std::string;
|
|
|
|
protected:
|
|
auto get_state() -> Generator::G_state;
|
|
|
|
}; // class generator
|
|
|
|
} //namespace generator
|
|
} //namespace fortuna
|
|
#endif//FORTUNA_GENERATOR_H
|