diff options
Diffstat (limited to 'tools/plink/sshbn.c')
-rwxr-xr-x[-rw-r--r--] | tools/plink/sshbn.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/tools/plink/sshbn.c b/tools/plink/sshbn.c index a5e0552ff..e71940e31 100644..100755 --- a/tools/plink/sshbn.c +++ b/tools/plink/sshbn.c @@ -181,7 +181,7 @@ static BignumInt internal_add(const BignumInt *a, const BignumInt *b, for (i = len-1; i >= 0; i--) { carry += (BignumDblInt)a[i] + b[i]; - c[i] = (BignumInt)carry; + c[i] = (BignumInt)(carry&BIGNUM_INT_MASK); carry >>= BIGNUM_INT_BITS; } @@ -201,7 +201,7 @@ static void internal_sub(const BignumInt *a, const BignumInt *b, for (i = len-1; i >= 0; i--) { carry += (BignumDblInt)a[i] + (b[i] ^ BIGNUM_INT_MASK); - c[i] = (BignumInt)carry; + c[i] = (BignumInt)(carry&BIGNUM_INT_MASK); carry >>= BIGNUM_INT_BITS; } } @@ -427,7 +427,7 @@ static void internal_mul(const BignumInt *a, const BignumInt *b, carry = 0; for (cp = cps, bp = b + len; cp--, bp-- > b ;) { t = (MUL_WORD(*ap, *bp) + carry) + *cp; - *cp = (BignumInt) t; + *cp = (BignumInt) (t & 0xffffffff); carry = (BignumInt)(t >> BIGNUM_INT_BITS); } *cp = carry; @@ -529,7 +529,7 @@ static void internal_mul_low(const BignumInt *a, const BignumInt *b, carry = 0; for (cp = cps, bp = b + len; bp--, cp-- > c ;) { t = (MUL_WORD(*ap, *bp) + carry) + *cp; - *cp = (BignumInt) t; + *cp = (BignumInt) (t&BIGNUM_INT_MASK); carry = (BignumInt)(t >> BIGNUM_INT_BITS); } } @@ -609,7 +609,7 @@ static void internal_add_shifted(BignumInt *number, while (addend) { assert(word <= number[0]); addend += number[word]; - number[word] = (BignumInt) addend & BIGNUM_INT_MASK; + number[word] = (BignumInt) (addend & BIGNUM_INT_MASK); addend >>= BIGNUM_INT_BITS; word++; } @@ -698,9 +698,9 @@ static void internal_mod(BignumInt *a, int alen, t = MUL_WORD(q, m[k]); t += c; c = (unsigned)(t >> BIGNUM_INT_BITS); - if ((BignumInt) t > a[i + k]) + if (((BignumInt)(t&0xffffffff)) > a[i + k]) c++; - a[i + k] -= (BignumInt) t; + a[i + k] -= (BignumInt) (t&0xffffffff); } /* Add back m in case of borrow */ @@ -1418,7 +1418,7 @@ Bignum bigmuladd(Bignum a, Bignum b, Bignum addend) for (i = 1; i <= rlen; i++) { carry += (i <= (int)ret[0] ? ret[i] : 0); carry += (i <= (int)addend[0] ? addend[i] : 0); - ret[i] = (BignumInt) carry & BIGNUM_INT_MASK; + ret[i] = (BignumInt) (carry & BIGNUM_INT_MASK); carry >>= BIGNUM_INT_BITS; if (ret[i] != 0 && i > maxspot) maxspot = i; @@ -1457,7 +1457,7 @@ Bignum bigadd(Bignum a, Bignum b) for (i = 1; i <= rlen; i++) { carry += (i <= (int)a[0] ? a[i] : 0); carry += (i <= (int)b[0] ? b[i] : 0); - ret[i] = (BignumInt) carry & BIGNUM_INT_MASK; + ret[i] = (BignumInt) (carry & BIGNUM_INT_MASK); carry >>= BIGNUM_INT_BITS; if (ret[i] != 0 && i > maxspot) maxspot = i; @@ -1487,7 +1487,7 @@ Bignum bigsub(Bignum a, Bignum b) for (i = 1; i <= rlen; i++) { carry += (i <= (int)a[0] ? a[i] : 0); carry += (i <= (int)b[0] ? b[i] ^ BIGNUM_INT_MASK : BIGNUM_INT_MASK); - ret[i] = (BignumInt) carry & BIGNUM_INT_MASK; + ret[i] = (BignumInt) (carry & BIGNUM_INT_MASK); carry >>= BIGNUM_INT_BITS; if (ret[i] != 0 && i > maxspot) maxspot = i; @@ -1556,7 +1556,7 @@ Bignum bignum_add_long(Bignum number, unsigned long addendx) carry += addend & BIGNUM_INT_MASK; carry += (i <= (int)number[0] ? number[i] : 0); addend >>= BIGNUM_INT_BITS; - ret[i] = (BignumInt) carry & BIGNUM_INT_MASK; + ret[i] = (BignumInt) (carry & BIGNUM_INT_MASK); carry >>= BIGNUM_INT_BITS; if (ret[i] != 0) maxspot = i; |