From 61648131fb37777c927e955e4beb82665be1640f Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 28 Jun 2003 14:11:28 +0000 Subject: [PATCH] Failure to set multipliers[NPRIMES] was rendering the input-modulus 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'. [originally from svn r3316] --- sshprime.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sshprime.c b/sshprime.c index b48ce1a3..4d79aacd 100644 --- a/sshprime.c +++ b/sshprime.c @@ -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++)