#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,
*/
*state->commentptr = snewn(30, char);
{
- time_t t;
- struct tm *tm;
- time(&t);
- tm = localtime(&t);
+ struct tm tm;
+ tm = ltime();
if (state->is_dsa)
- strftime(*state->commentptr, 30, "dsa-key-%Y%m%d", tm);
+ strftime(*state->commentptr, 30, "dsa-key-%Y%m%d", &tm);
else
- strftime(*state->commentptr, 30, "rsa-key-%Y%m%d", tm);
+ strftime(*state->commentptr, 30, "rsa-key-%Y%m%d", &tm);
}
/*
case WM_HELP:
if (help_path) {
int id = ((LPHELPINFO)lParam)->iCtrlId;
- char *cmd = NULL;
+ char *topic = NULL;
switch (id) {
case IDC_GENERATING:
case IDC_PROGRESS:
case IDC_GENSTATIC:
case IDC_GENERATE:
- cmd = "JI(`',`puttygen.generate')"; break;
+ topic = "puttygen.generate"; break;
case IDC_PKSTATIC:
case IDC_KEYDISPLAY:
- cmd = "JI(`',`puttygen.pastekey')"; break;
+ topic = "puttygen.pastekey"; break;
case IDC_FPSTATIC:
case IDC_FINGERPRINT:
- cmd = "JI(`',`puttygen.fingerprint')"; break;
+ topic = "puttygen.fingerprint"; break;
case IDC_COMMENTSTATIC:
case IDC_COMMENTEDIT:
- cmd = "JI(`',`puttygen.comment')"; break;
+ topic = "puttygen.comment"; break;
case IDC_PASSPHRASE1STATIC:
case IDC_PASSPHRASE1EDIT:
case IDC_PASSPHRASE2STATIC:
case IDC_PASSPHRASE2EDIT:
- cmd = "JI(`',`puttygen.passphrase')"; break;
+ topic = "puttygen.passphrase"; break;
case IDC_LOADSTATIC:
case IDC_LOAD:
- cmd = "JI(`',`puttygen.load')"; break;
+ topic = "puttygen.load"; break;
case IDC_SAVESTATIC:
case IDC_SAVE:
- cmd = "JI(`',`puttygen.savepriv')"; break;
+ topic = "puttygen.savepriv"; break;
case IDC_SAVEPUB:
- cmd = "JI(`',`puttygen.savepub')"; break;
+ topic = "puttygen.savepub"; break;
case IDC_TYPESTATIC:
case IDC_KEYSSH1:
case IDC_KEYSSH2RSA:
case IDC_KEYSSH2DSA:
- cmd = "JI(`',`puttygen.keytype')"; break;
+ topic = "puttygen.keytype"; break;
case IDC_BITSSTATIC:
case IDC_BITS:
- cmd = "JI(`',`puttygen.bits')"; break;
+ topic = "puttygen.bits"; break;
case IDC_IMPORT:
case IDC_EXPORT_OPENSSH:
case IDC_EXPORT_SSHCOM:
- cmd = "JI(`',`puttygen.conversions')"; break;
+ topic = "puttygen.conversions"; break;
}
- if (cmd) {
+ if (topic) {
+ char *cmd = dupprintf("JI(`',`%s')", topic);
WinHelp(hwnd, help_path, HELP_COMMAND, (DWORD)cmd);
+ sfree(cmd);
requested_help = TRUE;
} else {
MessageBeep(0);
int argc;
char **argv;
- split_into_argv(cmdline, &argc, &argv, NULL);
-
- if (argc > 0) {
- /*
- * Assume the first argument to be a private key file, and
- * attempt to load it.
- */
- cmdline_keyfile = argv[0];
- }
-
InitCommonControls();
hinst = inst;
+ hwnd = NULL;
/*
* See if we can find our Help file.
if (p && p >= r) r = p+1;
q = strrchr(b, ':');
if (q && q >= r) r = q+1;
- strcpy(r, "putty.hlp");
+ strcpy(r, PUTTY_HELP_FILE);
if ( (fp = fopen(b, "r")) != NULL) {
help_path = dupstr(b);
fclose(fp);
help_path = NULL;
}
- random_init();
+ split_into_argv(cmdline, &argc, &argv, NULL);
+
+ if (argc > 0) {
+ if (!strcmp(argv[0], "-pgpfp")) {
+ pgp_fingerprints();
+ exit(1);
+ } else {
+ /*
+ * Assume the first argument to be a private key file, and
+ * attempt to load it.
+ */
+ cmdline_keyfile = argv[0];
+ }
+ }
+
+ random_ref();
return DialogBox(hinst, MAKEINTRESOURCE(201), NULL,
MainDlgProc) != IDOK;
}