blob: a7a244d8a57c242c93596c3fdf16ad587f79010e (
plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/* ISC license. */
#include <skalibs/sysdeps.h>
#if defined(SKALIBS_HASARC4RANDOM)
#include <skalibs/nonposix.h>
#include <stdlib.h>
#include <skalibs/random.h>
void random_buf_early (char *s, size_t n)
{
arc4random_buf(s, n) ;
}
#elif defined(SKALIBS_HASGETRANDOM) && defined(SKALIBS_HASGRNDINSECURE)
#include <sys/random.h>
#include <skalibs/random.h>
void random_buf_early (char *s, size_t n)
{
while (n)
{
ssize_t r = getrandom(s, n, GRND_INSECURE) ;
if (r >= 0)
{
s += r ;
n -= r ;
}
}
}
#elif defined(SKALIBS_HASDEVURANDOM)
#include <skalibs/random.h>
void random_buf_early (char *s, size_t n)
{
random_devurandom(s, n) ;
}
#else
#include <skalibs/surf.h>
#include <skalibs/random.h>
void random_buf_early (char *s, size_t n)
{
autosurf(s, n) ;
}
#endif
|