bignum_mod_short shouldn't be depending on a fixed place value in
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 28 Jun 2003 14:10:06 +0000 (14:10 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 28 Jun 2003 14:10:06 +0000 (14:10 +0000)
the bignum data! This wasn't actually causing puttygen-zero-div (its
unwarranted assumption was still correct under Windows) but it would
have caused the same symptoms under Unix when I got round to porting
PuTTYgen.

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

sshbn.c

diff --git a/sshbn.c b/sshbn.c
index 3742227..2d8359e 100644 (file)
--- a/sshbn.c
+++ b/sshbn.c
@@ -814,7 +814,7 @@ unsigned short bignum_mod_short(Bignum number, unsigned short modulus)
     r = 0;
     mod = modulus;
     for (i = number[0]; i > 0; i--)
-       r = (r * 65536 + number[i]) % mod;
+       r = (r * (BIGNUM_TOP_BIT % mod) * 2 + number[i] % mod) % mod;
     return (unsigned short) r;
 }