diff options
author | Werner Koch <[email protected]> | 1998-01-24 16:32:27 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 1998-01-24 16:32:27 +0000 |
commit | d71f8bce7e73b41c1d19d2dae6396ea8eace9c07 (patch) | |
tree | 89854e6434a270ad627f4f4011385a7739f8f3df /cipher/random.c | |
parent | backup (diff) | |
download | gnupg-d71f8bce7e73b41c1d19d2dae6396ea8eace9c07.tar.gz gnupg-d71f8bce7e73b41c1d19d2dae6396ea8eace9c07.zip |
Trust stuff works partly.
Diffstat (limited to 'cipher/random.c')
-rw-r--r-- | cipher/random.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cipher/random.c b/cipher/random.c index b082022af..dbf71478b 100644 --- a/cipher/random.c +++ b/cipher/random.c @@ -167,6 +167,10 @@ the OS a chance to collect more entropy! (Need %d more bytes)\n", length ); #else /* not HAVE_DEV_RANDOM */ +#ifndef RAND_MAX /* for SunOS */ + #define RAND_MAX 32767 +#endif + static void fill_buffer( byte *buffer, size_t length, int level ) { @@ -178,11 +182,20 @@ fill_buffer( byte *buffer, size_t length, int level ) "it compile - it is in no way a strong RNG!\n\n" "DON'T USE ANY DATA GENERATED BY THIS PROGRAM!!\n\n"); initialized=1; + #ifdef HAVE_RAND srand(make_timestamp()*getpid()); + #else + srandom(make_timestamp()*getpid()); + #endif } + #ifdef HAVE_RAND while( length-- ) *buffer++ = ((unsigned)(1 + (int) (256.0*rand()/(RAND_MAX+1.0)))-1); + #else + while( length-- ) + *buffer++ = ((unsigned)(1 + (int) (256.0*random()/(RAND_MAX+1.0)))-1); + #endif } #endif |