mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-07 06:22:47 -05:00
Expose key generation functions in testcrypt.
They're not much use for 'real' key generation, since like all the other randomness-using testcrypt functions, they need you to have explicitly queued up some random data. But for generating keys for test purposes, they have the great virtue that they deliver the key in the internal format, where we can generate all the various public and private blobs from it as well as the on-disk formats. A minor change to one of the keygen functions itself: rsa_generate now fills in the 'bits' and 'bytes' fields of the returned RSAKey, without which it didn't actually work to try to generate a public blob from it. (We'd never noticed before, because no previous client of rsa_generate even tried that.)
This commit is contained in:
44
testcrypt.c
44
testcrypt.c
@ -920,6 +920,50 @@ mp_int *primegen_wrapper(
|
||||
}
|
||||
#define primegen primegen_wrapper
|
||||
|
||||
RSAKey *rsa1_generate(int bits)
|
||||
{
|
||||
RSAKey *rsakey = snew(RSAKey);
|
||||
rsa_generate(rsakey, bits, no_progress, NULL);
|
||||
rsakey->comment = NULL;
|
||||
return rsakey;
|
||||
}
|
||||
|
||||
ssh_key *rsa_generate_wrapper(int bits)
|
||||
{
|
||||
return &rsa1_generate(bits)->sshk;
|
||||
}
|
||||
#define rsa_generate rsa_generate_wrapper
|
||||
|
||||
ssh_key *dsa_generate_wrapper(int bits)
|
||||
{
|
||||
struct dss_key *dsskey = snew(struct dss_key);
|
||||
dsa_generate(dsskey, bits, no_progress, NULL);
|
||||
return &dsskey->sshk;
|
||||
}
|
||||
#define dsa_generate dsa_generate_wrapper
|
||||
|
||||
ssh_key *ecdsa_generate_wrapper(int bits)
|
||||
{
|
||||
struct ecdsa_key *ek = snew(struct ecdsa_key);
|
||||
if (!ecdsa_generate(ek, bits, no_progress, NULL)) {
|
||||
sfree(ek);
|
||||
return NULL;
|
||||
}
|
||||
return &ek->sshk;
|
||||
}
|
||||
#define ecdsa_generate ecdsa_generate_wrapper
|
||||
|
||||
ssh_key *eddsa_generate_wrapper(int bits)
|
||||
{
|
||||
struct eddsa_key *ek = snew(struct eddsa_key);
|
||||
if (!eddsa_generate(ek, bits, no_progress, NULL)) {
|
||||
sfree(ek);
|
||||
return NULL;
|
||||
}
|
||||
return &ek->sshk;
|
||||
}
|
||||
#define eddsa_generate eddsa_generate_wrapper
|
||||
|
||||
#define VALTYPE_TYPEDEF(n,t,f) \
|
||||
typedef t TD_val_##n; \
|
||||
typedef t *TD_out_val_##n;
|
||||
|
Reference in New Issue
Block a user