xtest:Rename --sha-perf to --hash-perf and add SM3
Rename --sha-perf to --hash-perf and add SM3
Signed-off-by: yuzexi <yuzexi@hisilicon.com>
Reviewed-by: Xiaoxu Zeng <zengxiaoxu@huawei.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: wangyuan <wangyuan46@huawei.com>
diff --git a/host/xtest/CMakeLists.txt b/host/xtest/CMakeLists.txt
index 320d336..776787b 100644
--- a/host/xtest/CMakeLists.txt
+++ b/host/xtest/CMakeLists.txt
@@ -55,7 +55,7 @@
regression_6000.c
regression_8000.c
regression_8100.c
- sha_perf.c
+ hash_perf.c
stats.c
xtest_helpers.c
xtest_main.c
diff --git a/host/xtest/Makefile b/host/xtest/Makefile
index 36c7e3d..8505629 100644
--- a/host/xtest/Makefile
+++ b/host/xtest/Makefile
@@ -76,7 +76,7 @@
regression_6000.c \
regression_8000.c \
regression_8100.c \
- sha_perf.c \
+ hash_perf.c \
stats.c \
xtest_helpers.c \
xtest_main.c \
@@ -129,7 +129,7 @@
CFLAGS += -I../../ta/storage_benchmark/include
CFLAGS += -I../../ta/concurrent/include
CFLAGS += -I../../ta/concurrent_large/include
-CFLAGS += -I../../ta/sha_perf/include
+CFLAGS += -I../../ta/hash_perf/include
CFLAGS += -I../../ta/aes_perf/include
CFLAGS += -I../../ta/socket/include
CFLAGS += -I../../ta/sdp_basic/include
diff --git a/host/xtest/benchmark_2000.c b/host/xtest/benchmark_2000.c
index 83f3ea9..da9db74 100644
--- a/host/xtest/benchmark_2000.c
+++ b/host/xtest/benchmark_2000.c
@@ -33,7 +33,7 @@
size_t size = 1024; /* Buffer size */
int offset = 0; /* Buffer offset wrt. alloc'ed address */
- sha_perf_run_test(algo, size, CRYPTO_DEF_COUNT,
+ hash_perf_run_test(algo, size, CRYPTO_DEF_COUNT,
CRYPTO_DEF_LOOPS, CRYPTO_USE_RANDOM, offset,
CRYPTO_DEF_WARMUP, CRYPTO_DEF_VERBOSITY);
@@ -47,7 +47,7 @@
size_t size = 4096; /* Buffer size */
int offset = 0; /* Buffer offset wrt. alloc'ed address */
- sha_perf_run_test(algo, size, CRYPTO_DEF_COUNT,
+ hash_perf_run_test(algo, size, CRYPTO_DEF_COUNT,
CRYPTO_DEF_LOOPS, CRYPTO_USE_RANDOM, offset,
CRYPTO_DEF_WARMUP, CRYPTO_DEF_VERBOSITY);
diff --git a/host/xtest/crypto_common.h b/host/xtest/crypto_common.h
index 9117c90..68debea 100644
--- a/host/xtest/crypto_common.h
+++ b/host/xtest/crypto_common.h
@@ -8,9 +8,7 @@
#define XTEST_CRYPTO_COMMON_H
#include "ta_aes_perf.h"
-#include "ta_sha_perf.h"
-
-
+#include "ta_hash_perf.h"
#define AES_PERF_INPLACE 0
@@ -44,8 +42,8 @@
size_t unit, unsigned int n, unsigned int l,
int random_in, int in_place, int warmup, int verbosity);
-int sha_perf_runner_cmd_parser(int argc, char *argv[]);
-void sha_perf_run_test(int algo, size_t size, unsigned int n,
+int hash_perf_runner_cmd_parser(int argc, char *argv[]);
+void hash_perf_run_test(int algo, size_t size, unsigned int n,
unsigned int l, int random_in, int offset,
int warmup, int verbosity);
diff --git a/host/xtest/sha_perf.c b/host/xtest/hash_perf.c
similarity index 93%
rename from host/xtest/sha_perf.c
rename to host/xtest/hash_perf.c
index c9656d0..baeb5cc 100644
--- a/host/xtest/sha_perf.c
+++ b/host/xtest/hash_perf.c
@@ -52,7 +52,7 @@
static void open_ta(void)
{
TEEC_Result res = TEEC_ERROR_GENERIC;
- TEEC_UUID uuid = TA_SHA_PERF_UUID;
+ TEEC_UUID uuid = TA_HASH_PERF_UUID;
uint32_t err_origin = 0;
res = TEEC_InitializeContext(NULL, &ctx);
@@ -118,6 +118,8 @@
return "SHA384";
case TA_SHA_SHA512:
return "SHA512";
+ case TA_SM3:
+ return "SM3";
default:
return "???";
}
@@ -136,6 +138,8 @@
return 48;
case TA_SHA_SHA512:
return 64;
+ case TA_SM3:
+ return 32;
default:
return 0;
}
@@ -144,7 +148,6 @@
#define _TO_STR(x) #x
#define TO_STR(x) _TO_STR(x)
-
static void alloc_shm(size_t sz, uint32_t algo, int offset)
{
TEEC_Result res = TEEC_ERROR_GENERIC;
@@ -213,7 +216,7 @@
return ns;
}
-static uint64_t run_test_once(void *in, size_t size, int random_in,
+static uint64_t run_test_once(void *in, size_t size, int random_in,
TEEC_Operation *op)
{
struct timespec t0 = { };
@@ -225,7 +228,7 @@
read_random(in, size);
get_current_time(&t0);
- res = TEEC_InvokeCommand(&sess, TA_SHA_PERF_CMD_PROCESS, op,
+ res = TEEC_InvokeCommand(&sess, TA_HASH_PERF_CMD_PROCESS, op,
&ret_origin);
check_res(res, "TEEC_InvokeCommand", &ret_origin);
get_current_time(&t1);
@@ -242,7 +245,7 @@
op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE,
TEEC_NONE, TEEC_NONE);
op.params[0].value.a = algo;
- res = TEEC_InvokeCommand(&sess, TA_SHA_PERF_CMD_PREPARE_OP, &op,
+ res = TEEC_InvokeCommand(&sess, TA_HASH_PERF_CMD_PREPARE_OP, &op,
&ret_origin);
check_res(res, "TEEC_InvokeCommand", &ret_origin);
}
@@ -283,7 +286,7 @@
* warmup - Start with a-second busy loop
* verbosity - Verbosity level
* */
-extern void sha_perf_run_test(int algo, size_t size, unsigned int n,
+extern void hash_perf_run_test(int algo, size_t size, unsigned int n,
unsigned int l, int random_in, int offset,
int warmup, int verbosity)
{
@@ -294,7 +297,7 @@
struct timespec ts = { };
double sd = 0;
- vverbose("sha-perf\n");
+ vverbose("hash-perf\n");
if (clock_getres(CLOCK_MONOTONIC, &ts) < 0) {
perror("clock_getres");
return;
@@ -357,10 +360,10 @@
fprintf(stderr, "Usage: %s [-h]\n", progname);
fprintf(stderr, "Usage: %s [-a ALGO] [-l LOOP] [-n LOOP] [-r] [-s SIZE]", progname);
fprintf(stderr, " [-v [-v]] [-w SEC]\n");
- fprintf(stderr, "SHA performance testing tool for OP-TEE\n");
+ fprintf(stderr, "Hash performance testing tool for OP-TEE\n");
fprintf(stderr, "\n");
fprintf(stderr, "Options:\n");
- fprintf(stderr, " -a ALGO Algorithm (SHA1, SHA224, SHA256, SHA384, SHA512) [%s]\n", algo_str(algo));
+ fprintf(stderr, " -a ALGO Algorithm (SHA1, SHA224, SHA256, SHA384, SHA512, SM3) [%s]\n", algo_str(algo));
fprintf(stderr, " -h|--help Print this help and exit\n");
fprintf(stderr, " -l LOOP Inner loop iterations (TA calls TEE_DigestDoFinal() <x> times) [%u]\n", l);
fprintf(stderr, " -n LOOP Outer test loop iterations [%u]\n", n);
@@ -381,9 +384,7 @@
} \
} while (0);
-
-
-extern int sha_perf_runner_cmd_parser(int argc, char *argv[])
+extern int hash_perf_runner_cmd_parser(int argc, char *argv[])
{
int i = 0;
/* Command line params */
@@ -421,6 +422,8 @@
algo = TA_SHA_SHA384;
else if (!strcasecmp(argv[i], "SHA512"))
algo = TA_SHA_SHA512;
+ else if (!strcasecmp(argv[i], "SM3"))
+ algo = TA_SM3;
else {
fprintf(stderr, "%s, invalid algorithm\n",
argv[0]);
@@ -453,7 +456,7 @@
}
}
- sha_perf_run_test(algo, size, n, l, random_in, offset, warmup, verbosity);
+ hash_perf_run_test(algo, size, n, l, random_in, offset, warmup, verbosity);
return 0;
}
diff --git a/host/xtest/xtest_main.c b/host/xtest/xtest_main.c
index c61f4db..9771ae0 100644
--- a/host/xtest/xtest_main.c
+++ b/host/xtest/xtest_main.c
@@ -98,7 +98,8 @@
printf("\t run. A substring match is performed. May be\n");
printf("\t specified several times.\n");
printf("applets:\n");
- printf("\t--sha-perf [opts] SHA performance testing tool (-h for usage)\n");
+ printf("\t--sha-perf [opts] Deprecated, same as --hash-perf\n");
+ printf("\t--hash-perf [opts] Hash performance testing tool (-h for usage)\n");
printf("\t--aes-perf [opts] AES performance testing tool (-h for usage)\n");
#ifdef CFG_SECSTOR_TA_MGMT_PTA
printf("\t--install-ta [directory or list of TAs]\n");
@@ -153,7 +154,9 @@
init_ossl();
if (argc > 1 && !strcmp(argv[1], "--sha-perf"))
- return sha_perf_runner_cmd_parser(argc-1, &argv[1]);
+ return hash_perf_runner_cmd_parser(argc-1, &argv[1]);
+ else if (argc > 1 && !strcmp(argv[1], "--hash-perf"))
+ return hash_perf_runner_cmd_parser(argc-1, &argv[1]);
else if (argc > 1 && !strcmp(argv[1], "--aes-perf"))
return aes_perf_runner_cmd_parser(argc-1, &argv[1]);
#ifdef CFG_SECSTOR_TA_MGMT_PTA