From 17f61ecaf2bc8b6d54ce88f505517cf55dac9661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=93=E6=B4=AA=E6=98=8C?= Date: Tue, 21 Jan 2025 15:40:04 +0800 Subject: [PATCH] Add sm4_cbc --- 0002-feat-Add-SM4-CBC.patch | 56 +++++++++++++++++++++++++++++++++++++ libssh2.spec | 10 ++++++- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 0002-feat-Add-SM4-CBC.patch diff --git a/0002-feat-Add-SM4-CBC.patch b/0002-feat-Add-SM4-CBC.patch new file mode 100644 index 0000000..5808f7a --- /dev/null +++ b/0002-feat-Add-SM4-CBC.patch @@ -0,0 +1,56 @@ +From 342f169bc75c4e2479402fd6b7da7fcb76d95e21 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=E5=BA=93=E6=B4=AA=E6=98=8C?= +Date: Tue, 21 Jan 2025 09:43:38 +0800 +Subject: [PATCH] add sm4-cbc + +--- + src/crypt.c | 15 +++++++++++++++ + src/openssl.h | 3 +++ + 2 files changed, 18 insertions(+) + +diff --git a/src/crypt.c b/src/crypt.c +index 9652e6c..001ed65 100644 +--- a/src/crypt.c ++++ b/src/crypt.c +@@ -348,9 +348,24 @@ static const LIBSSH2_CRYPT_METHOD libssh2_crypt_method_3des_cbc = { + }; + #endif + ++ ++static const LIBSSH2_CRYPT_METHOD libssh2_crypt_method_sm4_cbc = { ++ "sm4-cbc", ++ "", ++ 16, /* blocksize */ ++ 16, /* initial value length */ ++ 16, /* secret length */ ++ 0, /* flags */ ++ &crypt_init, ++ &crypt_encrypt, ++ &crypt_dtor, ++ _libssh2_cipher_sm4 ++}; ++ + /* These are the crypt methods that are available to be negotiated. Methods + towards the start are chosen in preference to ones further down the list. */ + static const LIBSSH2_CRYPT_METHOD *_libssh2_crypt_methods[] = { ++ &libssh2_crypt_method_sm4_cbc, + #if LIBSSH2_AES_GCM + &libssh2_crypt_method_aes256_gcm, + &libssh2_crypt_method_aes128_gcm, +diff --git a/src/openssl.h b/src/openssl.h +index b7652c0..a7ad1b3 100644 +--- a/src/openssl.h ++++ b/src/openssl.h +@@ -418,6 +418,9 @@ libssh2_curve_type; + #define _libssh2_cipher_cast5 EVP_cast5_cbc + #define _libssh2_cipher_3des EVP_des_ede3_cbc + ++/*GM SM4_CBC*/ ++#define _libssh2_cipher_sm4 EVP_sm4_cbc ++ + #ifdef HAVE_OPAQUE_STRUCTS + #define _libssh2_cipher_dtor(ctx) EVP_CIPHER_CTX_free(*(ctx)) + #else +-- +2.43.0 + diff --git a/libssh2.spec b/libssh2.spec index fd933df..0b072f6 100644 --- a/libssh2.spec +++ b/libssh2.spec @@ -1,6 +1,6 @@ Name: libssh2 Version: 1.11.0 -Release: 4 +Release: 5 Summary: A library implementing the SSH2 protocol License: BSD URL: https://www.libssh2.org/ @@ -18,6 +18,7 @@ Patch8: backport-buildconf-drop.patch Patch9: backport-Prevent-possible-double-free-of-hostkey.patch Patch10: backport-Fix-unstable-connections-over-nonblocking-sockets.patch Patch11: backport-session-support-server-banners-up-to-8192-bytes-was-256.patch +Patch12: 0002-feat-Add-SM4-CBC.patch BuildRequires: coreutils findutils /usr/bin/man zlib-devel BuildRequires: gcc make sed openssl-devel > 1:1.0.2 openssh-server @@ -97,6 +98,13 @@ echo "exit 0" > tests/mansyntax.sh %{_mandir}/man3/libssh2_*.3* %changelog +* Tue Jan 21 2025 hcku - 1.11.0-5 +- Type:feature +- ID:NA +- SUG:NA +- DESC:Add Kex Algorithm SM4_CBC + + * Tue Oct 29 2024 bitianyuan - 1.11.0-4 - Type:bugfix - ID:NA -- Gitee