mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 01:02:24 +00:00
Fix error messages in ppk_loadpub_s.
The function will accept a public key file or a PPK, but if it fails to parse as any of those, the error message says "not a PuTTY SSH-2 private key", which is particularly incongruous in situations where you're specifically _not_ after the private half of the key. Now says "not a public key or a PuTTY SSH-2 private key".
This commit is contained in:
parent
a5c0205b87
commit
ffa25be185
@ -1237,7 +1237,7 @@ bool ppk_loadpub_s(BinarySource *src, char **algorithm, BinarySink *bs,
|
|||||||
bool ret = openssh_loadpub(src, algorithm, bs, commentptr, errorstr);
|
bool ret = openssh_loadpub(src, algorithm, bs, commentptr, errorstr);
|
||||||
return ret;
|
return ret;
|
||||||
} else if (type != SSH_KEYTYPE_SSH2) {
|
} else if (type != SSH_KEYTYPE_SSH2) {
|
||||||
error = "not a PuTTY SSH-2 private key";
|
error = "not a public key or a PuTTY SSH-2 private key";
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1249,7 +1249,7 @@ bool ppk_loadpub_s(BinarySource *src, char **algorithm, BinarySink *bs,
|
|||||||
if (0 == strncmp(header, "PuTTY-User-Key-File-", 20))
|
if (0 == strncmp(header, "PuTTY-User-Key-File-", 20))
|
||||||
error = "PuTTY key format too new";
|
error = "PuTTY key format too new";
|
||||||
else
|
else
|
||||||
error = "not a PuTTY SSH-2 private key";
|
error = "not a public key or a PuTTY SSH-2 private key";
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
error = "file format error";
|
error = "file format error";
|
||||||
|
@ -2418,7 +2418,7 @@ Private-MAC: 6f5e588e475e55434106ec2c3569695b03f423228b44993a9e97d52ffe7be5a8
|
|||||||
(True, algorithm, public_blob, comment, None))
|
(True, algorithm, public_blob, comment, None))
|
||||||
self.assertEqual(ppk_loadpub_s("not a key file"),
|
self.assertEqual(ppk_loadpub_s("not a key file"),
|
||||||
(False, None, b'', None,
|
(False, None, b'', None,
|
||||||
b'not a PuTTY SSH-2 private key'))
|
b'not a public key or a PuTTY SSH-2 private key'))
|
||||||
|
|
||||||
k1, c, e = ppk_load_s(input_clear_key, None)
|
k1, c, e = ppk_load_s(input_clear_key, None)
|
||||||
self.assertEqual((c, e), (comment, None))
|
self.assertEqual((c, e), (comment, None))
|
||||||
@ -2480,7 +2480,7 @@ Private-MAC: 5b1f6f4cc43eb0060d2c3e181bc0129343adba2b
|
|||||||
(True, algorithm, public_blob, comment, None))
|
(True, algorithm, public_blob, comment, None))
|
||||||
self.assertEqual(ppk_loadpub_s("not a key file"),
|
self.assertEqual(ppk_loadpub_s("not a key file"),
|
||||||
(False, None, b'', None,
|
(False, None, b'', None,
|
||||||
b'not a PuTTY SSH-2 private key'))
|
b'not a public key or a PuTTY SSH-2 private key'))
|
||||||
|
|
||||||
k1, c, e = ppk_load_s(v2_clear_key, None)
|
k1, c, e = ppk_load_s(v2_clear_key, None)
|
||||||
self.assertEqual((c, e), (comment, None))
|
self.assertEqual((c, e), (comment, None))
|
||||||
|
Loading…
Reference in New Issue
Block a user