+/*
+ * Helper functions to set the key type, taking care of keeping the
+ * menu and radio button selections in sync and also showing/hiding
+ * the appropriate size/curve control for the current key type.
+ */
+void ui_update_key_type_ctrls(HWND hwnd)
+{
+ enum { BITS, CURVE, NOTHING } which;
+ static const int bits_ids[] = {
+ IDC_BITSSTATIC, IDC_BITS, 0
+ };
+ static const int curve_ids[] = {
+ IDC_CURVESTATIC, IDC_CURVE, 0
+ };
+ static const int nothing_ids[] = {
+ IDC_NOTHINGSTATIC, 0
+ };
+
+ if (IsDlgButtonChecked(hwnd, IDC_KEYSSH1) ||
+ IsDlgButtonChecked(hwnd, IDC_KEYSSH2RSA) ||
+ IsDlgButtonChecked(hwnd, IDC_KEYSSH2DSA)) {
+ which = BITS;
+ } else if (IsDlgButtonChecked(hwnd, IDC_KEYSSH2ECDSA)) {
+ which = CURVE;
+ } else {
+ /* ED25519 implicitly only supports one curve */
+ which = NOTHING;
+ }
+
+ hidemany(hwnd, bits_ids, which != BITS);
+ hidemany(hwnd, curve_ids, which != CURVE);
+ hidemany(hwnd, nothing_ids, which != NOTHING);
+}
+void ui_set_key_type(HWND hwnd, struct MainDlgState *state, int button)
+{
+ CheckRadioButton(hwnd, IDC_KEYSSH1, IDC_KEYSSH2ED25519, button);
+ CheckMenuRadioItem(state->keymenu, IDC_KEYSSH1, IDC_KEYSSH2ED25519,
+ button, MF_BYCOMMAND);
+ ui_update_key_type_ctrls(hwnd);
+}
+