diff options
author | yuzexi <yuzexi@hisilicon.com> | 2022-11-24 15:42:34 +0800 |
---|---|---|
committer | Jérôme Forissier <jerome@forissier.org> | 2022-12-01 09:27:55 +0100 |
commit | 4c9b16a727941a8cc697c17a2c3f7745e41d717b (patch) | |
tree | d08c4ceb800607b6bfc633e49f2b2b000201279d | |
parent | dd336daac37e7a9e6694b2e3951f6cbed7fd5bc4 (diff) |
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>
-rw-r--r-- | Android.mk | 4 | ||||
-rw-r--r-- | host/xtest/CMakeLists.txt | 2 | ||||
-rw-r--r-- | host/xtest/Makefile | 4 | ||||
-rw-r--r-- | host/xtest/benchmark_2000.c | 4 | ||||
-rw-r--r-- | host/xtest/crypto_common.h | 8 | ||||
-rw-r--r-- | host/xtest/hash_perf.c (renamed from host/xtest/sha_perf.c) | 29 | ||||
-rw-r--r-- | host/xtest/xtest_main.c | 7 | ||||
-rw-r--r-- | ta/CMakeLists.txt | 2 | ||||
-rw-r--r-- | ta/Makefile | 4 | ||||
-rw-r--r-- | ta/hash_perf/Android.mk (renamed from ta/sha_perf/Android.mk) | 0 | ||||
-rw-r--r-- | ta/hash_perf/Makefile (renamed from ta/sha_perf/Makefile) | 0 | ||||
-rw-r--r-- | ta/hash_perf/include/ta_hash_perf.h (renamed from ta/sha_perf/include/ta_sha_perf.h) | 13 | ||||
-rw-r--r-- | ta/hash_perf/include/ta_hash_perf_priv.h (renamed from ta/sha_perf/include/ta_sha_perf_priv.h) | 6 | ||||
-rw-r--r-- | ta/hash_perf/include/user_ta_header_defines.h (renamed from ta/sha_perf/include/user_ta_header_defines.h) | 4 | ||||
-rw-r--r-- | ta/hash_perf/sub.mk (renamed from ta/sha_perf/sub.mk) | 2 | ||||
-rw-r--r-- | ta/hash_perf/ta_entry.c (renamed from ta/sha_perf/ta_entry.c) | 10 | ||||
-rw-r--r-- | ta/hash_perf/ta_hash_perf.c (renamed from ta/sha_perf/ta_sha_perf.c) | 25 |
17 files changed, 66 insertions, 58 deletions
@@ -51,7 +51,7 @@ srcs += adbg/src/adbg_case.c \ regression_6000.c \ regression_8000.c \ regression_8100.c \ - sha_perf.c \ + hash_perf.c \ stats.c \ xtest_helpers.c \ xtest_main.c \ @@ -107,7 +107,7 @@ LOCAL_C_INCLUDES += $(LOCAL_PATH)/host/xtest \ $(LOCAL_PATH)/ta/storage_benchmark/include \ $(LOCAL_PATH)/ta/concurrent/include \ $(LOCAL_PATH)/ta/concurrent_large/include \ - $(LOCAL_PATH)/ta/sha_perf/include \ + $(LOCAL_PATH)/ta/hash_perf/include \ $(LOCAL_PATH)/ta/aes_perf/include \ $(LOCAL_PATH)/ta/socket/include \ $(LOCAL_PATH)/ta/sdp_basic/include \ 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 @@ set (SRC 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 @@ srcs += adbg/src/adbg_case.c \ 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/sims_keepalive/include 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 @@ static void xtest_tee_benchmark_2001(ADBG_Case_t *c) 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 @@ static void xtest_tee_benchmark_2002(ADBG_Case_t *c) 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 @@ void aes_perf_run_test(int mode, int keysize, int decrypt, size_t size, 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 index c9656d0..baeb5cc 100644 --- a/host/xtest/sha_perf.c +++ b/host/xtest/hash_perf.c @@ -52,7 +52,7 @@ static void check_res(TEEC_Result res, const char *errmsg, uint32_t *orig) 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 @@ static const char *algo_str(uint32_t algo) return "SHA384"; case TA_SHA_SHA512: return "SHA512"; + case TA_SM3: + return "SM3"; default: return "???"; } @@ -136,6 +138,8 @@ static int hash_size(uint32_t algo) return 48; case TA_SHA_SHA512: return 64; + case TA_SM3: + return 32; default: return 0; } @@ -144,7 +148,6 @@ static int hash_size(uint32_t algo) #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 @@ static uint64_t timespec_diff_ns(struct timespec *start, struct timespec *end) 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 @@ static uint64_t run_test_once(void *in, size_t size, int random_in, 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 @@ static void prepare_op(int algo) 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 @@ static double mb_per_sec(size_t size, double usec) * 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 @@ extern void sha_perf_run_test(int algo, size_t size, unsigned int n, 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 @@ static void usage(const char *progname, 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 @@ static void usage(const char *progname, } \ } 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 @@ extern int sha_perf_runner_cmd_parser(int argc, char *argv[]) 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 @@ extern int sha_perf_runner_cmd_parser(int argc, char *argv[]) } } - 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 @@ void usage(char *program) 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 @@ int main(int argc, char *argv[]) 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 diff --git a/ta/CMakeLists.txt b/ta/CMakeLists.txt index 044d41a..9301067 100644 --- a/ta/CMakeLists.txt +++ b/ta/CMakeLists.txt @@ -13,7 +13,7 @@ target_include_directories(${PROJECT_NAME} INTERFACE os_test/include INTERFACE rpc_test/include INTERFACE sdp_basic/include - INTERFACE sha_perf/include + INTERFACE hash_perf/include INTERFACE sims/include INTERFACE miss/include INTERFACE sims_keepalive/include diff --git a/ta/Makefile b/ta/Makefile index 20f22e6..aca2c88 100644 --- a/ta/Makefile +++ b/ta/Makefile @@ -28,7 +28,7 @@ TA_DIRS := create_fail_test \ concurrent \ concurrent_large \ storage_benchmark \ - sha_perf \ + hash_perf \ aes_perf \ socket \ supp_plugin \ @@ -46,7 +46,7 @@ endif all: ta .PHONY: ta -ta: +ta: $(q)$(foreach dir,$(TA_DIRS), $(MAKE) -C $(dir) O=$(out-dir)/ta/$(dir) &&) true # remove build directories including ta/<ta-name>/ directories. diff --git a/ta/sha_perf/Android.mk b/ta/hash_perf/Android.mk index 6469095..6469095 100644 --- a/ta/sha_perf/Android.mk +++ b/ta/hash_perf/Android.mk diff --git a/ta/sha_perf/Makefile b/ta/hash_perf/Makefile index c6e15a4..c6e15a4 100644 --- a/ta/sha_perf/Makefile +++ b/ta/hash_perf/Makefile diff --git a/ta/sha_perf/include/ta_sha_perf.h b/ta/hash_perf/include/ta_hash_perf.h index 80ad41e..e997698 100644 --- a/ta/sha_perf/include/ta_sha_perf.h +++ b/ta/hash_perf/include/ta_hash_perf.h @@ -4,18 +4,18 @@ * All rights reserved. */ -#ifndef TA_SHA_PERF_H -#define TA_SHA_PERF_H +#ifndef TA_HASH_PERF_H +#define TA_HASH_PERF_H -#define TA_SHA_PERF_UUID { 0x614789f2, 0x39c0, 0x4ebf, \ +#define TA_HASH_PERF_UUID { 0x614789f2, 0x39c0, 0x4ebf, \ { 0xb2, 0x35, 0x92, 0xb3, 0x2a, 0xc1, 0x07, 0xed } } /* * Commands implemented by the TA */ -#define TA_SHA_PERF_CMD_PREPARE_OP 0 -#define TA_SHA_PERF_CMD_PROCESS 1 +#define TA_HASH_PERF_CMD_PREPARE_OP 0 +#define TA_HASH_PERF_CMD_PROCESS 1 /* * Supported algorithms @@ -26,5 +26,6 @@ #define TA_SHA_SHA256 2 #define TA_SHA_SHA384 3 #define TA_SHA_SHA512 4 +#define TA_SM3 5 -#endif /* TA_SHA_PERF_H */ +#endif /* TA_HASH_PERF_H */ diff --git a/ta/sha_perf/include/ta_sha_perf_priv.h b/ta/hash_perf/include/ta_hash_perf_priv.h index d0f583d..b9059b4 100644 --- a/ta/sha_perf/include/ta_sha_perf_priv.h +++ b/ta/hash_perf/include/ta_hash_perf_priv.h @@ -4,8 +4,8 @@ * All rights reserved. */ -#ifndef TA_SHA_PERF_PRIV_H -#define TA_SHA_PERF_PRIV_H +#ifndef TA_HASH_PERF_PRIV_H +#define TA_HASH_PERF_PRIV_H #include <tee_api.h> @@ -13,4 +13,4 @@ TEE_Result cmd_prepare_op(uint32_t param_types, TEE_Param params[4]); TEE_Result cmd_process(uint32_t param_types, TEE_Param params[4]); void cmd_clean_res(void); -#endif /* TA_SHA_PERF_PRIV_H */ +#endif /* TA_HASH_PERF_PRIV_H */ diff --git a/ta/sha_perf/include/user_ta_header_defines.h b/ta/hash_perf/include/user_ta_header_defines.h index 639ebb7..494afc0 100644 --- a/ta/sha_perf/include/user_ta_header_defines.h +++ b/ta/hash_perf/include/user_ta_header_defines.h @@ -7,9 +7,9 @@ #ifndef USER_TA_HEADER_DEFINES_H #define USER_TA_HEADER_DEFINES_H -#include "ta_sha_perf.h" +#include "ta_hash_perf.h" -#define TA_UUID TA_SHA_PERF_UUID +#define TA_UUID TA_HASH_PERF_UUID #define TA_FLAGS (TA_FLAG_USER_MODE | TA_FLAG_EXEC_DDR) #define TA_STACK_SIZE (2 * 1024) diff --git a/ta/sha_perf/sub.mk b/ta/hash_perf/sub.mk index c0aa4b6..d7d5236 100644 --- a/ta/sha_perf/sub.mk +++ b/ta/hash_perf/sub.mk @@ -1,3 +1,3 @@ global-incdirs-y += include -srcs-y += ta_sha_perf.c +srcs-y += ta_hash_perf.c srcs-y += ta_entry.c diff --git a/ta/sha_perf/ta_entry.c b/ta/hash_perf/ta_entry.c index e61eab7..167c7de 100644 --- a/ta/sha_perf/ta_entry.c +++ b/ta/hash_perf/ta_entry.c @@ -6,8 +6,8 @@ #include <tee_ta_api.h> -#include "ta_sha_perf.h" -#include "ta_sha_perf_priv.h" +#include "ta_hash_perf.h" +#include "ta_hash_perf_priv.h" /* * Trusted Application Entry Points @@ -39,7 +39,7 @@ TEE_Result TA_OpenSessionEntryPoint(uint32_t nParamTypes, void TA_CloseSessionEntryPoint(void *pSessionContext) { (void)pSessionContext; - + cmd_clean_res(); } @@ -51,10 +51,10 @@ TEE_Result TA_InvokeCommandEntryPoint(void *pSessionContext, (void)pSessionContext; switch (nCommandID) { - case TA_SHA_PERF_CMD_PREPARE_OP: + case TA_HASH_PERF_CMD_PREPARE_OP: return cmd_prepare_op(nParamTypes, pParams); - case TA_SHA_PERF_CMD_PROCESS: + case TA_HASH_PERF_CMD_PROCESS: return cmd_process(nParamTypes, pParams); default: diff --git a/ta/sha_perf/ta_sha_perf.c b/ta/hash_perf/ta_hash_perf.c index 01083df..4da8369 100644 --- a/ta/sha_perf/ta_sha_perf.c +++ b/ta/hash_perf/ta_hash_perf.c @@ -9,17 +9,17 @@ #include <string.h> #include <trace.h> -#include "ta_sha_perf.h" -#include "ta_sha_perf_priv.h" - -#define CHECK(res, name, action) do { \ - if ((res) != TEE_SUCCESS) { \ - DMSG(name ": 0x%08x", (res)); \ - action \ - } \ +#include "ta_hash_perf.h" +#include "ta_hash_perf_priv.h" + +#define CHECK(res, name, action) do { \ + if ((res) != TEE_SUCCESS) { \ + DMSG(name ": %#08"PRIx32, (res));\ + action \ + } \ } while(0) -static TEE_OperationHandle digest_op = NULL; +static TEE_OperationHandle digest_op; TEE_Result cmd_process(uint32_t param_types, TEE_Param params[4]) { @@ -49,6 +49,7 @@ TEE_Result cmd_process(uint32_t param_types, TEE_Param params[4]) res = TEE_DigestDoFinal(digest_op, in, insz, out, &outsz); CHECK(res, "TEE_DigestDoFinal", return res;); } + return TEE_SUCCESS; } @@ -80,6 +81,9 @@ TEE_Result cmd_prepare_op(uint32_t param_types, TEE_Param params[4]) case TA_SHA_SHA512: algo = TEE_ALG_SHA512; break; + case TA_SM3: + algo = TEE_ALG_SM3; + break; default: return TEE_ERROR_BAD_PARAMETERS; } @@ -93,9 +97,8 @@ TEE_Result cmd_prepare_op(uint32_t param_types, TEE_Param params[4]) return TEE_SUCCESS; } - void cmd_clean_res(void) { if (digest_op) - TEE_FreeOperation(digest_op); + TEE_FreeOperation(digest_op); } |