1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-02 20:12:48 -05:00

Remove the last lingering knowledge, outside sshbn.c, of the

internal structure of the Bignum type. Bignum is now a fully opaque
type unless you're inside sshbn.c.

[originally from svn r960]
This commit is contained in:
Simon Tatham
2001-03-01 17:41:26 +00:00
parent 7717c386a1
commit f72b5aa95f
7 changed files with 160 additions and 165 deletions

View File

@ -674,7 +674,7 @@ Bignum primegen(int bits, int modulus, int residue,
/*
* Generate a k-bit random number with top and bottom bits set.
*/
p = newbn((bits+15)/16);
p = bn_power_2(bits-1);
for (i = 0; i < bits; i++) {
if (i == 0 || i == bits-1)
v = 1;
@ -754,7 +754,7 @@ Bignum primegen(int bits, int modulus, int residue,
* Invent a random number between 1 and p-1 inclusive.
*/
while (1) {
w = newbn((bits+15)/16);
w = bn_power_2(bits-1);
for (i = 0; i < bits; i++) {
if (bitsleft <= 0)
bitsleft = 8; byte = random_byte();
@ -763,6 +763,7 @@ Bignum primegen(int bits, int modulus, int residue,
bitsleft--;
bignum_set_bit(w, i, v);
}
bn_restore_invariant(w);
if (bignum_cmp(w, p) >= 0 || bignum_cmp(w, Zero) == 0) {
freebn(w);
continue;