mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
Give a better error message if a PuTTY private key file has a version
number we don't understand. It's nicer to report 'format too new' than 'not a PuTTY key file'. [originally from svn r9763]
This commit is contained in:
parent
8f3cc4a9bf
commit
40ce043a97
2
cmdgen.c
2
cmdgen.c
@ -779,11 +779,13 @@ int main(int argc, char **argv)
|
|||||||
if (!load_encrypted) {
|
if (!load_encrypted) {
|
||||||
ssh2blob = ssh2_userkey_loadpub(infilename, &ssh2alg,
|
ssh2blob = ssh2_userkey_loadpub(infilename, &ssh2alg,
|
||||||
&ssh2bloblen, NULL, &error);
|
&ssh2bloblen, NULL, &error);
|
||||||
|
if (ssh2blob) {
|
||||||
ssh2algf = find_pubkey_alg(ssh2alg);
|
ssh2algf = find_pubkey_alg(ssh2alg);
|
||||||
if (ssh2algf)
|
if (ssh2algf)
|
||||||
bits = ssh2algf->pubkey_bits(ssh2blob, ssh2bloblen);
|
bits = ssh2algf->pubkey_bits(ssh2blob, ssh2bloblen);
|
||||||
else
|
else
|
||||||
bits = -1;
|
bits = -1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ssh2key = ssh2_load_userkey(infilename, passphrase, &error);
|
ssh2key = ssh2_load_userkey(infilename, passphrase, &error);
|
||||||
}
|
}
|
||||||
|
@ -647,6 +647,11 @@ struct ssh2_userkey *ssh2_load_userkey(const Filename *filename,
|
|||||||
/* this is an old key file; warn and then continue */
|
/* this is an old key file; warn and then continue */
|
||||||
old_keyfile_warning();
|
old_keyfile_warning();
|
||||||
old_fmt = 1;
|
old_fmt = 1;
|
||||||
|
} else if (0 == strncmp(header, "PuTTY-User-Key-File-", 20)) {
|
||||||
|
/* this is a key file FROM THE FUTURE; refuse it, but with a
|
||||||
|
* more specific error message than the generic one below */
|
||||||
|
error = "PuTTY key format too new";
|
||||||
|
goto error;
|
||||||
} else {
|
} else {
|
||||||
error = "not a PuTTY SSH-2 private key";
|
error = "not a PuTTY SSH-2 private key";
|
||||||
goto error;
|
goto error;
|
||||||
@ -891,6 +896,9 @@ unsigned char *ssh2_userkey_loadpub(const Filename *filename, char **algorithm,
|
|||||||
if (!read_header(fp, header)
|
if (!read_header(fp, header)
|
||||||
|| (0 != strcmp(header, "PuTTY-User-Key-File-2") &&
|
|| (0 != strcmp(header, "PuTTY-User-Key-File-2") &&
|
||||||
0 != strcmp(header, "PuTTY-User-Key-File-1"))) {
|
0 != strcmp(header, "PuTTY-User-Key-File-1"))) {
|
||||||
|
if (0 == strncmp(header, "PuTTY-User-Key-File-", 20))
|
||||||
|
error = "PuTTY key format too new";
|
||||||
|
else
|
||||||
error = "not a PuTTY SSH-2 private key";
|
error = "not a PuTTY SSH-2 private key";
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user