126 Star 3 Fork 18

src-openEuler/libwd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0038-uadk_tool-support-sm4-ce-benchmark-test.patch 5.13 KB
一键复制 编辑 原始数据 按行查看 历史
JangShui Yang 提交于 2024-04-07 18:05 . libwd: update the source code
From 3ca60986407cfe3b1ddd264b0bfbe24d88856d71 Mon Sep 17 00:00:00 2001
From: Qi Tao <taoqi10@huawei.com>
Date: Mon, 11 Mar 2024 16:31:35 +0800
Subject: [PATCH 38/44] uadk_tool: support sm4 ce benchmark test
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Support performance test for sm4-ce. Add CBC-CS1、CBC-CS2
and CBC-CS3 mode for SM4 algorithm in benchmark tool.
Signed-off-by: Qi Tao <taoqi10@huawei.com>
---
uadk_tool/benchmark/sec_uadk_benchmark.c | 25 ++++++++++++++++++++++++
uadk_tool/benchmark/sec_wd_benchmark.c | 18 +++++++++++++++++
uadk_tool/benchmark/uadk_benchmark.c | 11 ++++++++++-
uadk_tool/benchmark/uadk_benchmark.h | 4 ++++
4 files changed, 57 insertions(+), 1 deletion(-)
diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c
index c3da616..f8b19ba 100644
--- a/uadk_tool/benchmark/sec_uadk_benchmark.c
+++ b/uadk_tool/benchmark/sec_uadk_benchmark.c
@@ -346,6 +346,24 @@ static int sec_uadk_param_parse(thread_data *tddata, struct acc_option *options)
mode = WD_CIPHER_CBC;
alg = WD_CIPHER_SM4;
break;
+ case SM4_128_CBC_CS1:
+ keysize = 16;
+ ivsize = 16;
+ mode = WD_CIPHER_CBC_CS1;
+ alg = WD_CIPHER_SM4;
+ break;
+ case SM4_128_CBC_CS2:
+ keysize = 16;
+ ivsize = 16;
+ mode = WD_CIPHER_CBC_CS2;
+ alg = WD_CIPHER_SM4;
+ break;
+ case SM4_128_CBC_CS3:
+ keysize = 16;
+ ivsize = 16;
+ mode = WD_CIPHER_CBC_CS3;
+ alg = WD_CIPHER_SM4;
+ break;
case SM4_128_CTR:
keysize = 16;
ivsize = 16;
@@ -673,6 +691,7 @@ static void uninit_ctx_config2(int subtype)
/* uninit2 */
switch(subtype) {
case CIPHER_TYPE:
+ case CIPHER_INSTR_TYPE:
wd_cipher_uninit2();
break;
case AEAD_TYPE:
@@ -707,6 +726,11 @@ static int init_ctx_config2(struct acc_option *options)
if (ret)
SEC_TST_PRT("failed to do cipher init2!\n");
break;
+ case CIPHER_INSTR_TYPE:
+ ret = wd_cipher_init2(alg_name, SCHED_POLICY_NONE, TASK_INSTR);
+ if (ret)
+ SEC_TST_PRT("failed to do cipher intruction init2!\n");
+ break;
case AEAD_TYPE:
ret = wd_aead_init2(alg_name, SCHED_POLICY_RR, TASK_HW);
if (ret)
@@ -1542,6 +1566,7 @@ int sec_uadk_sync_threads(struct acc_option *options)
switch (options->subtype) {
case CIPHER_TYPE:
+ case CIPHER_INSTR_TYPE:
uadk_sec_sync_run = sec_uadk_cipher_sync;
break;
case AEAD_TYPE:
diff --git a/uadk_tool/benchmark/sec_wd_benchmark.c b/uadk_tool/benchmark/sec_wd_benchmark.c
index 2ed8493..bb47d61 100644
--- a/uadk_tool/benchmark/sec_wd_benchmark.c
+++ b/uadk_tool/benchmark/sec_wd_benchmark.c
@@ -412,6 +412,24 @@ static int sec_wd_param_parse(thread_data *tddata, struct acc_option *options)
mode = WCRYPTO_CIPHER_CBC;
alg = WCRYPTO_CIPHER_SM4;
break;
+ case SM4_128_CBC_CS1:
+ keysize = 16;
+ ivsize = 16;
+ mode = WCRYPTO_CIPHER_CBC_CS1;
+ alg = WCRYPTO_CIPHER_SM4;
+ break;
+ case SM4_128_CBC_CS2:
+ keysize = 16;
+ ivsize = 16;
+ mode = WCRYPTO_CIPHER_CBC_CS2;
+ alg = WCRYPTO_CIPHER_SM4;
+ break;
+ case SM4_128_CBC_CS3:
+ keysize = 16;
+ ivsize = 16;
+ mode = WCRYPTO_CIPHER_CBC_CS3;
+ alg = WCRYPTO_CIPHER_SM4;
+ break;
case SM4_128_CTR:
keysize = 16;
ivsize = 16;
diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c
index 9c025cf..f9bb69c 100644
--- a/uadk_tool/benchmark/uadk_benchmark.c
+++ b/uadk_tool/benchmark/uadk_benchmark.c
@@ -120,6 +120,9 @@ static struct acc_alg_item alg_options[] = {
{"3des-192-cbc", DES3_192_CBC},
{"sm4-128-ecb", SM4_128_ECB},
{"sm4-128-cbc", SM4_128_CBC},
+ {"sm4-128-cbc-cs1", SM4_128_CBC_CS1},
+ {"sm4-128-cbc-cs2", SM4_128_CBC_CS2},
+ {"sm4-128-cbc-cs3", SM4_128_CBC_CS3},
{"sm4-128-ctr", SM4_128_CTR},
{"sm4-128-ofb", SM4_128_OFB},
{"sm4-128-cfb", SM4_128_CFB},
@@ -209,6 +212,9 @@ static struct acc_alg_item alg_name_options[] = {
{"cbc(des3_ede)", DES3_192_CBC},
{"ecb(sm4)", SM4_128_ECB},
{"cbc(sm4)", SM4_128_CBC},
+ {"cbc-cs1(sm4)", SM4_128_CBC_CS1},
+ {"cbc-cs2(sm4)", SM4_128_CBC_CS2},
+ {"cbc-cs3(sm4)", SM4_128_CBC_CS3},
{"ctr(sm4)", SM4_128_CTR},
{"ofb(sm4)", SM4_128_OFB},
{"cfb(sm4)", SM4_128_CFB},
@@ -476,8 +482,11 @@ static void parse_alg_param(struct acc_option *option)
option->subtype = ECDSA_TYPE;
} else if (option->algtype <= SM4_128_XTS_GB) {
snprintf(option->algclass, MAX_ALG_NAME, "%s", "cipher");
+ if (option->modetype == INSTR_MODE)
+ option->subtype = CIPHER_INSTR_TYPE;
+ else
+ option->subtype = CIPHER_TYPE;
option->acctype = SEC_TYPE;
- option->subtype = CIPHER_TYPE;
} else if (option->algtype <= SM4_128_GCM) {
snprintf(option->algclass, MAX_ALG_NAME, "%s", "aead");
option->acctype = SEC_TYPE;
diff --git a/uadk_tool/benchmark/uadk_benchmark.h b/uadk_tool/benchmark/uadk_benchmark.h
index e370d3e..ea8e437 100644
--- a/uadk_tool/benchmark/uadk_benchmark.h
+++ b/uadk_tool/benchmark/uadk_benchmark.h
@@ -105,6 +105,7 @@ enum alg_type {
X25519_TYPE,
X448_TYPE,
DIGEST_INSTR_TYPE,
+ CIPHER_INSTR_TYPE,
};
enum sync_type {
@@ -172,6 +173,9 @@ enum test_alg {
DES3_192_CBC,
SM4_128_ECB,
SM4_128_CBC,
+ SM4_128_CBC_CS1,
+ SM4_128_CBC_CS2,
+ SM4_128_CBC_CS3,
SM4_128_CTR,
SM4_128_OFB,
SM4_128_CFB,
--
2.25.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/libwd.git
git@gitee.com:src-openeuler/libwd.git
src-openeuler
libwd
libwd
master

搜索帮助