mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 01:02:24 +00:00
Add some missing invariants in bigdiv and bigmod.
The underlying function 'bigdivmod' does not ensure either of its outputs is normalised, so its callers must do so.
This commit is contained in:
parent
df87cb9dfc
commit
eac7e041f1
6
sshbn.c
6
sshbn.c
@ -1610,6 +1610,8 @@ Bignum bigdiv(Bignum a, Bignum b)
|
||||
{
|
||||
Bignum q = newbn(a[0]);
|
||||
bigdivmod(a, b, NULL, q);
|
||||
while (q[0] > 1 && q[q[0]] == 0)
|
||||
q[0]--;
|
||||
return q;
|
||||
}
|
||||
|
||||
@ -1620,6 +1622,8 @@ Bignum bigmod(Bignum a, Bignum b)
|
||||
{
|
||||
Bignum r = newbn(b[0]);
|
||||
bigdivmod(a, b, r, NULL);
|
||||
while (r[0] > 1 && r[r[0]] == 0)
|
||||
r[0]--;
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -1679,6 +1683,8 @@ Bignum modinv(Bignum number, Bignum modulus)
|
||||
bigdivmod(a, b, t, q);
|
||||
while (t[0] > 1 && t[t[0]] == 0)
|
||||
t[0]--;
|
||||
while (q[0] > 1 && q[q[0]] == 0)
|
||||
q[0]--;
|
||||
freebn(a);
|
||||
a = b;
|
||||
b = t;
|
||||
|
Loading…
Reference in New Issue
Block a user