1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 11:32:48 -05:00

Give rsa_fingerprint() a new name and API.

It's an SSH-1 specific function, so it should have a name reflecting
that, and it didn't. Also it had one of those outdated APIs involving
passing it a client-allocated buffer and size. Now it has a sensible
name, and internally it constructs the output string using a strbuf
and returns it dynamically allocated.
This commit is contained in:
Simon Tatham
2018-06-03 08:08:53 +01:00
parent 3f1f7c3ce7
commit ae3863679d
7 changed files with 46 additions and 54 deletions

View File

@ -734,8 +734,7 @@ void load_key_file(HWND hwnd, struct MainDlgState *state,
SetDlgItemText(hwnd, IDC_PASSPHRASE2EDIT,
passphrase);
if (type == SSH_KEYTYPE_SSH1) {
char buf[128];
char *savecomment;
char *fingerprint, *savecomment;
state->ssh2 = FALSE;
state->commentptr = &state->key.comment;
@ -746,11 +745,11 @@ void load_key_file(HWND hwnd, struct MainDlgState *state,
*/
savecomment = state->key.comment;
state->key.comment = NULL;
rsa_fingerprint(buf, sizeof(buf),
&state->key);
fingerprint = rsa_ssh1_fingerprint(&state->key);
state->key.comment = savecomment;
SetDlgItemText(hwnd, IDC_FINGERPRINT, fingerprint);
sfree(fingerprint);
SetDlgItemText(hwnd, IDC_FINGERPRINT, buf);
/*
* Construct a decimal representation
* of the key, for pasting into
@ -1406,7 +1405,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg,
* Now update the key controls with all the key data.
*/
{
char *savecomment;
char *fp, *savecomment;
/*
* Blank passphrase, initially. This isn't dangerous,
* because we will warn (Are You Sure?) before allowing
@ -1423,16 +1422,12 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg,
*/
savecomment = *state->commentptr;
*state->commentptr = NULL;
if (state->ssh2) {
char *fp;
if (state->ssh2)
fp = ssh2_fingerprint(state->ssh2key.alg, state->ssh2key.data);
SetDlgItemText(hwnd, IDC_FINGERPRINT, fp);
sfree(fp);
} else {
char buf[128];
rsa_fingerprint(buf, sizeof(buf), &state->key);
SetDlgItemText(hwnd, IDC_FINGERPRINT, buf);
}
else
fp = rsa_ssh1_fingerprint(&state->key);
SetDlgItemText(hwnd, IDC_FINGERPRINT, fp);
sfree(fp);
*state->commentptr = savecomment;
/*
* Construct a decimal representation of the key, for

View File

@ -290,14 +290,16 @@ void keylist_update(void)
if (keylist) {
SendDlgItemMessage(keylist, 100, LB_RESETCONTENT, 0, 0);
for (i = 0; NULL != (rkey = pageant_nth_ssh1_key(i)); i++) {
char listentry[512], *p;
char *listentry, *fp, *p;
fp = rsa_ssh1_fingerprint(rkey);
listentry = dupprintf("ssh1\t%s", fp);
sfree(fp);
/*
* Replace two spaces in the fingerprint with tabs, for
* nice alignment in the box.
*/
strcpy(listentry, "ssh1\t");
p = listentry + strlen(listentry);
rsa_fingerprint(p, sizeof(listentry) - (p - listentry), rkey);
p = strchr(listentry, ' ');
if (p)
*p = '\t';
@ -306,6 +308,7 @@ void keylist_update(void)
*p = '\t';
SendDlgItemMessage(keylist, 100, LB_ADDSTRING,
0, (LPARAM) listentry);
sfree(listentry);
}
for (i = 0; NULL != (skey = pageant_nth_ssh2_key(i)); i++) {
char *listentry, *p;