diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-11-23 20:03:58 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-11-23 20:03:58 +0000 |
commit | 55ac5056bd7f3997f67bc7a478f3e1d01ffb0e52 (patch) | |
tree | f3620b34222f15cdde0c5c0a4032ffb44a53859d /src/util/crypto_random.c | |
parent | 07f6af3914a9b438cb1526a628689bc0d8a6db27 (diff) |
LRN: Fix the use of SRANDOM
Diffstat (limited to 'src/util/crypto_random.c')
-rw-r--r-- | src/util/crypto_random.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/util/crypto_random.c b/src/util/crypto_random.c index 9fc14863cc..a1485029e3 100644 --- a/src/util/crypto_random.c +++ b/src/util/crypto_random.c @@ -74,6 +74,17 @@ weak_random () return ((double) RANDOM () / RAND_MAX); } +/** + * Seed a weak random generator. Only GNUNET_CRYPTO_QUALITY_WEAK-mode generator + * can be seeded. + * + * @param seed the seed to use + */ +void +GNUNET_CRYPTO_seed_weak_random (int32_t seed) +{ + SRANDOM (seed); +} /** * Produce a random value. @@ -302,8 +313,8 @@ void __attribute__ ((constructor)) GNUNET_CRYPTO_random_init () #endif gcry_set_progress_handler (&entropy_generator, NULL); atexit (&killfind); - SRANDOM (time (NULL) ^ - GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX)); + GNUNET_CRYPTO_seed_weak_random (time (NULL) ^ + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX)); } |