[Ttssh2-commit] [5768] KDF フォーマットの SSH 秘密鍵をパスフレーズなしで復号できない問題を修正

svnno****@sourc***** svnno****@sourc*****
2015年 1月 29日 (木) 17:38:57 JST


Revision: 5768
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/5768
Author:   maya
Date:     2015-01-29 17:38:56 +0900 (Thu, 29 Jan 2015)
Log Message:
-----------
KDF フォーマットの SSH 秘密鍵をパスフレーズなしで復号できない問題を修正
生成した SSH 秘密鍵をパスフレーズなしの KDF フォーマットで保存するときに暗号化してしまう問題を修正

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

-------------- next part --------------
Modified: trunk/ttssh2/ttxssh/keyfiles.c
===================================================================
--- trunk/ttssh2/ttxssh/keyfiles.c	2015-01-27 16:59:40 UTC (rev 5767)
+++ trunk/ttssh2/ttxssh/keyfiles.c	2015-01-29 08:38:56 UTC (rev 5768)
@@ -451,21 +451,27 @@
 	// \x88Í\x86\x89\xBB\x83A\x83\x8B\x83S\x83\x8A\x83Y\x83\x80\x82̖\xBC\x91O
 	ciphername = buffer_get_string_msg(copy_consumed, NULL);
 	ciphernameval = get_cipher_by_name(ciphername);
-	if (ciphernameval == SSH_CIPHER_NONE) {
+	if (ciphernameval == SSH_CIPHER_NONE && strcmp(ciphername, "none") != 0) {
 		//error("%s: unknown cipher name", __func__);
 		goto error;
 	}
-	// \x83p\x83X\x83t\x83\x8C\x81[\x83Y\x82̃`\x83F\x83b\x83N\x81B\x8B\xF3\x82̃p\x83X\x83\x8F\x81[\x83h\x82͔F\x82߂Ȃ\xA2\x81B
-	if (passphrase == NULL || strlen(passphrase) == 0) {
+	// \x83p\x83X\x83t\x83\x8C\x81[\x83Y\x82̃`\x83F\x83b\x83N\x81B\x88Í\x86\x89\xBB\x82\xAA none \x82łȂ\xA2\x8Fꍇ\x82͋\xF3\x82̃p\x83X\x83\x8F\x81[\x83h\x82\xF0\x94F\x82߂Ȃ\xA2\x81B
+	if ((passphrase == NULL || strlen(passphrase) == 0) &&
+	    strcmp(ciphername, "none") != 0) {
 		/* passphrase required */
 		goto error;
 	}
 
 	kdfname = buffer_get_string_msg(copy_consumed, NULL);
-	if (kdfname == NULL || strcmp(kdfname, KDFNAME) != 0) {
+	if (kdfname == NULL ||
+	    (!strcmp(kdfname, "none") && !strcmp(kdfname, KDFNAME))) {
 		//error("%s: unknown kdf name", __func__);
 		goto error;
 	}
+	if (!strcmp(kdfname, "none") && strcmp(ciphername, "none") != 0) {
+		//error("%s: cipher %s requires kdf", __func__, ciphername);
+		goto error;
+	}
 
 	/* kdf options */
 	kdfp = buffer_get_string_msg(copy_consumed, &klen);

Modified: trunk/ttssh2/ttxssh/ssh.c
===================================================================
--- trunk/ttssh2/ttxssh/ssh.c	2015-01-27 16:59:40 UTC (rev 5767)
+++ trunk/ttssh2/ttxssh/ssh.c	2015-01-29 08:38:56 UTC (rev 5768)
@@ -4023,7 +4023,7 @@
 int get_cipher_block_size(SSHCipher cipher)
 {
 	ssh2_cipher_t *ptr = ssh2_ciphers;
-	int val = 0;
+	int val = 8;
 
 	while (ptr->name != NULL) {
 		if (cipher == ptr->cipher) {

Modified: trunk/ttssh2/ttxssh/ttxssh.c
===================================================================
--- trunk/ttssh2/ttxssh/ttxssh.c	2015-01-27 16:59:40 UTC (rev 5767)
+++ trunk/ttssh2/ttxssh/ttxssh.c	2015-01-29 08:38:56 UTC (rev 5768)
@@ -4207,6 +4207,11 @@
 	if (b == NULL || kdf == NULL || encoded == NULL || blob == NULL)
 		goto ed25519_error;
 
+	if (passphrase == NULL || !strlen(passphrase)) {
+		ciphername = "none";
+		kdfname = "none";
+	}
+
 	ciphernameval = get_cipher_by_name(ciphername);
 	blocksize = get_cipher_block_size(ciphernameval);
 	keylen = get_cipher_key_len(ciphernameval);



Ttssh2-commit メーリングリストの案内