blob: e47f8df39ee2c6edea1dabe6ada9f4934869b0a8 (
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/* ISC license. */
#include <skalibs/sysdeps.h>
#ifdef SKALIBS_HASARC4RANDOM
#include <skalibs/nonposix.h>
#include <stdlib.h>
#include <skalibs/random.h>
int random_init ()
{
#ifdef SKALIBS_HASARC4RANDOM_ADDRANDOM
char seed[160] ;
random_makeseed(seed) ;
arc4random_addrandom((unsigned char *)seed, 160) ;
#endif
return 1 ;
}
#else
#ifdef SKALIBS_HASGETRANDOM
#include <skalibs/djbunix.h>
#include <skalibs/random.h>
int random_init ()
{
#ifdef SKALIBS_HASDEVURANDOM
char seed[160] ;
random_makeseed(seed) ;
openwritenclose_unsafe("/dev/urandom", seed, 160) ;
#endif
return 1 ;
}
#else
#include <skalibs/surf.h>
#include <skalibs/random.h>
#include "random-internal.h"
SURFSchedule surf_here = SURFSCHEDULE_ZERO ;
#ifdef SKALIBS_HASDEVURANDOM
#include <errno.h>
#include <skalibs/djbunix.h>
int random_fd = -1 ;
int random_init ()
{
char seed[160] ;
if (random_fd >= 0) return 1 ;
random_makeseed(seed) ;
surf_init(&surf_here, seed) ;
openwritenclose_unsafe("/dev/urandom", seed, 160) ;
random_fd = openc_readb("/dev/urandom") ;
return random_fd >= 0 ;
}
#else /* default */
int random_init ()
{
char seed[160] ;
random_makeseed(seed) ;
surf_init(&surf_here, seed) ;
return 1 ;
}
#endif
#endif
#endif
|