fix
authorChristian Grothoff <christian@grothoff.org>
Tue, 8 Jun 2010 06:55:01 +0000 (06:55 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 8 Jun 2010 06:55:01 +0000 (06:55 +0000)
src/util/crypto_random.c

index 35dafd071b98afcda77b4b4d95c19927e645aeaf..eea047ac6999fbb11665dd2bd187130c4653e878 100644 (file)
@@ -99,9 +99,9 @@ GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, unsigned int n)
   ret = GNUNET_malloc (n * sizeof (unsigned int));
   for (i = 0; i < n; i++)
     ret[i] = i;
-  for (i = 0; i < n; i++)
+  for (i = n - 1; i > 0; i--)
     {
-      x = GNUNET_CRYPTO_random_u32 (mode, n);
+      x = GNUNET_CRYPTO_random_u32 (mode, i+1);
       tmp = ret[x];
       ret[x] = ret[i];
       ret[i] = tmp;