aboutsummaryrefslogtreecommitdiff
path: root/src/util/crypto_random.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-23 20:03:58 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-23 20:03:58 +0000
commit55ac5056bd7f3997f67bc7a478f3e1d01ffb0e52 (patch)
treef3620b34222f15cdde0c5c0a4032ffb44a53859d /src/util/crypto_random.c
parent07f6af3914a9b438cb1526a628689bc0d8a6db27 (diff)
downloadgnunet-55ac5056bd7f3997f67bc7a478f3e1d01ffb0e52.tar.gz
gnunet-55ac5056bd7f3997f67bc7a478f3e1d01ffb0e52.zip
LRN: Fix the use of SRANDOM
Diffstat (limited to 'src/util/crypto_random.c')
-rw-r--r--src/util/crypto_random.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/util/crypto_random.c b/src/util/crypto_random.c
index 9fc14863c..a1485029e 100644
--- a/src/util/crypto_random.c
+++ b/src/util/crypto_random.c
@@ -74,6 +74,17 @@ weak_random ()
74 return ((double) RANDOM () / RAND_MAX); 74 return ((double) RANDOM () / RAND_MAX);
75} 75}
76 76
77/**
78 * Seed a weak random generator. Only GNUNET_CRYPTO_QUALITY_WEAK-mode generator
79 * can be seeded.
80 *
81 * @param seed the seed to use
82 */
83void
84GNUNET_CRYPTO_seed_weak_random (int32_t seed)
85{
86 SRANDOM (seed);
87}
77 88
78/** 89/**
79 * Produce a random value. 90 * Produce a random value.
@@ -302,8 +313,8 @@ void __attribute__ ((constructor)) GNUNET_CRYPTO_random_init ()
302#endif 313#endif
303 gcry_set_progress_handler (&entropy_generator, NULL); 314 gcry_set_progress_handler (&entropy_generator, NULL);
304 atexit (&killfind); 315 atexit (&killfind);
305 SRANDOM (time (NULL) ^ 316 GNUNET_CRYPTO_seed_weak_random (time (NULL) ^
306 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX)); 317 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX));
307} 318}
308 319
309 320