#define DEFAULT_KEYSIZE 1024
-static int requested_help;
-
static char *cmdline_keyfile = NULL;
/*
{
OPENFILENAME of;
memset(&of, 0, sizeof(of));
-#ifdef OPENFILENAME_SIZE_VERSION_400
- of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
-#else
- of.lStructSize = sizeof(of);
-#endif
of.hwndOwner = hwnd;
if (ppk) {
of.lpstrFilter = "PuTTY Private Key Files (*.ppk)\0*.ppk\0"
*filename = '\0';
of.nMaxFile = FILENAME_MAX;
of.lpstrFileTitle = NULL;
- of.lpstrInitialDir = NULL;
of.lpstrTitle = dlgtitle;
of.Flags = 0;
- if (save)
- return GetSaveFileName(&of);
- else
- return GetOpenFileName(&of);
+ return request_file(NULL, &of, FALSE, save);
}
/*
{
static const char mbtitle[] = "PuTTY Key File Warning";
static const char message[] =
- "You are loading an SSH 2 private key which has an\n"
+ "You are loading an SSH-2 private key which has an\n"
"old version of the file format. This means your key\n"
"file is not fully tamperproof. Future versions of\n"
"PuTTY may stop supporting this private key format,\n"
int needs_pass;
int type, realtype;
int ret;
+ const char *errmsg = NULL;
char *comment;
struct PassphraseProcStruct pps;
struct RSAKey newkey1;
if (type != SSH_KEYTYPE_SSH1 &&
type != SSH_KEYTYPE_SSH2 &&
!import_possible(type)) {
- char msg[256];
- sprintf(msg, "Couldn't load private key (%s)",
- key_type_to_str(type));
- MessageBox(NULL, msg,
- "PuTTYgen Error", MB_OK | MB_ICONERROR);
+ char *msg = dupprintf("Couldn't load private key (%s)",
+ key_type_to_str(type));
+ message_box(msg, "PuTTYgen Error", MB_OK | MB_ICONERROR,
+ HELPCTXID(errors_cantloadkey));
+ sfree(msg);
return;
}
dlgret = DialogBoxParam(hinst,
MAKEINTRESOURCE(210),
NULL, PassphraseProc,
- (LPARAM) & pps);
+ (LPARAM) &pps);
if (!dlgret) {
ret = -2;
break;
if (type == SSH_KEYTYPE_SSH1) {
if (realtype == type)
ret = loadrsakey(&filename, &newkey1,
- passphrase, NULL);
+ passphrase, &errmsg);
else
ret = import_ssh1(&filename, realtype,
- &newkey1, passphrase);
+ &newkey1, passphrase, &errmsg);
} else {
if (realtype == type)
newkey2 = ssh2_load_userkey(&filename,
- passphrase, NULL);
+ passphrase, &errmsg);
else
newkey2 = import_ssh2(&filename, realtype,
- passphrase);
+ passphrase, &errmsg);
if (newkey2 == SSH2_WRONG_PASSPHRASE)
ret = -1;
else if (!newkey2)
if (comment)
sfree(comment);
if (ret == 0) {
- MessageBox(NULL, "Couldn't load private key.",
- "PuTTYgen Error", MB_OK | MB_ICONERROR);
+ char *msg = dupprintf("Couldn't load private key (%s)", errmsg);
+ message_box(msg, "PuTTYgen Error", MB_OK | MB_ICONERROR,
+ HELPCTXID(errors_cantloadkey));
+ sfree(msg);
} else if (ret == 1) {
/*
* Now update the key controls with all the
menu1 = CreateMenu();
AppendMenu(menu1, MF_ENABLED, IDC_GENERATE, "&Generate key pair");
AppendMenu(menu1, MF_SEPARATOR, 0, 0);
- AppendMenu(menu1, MF_ENABLED, IDC_KEYSSH1, "SSH&1 key (RSA)");
- AppendMenu(menu1, MF_ENABLED, IDC_KEYSSH2RSA, "SSH2 &RSA key");
- AppendMenu(menu1, MF_ENABLED, IDC_KEYSSH2DSA, "SSH2 &DSA key");
+ AppendMenu(menu1, MF_ENABLED, IDC_KEYSSH1, "SSH-&1 key (RSA)");
+ AppendMenu(menu1, MF_ENABLED, IDC_KEYSSH2RSA, "SSH-2 &RSA key");
+ AppendMenu(menu1, MF_ENABLED, IDC_KEYSSH2DSA, "SSH-2 &DSA key");
AppendMenu(menu, MF_POPUP | MF_ENABLED, (UINT) menu1, "&Key");
state->keymenu = menu1;
endbox(&cp);
beginbox(&cp, "Parameters", IDC_BOX_PARAMS);
radioline(&cp, "Type of key to generate:", IDC_TYPESTATIC, 3,
- "SSH&1 (RSA)", IDC_KEYSSH1,
- "SSH2 &RSA", IDC_KEYSSH2RSA,
- "SSH2 &DSA", IDC_KEYSSH2DSA, NULL);
+ "SSH-&1 (RSA)", IDC_KEYSSH1,
+ "SSH-2 &RSA", IDC_KEYSSH2RSA,
+ "SSH-2 &DSA", IDC_KEYSSH2DSA, NULL);
staticedit(&cp, "Number of &bits in a generated key:",
IDC_BITSSTATIC, IDC_BITS, 20);
endbox(&cp);
if (type != realtype &&
import_target_type(type) != realtype) {
char msg[256];
- sprintf(msg, "Cannot export an SSH%d key in an SSH%d"
+ sprintf(msg, "Cannot export an SSH-%d key in an SSH-%d"
" format", (state->ssh2 ? 2 : 1),
(state->ssh2 ? 1 : 2));
MessageBox(hwnd, msg,
InitCommonControls();
hinst = inst;
+ hwnd = NULL;
/*
* See if we can find our Help file.