This repository has been archived on 2022-02-10. You can view files and clone it, but cannot push or open issues or pull requests.
fortuna/generator.h
surtur 2f2f47da01
All checks were successful
continuous-integration/drone/push Build is passing
generator: silence pedantic warnings for __int128
in fortuna, a use of 128bit integer is necessary, which also violates ISO C++:
"warning: ISO C++ does not support ‘__int128’ for ‘ctr’ [-Wpedantic]"

enclosing only the problematic blocks in ignore is chosen as a superior
course of action, compared to completely removing "-Wpedantic" from
CXX_FLAGS, as proposed in #2, as that would prevent any further
"pedantic" warnings from any further code to be shown.

this way, it is assured that the warning "ignore" is activated after
push the push, after which the environment is returned back to its
previous state with a pop, allowing any further warnings to appear.

closes #2
2021-11-15 22:47:22 +01:00

37 lines
787 B
C++

#ifndef FORTUNA_GENERATOR_H
#define FORTUNA_GENERATOR_H
#include <string>
namespace fortuna {
namespace generator {
class Generator {
public:
void initialize_generator();
auto generate_blocks(unsigned int k_blocks) -> std::string;
private:
struct G_state;
auto reseed(const std::string& s) -> void;
auto do_sha(const std::string& k_n_s) -> std::string;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
auto do_crypto(int64_t k, unsigned __int128 ctr) -> std::string;
#pragma GCC diagnostic pop
/* 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