Dynalib Utils
ISAACRandom.h
Go to the documentation of this file.
1 //
2 // Created by Ken Kopelson on 30/04/18.
3 //
4 
5 /*
6 ------------------------------------------------------------------------------
7 ISAACRandom.h: definitions for a crypto number generator
8 Bob Jenkins, 1996, Public Domain
9 ------------------------------------------------------------------------------
10 */
11 #ifndef STANDARD
12 #include "standard.h"
13 #endif
14 
15 #ifndef ISAAC
16 #define ISAAC
17 
18 #include <cstdint>
19 #include <cstddef>
20 #include "../TypeDefs.h"
21 
22 using namespace std;
23 
24 #define RANDSIZL (8)
25 #define RANDSIZ (1<<RANDSIZL)
26 
27 struct RandContext {
28  uint32_t randcnt;
29  uint32_t randrsl[RANDSIZ];
30  uint32_t randmem[RANDSIZ];
31  uint32_t randa;
32  uint32_t randb;
33  uint32_t randc;
34 };
35 
36 /*
37 ------------------------------------------------------------------------------
38  If (flag==TRUE), then use the contents of randrsl[0..255] as the seed.
39 ------------------------------------------------------------------------------
40 */
41 extern void isaacSeed(char* seed, RandContext* ctx);
42 extern void isaacInit(bool hasSeed, RandContext* ctx);
43 extern void isaacRandom(RandContext* ctx);
44 extern uint32_t randInt(RandContext* ctx);
45 extern void randBytes(RandContext* ctx, uchar* buf, int count);
46 
47 #endif /* RAND */
Definition: ISAACRandom.h:27
uint32_t randb
Definition: ISAACRandom.h:32
void isaacInit(bool hasSeed, RandContext *ctx)
Definition: ISAACRandom.cpp:59
uint32_t randcnt
Definition: ISAACRandom.h:28
uint32_t randa
Definition: ISAACRandom.h:31
#define RANDSIZ
Definition: ISAACRandom.h:25
void randBytes(RandContext *ctx, uchar *buf, int count)
Definition: ISAACRandom.cpp:145
void isaacSeed(char *seed, RandContext *ctx)
Definition: ISAACRandom.cpp:45
void isaacRandom(RandContext *ctx)
Definition: ISAACRandom.cpp:121
uint8_t uchar
Definition: TypeDefs.h:22
uint32_t randInt(RandContext *ctx)
Definition: ISAACRandom.cpp:137
uint32_t randc
Definition: ISAACRandom.h:33