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

Function init_if_needed

common/pseudorand.c:15–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 4

pseudorandFunction · 0.85
pseudorand_u64Function · 0.85
pseudorand_doubleFunction · 0.85
siphash_seedFunction · 0.85

Calls 2

isaac64_initFunction · 0.85
sha256Class · 0.70

Tested by

no test coverage detected