• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision9658 (tree)
Zeit2021-12-31 22:50:02
Autornmaya

Log Message

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

Ändern Zusammenfassung

Diff

--- branches/libressl_3_4_2/ttssh2/ttxssh/cipher-ctr.c (revision 9657)
+++ branches/libressl_3_4_2/ttssh2/ttxssh/cipher-ctr.c (revision 9658)
@@ -133,6 +133,22 @@
133133 const EVP_CIPHER *
134134 evp_aes_128_ctr(void)
135135 {
136+#ifndef LIBRESSL_VERSION_NUMBER
137+ static EVP_CIPHER *p = NULL;
138+
139+ if (p == NULL) {
140+ p = EVP_CIPHER_meth_new(NID_undef, /*block_size*/AES_BLOCK_SIZE, /*key_len*/16);
141+ /*** TODO: OPENSSL1.1.1 ERROR CHECK(ticket#39335で処置予定) ***/
142+ }
143+ if (p) {
144+ EVP_CIPHER_meth_set_iv_length(p, AES_BLOCK_SIZE);
145+ EVP_CIPHER_meth_set_init(p, ssh_aes_ctr_init);
146+ EVP_CIPHER_meth_set_cleanup(p, ssh_aes_ctr_cleanup);
147+ EVP_CIPHER_meth_set_do_cipher(p, ssh_aes_ctr);
148+ EVP_CIPHER_meth_set_flags(p, EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV);
149+ }
150+ return (p);
151+#else
136152 static EVP_CIPHER aes_ctr;
137153
138154 memset(&aes_ctr, 0, sizeof(EVP_CIPHER));
@@ -147,6 +163,7 @@
147163 aes_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
148164 #endif
149165 return (&aes_ctr);
166+#endif
150167 }
151168
152169 //============================================================================
@@ -212,6 +229,22 @@
212229 const EVP_CIPHER *
213230 evp_des3_ctr(void)
214231 {
232+#ifndef LIBRESSL_VERSION_NUMBER
233+ static EVP_CIPHER *p = NULL;
234+
235+ if (p == NULL) {
236+ p = EVP_CIPHER_meth_new(NID_undef, /*block_size*/DES_BLOCK_SIZE, /*key_len*/24);
237+ /*** TODO: OPENSSL1.1.1 ERROR CHECK(ticket#39335で処置予定) ***/
238+ }
239+ if (p) {
240+ EVP_CIPHER_meth_set_iv_length(p, DES_BLOCK_SIZE);
241+ EVP_CIPHER_meth_set_init(p, ssh_des3_ctr_init);
242+ EVP_CIPHER_meth_set_cleanup(p, ssh_des3_ctr_cleanup);
243+ EVP_CIPHER_meth_set_do_cipher(p, ssh_des3_ctr);
244+ EVP_CIPHER_meth_set_flags(p, EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV);
245+ }
246+ return (p);
247+#else
215248 static EVP_CIPHER des3_ctr;
216249
217250 memset(&des3_ctr, 0, sizeof(EVP_CIPHER));
@@ -226,6 +259,7 @@
226259 des3_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
227260 #endif
228261 return (&des3_ctr);
262+#endif
229263 }
230264
231265 //============================================================================
@@ -306,6 +340,22 @@
306340 const EVP_CIPHER *
307341 evp_bf_ctr(void)
308342 {
343+#ifndef LIBRESSL_VERSION_NUMBER
344+ static EVP_CIPHER *p = NULL;
345+
346+ if (p == NULL) {
347+ p = EVP_CIPHER_meth_new(NID_undef, /*block_size*/BF_BLOCK, /*key_len*/16);
348+ /*** TODO: OPENSSL1.1.1 ERROR CHECK(ticket#39335で処置予定) ***/
349+ }
350+ if (p) {
351+ EVP_CIPHER_meth_set_iv_length(p, BF_BLOCK);
352+ EVP_CIPHER_meth_set_init(p, ssh_bf_ctr_init);
353+ EVP_CIPHER_meth_set_cleanup(p, ssh_bf_ctr_cleanup);
354+ EVP_CIPHER_meth_set_do_cipher(p, ssh_bf_ctr);
355+ EVP_CIPHER_meth_set_flags(p, EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV);
356+ }
357+ return (p);
358+#else
309359 static EVP_CIPHER blowfish_ctr;
310360
311361 memset(&blowfish_ctr, 0, sizeof(EVP_CIPHER));
@@ -320,6 +370,7 @@
320370 blowfish_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
321371 #endif
322372 return (&blowfish_ctr);
373+#endif
323374 }
324375
325376 //============================================================================
@@ -400,6 +451,22 @@
400451 const EVP_CIPHER *
401452 evp_cast5_ctr(void)
402453 {
454+#ifndef LIBRESSL_VERSION_NUMBER
455+ static EVP_CIPHER *p = NULL;
456+
457+ if (p == NULL) {
458+ p = EVP_CIPHER_meth_new(NID_undef, /*block_size*/CAST_BLOCK, /*key_len*/16);
459+ /*** TODO: OPENSSL1.1.1 ERROR CHECK(ticket#39335で処置予定) ***/
460+ }
461+ if (p) {
462+ EVP_CIPHER_meth_set_iv_length(p, CAST_BLOCK);
463+ EVP_CIPHER_meth_set_init(p, ssh_cast5_ctr_init);
464+ EVP_CIPHER_meth_set_cleanup(p, ssh_cast5_ctr_cleanup);
465+ EVP_CIPHER_meth_set_do_cipher(p, ssh_cast5_ctr);
466+ EVP_CIPHER_meth_set_flags(p, EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV);
467+ }
468+ return (p);
469+#else
403470 static EVP_CIPHER cast5_ctr;
404471
405472 memset(&cast5_ctr, 0, sizeof(EVP_CIPHER));
@@ -414,6 +481,7 @@
414481 cast5_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
415482 #endif
416483 return (&cast5_ctr);
484+#endif
417485 }
418486
419487 //============================================================================
@@ -474,6 +542,22 @@
474542 const EVP_CIPHER *
475543 evp_camellia_128_ctr(void)
476544 {
545+#ifndef LIBRESSL_VERSION_NUMBER
546+ static EVP_CIPHER *p = NULL;
547+
548+ if (p == NULL) {
549+ p = EVP_CIPHER_meth_new(NID_undef, /*block_size*/CAMELLIA_BLOCK_SIZE, /*key_len*/16);
550+ /*** TODO: OPENSSL1.1.1 ERROR CHECK(ticket#39335で処置予定) ***/
551+ }
552+ if (p) {
553+ EVP_CIPHER_meth_set_iv_length(p, CAMELLIA_BLOCK_SIZE);
554+ EVP_CIPHER_meth_set_init(p, ssh_camellia_ctr_init);
555+ EVP_CIPHER_meth_set_cleanup(p, ssh_camellia_ctr_cleanup);
556+ EVP_CIPHER_meth_set_do_cipher(p, ssh_camellia_ctr);
557+ EVP_CIPHER_meth_set_flags(p, EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV);
558+ }
559+ return (p);
560+#else
477561 static EVP_CIPHER camellia_ctr;
478562
479563 memset(&camellia_ctr, 0, sizeof(EVP_CIPHER));
@@ -488,4 +572,5 @@
488572 camellia_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
489573 #endif
490574 return (&camellia_ctr);
575+#endif
491576 }
Show on old repository browser