- case IDC_GENERATE:
- state = (struct MainDlgState *)GetWindowLong(hwnd, GWL_USERDATA);
- if (!state->generation_thread_exists) {
- BOOL ok;
- state->keysize = GetDlgItemInt(hwnd, IDC_BITS,
- &ok, FALSE);
- if (!ok) state->keysize = DEFAULT_KEYSIZE;
- if (state->keysize < 256) {
- int ret = MessageBox(hwnd,
- "PuTTYgen will not generate a key"
- " smaller than 256 bits.\n"
- "Key length reset to 256. Continue?",
- "PuTTYgen Warning",
- MB_ICONWARNING | MB_OKCANCEL);
- if (ret != IDOK)
- break;
- state->keysize = 256;
- SetDlgItemInt(hwnd, IDC_BITS, 256, FALSE);
- }
- hidemany(hwnd, nokey_ids, TRUE);
- hidemany(hwnd, generating_ids, FALSE);
- hidemany(hwnd, gotkey_ids, TRUE);
- EnableWindow(GetDlgItem(hwnd, IDC_GENERATE), 0);
- EnableWindow(GetDlgItem(hwnd, IDC_LOAD), 0);
- EnableWindow(GetDlgItem(hwnd, IDC_SAVE), 0);
- state->key_exists = FALSE;
- SetDlgItemText(hwnd, IDC_GENERATING, entropy_msg);
- state->collecting_entropy = TRUE;
-
- /*
- * My brief statistical tests on mouse movements
- * suggest that there are about 2.5 bits of
- * randomness in the x position, 2.5 in the y
- * position, and 1.7 in the message time, making
- * 5.7 bits of unpredictability per mouse movement.
- * However, other people have told me it's far less
- * than that, so I'm going to be stupidly cautious
- * and knock that down to a nice round 2. With this
- * method, we require two words per mouse movement,
- * so with 2 bits per mouse movement we expect 2
- * bits every 2 words.
- */
- 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);
-
- SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETRANGE, 0,
- MAKELPARAM(0, state->entropy_required));
- SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETPOS, 0, 0);
- }
- break;
- case IDC_SAVE:
- state = (struct MainDlgState *)GetWindowLong(hwnd, GWL_USERDATA);
- if (state->key_exists) {
- char filename[FILENAME_MAX];
- char passphrase[PASSPHRASE_MAXLEN];
- char passphrase2[PASSPHRASE_MAXLEN];
- GetDlgItemText(hwnd, IDC_PASSPHRASE1EDIT,
- passphrase, sizeof(passphrase));
- GetDlgItemText(hwnd, IDC_PASSPHRASE2EDIT,
- passphrase2, sizeof(passphrase2));
+ case IDC_GENERATE:
+ state =
+ (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA);
+ if (!state->generation_thread_exists) {
+ BOOL ok;
+ state->keysize = GetDlgItemInt(hwnd, IDC_BITS, &ok, FALSE);
+ if (!ok)
+ state->keysize = DEFAULT_KEYSIZE;
+ /* If we ever introduce a new key type, check it here! */
+ state->ssh2 = !IsDlgButtonChecked(hwnd, IDC_KEYSSH1);
+ state->is_dsa = IsDlgButtonChecked(hwnd, IDC_KEYSSH2DSA);
+ if (state->keysize < 256) {
+ int ret = MessageBox(hwnd,
+ "PuTTYgen will not generate a key"
+ " smaller than 256 bits.\n"
+ "Key length reset to 256. Continue?",
+ "PuTTYgen Warning",
+ MB_ICONWARNING | MB_OKCANCEL);
+ if (ret != IDOK)
+ break;
+ state->keysize = 256;
+ SetDlgItemInt(hwnd, IDC_BITS, 256, FALSE);
+ }
+ hidemany(hwnd, nokey_ids, TRUE);
+ hidemany(hwnd, generating_ids, FALSE);
+ hidemany(hwnd, gotkey_ids, TRUE);
+ EnableWindow(GetDlgItem(hwnd, IDC_GENERATE), 0);
+ EnableWindow(GetDlgItem(hwnd, IDC_LOAD), 0);
+ EnableWindow(GetDlgItem(hwnd, IDC_SAVE), 0);
+ EnableWindow(GetDlgItem(hwnd, IDC_SAVEPUB), 0);
+ EnableWindow(GetDlgItem(hwnd, IDC_KEYSSH1), 0);
+ EnableWindow(GetDlgItem(hwnd, IDC_KEYSSH2RSA), 0);
+ EnableWindow(GetDlgItem(hwnd, IDC_KEYSSH2DSA), 0);
+ EnableWindow(GetDlgItem(hwnd, IDC_BITS), 0);
+ state->key_exists = FALSE;
+ SetDlgItemText(hwnd, IDC_GENERATING, entropy_msg);
+ state->collecting_entropy = TRUE;
+
+ /*
+ * My brief statistical tests on mouse movements
+ * suggest that there are about 2.5 bits of
+ * randomness in the x position, 2.5 in the y
+ * position, and 1.7 in the message time, making
+ * 5.7 bits of unpredictability per mouse movement.
+ * However, other people have told me it's far less
+ * than that, so I'm going to be stupidly cautious
+ * and knock that down to a nice round 2. With this
+ * method, we require two words per mouse movement,
+ * so with 2 bits per mouse movement we expect 2
+ * bits every 2 words.
+ */
+ 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);
+
+ SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETRANGE, 0,
+ MAKELPARAM(0, state->entropy_required));
+ SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETPOS, 0, 0);
+ }
+ break;
+ case IDC_SAVE:
+ state =
+ (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA);
+ if (state->key_exists) {
+ char filename[FILENAME_MAX];
+ char passphrase[PASSPHRASE_MAXLEN];
+ char passphrase2[PASSPHRASE_MAXLEN];
+ GetDlgItemText(hwnd, IDC_PASSPHRASE1EDIT,
+ passphrase, sizeof(passphrase));
+ GetDlgItemText(hwnd, IDC_PASSPHRASE2EDIT,
+ passphrase2, sizeof(passphrase2));