summaryrefslogtreecommitdiff
path: root/entropy.c
diff options
context:
space:
mode:
Diffstat (limited to 'entropy.c')
-rw-r--r--entropy.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/entropy.c b/entropy.c
index cbb36fd29..09dcae3ba 100644
--- a/entropy.c
+++ b/entropy.c
@@ -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
38RCSID("$Id: entropy.c,v 1.13 2000/06/07 12:20:23 djm Exp $"); 38RCSID("$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 */