[Ttssh2-commit] [4374] 鍵生成ダイアログの挙動を変更

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 3月 8日 (火) 10:00:58 JST


Revision: 4374
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4374
Author:   doda
Date:     2011-03-08 10:00:58 +0900 (Tue, 08 Mar 2011)

Log Message:
-----------
鍵生成ダイアログの挙動を変更
・ECDSA 鍵を選んだ時はビット数の入力ボックスを無効化するようにした
・ECDSA 鍵を選んだ後に RSA/DSA 鍵を選んだ時はビット数の値を元に戻すようにした

Modified Paths:
--------------
    trunk/ttssh2/ttxssh/ssh.h
    trunk/ttssh2/ttxssh/ttxssh.c


-------------- next part --------------
Modified: trunk/ttssh2/ttxssh/ssh.h
===================================================================
--- trunk/ttssh2/ttxssh/ssh.h	2011-03-08 00:22:12 UTC (rev 4373)
+++ trunk/ttssh2/ttxssh/ssh.h	2011-03-08 01:00:58 UTC (rev 4374)
@@ -208,6 +208,7 @@
 	KEY_UNSPEC,
 	KEY_MAX = KEY_UNSPEC,
 };
+#define isECDSAkey(type)	((type) >= KEY_ECDSA256 && (type) <= KEY_ECDSA521)
 
 typedef struct ssh2_host_key {
 	enum ssh_keytype type;

Modified: trunk/ttssh2/ttxssh/ttxssh.c
===================================================================
--- trunk/ttssh2/ttxssh/ttxssh.c	2011-03-08 00:22:12 UTC (rev 4373)
+++ trunk/ttssh2/ttxssh/ttxssh.c	2011-03-08 01:00:58 UTC (rev 4374)
@@ -3606,6 +3606,7 @@
                                      LPARAM lParam)
 {
 	static enum ssh_keytype key_type;
+	static int saved_key_bits;
 	char uimsg[MAX_UIMSG];
 	LOGFONT logfont;
 	HFONT font;
@@ -3670,6 +3671,7 @@
 		// default key type
 		SendMessage(GetDlgItem(dlg, IDC_RSA_TYPE), BM_SETCHECK, BST_CHECKED, 0);
 		key_type = KEY_RSA;
+		saved_key_bits = GetDlgItemInt(dlg, IDC_KEYBITS, NULL, FALSE);
 
 		// default key bits
 		SetDlgItemInt(dlg, IDC_KEYBITS, SSH_KEYGEN_DEFAULT_BITS, FALSE);
@@ -3766,7 +3768,9 @@
 				EnableWindow(GetDlgItem(dlg, IDC_ECDSA256_TYPE), TRUE);
 				EnableWindow(GetDlgItem(dlg, IDC_ECDSA384_TYPE), TRUE);
 				EnableWindow(GetDlgItem(dlg, IDC_ECDSA521_TYPE), TRUE);
-				EnableWindow(GetDlgItem(dlg, IDC_KEYBITS), TRUE);
+				if (!isECDSAkey(key_type)) {
+					EnableWindow(GetDlgItem(dlg, IDC_KEYBITS), TRUE);
+				}
 				EnableWindow(GetDlgItem(dlg, IDOK), TRUE);
 				EnableWindow(GetDlgItem(dlg, IDCANCEL), TRUE);
 
@@ -3787,28 +3791,52 @@
 
 		// if radio button pressed...
 		case IDC_RSA1_TYPE | (BN_CLICKED << 16):
+			if (isECDSAkey(key_type)) {
+				EnableWindow(GetDlgItem(dlg, IDC_KEYBITS), TRUE);
+				SetDlgItemInt(dlg, IDC_KEYBITS, saved_key_bits, FALSE);
+			}
 			key_type = KEY_RSA1;
 			break;
 
 		case IDC_RSA_TYPE | (BN_CLICKED << 16):
+			if (isECDSAkey(key_type)) {
+				EnableWindow(GetDlgItem(dlg, IDC_KEYBITS), TRUE);
+				SetDlgItemInt(dlg, IDC_KEYBITS, saved_key_bits, FALSE);
+			}
 			key_type = KEY_RSA;
 			break;
 
 		case IDC_DSA_TYPE | (BN_CLICKED << 16):
+			if (isECDSAkey(key_type)) {
+				EnableWindow(GetDlgItem(dlg, IDC_KEYBITS), TRUE);
+				SetDlgItemInt(dlg, IDC_KEYBITS, saved_key_bits, FALSE);
+			}
 			key_type = KEY_DSA;
 			break;
 
 		case IDC_ECDSA256_TYPE | (BN_CLICKED << 16):
+			if (!isECDSAkey(key_type)) {
+				EnableWindow(GetDlgItem(dlg, IDC_KEYBITS), FALSE);
+				saved_key_bits = GetDlgItemInt(dlg, IDC_KEYBITS, NULL, FALSE);
+			}
 			key_type = KEY_ECDSA256;
 			SetDlgItemInt(dlg, IDC_KEYBITS, 256, FALSE);
 			break;
 
 		case IDC_ECDSA384_TYPE | (BN_CLICKED << 16):
+			if (!isECDSAkey(key_type)) {
+				EnableWindow(GetDlgItem(dlg, IDC_KEYBITS), FALSE);
+				saved_key_bits = GetDlgItemInt(dlg, IDC_KEYBITS, NULL, FALSE);
+			}
 			key_type = KEY_ECDSA384;
 			SetDlgItemInt(dlg, IDC_KEYBITS, 384, FALSE);
 			break;
 
 		case IDC_ECDSA521_TYPE | (BN_CLICKED << 16):
+			if (!isECDSAkey(key_type)) {
+				EnableWindow(GetDlgItem(dlg, IDC_KEYBITS), FALSE);
+				saved_key_bits = GetDlgItemInt(dlg, IDC_KEYBITS, NULL, FALSE);
+			}
 			key_type = KEY_ECDSA521;
 			SetDlgItemInt(dlg, IDC_KEYBITS, 521, FALSE);
 			break;



Ttssh2-commit メーリングリストの案内
Back to archive index