diff options
-rw-r--r-- | src/util/crypto_random.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/util/crypto_random.c b/src/util/crypto_random.c index 35dafd071..eea047ac6 100644 --- a/src/util/crypto_random.c +++ b/src/util/crypto_random.c | |||
@@ -99,9 +99,9 @@ GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, unsigned int n) | |||
99 | ret = GNUNET_malloc (n * sizeof (unsigned int)); | 99 | ret = GNUNET_malloc (n * sizeof (unsigned int)); |
100 | for (i = 0; i < n; i++) | 100 | for (i = 0; i < n; i++) |
101 | ret[i] = i; | 101 | ret[i] = i; |
102 | for (i = 0; i < n; i++) | 102 | for (i = n - 1; i > 0; i--) |
103 | { | 103 | { |
104 | x = GNUNET_CRYPTO_random_u32 (mode, n); | 104 | x = GNUNET_CRYPTO_random_u32 (mode, i+1); |
105 | tmp = ret[x]; | 105 | tmp = ret[x]; |
106 | ret[x] = ret[i]; | 106 | ret[x] = ret[i]; |
107 | ret[i] = tmp; | 107 | ret[i] = tmp; |