File: random_source.h

package info (click to toggle)
entropybroker 2.9-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,600 kB
  • sloc: cpp: 14,386; sh: 934; makefile: 188; java: 148; perl: 12
file content (24 lines) | stat: -rw-r--r-- 658 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <cryptopp/osrng.h>

typedef enum { RS_CRYPTOPP, RS_DEV_URANDOM, RS_DEV_RANDOM } random_source_t;

class random_source
{
private:
	const random_source_t rs;
	CryptoPP::AutoSeededRandomPool *rng;
	std::string state_file;
	bool notified_errors;

	void dump_state(const std::string & file);
	void retrieve_state(const std::string & file);

public:
	random_source(const random_source_t rst);
	random_source(const random_source_t rst, const std::string & dump_file_in);
	~random_source();

	void get(unsigned char *const p, const size_t n);
	bool check_empty() const;
	void seed(const unsigned char *const in, const size_t n, const double byte_count);
};