From 911ead25e72bc99afb855b698d7b03e41f2b9c39 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 13 Mar 2021 10:05:43 +0000 Subject: [PATCH] Windows Pageant: configurable fingerprint type. There's now a drop-down list box below the key list, from which you can select a fingerprint type. Also, like GUI PuTTYgen, I've widened the key list window to make room for wider SHA256 fingerprints. --- windows/pageant.rc | 14 ++++++++------ windows/winpgnt.c | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/windows/pageant.rc b/windows/pageant.rc index 2ffd395a..2469070c 100644 --- a/windows/pageant.rc +++ b/windows/pageant.rc @@ -24,17 +24,19 @@ BEGIN PUSHBUTTON "&Cancel", IDCANCEL, 80, 42, 40, 14 END -211 DIALOG DISCARDABLE 0, 0, 330, 200 +211 DIALOG DISCARDABLE 0, 0, 450, 211 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Pageant Key List" FONT 8, "MS Shell Dlg" BEGIN - LISTBOX 100, 10, 10, 310, 155, + LISTBOX 100, 10, 10, 420, 155, LBS_EXTENDEDSEL | LBS_HASSTRINGS | LBS_USETABSTOPS | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "&Add Key", 101, 75, 162, 60, 14 - PUSHBUTTON "&Remove Key", 102, 195, 162, 60, 14 - PUSHBUTTON "&Help", 103, 10, 182, 50, 14 - DEFPUSHBUTTON "&Close", IDOK, 270, 182, 50, 14 + PUSHBUTTON "&Add Key", 101, 75, 187, 60, 14 + PUSHBUTTON "&Remove Key", 102, 315, 187, 60, 14 + PUSHBUTTON "&Help", 103, 10, 187, 50, 14 + DEFPUSHBUTTON "&Close", IDOK, 390, 187, 50, 14 + LTEXT "&Fingerprint type:", 104, 10, 172, 60, 8 + COMBOBOX 105, 70, 170, 60, 12, CBS_DROPDOWNLIST END /* Accelerators used: cl */ diff --git a/windows/winpgnt.c b/windows/winpgnt.c index 96edc2e2..1f9d9e50 100644 --- a/windows/winpgnt.c +++ b/windows/winpgnt.c @@ -63,6 +63,7 @@ static HWND keylist; static HWND aboutbox; static HMENU systray_menu, session_menu; static bool already_running; +static FingerprintType fptype = SSH_FPTYPE_DEFAULT; static char *putty_path; static bool restrict_putty_acl = false; @@ -353,7 +354,7 @@ void keylist_update(void) * stop and leave out a tab character. Urgh. */ - p = ssh2_fingerprint(skey->key, SSH_FPTYPE_DEFAULT); + p = ssh2_fingerprint(skey->key, fptype); listentry = dupprintf("%s\t%s", p, skey->comment); sfree(p); @@ -512,6 +513,14 @@ static INT_PTR CALLBACK KeyListProc(HWND hwnd, UINT msg, RSAKey *rkey; ssh2_userkey *skey; + static const struct { + const char *name; + FingerprintType value; + } fptypes[] = { + {"SHA256", SSH_FPTYPE_SHA256}, + {"MD5", SSH_FPTYPE_MD5}, + }; + switch (msg) { case WM_INITDIALOG: { /* @@ -539,11 +548,21 @@ static INT_PTR CALLBACK KeyListProc(HWND hwnd, UINT msg, keylist = hwnd; { - static int tabs[] = { 35, 75, 250 }; + static int tabs[] = { 35, 75, 300 }; SendDlgItemMessage(hwnd, 100, LB_SETTABSTOPS, sizeof(tabs) / sizeof(*tabs), (LPARAM) tabs); } + + int selection = 0; + for (size_t i = 0; i < lenof(fptypes); i++) { + SendDlgItemMessage(hwnd, 105, CB_ADDSTRING, + 0, (LPARAM)fptypes[i].name); + if (fptype == fptypes[i].value) + selection = (int)i; + } + SendDlgItemMessage(hwnd, 105, CB_SETCURSEL, 0, selection); + keylist_update(); return 0; } @@ -632,6 +651,16 @@ static INT_PTR CALLBACK KeyListProc(HWND hwnd, UINT msg, launch_help(hwnd, WINHELP_CTX_pageant_general); } return 0; + case 105: /* fingerprint type */ + if (HIWORD(wParam) == CBN_SELCHANGE) { + int selection = SendDlgItemMessage( + hwnd, 105, CB_GETCURSEL, 0, 0); + if (selection >= 0 && (size_t)selection < lenof(fptypes)) { + fptype = fptypes[selection].value; + keylist_update(); + } + } + return 0; } return 0; case WM_HELP: {