Failure to set multipliers[NPRIMES] was rendering the input-modulus
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 28 Jun 2003 14:11:28 +0000 (14:11 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 28 Jun 2003 14:11:28 +0000 (14:11 +0000)
feature (make sure your prime is not congruent to Foo mod Bar)
largely ineffective. As a result, RSA keys were being generated
every so often with at least one prime congruent to 1 mod 37,
causing modinv(37, phi(n)) to divide by zero, and rightly so. I
believe this fixes `puttygen-zero-div'.

git-svn-id: svn://svn.tartarus.org/sgt/putty@3316 cda61777-01e9-0310-a592-d414129be87e

sshprime.c

index b48ce1a..4d79aac 100644 (file)
@@ -1255,6 +1255,10 @@ Bignum primegen(int bits, int modulus, int residue, Bignum factor,
     moduli[NPRIMES] = modulus;
     residues[NPRIMES] = (bignum_mod_short(p, (unsigned short) modulus)
                         + modulus - residue);
+    if (factor)
+       multipliers[NPRIMES] = bignum_mod_short(factor, modulus);
+    else
+       multipliers[NPRIMES] = 1;
     delta = 0;
     while (1) {
        for (i = 0; i < (sizeof(moduli) / sizeof(*moduli)); i++)