-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFortuna.h
36 lines (31 loc) · 801 Bytes
/
Fortuna.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef FORTUNA_H
#define FORTUNA_H
#include "Accumulator.h"
#include "SeedFile.h"
#include <inttypes.h>
/**
* Seed file is optional. The reason is that I think it is useful to have but
* could leave the device open to more side channel attacks. Hence I have made
* it optional.
*/
class Fortuna {
public:
Fortuna();
Fortuna(SeedFile *seedFile);
bool registerSource(Source *source);
void gatherEntropy(){accumulator.addEventData(&prngState);}
/*
* return NULL on no random data
*/
uint8_t* getRandomData(uint32_t byteSize);
private:
Accumulator accumulator;
PRNGState prngState;
time_t reseedTime;
time_t getTime();
SeedFile *seedFile;
bool seedFileReseed;
Sha256Class sha;
uint8_t *poolEntropy;
};
#endif /* FORTUNA_H */