- state = (struct MainDlgState *)GetWindowLong(hwnd, GWL_USERDATA);
- state->generation_thread_exists = FALSE;
- state->key_exists = TRUE;
- SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETPOS, PROGRESSRANGE, 0);
- EnableWindow(GetDlgItem(hwnd, IDC_GENERATE), 1);
- EnableWindow(GetDlgItem(hwnd, IDC_LOAD), 1);
- EnableWindow(GetDlgItem(hwnd, IDC_SAVE), 1);
- /*
- * Invent a comment for the key. We'll do this by including
- * the date in it. This will be so horrifyingly ugly that
- * the user will immediately want to change it, which is
- * what we want :-)
- */
- state->key.comment = malloc(30);
- {
- time_t t;
- struct tm *tm;
- time(&t);
- tm = localtime(&t);
- strftime(state->key.comment, 30, "rsa-key-%Y%m%d", tm);
- }
-
- /*
- * Now update the key controls with all the key data.
- */
- {
- char buf[128];
- /*
- * Blank passphrase, initially. This isn't dangerous,
- * because we will warn (Are You Sure?) before allowing
- * the user to save an unprotected private key.
- */
- SetDlgItemText(hwnd, IDC_PASSPHRASE1EDIT, "");
- SetDlgItemText(hwnd, IDC_PASSPHRASE2EDIT, "");
- /*
- * Set the comment.
- */
- SetDlgItemText(hwnd, IDC_COMMENTEDIT, state->key.comment);
- /*
- * Set the key fingerprint.
- */
- {
- char *savecomment = state->key.comment;
- state->key.comment = NULL;
- rsa_fingerprint(buf, sizeof(buf), &state->key);
- state->key.comment = savecomment;
- }
- SetDlgItemText(hwnd, IDC_FINGERPRINT, buf);
- /*
- * Construct a decimal representation of the key, for
- * pasting into .ssh/authorized_keys on a Unix box.
- */
- setupbigedit(hwnd, IDC_KEYDISPLAY, &state->key);
- }
- /*
- * Finally, hide the progress bar and show the key data.
- */
- hidemany(hwnd, nokey_ids, TRUE);
- hidemany(hwnd, generating_ids, TRUE);
- hidemany(hwnd, gotkey_ids, FALSE);
- break;
+ state = (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA);
+ state->generation_thread_exists = FALSE;
+ state->key_exists = TRUE;
+ SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETRANGE, 0,
+ MAKELPARAM(0, PROGRESSRANGE));
+ SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETPOS, PROGRESSRANGE, 0);
+ EnableWindow(GetDlgItem(hwnd, IDC_GENERATE), 1);
+ EnableWindow(GetDlgItem(hwnd, IDC_LOAD), 1);
+ EnableWindow(GetDlgItem(hwnd, IDC_SAVE), 1);
+ EnableWindow(GetDlgItem(hwnd, IDC_SAVEPUB), 1);
+ EnableWindow(GetDlgItem(hwnd, IDC_KEYSSH1), 1);
+ EnableWindow(GetDlgItem(hwnd, IDC_KEYSSH2RSA), 1);
+ EnableWindow(GetDlgItem(hwnd, IDC_KEYSSH2DSA), 1);
+ EnableWindow(GetDlgItem(hwnd, IDC_BITS), 1);
+ if (state->ssh2) {
+ if (state->is_dsa) {
+ state->ssh2key.data = &state->dsskey;
+ state->ssh2key.alg = &ssh_dss;
+ } else {
+ state->ssh2key.data = &state->key;
+ state->ssh2key.alg = &ssh_rsa;
+ }
+ state->commentptr = &state->ssh2key.comment;
+ } else {
+ state->commentptr = &state->key.comment;
+ }
+ /*
+ * Invent a comment for the key. We'll do this by including
+ * the date in it. This will be so horrifyingly ugly that
+ * the user will immediately want to change it, which is
+ * what we want :-)
+ */
+ *state->commentptr = smalloc(30);
+ {
+ time_t t;
+ struct tm *tm;
+ time(&t);
+ tm = localtime(&t);
+ if (state->is_dsa)
+ strftime(*state->commentptr, 30, "dsa-key-%Y%m%d", tm);
+ else
+ strftime(*state->commentptr, 30, "rsa-key-%Y%m%d", tm);
+ }
+
+ /*
+ * Now update the key controls with all the key data.
+ */
+ {
+ char *savecomment;
+ /*
+ * Blank passphrase, initially. This isn't dangerous,
+ * because we will warn (Are You Sure?) before allowing
+ * the user to save an unprotected private key.
+ */
+ SetDlgItemText(hwnd, IDC_PASSPHRASE1EDIT, "");
+ SetDlgItemText(hwnd, IDC_PASSPHRASE2EDIT, "");
+ /*
+ * Set the comment.
+ */
+ SetDlgItemText(hwnd, IDC_COMMENTEDIT, *state->commentptr);
+ /*
+ * Set the key fingerprint.
+ */
+ savecomment = *state->commentptr;
+ *state->commentptr = NULL;
+ if (state->ssh2) {
+ char *fp;
+ fp = state->ssh2key.alg->fingerprint(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);
+ }
+ *state->commentptr = savecomment;
+ /*
+ * Construct a decimal representation of the key, for
+ * pasting into .ssh/authorized_keys or
+ * .ssh/authorized_keys2 on a Unix box.
+ */
+ if (state->ssh2) {
+ setupbigedit2(hwnd, IDC_KEYDISPLAY,
+ IDC_PKSTATIC, &state->ssh2key);
+ } else {
+ setupbigedit1(hwnd, IDC_KEYDISPLAY,
+ IDC_PKSTATIC, &state->key);
+ }
+ }
+ /*
+ * Finally, hide the progress bar and show the key data.
+ */
+ hidemany(hwnd, nokey_ids, TRUE);
+ hidemany(hwnd, generating_ids, TRUE);
+ hidemany(hwnd, gotkey_ids, FALSE);
+ break;