diff options
Diffstat (limited to 'entropy.c')
-rw-r--r-- | entropy.c | 26 |
1 files changed, 16 insertions, 10 deletions
@@ -40,7 +40,7 @@ | |||
40 | #include "pathnames.h" | 40 | #include "pathnames.h" |
41 | #include "log.h" | 41 | #include "log.h" |
42 | 42 | ||
43 | RCSID("$Id: entropy.c,v 1.35 2001/03/03 13:29:21 djm Exp $"); | 43 | RCSID("$Id: entropy.c,v 1.36 2001/03/18 22:38:16 djm Exp $"); |
44 | 44 | ||
45 | #ifndef offsetof | 45 | #ifndef offsetof |
46 | # define offsetof(type, member) ((size_t) &((type *)0)->member) | 46 | # define offsetof(type, member) ((size_t) &((type *)0)->member) |
@@ -68,7 +68,8 @@ RCSID("$Id: entropy.c,v 1.35 2001/03/03 13:29:21 djm Exp $"); | |||
68 | # define SAVED_IDS_WORK_WITH_SETEUID | 68 | # define SAVED_IDS_WORK_WITH_SETEUID |
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | void check_openssl_version(void) | 71 | void |
72 | check_openssl_version(void) | ||
72 | { | 73 | { |
73 | if (SSLeay() != OPENSSL_VERSION_NUMBER) | 74 | if (SSLeay() != OPENSSL_VERSION_NUMBER) |
74 | fatal("OpenSSL version mismatch. Built against %lx, you " | 75 | fatal("OpenSSL version mismatch. Built against %lx, you " |
@@ -83,7 +84,8 @@ void check_openssl_version(void) | |||
83 | 84 | ||
84 | #ifdef USE_PRNGD | 85 | #ifdef USE_PRNGD |
85 | /* Collect entropy from PRNGD/EGD */ | 86 | /* Collect entropy from PRNGD/EGD */ |
86 | int get_random_bytes(unsigned char *buf, int len) | 87 | int |
88 | get_random_bytes(unsigned char *buf, int len) | ||
87 | { | 89 | { |
88 | int fd; | 90 | int fd; |
89 | char msg[2]; | 91 | char msg[2]; |
@@ -180,7 +182,8 @@ done: | |||
180 | #else /* !USE_PRNGD */ | 182 | #else /* !USE_PRNGD */ |
181 | #ifdef RANDOM_POOL | 183 | #ifdef RANDOM_POOL |
182 | /* Collect entropy from /dev/urandom or pipe */ | 184 | /* Collect entropy from /dev/urandom or pipe */ |
183 | int get_random_bytes(unsigned char *buf, int len) | 185 | int |
186 | get_random_bytes(unsigned char *buf, int len) | ||
184 | { | 187 | { |
185 | int random_pool; | 188 | int random_pool; |
186 | 189 | ||
@@ -226,7 +229,8 @@ seed_rng(void) | |||
226 | memset(buf, '\0', sizeof(buf)); | 229 | memset(buf, '\0', sizeof(buf)); |
227 | } | 230 | } |
228 | 231 | ||
229 | void init_rng(void) | 232 | void |
233 | init_rng(void) | ||
230 | { | 234 | { |
231 | check_openssl_version(); | 235 | check_openssl_version(); |
232 | } | 236 | } |
@@ -403,8 +407,7 @@ stir_rusage(int who, double entropy_estimate) | |||
403 | } | 407 | } |
404 | 408 | ||
405 | 409 | ||
406 | static | 410 | static int |
407 | int | ||
408 | _get_timeval_msec_difference(struct timeval *t1, struct timeval *t2) { | 411 | _get_timeval_msec_difference(struct timeval *t1, struct timeval *t2) { |
409 | int secdiff, usecdiff; | 412 | int secdiff, usecdiff; |
410 | 413 | ||
@@ -842,8 +845,10 @@ seed_rng(void) | |||
842 | /* commands */ | 845 | /* commands */ |
843 | old_sigchld_handler = mysignal(SIGCHLD, SIG_DFL); | 846 | old_sigchld_handler = mysignal(SIGCHLD, SIG_DFL); |
844 | 847 | ||
845 | debug("Seeded RNG with %i bytes from programs", (int)stir_from_programs()); | 848 | debug("Seeded RNG with %i bytes from programs", |
846 | debug("Seeded RNG with %i bytes from system calls", (int)stir_from_system()); | 849 | (int)stir_from_programs()); |
850 | debug("Seeded RNG with %i bytes from system calls", | ||
851 | (int)stir_from_system()); | ||
847 | 852 | ||
848 | if (!RAND_status()) | 853 | if (!RAND_status()) |
849 | fatal("Not enough entropy in RNG"); | 854 | fatal("Not enough entropy in RNG"); |
@@ -854,7 +859,8 @@ seed_rng(void) | |||
854 | fatal("Couldn't initialise builtin random number generator -- exiting."); | 859 | fatal("Couldn't initialise builtin random number generator -- exiting."); |
855 | } | 860 | } |
856 | 861 | ||
857 | void init_rng(void) | 862 | void |
863 | init_rng(void) | ||
858 | { | 864 | { |
859 | int original_euid; | 865 | int original_euid; |
860 | 866 | ||