[ttssh2-commit] [9658] r9623 で削除した OpenSSL 1.1 以降用のコードを戻し、#ifdef で使い分ける

Zurück zum Archiv-Index
scmno****@osdn***** scmno****@osdn*****
2021年 12月 31日 (金) 22:50:02 JST


Revision: 9658
          https://osdn.net/projects/ttssh2/scm/svn/commits/9658
Author:   nmaya
Date:     2021-12-31 22:50:02 +0900 (Fri, 31 Dec 2021)
Log Message:
-----------
r9623 で削除した OpenSSL 1.1 以降用のコードを戻し、#ifdef で使い分ける

Revision Links:
--------------
    https://osdn.net/projects/ttssh2/scm/svn/commits/9623

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

-------------- next part --------------
Modified: branches/libressl_3_4_2/ttssh2/ttxssh/cipher-ctr.c
===================================================================
--- branches/libressl_3_4_2/ttssh2/ttxssh/cipher-ctr.c	2021-12-30 09:36:13 UTC (rev 9657)
+++ branches/libressl_3_4_2/ttssh2/ttxssh/cipher-ctr.c	2021-12-31 13:50:02 UTC (rev 9658)
@@ -133,6 +133,22 @@
 const EVP_CIPHER *
 evp_aes_128_ctr(void)
 {
+#ifndef LIBRESSL_VERSION_NUMBER
+	static EVP_CIPHER *p = NULL;
+
+	if (p == NULL) {
+		p = EVP_CIPHER_meth_new(NID_undef, /*block_size*/AES_BLOCK_SIZE, /*key_len*/16);
+		/*** TODO: OPENSSL1.1.1 ERROR CHECK(ticket#39335\x82ŏ\x88\x92u\x97\\x92\xE8) ***/
+	}
+	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);
+#else
 	static EVP_CIPHER aes_ctr;
 
 	memset(&aes_ctr, 0, sizeof(EVP_CIPHER));
@@ -147,6 +163,7 @@
 	aes_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
 #endif
 	return (&aes_ctr);
+#endif
 }
 
 //============================================================================
@@ -212,6 +229,22 @@
 const EVP_CIPHER *
 evp_des3_ctr(void)
 {
+#ifndef LIBRESSL_VERSION_NUMBER
+	static EVP_CIPHER *p = NULL;
+
+	if (p == NULL) {
+		p = EVP_CIPHER_meth_new(NID_undef, /*block_size*/DES_BLOCK_SIZE, /*key_len*/24);
+		/*** TODO: OPENSSL1.1.1 ERROR CHECK(ticket#39335\x82ŏ\x88\x92u\x97\\x92\xE8) ***/
+	}
+	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);
+#else
 	static EVP_CIPHER des3_ctr;
 
 	memset(&des3_ctr, 0, sizeof(EVP_CIPHER));
@@ -226,6 +259,7 @@
 	des3_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
 #endif
 	return (&des3_ctr);
+#endif
 }
 
 //============================================================================
@@ -306,6 +340,22 @@
 const EVP_CIPHER *
 evp_bf_ctr(void)
 {
+#ifndef LIBRESSL_VERSION_NUMBER
+	static EVP_CIPHER *p = NULL;
+
+	if (p == NULL) {
+		p = EVP_CIPHER_meth_new(NID_undef, /*block_size*/BF_BLOCK, /*key_len*/16);
+		/*** TODO: OPENSSL1.1.1 ERROR CHECK(ticket#39335\x82ŏ\x88\x92u\x97\\x92\xE8) ***/
+	}
+	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);
+#else
 	static EVP_CIPHER blowfish_ctr;
 
 	memset(&blowfish_ctr, 0, sizeof(EVP_CIPHER));
@@ -320,6 +370,7 @@
 	blowfish_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
 #endif
 	return (&blowfish_ctr);
+#endif
 }
 
 //============================================================================
@@ -400,6 +451,22 @@
 const EVP_CIPHER *
 evp_cast5_ctr(void)
 {
+#ifndef LIBRESSL_VERSION_NUMBER
+	static EVP_CIPHER *p = NULL;
+
+	if (p == NULL) {
+		p = EVP_CIPHER_meth_new(NID_undef, /*block_size*/CAST_BLOCK, /*key_len*/16);
+		/*** TODO: OPENSSL1.1.1 ERROR CHECK(ticket#39335\x82ŏ\x88\x92u\x97\\x92\xE8) ***/
+	}
+	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);
+#else
 	static EVP_CIPHER cast5_ctr;
 
 	memset(&cast5_ctr, 0, sizeof(EVP_CIPHER));
@@ -414,6 +481,7 @@
 	cast5_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
 #endif
 	return (&cast5_ctr);
+#endif
 }
 
 //============================================================================
@@ -474,6 +542,22 @@
 const EVP_CIPHER *
 evp_camellia_128_ctr(void)
 {
+#ifndef LIBRESSL_VERSION_NUMBER
+	static EVP_CIPHER *p = NULL;
+
+	if (p == NULL) {
+		p = EVP_CIPHER_meth_new(NID_undef, /*block_size*/CAMELLIA_BLOCK_SIZE, /*key_len*/16);
+		/*** TODO: OPENSSL1.1.1 ERROR CHECK(ticket#39335\x82ŏ\x88\x92u\x97\\x92\xE8) ***/
+	}
+	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);
+#else
 	static EVP_CIPHER camellia_ctr;
 
 	memset(&camellia_ctr, 0, sizeof(EVP_CIPHER));
@@ -488,4 +572,5 @@
 	camellia_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
 #endif
 	return (&camellia_ctr);
+#endif
 }


ttssh2-commit メーリングリストの案内
Zurück zum Archiv-Index