From db5e618dee75e513a66528083298fe967ec02937 Mon Sep 17 00:00:00 2001 From: wuliaokanke Date: Mon, 12 Dec 2022 11:46:07 +0800 Subject: [PATCH 1/2] add sm4 ctr/ofb/cfb --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 1a746ea..bf9b7d5 100644 --- a/build.sh +++ b/build.sh @@ -15,9 +15,9 @@ function main() make -j make install cd ../kae_engine - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig + export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig autoreconf -i - ./configure --libdir=/usr/local/lib/engines-1.1/ --enable-kae + ./configure --libdir=/usr/local/lib/engines-1.1/ make -j make install elif [ "$1" = "cleanup" ];then -- Gitee From 32639a432197d9c36739d586713902da19c0ccd2 Mon Sep 17 00:00:00 2001 From: wuliaokanke Date: Mon, 12 Dec 2022 14:53:14 +0800 Subject: [PATCH 2/2] add kae2 v2 sm4 ctr cfb ofb --- build.sh | 2 +- kae_engine/src/uadk_cipher.c | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index bf9b7d5..4fb801b 100644 --- a/build.sh +++ b/build.sh @@ -15,7 +15,7 @@ function main() make -j make install cd ../kae_engine - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig + export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig autoreconf -i ./configure --libdir=/usr/local/lib/engines-1.1/ make -j diff --git a/kae_engine/src/uadk_cipher.c b/kae_engine/src/uadk_cipher.c index cc06429..59d8e2b 100644 --- a/kae_engine/src/uadk_cipher.c +++ b/kae_engine/src/uadk_cipher.c @@ -91,6 +91,9 @@ static int cipher_hw_v2_nids[] = { NID_des_ede3_cbc, NID_des_ede3_ecb, NID_sm4_ecb, + NID_sm4_cfb128, + NID_sm4_ofb128, + NID_sm4_ctr, 0, }; @@ -1007,7 +1010,18 @@ static int bind_v2_cipher(void) sizeof(struct cipher_priv_ctx), uadk_e_cipher_init, uadk_e_do_cipher, uadk_e_cipher_cleanup, EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv); - + UADK_CIPHER_DESCR(sm4_ofb128, 1, 16, 16, EVP_CIPH_OFB_MODE, + sizeof(struct cipher_priv_ctx), uadk_e_cipher_init, + uadk_e_do_cipher, uadk_e_cipher_cleanup, + EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv); + UADK_CIPHER_DESCR(sm4_cfb128, 1, 16, 16, EVP_CIPH_OFB_MODE, + sizeof(struct cipher_priv_ctx), uadk_e_cipher_init, + uadk_e_do_cipher, uadk_e_cipher_cleanup, + EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv); + UADK_CIPHER_DESCR(sm4_ctr, 1, 16, 16, EVP_CIPH_CTR_MODE, + sizeof(struct cipher_priv_ctx), uadk_e_cipher_init, + uadk_e_do_cipher, uadk_e_cipher_cleanup, + EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv); return 0; } @@ -1061,8 +1075,7 @@ static int bind_v3_cipher(void) sizeof(struct cipher_priv_ctx), uadk_e_cipher_init, uadk_e_do_cipher, uadk_e_cipher_cleanup, EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv); - - return 0; + return 0; } int uadk_e_bind_cipher(ENGINE *e) -- Gitee