[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r11026 - gnunet/src/util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r11026 - gnunet/src/util |
Date: |
Thu, 22 Apr 2010 11:21:18 +0200 |
Author: grothoff
Date: 2010-04-22 11:21:18 +0200 (Thu, 22 Apr 2010)
New Revision: 11026
Modified:
gnunet/src/util/crypto_random.c
Log:
make weakness more explicit
Modified: gnunet/src/util/crypto_random.c
===================================================================
--- gnunet/src/util/crypto_random.c 2010-04-22 09:15:55 UTC (rev 11025)
+++ gnunet/src/util/crypto_random.c 2010-04-22 09:21:18 UTC (rev 11026)
@@ -30,6 +30,18 @@
#include <gcrypt.h>
/**
+ * Create a cryptographically weak pseudo-random number in the interval of 0
to 1.
+ *
+ * @return number between 0 and 1.
+ */
+static double
+weak_random ()
+{
+ return ((double) RANDOM () / RAND_MAX);
+}
+
+
+/**
* Produce a random value.
*
* @param mode desired quality of the random number
@@ -59,7 +71,7 @@
}
else
{
- ret = i * ((double) RANDOM () / RAND_MAX);
+ ret = i * weak_random ();
if (ret >= i)
ret = i - 1;
return ret;
@@ -119,7 +131,7 @@
}
else
{
- ret = max * ((double) RANDOM () / RAND_MAX);
+ ret = max * weak_random ();
if (ret >= max)
ret = max - 1;
return ret;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r11026 - gnunet/src/util,
gnunet <=