now check that all the modular functions (modpow, modinv, modmul,
bigdivmod) have nonzero moduli, and that modinv also has a nonzero
thing to try to invert.
git-svn-id: svn://svn.tartarus.org/sgt/putty@9987
cda61777-01e9-0310-a592-
d414129be87e
+ assert(m0 >> (BIGNUM_INT_BITS-1) == 1);
if (mlen > 1)
m1 = m[1];
else
if (mlen > 1)
m1 = m[1];
else
int pqlen, mlen, rlen, i, j;
Bignum result;
int pqlen, mlen, rlen, i, j;
Bignum result;
+ /*
+ * The most significant word of mod needs to be non-zero. It
+ * should already be, but let's make sure.
+ */
+ assert(mod[mod[0]] != 0);
+
/* Allocate m of size mlen, copy mod to m */
/* We use big endian internally */
mlen = mod[0];
/* Allocate m of size mlen, copy mod to m */
/* We use big endian internally */
mlen = mod[0];
int mshift;
int plen, mlen, i, j;
int mshift;
int plen, mlen, i, j;
+ /*
+ * The most significant word of mod needs to be non-zero. It
+ * should already be, but let's make sure.
+ */
+ assert(mod[mod[0]] != 0);
+
/* Allocate m of size mlen, copy mod to m */
/* We use big endian internally */
mlen = mod[0];
/* Allocate m of size mlen, copy mod to m */
/* We use big endian internally */
mlen = mod[0];
Bignum x = copybn(One);
int sign = +1;
Bignum x = copybn(One);
int sign = +1;
+ assert(number[number[0]] != 0);
+ assert(modulus[modulus[0]] != 0);
+
while (bignum_cmp(b, One) != 0) {
Bignum t = newbn(b[0]);
Bignum q = newbn(a[0]);
while (bignum_cmp(b, One) != 0) {
Bignum t = newbn(b[0]);
Bignum q = newbn(a[0]);