diff options
Diffstat (limited to '')
-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 |