From f26b3d771ea81495859eb4d899af447fc9b6b3e5 Mon Sep 17 00:00:00 2001 From: simon 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'. git-svn-id: svn://svn.tartarus.org/sgt/putty@3316 cda61777-01e9-0310-a592-d414129be87e --- 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++) -- 2.11.0