mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-05 21:42:47 -05:00
New vtable API for keygen progress reporting.
The old API was one of those horrible things I used to do when I was young and foolish, in which you have just one function, and indicate which of lots of things it's doing by passing in flags. It was crying out to be replaced with a vtable. While I'm at it, I've reworked the code on the Windows side that decides what to do with the progress bar, so that it's based on actually justifiable estimates of probability rather than magic integer constants. Since computers are generally faster now than they were at the start of this project, I've also decided there's no longer any point in making the fixed final part of RSA key generation bother to report progress at all. So the progress bars are now only for the variable part, i.e. the actual prime generations.
This commit is contained in:
12
testcrypt.c
12
testcrypt.c
@ -1047,18 +1047,18 @@ strbuf *rsa1_save_sb_wrapper(RSAKey *key, const char *comment,
|
||||
|
||||
#define return_void(out, expression) (expression)
|
||||
|
||||
static void no_progress(void *param, int action, int phase, int iprogress) {}
|
||||
static ProgressReceiver null_progress = { .vt = &null_progress_vt };
|
||||
|
||||
mp_int *primegen_wrapper(PrimeCandidateSource *pcs)
|
||||
{
|
||||
return primegen(pcs, 0, no_progress, NULL);
|
||||
return primegen(pcs, &null_progress);
|
||||
}
|
||||
#define primegen primegen_wrapper
|
||||
|
||||
RSAKey *rsa1_generate(int bits)
|
||||
{
|
||||
RSAKey *rsakey = snew(RSAKey);
|
||||
rsa_generate(rsakey, bits, no_progress, NULL);
|
||||
rsa_generate(rsakey, bits, &null_progress);
|
||||
rsakey->comment = NULL;
|
||||
return rsakey;
|
||||
}
|
||||
@ -1072,7 +1072,7 @@ ssh_key *rsa_generate_wrapper(int bits)
|
||||
ssh_key *dsa_generate_wrapper(int bits)
|
||||
{
|
||||
struct dss_key *dsskey = snew(struct dss_key);
|
||||
dsa_generate(dsskey, bits, no_progress, NULL);
|
||||
dsa_generate(dsskey, bits, &null_progress);
|
||||
return &dsskey->sshk;
|
||||
}
|
||||
#define dsa_generate dsa_generate_wrapper
|
||||
@ -1080,7 +1080,7 @@ ssh_key *dsa_generate_wrapper(int bits)
|
||||
ssh_key *ecdsa_generate_wrapper(int bits)
|
||||
{
|
||||
struct ecdsa_key *ek = snew(struct ecdsa_key);
|
||||
if (!ecdsa_generate(ek, bits, no_progress, NULL)) {
|
||||
if (!ecdsa_generate(ek, bits)) {
|
||||
sfree(ek);
|
||||
return NULL;
|
||||
}
|
||||
@ -1091,7 +1091,7 @@ ssh_key *ecdsa_generate_wrapper(int bits)
|
||||
ssh_key *eddsa_generate_wrapper(int bits)
|
||||
{
|
||||
struct eddsa_key *ek = snew(struct eddsa_key);
|
||||
if (!eddsa_generate(ek, bits, no_progress, NULL)) {
|
||||
if (!eddsa_generate(ek, bits)) {
|
||||
sfree(ek);
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user