[Ttssh2-commit] [6560] ※これはブランチへのコミットです

svnno****@sourc***** svnno****@sourc*****
2017年 1月 6日 (金) 00:22:41 JST


Revision: 6560
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6560
Author:   yutakapon
Date:     2017-01-06 00:22:41 +0900 (Fri, 06 Jan 2017)
Log Message:
-----------
※これはブランチへのコミットです
EVP_CIPHER 構造体を動的アロケート化した。

Modified Paths:
--------------
    branches/openssl_1_1_0/ttssh2/ttxssh/cipher-ctr.c
    branches/openssl_1_1_0/ttssh2/ttxssh/ttxssh.c

-------------- next part --------------
Modified: branches/openssl_1_1_0/ttssh2/ttxssh/cipher-ctr.c
===================================================================
--- branches/openssl_1_1_0/ttssh2/ttxssh/cipher-ctr.c	2017-01-04 15:02:08 UTC (rev 6559)
+++ branches/openssl_1_1_0/ttssh2/ttxssh/cipher-ctr.c	2017-01-05 15:22:41 UTC (rev 6560)
@@ -133,6 +133,7 @@
 const EVP_CIPHER *
 evp_aes_128_ctr(void)
 {
+#if OPENSSL_VERSION_NUMBER < 0x10100000UL 
 	static EVP_CIPHER aes_ctr;
 
 	memset(&aes_ctr, 0, sizeof(EVP_CIPHER));
@@ -147,6 +148,21 @@
 	aes_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
 #endif
 	return (&aes_ctr);
+#else
+	static EVP_CIPHER *p = NULL;
+
+	if (p == NULL) {
+		p = EVP_CIPHER_meth_new(NID_undef, /*block_size*/AES_BLOCK_SIZE, /*key_len*/16);
+	}
+	if (p) {
+		EVP_CIPHER_meth_set_iv_length(p, AES_BLOCK_SIZE);
+		EVP_CIPHER_meth_set_init(p, ssh_aes_ctr_init);
+		EVP_CIPHER_meth_set_cleanup(p, ssh_aes_ctr_cleanup);
+		EVP_CIPHER_meth_set_do_cipher(p, ssh_aes_ctr);
+		EVP_CIPHER_meth_set_flags(p, EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV);
+	}
+	return (p);
+#endif
 }
 
 //============================================================================
@@ -212,6 +228,7 @@
 const EVP_CIPHER *
 evp_des3_ctr(void)
 {
+#if OPENSSL_VERSION_NUMBER < 0x10100000UL 
 	static EVP_CIPHER des3_ctr;
 
 	memset(&des3_ctr, 0, sizeof(EVP_CIPHER));
@@ -226,6 +243,21 @@
 	des3_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
 #endif
 	return (&des3_ctr);
+#else
+	static EVP_CIPHER *p = NULL;
+
+	if (p == NULL) {
+		p = EVP_CIPHER_meth_new(NID_undef, /*block_size*/DES_BLOCK_SIZE, /*key_len*/24);
+	}
+	if (p) {
+		EVP_CIPHER_meth_set_iv_length(p, DES_BLOCK_SIZE);
+		EVP_CIPHER_meth_set_init(p, ssh_des3_ctr_init);
+		EVP_CIPHER_meth_set_cleanup(p, ssh_des3_ctr_cleanup);
+		EVP_CIPHER_meth_set_do_cipher(p, ssh_des3_ctr);
+		EVP_CIPHER_meth_set_flags(p, EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV);
+	}
+	return (p);
+#endif
 }
 
 //============================================================================
@@ -306,6 +338,7 @@
 const EVP_CIPHER *
 evp_bf_ctr(void)
 {
+#if OPENSSL_VERSION_NUMBER < 0x10100000UL 
 	static EVP_CIPHER blowfish_ctr;
 
 	memset(&blowfish_ctr, 0, sizeof(EVP_CIPHER));
@@ -320,6 +353,21 @@
 	blowfish_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
 #endif
 	return (&blowfish_ctr);
+#else
+	static EVP_CIPHER *p = NULL;
+
+	if (p == NULL) {
+		p = EVP_CIPHER_meth_new(NID_undef, /*block_size*/BF_BLOCK, /*key_len*/16);
+	}
+	if (p) {
+		EVP_CIPHER_meth_set_iv_length(p, BF_BLOCK);
+		EVP_CIPHER_meth_set_init(p, ssh_bf_ctr_init);
+		EVP_CIPHER_meth_set_cleanup(p, ssh_bf_ctr_cleanup);
+		EVP_CIPHER_meth_set_do_cipher(p, ssh_bf_ctr);
+		EVP_CIPHER_meth_set_flags(p, EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV);
+	}
+	return (p);
+#endif
 }
 
 //============================================================================
@@ -400,6 +448,7 @@
 const EVP_CIPHER *
 evp_cast5_ctr(void)
 {
+#if OPENSSL_VERSION_NUMBER < 0x10100000UL 
 	static EVP_CIPHER cast5_ctr;
 
 	memset(&cast5_ctr, 0, sizeof(EVP_CIPHER));
@@ -414,6 +463,21 @@
 	cast5_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
 #endif
 	return (&cast5_ctr);
+#else
+	static EVP_CIPHER *p = NULL;
+
+	if (p == NULL) {
+		p = EVP_CIPHER_meth_new(NID_undef, /*block_size*/CAST_BLOCK, /*key_len*/16);
+	}
+	if (p) {
+		EVP_CIPHER_meth_set_iv_length(p, CAST_BLOCK);
+		EVP_CIPHER_meth_set_init(p, ssh_cast5_ctr_init);
+		EVP_CIPHER_meth_set_cleanup(p, ssh_cast5_ctr_cleanup);
+		EVP_CIPHER_meth_set_do_cipher(p, ssh_cast5_ctr);
+		EVP_CIPHER_meth_set_flags(p, EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV);
+	}
+	return (p);
+#endif
 }
 
 //============================================================================
@@ -486,6 +550,7 @@
 const EVP_CIPHER *
 evp_camellia_128_ctr(void)
 {
+#if OPENSSL_VERSION_NUMBER < 0x10100000UL 
 	static EVP_CIPHER camellia_ctr;
 
 	memset(&camellia_ctr, 0, sizeof(EVP_CIPHER));
@@ -500,4 +565,19 @@
 	camellia_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
 #endif
 	return (&camellia_ctr);
+#else
+	static EVP_CIPHER *p = NULL;
+
+	if (p == NULL) {
+		p = EVP_CIPHER_meth_new(NID_undef, /*block_size*/CAMELLIA_BLOCK_SIZE, /*key_len*/16);
+	}
+	if (p) {
+		EVP_CIPHER_meth_set_iv_length(p, CAMELLIA_BLOCK_SIZE);
+		EVP_CIPHER_meth_set_init(p, ssh_camellia_ctr_init);
+		EVP_CIPHER_meth_set_cleanup(p, ssh_camellia_ctr_cleanup);
+		EVP_CIPHER_meth_set_do_cipher(p, ssh_camellia_ctr);
+		EVP_CIPHER_meth_set_flags(p, EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV);
+	}
+	return (p);
+#endif
 }

Modified: branches/openssl_1_1_0/ttssh2/ttxssh/ttxssh.c
===================================================================
--- branches/openssl_1_1_0/ttssh2/ttxssh/ttxssh.c	2017-01-04 15:02:08 UTC (rev 6559)
+++ branches/openssl_1_1_0/ttssh2/ttxssh/ttxssh.c	2017-01-05 15:22:41 UTC (rev 6560)
@@ -3897,6 +3897,7 @@
 
 const EVP_CIPHER *evp_ssh1_3des(void)
 {
+#if OPENSSL_VERSION_NUMBER < 0x10100000UL 
 	static EVP_CIPHER ssh1_3des;
 
 	memset(&ssh1_3des, 0, sizeof(EVP_CIPHER));
@@ -3909,6 +3910,21 @@
 	ssh1_3des.do_cipher = ssh1_3des_cbc;
 	ssh1_3des.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH;
 	return (&ssh1_3des);
+#else
+	static EVP_CIPHER *p = NULL;
+
+	if (p == NULL) {
+		p = EVP_CIPHER_meth_new(NID_undef, /*block_size*/8, /*key_len*/16);
+	}
+	if (p) {
+		EVP_CIPHER_meth_set_iv_length(p, 0);
+		EVP_CIPHER_meth_set_init(p, ssh1_3des_init);
+		EVP_CIPHER_meth_set_cleanup(p, ssh1_3des_cleanup);
+		EVP_CIPHER_meth_set_do_cipher(p, ssh1_3des_cbc);
+		EVP_CIPHER_meth_set_flags(p, EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH);
+	}
+	return (p);
+#endif
 }
 
 static void ssh_make_comment(char *comment, int maxlen)



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