mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-06-30 19:12:48 -05:00
Uppity: option to use a pregenerated key for RSA kex.
As and when I make this SSH server into a test suite, I'm not going to want to wait for a gratuitous RSA key generation in every test run. So now you can provide one in advance. It has to be in SSH-1 format, because that's the format for which I happen to already have internal API routines that return an RSAKey instead of an opaque ssh_key. But since you also have to store it without a passphrase, that doesn't really matter anyway.
This commit is contained in:
@ -579,6 +579,35 @@ int main(int argc, char **argv)
|
||||
key_type_to_str(keytype));
|
||||
exit(1);
|
||||
}
|
||||
} else if (longoptarg(arg, "--rsakexkey", &val, &argc, &argv)) {
|
||||
Filename *keyfile;
|
||||
int keytype;
|
||||
const char *error;
|
||||
|
||||
keyfile = filename_from_str(val);
|
||||
keytype = key_type(keyfile);
|
||||
|
||||
if (keytype != SSH_KEYTYPE_SSH1) {
|
||||
fprintf(stderr, "%s: '%s' is not loadable as an SSH-1 format "
|
||||
"private key (%s)", appname, val,
|
||||
key_type_to_str(keytype));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (ssc.rsa_kex_key) {
|
||||
freersakey(ssc.rsa_kex_key);
|
||||
} else {
|
||||
ssc.rsa_kex_key = snew(RSAKey);
|
||||
}
|
||||
|
||||
if (!rsa_ssh1_loadkey(keyfile, ssc.rsa_kex_key,
|
||||
NULL, &error)) {
|
||||
fprintf(stderr, "%s: unable to load RSA kex key '%s': "
|
||||
"%s\n", appname, val, error);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ssc.rsa_kex_key->sshk.vt = &ssh_rsa;
|
||||
} else if (longoptarg(arg, "--userkey", &val, &argc, &argv)) {
|
||||
Filename *keyfile;
|
||||
int keytype;
|
||||
|
Reference in New Issue
Block a user