1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-06-30 19:12:48 -05:00

Windows Pageant: use nicer key-type strings.

If you load a certified key into Windows Pageant, the official SSH id
for the key type is so long that it overflows its space in the list
box and overlaps the key fingerprint hash.

This commit introduces yet another footling little ssh_keyalg method
which returns a shorter human-readable description of the key type,
and uses that in the Windows Pageant list box only.

(Not in the Unix Pageant list, though, because being output to stdout,
that seems like something people are more likely to want to
machine-read, which firstly means we shouldn't change it lightly, and
secondly, if we did change it we'd want to avoid having a variable
number of spaces in the replacement key type text.)
This commit is contained in:
Simon Tatham
2022-08-02 17:54:47 +01:00
parent 3e7274fdad
commit fea08bb244
6 changed files with 55 additions and 9 deletions

View File

@ -346,7 +346,7 @@ static void keylist_update_callback(
* Expect the fingerprint to contain two words: bit count and
* hash.
*/
put_dataz(disp->alg, "ssh1");
put_dataz(disp->alg, "SSH-1");
put_datapl(disp->bits, ptrlen_get_word(&fingerprint, " "));
put_datapl(disp->hash, ptrlen_get_word(&fingerprint, " "));
break;
@ -357,7 +357,21 @@ static void keylist_update_callback(
* Expect the fingerprint to contain three words: algorithm
* name, bit count, hash.
*/
put_datapl(disp->alg, ptrlen_get_word(&fingerprint, " "));
const ssh_keyalg *alg = pubkey_blob_to_alg(
ptrlen_from_strbuf(key->blob));
ptrlen keytype_word = ptrlen_get_word(&fingerprint, " ");
if (alg) {
/* Use our own human-legible algorithm names if available,
* because they fit better in the space. (Certificate key
* algorithm names in particular are terribly long.) */
char *alg_desc = ssh_keyalg_desc(alg);
put_dataz(disp->alg, alg_desc);
sfree(alg_desc);
} else {
put_datapl(disp->alg, keytype_word);
}
put_datapl(disp->bits, ptrlen_get_word(&fingerprint, " "));
put_datapl(disp->hash, ptrlen_get_word(&fingerprint, " "));
@ -368,8 +382,6 @@ static void keylist_update_callback(
* overlap into the bits column without colliding with
* pointless text.
*/
const ssh_keyalg *alg = pubkey_blob_to_alg(
ptrlen_from_strbuf(key->blob));
if (!(alg == &ssh_dsa || alg == &ssh_rsa))
strbuf_clear(disp->bits);
}