MCPcopy Create free account
hub / github.com/ElementsProject/lightning / init_if_needed

Function init_if_needed

common/pseudorand.c:13–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11static bool pseudorand_initted = false;
12
13static void init_if_needed(void)
14{
15 if (unlikely(!pseudorand_initted)) {
16 unsigned char seedbuf[16];
17 struct sha256 sha;
18
19 randbytes(seedbuf, sizeof(seedbuf));
20 memcpy(&siphashseed, seedbuf, sizeof(siphashseed));
21
22 /* In case isaac is reversible, don't leak seed. */
23 sha256(&sha, seedbuf, sizeof(seedbuf));
24 isaac64_init(&isaac64, sha.u.u8, sizeof(sha.u.u8));
25 pseudorand_initted = true;
26 }
27}
28
29uint64_t pseudorand_(uint64_t max, uint64_t *offset)
30{

Callers 4

pseudorand_Function · 0.85
pseudorand_u64_Function · 0.85
pseudorand_double_Function · 0.85
siphash_seedFunction · 0.85

Calls 2

isaac64_initFunction · 0.85
sha256Class · 0.70

Tested by

no test coverage detected