diff options
author | Damien Miller <djm@mindrot.org> | 2000-06-18 14:07:04 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2000-06-18 14:07:04 +1000 |
commit | 7b22d65034ac280e0b4eaa857c71b17ee3ad7d99 (patch) | |
tree | b4fd3f622d95a30394908bc7e9aa30a3658e7b4f /entropy.c | |
parent | 1a13225d877ffdd035659bf5577d5aff388bb317 (diff) |
- (djm) Add summary of configure options to end of ./configure run
- (djm) Not all systems define RUSAGE_SELF & RUSAGE_CHILDREN. Report from
Michael Stone <mstone@cs.loyola.edu>
- (djm) rusage is a privileged operation on some Unices (incl.
Solaris 2.5.1). Report from Paul D. Smith <pausmith@nortelnetworks.com>
- (djm) Avoid PAM failures when running without a TTY. Report from
Martin Petrak <petrak@spsknm.schools.sk>
- (djm) Include sys/types.h when including netinet/in.h in configure tests.
Patch from Jun-ichiro itojun Hagino <itojun@iijlab.net>
Diffstat (limited to 'entropy.c')
-rw-r--r-- | entropy.c | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -35,7 +35,7 @@ | |||
35 | #include <openssl/rand.h> | 35 | #include <openssl/rand.h> |
36 | #include <openssl/sha.h> | 36 | #include <openssl/sha.h> |
37 | 37 | ||
38 | RCSID("$Id: entropy.c,v 1.13 2000/06/07 12:20:23 djm Exp $"); | 38 | RCSID("$Id: entropy.c,v 1.14 2000/06/18 04:07:04 djm Exp $"); |
39 | 39 | ||
40 | #ifndef offsetof | 40 | #ifndef offsetof |
41 | # define offsetof(type, member) ((size_t) &((type *)0)->member) | 41 | # define offsetof(type, member) ((size_t) &((type *)0)->member) |
@@ -55,6 +55,13 @@ RCSID("$Id: entropy.c,v 1.13 2000/06/07 12:20:23 djm Exp $"); | |||
55 | 55 | ||
56 | #define WHITESPACE " \t\n" | 56 | #define WHITESPACE " \t\n" |
57 | 57 | ||
58 | #ifndef RUSAGE_SELF | ||
59 | # define RUSAGE_SELF 0 | ||
60 | #endif | ||
61 | #ifndef RUSAGE_CHILDREN | ||
62 | # define RUSAGE_CHILDREN 0 | ||
63 | #endif | ||
64 | |||
58 | #if defined(EGD_SOCKET) || defined(RANDOM_POOL) | 65 | #if defined(EGD_SOCKET) || defined(RANDOM_POOL) |
59 | 66 | ||
60 | #ifdef EGD_SOCKET | 67 | #ifdef EGD_SOCKET |
@@ -187,11 +194,11 @@ stir_from_system(void) | |||
187 | total_entropy_estimate = 0; | 194 | total_entropy_estimate = 0; |
188 | 195 | ||
189 | i = getpid(); | 196 | i = getpid(); |
190 | RAND_add(&i, sizeof(i), 0.1); | 197 | RAND_add(&i, sizeof(i), 0.5); |
191 | total_entropy_estimate += 0.1; | 198 | total_entropy_estimate += 0.1; |
192 | 199 | ||
193 | i = getppid(); | 200 | i = getppid(); |
194 | RAND_add(&i, sizeof(i), 0.1); | 201 | RAND_add(&i, sizeof(i), 0.5); |
195 | total_entropy_estimate += 0.1; | 202 | total_entropy_estimate += 0.1; |
196 | 203 | ||
197 | i = getuid(); | 204 | i = getuid(); |
@@ -200,7 +207,7 @@ stir_from_system(void) | |||
200 | RAND_add(&i, sizeof(i), 0.0); | 207 | RAND_add(&i, sizeof(i), 0.0); |
201 | 208 | ||
202 | total_entropy_estimate += stir_gettimeofday(1.0); | 209 | total_entropy_estimate += stir_gettimeofday(1.0); |
203 | total_entropy_estimate += stir_clock(0.2); | 210 | total_entropy_estimate += stir_clock(0.5); |
204 | total_entropy_estimate += stir_rusage(RUSAGE_SELF, 2.0); | 211 | total_entropy_estimate += stir_rusage(RUSAGE_SELF, 2.0); |
205 | 212 | ||
206 | return(total_entropy_estimate); | 213 | return(total_entropy_estimate); |
@@ -301,9 +308,9 @@ stir_rusage(int who, double entropy_estimate) | |||
301 | struct rusage ru; | 308 | struct rusage ru; |
302 | 309 | ||
303 | if (getrusage(who, &ru) == -1) | 310 | if (getrusage(who, &ru) == -1) |
304 | fatal("Couldn't getrusage: %s", strerror(errno)); | 311 | return(0); |
305 | 312 | ||
306 | RAND_add(&ru, sizeof(ru), 0.1); | 313 | RAND_add(&ru, sizeof(ru), entropy_estimate); |
307 | 314 | ||
308 | return(entropy_estimate); | 315 | return(entropy_estimate); |
309 | #else /* _HAVE_GETRUSAGE */ | 316 | #else /* _HAVE_GETRUSAGE */ |