fix
authorChristian Grothoff <christian@grothoff.org>
Fri, 8 Oct 2010 15:47:24 +0000 (15:47 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 8 Oct 2010 15:47:24 +0000 (15:47 +0000)
src/util/crypto_ksk.c

index 24886969501134e03d63be8c53c0101668b77a92..7600c560047afdcd2281cbef8f391a6742cd56aa 100644 (file)
@@ -321,7 +321,7 @@ gen_prime (gcry_mpi_t *ptest, unsigned int nbits, GNUNET_HashCode * hc)
       /* Calculate all remainders. */
       tmp = gcry_mpi_new (0);
       sp = gcry_mpi_new (0);
-      for (i = 0; i <= no_of_small_primer_numbers; i++)
+      for (i = 0; i <= no_of_small_prime_numbers; i++)
         {
           size_t written;
 
@@ -337,14 +337,15 @@ gen_prime (gcry_mpi_t *ptest, unsigned int nbits, GNUNET_HashCode * hc)
       for (step = 0; step < 20000; step += 2)
         {
           /* Check against all the small primes we have in mods. */
-          for (i = 0; (x = small_prime_numbers[i]); i++)
+          for (i = 0; i <= no_of_small_prime_numbers; i++)
             {
+             uint16_t x = small_prime_numbers[i];
               while (mods[i] + step >= x)
                 mods[i] -= x;
               if (!(mods[i] + step))
                 break;
             }
-          if (x)
+          if (i <= no_of_small_prime_numbers)
             continue;           /* Found a multiple of an already known prime. */
 
           gcry_mpi_add_ui (*ptest, prime, step);