Backport uadk engine patch from linaro. Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com> (cherry picked from commit 4f6b3e8022834a09849728415c9ea73d7fdb794a)
91 lines
2.7 KiB
Diff
91 lines
2.7 KiB
Diff
From 2dc0aa3a544afd4861656f4e876e287aa3ead9b9 Mon Sep 17 00:00:00 2001
|
|
From: Kai Ye <yekai13@huawei.com>
|
|
Date: Tue, 8 Mar 2022 16:15:32 +0800
|
|
Subject: [PATCH 34/36] cipher: support the sm4-ecb alg
|
|
|
|
the uadk sdk layer has supported the sm4-ecb alg. Kunpeng 920
|
|
supports the sm4-ecb by new chip fs.
|
|
|
|
Signed-off-by: Kai Ye <yekai13@huawei.com>
|
|
---
|
|
src/uadk_cipher.c | 15 ++++++++-------
|
|
src/v1/alg/ciphers/sec_ciphers.c | 1 +
|
|
2 files changed, 9 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/src/uadk_cipher.c b/src/uadk_cipher.c
|
|
index 8f8af7e..e4595be 100644
|
|
--- a/src/uadk_cipher.c
|
|
+++ b/src/uadk_cipher.c
|
|
@@ -87,6 +87,7 @@ static int cipher_920_nids[] = {
|
|
NID_sm4_cbc,
|
|
NID_des_ede3_cbc,
|
|
NID_des_ede3_ecb,
|
|
+ NID_sm4_ecb,
|
|
0,
|
|
};
|
|
|
|
@@ -103,7 +104,6 @@ static int cipher_930_nids[] = {
|
|
NID_aes_128_xts,
|
|
NID_aes_256_xts,
|
|
NID_sm4_cbc,
|
|
- NID_sm4_ecb,
|
|
NID_des_ede3_cbc,
|
|
NID_des_ede3_ecb,
|
|
NID_aes_128_cfb128,
|
|
@@ -984,6 +984,11 @@ 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_ecb, 16, 16, 16, EVP_CIPH_ECB_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;
|
|
}
|
|
|
|
@@ -1037,10 +1042,6 @@ 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);
|
|
- UADK_CIPHER_DESCR(sm4_ecb, 16, 16, 16, EVP_CIPH_ECB_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;
|
|
}
|
|
@@ -1088,6 +1089,8 @@ static void destroy_v2_cipher(void)
|
|
uadk_des_ede3_cbc = 0;
|
|
EVP_CIPHER_meth_free(uadk_des_ede3_ecb);
|
|
uadk_des_ede3_ecb = 0;
|
|
+ EVP_CIPHER_meth_free(uadk_sm4_ecb);
|
|
+ uadk_sm4_ecb = 0;
|
|
}
|
|
|
|
static void destroy_v3_cipher(void)
|
|
@@ -1116,8 +1119,6 @@ static void destroy_v3_cipher(void)
|
|
uadk_sm4_ofb128 = 0;
|
|
EVP_CIPHER_meth_free(uadk_sm4_ctr);
|
|
uadk_sm4_ctr = 0;
|
|
- EVP_CIPHER_meth_free(uadk_sm4_ecb);
|
|
- uadk_sm4_ecb = 0;
|
|
}
|
|
|
|
void uadk_e_destroy_cipher(void)
|
|
diff --git a/src/v1/alg/ciphers/sec_ciphers.c b/src/v1/alg/ciphers/sec_ciphers.c
|
|
index 2c619be..b4743ed 100644
|
|
--- a/src/v1/alg/ciphers/sec_ciphers.c
|
|
+++ b/src/v1/alg/ciphers/sec_ciphers.c
|
|
@@ -85,6 +85,7 @@ static int g_known_cipher_nids[CIPHERS_COUNT] = {
|
|
NID_sm4_ctr,
|
|
NID_sm4_cbc,
|
|
NID_sm4_ofb128,
|
|
+ NID_sm4_ecb,
|
|
};
|
|
|
|
#define SEC_CIPHERS_RETURN_FAIL_IF(cond, mesg, ret) \
|
|
--
|
|
2.24.4
|
|
|