X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/9a30e26b7801d63e4ccfe8d36169299c09b89dff..7440fd4419acfc9c784f142fb9dee3e64c9a18c2:/puttygen.c diff --git a/puttygen.c b/puttygen.c index 42af3976..ffe4317d 100644 --- a/puttygen.c +++ b/puttygen.c @@ -2,8 +2,6 @@ * PuTTY key generation front end. */ -#include -#include #include #include #include @@ -12,7 +10,12 @@ #include "putty.h" #include "ssh.h" -#include "winstuff.h" + +#include + +#ifdef MSVC4 +#define ICON_BIG 1 +#endif #define WM_DONEKEY (WM_XUSER + 1) @@ -293,7 +296,7 @@ static int CALLBACK AboutProc(HWND hwnd, UINT msg, return 0; case 101: EnableWindow(hwnd, 0); - DialogBox(hinst, MAKEINTRESOURCE(214), NULL, LicenceProc); + DialogBox(hinst, MAKEINTRESOURCE(214), hwnd, LicenceProc); EnableWindow(hwnd, 1); SetActiveWindow(hwnd); return 0; @@ -385,8 +388,8 @@ static void setupbigedit2(HWND hwnd, int id, int idstatic, int i; pub_blob = key->alg->public_blob(key->data, &pub_len); - buffer = smalloc(strlen(key->alg->name) + 4 * ((pub_len + 2) / 3) + - strlen(key->comment) + 3); + buffer = snewn(strlen(key->alg->name) + 4 * ((pub_len + 2) / 3) + + strlen(key->comment) + 3, char); strcpy(buffer, key->alg->name); p = buffer + strlen(buffer); *p++ = ' '; @@ -677,14 +680,14 @@ void load_key_file(HWND hwnd, struct MainDlgState *state, if (type == SSH_KEYTYPE_SSH1) { if (realtype == type) ret = loadrsakey(&filename, &newkey1, - passphrase); + passphrase, NULL); else ret = import_ssh1(&filename, realtype, &newkey1, passphrase); } else { if (realtype == type) newkey2 = ssh2_load_userkey(&filename, - passphrase); + passphrase, NULL); else newkey2 = import_ssh2(&filename, realtype, passphrase); @@ -813,8 +816,10 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, */ } requested_help = FALSE; + SendMessage(hwnd, WM_SETICON, (WPARAM) ICON_BIG, + (LPARAM) LoadIcon(hinst, MAKEINTRESOURCE(200))); - state = smalloc(sizeof(*state)); + state = snew(struct MainDlgState); state->generation_thread_exists = FALSE; state->collecting_entropy = FALSE; state->entropy = NULL; @@ -851,7 +856,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, AppendMenu(menu1, MF_ENABLED, IDC_EXPORT_SSHCOM, "Export &ssh.com key"); AppendMenu(menu, MF_POPUP | MF_ENABLED, (UINT) menu1, - "&Conversions"); + "Con&versions"); state->cvtmenu = menu1; menu1 = CreateMenu(); @@ -894,7 +899,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, "&Public key for pasting into authorized_keys file:", IDC_PKSTATIC, IDC_KEYDISPLAY, 5); SendDlgItemMessage(hwnd, IDC_KEYDISPLAY, EM_SETREADONLY, 1, 0); - staticedit(&cp, "Key fingerprint:", IDC_FPSTATIC, + staticedit(&cp, "Key f&ingerprint:", IDC_FPSTATIC, IDC_FINGERPRINT, 75); SendDlgItemMessage(hwnd, IDC_FINGERPRINT, EM_SETREADONLY, 1, 0); @@ -968,7 +973,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, MAKELPARAM(0, PROGRESSRANGE)); SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETPOS, 0, 0); - params = smalloc(sizeof(*params)); + params = snew(struct rsa_key_thread_params); params->progressbar = GetDlgItem(hwnd, IDC_PROGRESS); params->dialog = hwnd; params->keysize = state->keysize; @@ -1015,7 +1020,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, int len = GetWindowTextLength(editctl); if (*state->commentptr) sfree(*state->commentptr); - *state->commentptr = smalloc(len + 1); + *state->commentptr = snewn(len + 1, char); GetWindowText(editctl, *state->commentptr, len + 1); if (state->ssh2) { setupbigedit2(hwnd, IDC_KEYDISPLAY, IDC_PKSTATIC, @@ -1029,7 +1034,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, break; case IDC_ABOUT: EnableWindow(hwnd, 0); - DialogBox(hinst, MAKEINTRESOURCE(213), NULL, AboutProc); + DialogBox(hinst, MAKEINTRESOURCE(213), hwnd, AboutProc); EnableWindow(hwnd, 1); SetActiveWindow(hwnd); return 0; @@ -1044,6 +1049,9 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, } return 0; case IDC_GENERATE: + if (HIWORD(wParam) != BN_CLICKED && + HIWORD(wParam) != BN_DOUBLECLICKED) + break; state = (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA); if (!state->generation_thread_exists) { @@ -1087,8 +1095,8 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, state->entropy_required = (state->keysize / 2) * 2; state->entropy_got = 0; state->entropy_size = (state->entropy_required * - sizeof(*state->entropy)); - state->entropy = smalloc(state->entropy_size); + sizeof(unsigned)); + state->entropy = snewn(state->entropy_required, unsigned); SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETRANGE, 0, MAKELPARAM(0, state->entropy_required)); @@ -1098,6 +1106,8 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, case IDC_SAVE: case IDC_EXPORT_OPENSSH: case IDC_EXPORT_SSHCOM: + if (HIWORD(wParam) != BN_CLICKED) + break; state = (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA); if (state->key_exists) { @@ -1191,6 +1201,8 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, } break; case IDC_SAVEPUB: + if (HIWORD(wParam) != BN_CLICKED) + break; state = (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA); if (state->key_exists) { @@ -1224,6 +1236,8 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, break; case IDC_LOAD: case IDC_IMPORT: + if (HIWORD(wParam) != BN_CLICKED) + break; state = (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA); if (!state->generation_thread_exists) { @@ -1261,7 +1275,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, * the user will immediately want to change it, which is * what we want :-) */ - *state->commentptr = smalloc(30); + *state->commentptr = snewn(30, char); { time_t t; struct tm *tm;