mirror of
https://github.com/openharmony/tee_tee_os_framework.git
synced 2026-07-01 07:22:28 -04:00
Delete some xts test cases
Signed-off-by: suwanghw <wangsu14@huawei.com>
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 3.14.1)
|
||||
|
||||
project(tee_test)
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/common.cmake)
|
||||
|
||||
add_subdirectory(ta)
|
||||
@@ -1,325 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
import("//test/xts/tools/lite/build/suite_lite.gni")
|
||||
|
||||
hcpptest_suite("tee_test_client_api") {
|
||||
suite_name = "acts"
|
||||
|
||||
tee_dev_kit_dir = "//base/tee/tee_dev_kit"
|
||||
tee_test_root_dir = "//base/tee/tee_os_framework/test/xts"
|
||||
sources = [
|
||||
tee_test_root_dir + "/utils/public_test/public_test.cpp",
|
||||
tee_test_root_dir + "/utils/session_mgr/client_session_mgr.cpp",
|
||||
|
||||
tee_test_root_dir + "/ca/client_api/src/initializecontext_test.cpp",
|
||||
tee_test_root_dir + "/ca/client_api/src/opensession_test.cpp",
|
||||
tee_test_root_dir + "/ca/client_api/src/invokecommand_test.cpp",
|
||||
tee_test_root_dir + "/ca/client_api/src/closesession_test.cpp",
|
||||
tee_test_root_dir + "/ca/client_api/src/finalizecontext_test.cpp",
|
||||
tee_test_root_dir + "/ca/client_api/src/allocatesharedmemory_test.cpp",
|
||||
tee_test_root_dir + "/ca/client_api/src/registersharedmemory_test.cpp",
|
||||
tee_test_root_dir + "/ca/client_api/src/releasesharedmemory_test.cpp",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
tee_dev_kit_dir + "/sdk/include/TA",
|
||||
tee_dev_kit_dir + "/sdk/thirdparty/open_source/libboundscheck/include/libhwsecurec",
|
||||
tee_dev_kit_dir + "/sdk/include/CA",
|
||||
|
||||
tee_test_root_dir + "/utils",
|
||||
tee_test_root_dir + "/utils/include",
|
||||
tee_test_root_dir + "/utils/public_test",
|
||||
tee_test_root_dir + "/utils/cmd_id",
|
||||
tee_test_root_dir + "/ca/client_api/common",
|
||||
|
||||
"//test/xts/tools/lite/hctest/include",
|
||||
"//third_party/googletest/googletest/include",
|
||||
"//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//base/tee/tee_client/frameworks/build/lite:libteec_vendor",
|
||||
"//third_party/bounds_checking_function:libsec_static",
|
||||
]
|
||||
|
||||
cflags = [ "-Wno-error" ]
|
||||
ldflags = [
|
||||
"-lstdc++",
|
||||
"-lm",
|
||||
"-lpthread",
|
||||
]
|
||||
}
|
||||
|
||||
hcpptest_suite("tee_test_tcf_api") {
|
||||
suite_name = "acts"
|
||||
|
||||
tee_dev_kit_dir = "//base/tee/tee_dev_kit"
|
||||
tee_test_root_dir = "//base/tee/tee_os_framework/test/xts"
|
||||
sources = [
|
||||
tee_test_root_dir + "/utils/public_test/public_test.cpp",
|
||||
tee_test_root_dir + "/utils/session_mgr/client_session_mgr.cpp",
|
||||
|
||||
tee_test_root_dir + "/ca/tcf_api/src/property/get_prop_as_identity_test.cpp",
|
||||
tee_test_root_dir + "/ca/tcf_api/src/property/get_prop_as_string_test.cpp",
|
||||
tee_test_root_dir + "/ca/tcf_api/src/property/get_prop_as_bool_test.cpp",
|
||||
tee_test_root_dir + "/ca/tcf_api/src/property/get_prop_as_u32_test.cpp",
|
||||
tee_test_root_dir + "/ca/tcf_api/src/property/get_prop_as_u64_test.cpp",
|
||||
tee_test_root_dir + "/ca/tcf_api/src/property/get_prop_as_binaryblock_test.cpp",
|
||||
tee_test_root_dir + "/ca/tcf_api/src/property/get_prop_as_uuid_test.cpp",
|
||||
tee_test_root_dir + "/ca/tcf_api/src/property/get_prop_with_enumerator_test.cpp",
|
||||
tee_test_root_dir + "/ca/tcf_api/src/mem/tee_malloc_test.cpp",
|
||||
tee_test_root_dir + "/ca/tcf_api/src/mem/tee_realloc_test.cpp",
|
||||
tee_test_root_dir + "/ca/tcf_api/src/mem/tee_memmove_test.cpp",
|
||||
tee_test_root_dir + "/ca/tcf_api/src/mem/tee_memfill_test.cpp",
|
||||
tee_test_root_dir + "/ca/tcf_api/src/mem/tee_free_test.cpp",
|
||||
tee_test_root_dir + "/ca/tcf_api/src/mem/tee_memcompare_test.cpp",
|
||||
tee_test_root_dir + "/ca/tcf_api/src/mem/tee_checkmemaccessrights_test.cpp",
|
||||
tee_test_root_dir + "/ca/tcf_api/src/mem/tee_instance_test.cpp",
|
||||
tee_test_root_dir + "/ca/tcf_api/src/other/internal_client_api_test.cpp",
|
||||
tee_test_root_dir + "/ca/tcf_api/src/other/tee_panic_test.cpp",
|
||||
tee_test_root_dir + "/ca/tcf_api/src/common_test.cpp",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
tee_dev_kit_dir + "/sdk/include/TA",
|
||||
tee_dev_kit_dir + "/sdk/thirdparty/open_source/libboundscheck/include/libhwsecurec",
|
||||
tee_dev_kit_dir + "/sdk/include/CA",
|
||||
|
||||
tee_test_root_dir + "/utils",
|
||||
tee_test_root_dir + "/utils/include",
|
||||
tee_test_root_dir + "/utils/public_test",
|
||||
tee_test_root_dir + "/utils/cmd_id",
|
||||
tee_test_root_dir + "/ca/tcf_api/common",
|
||||
|
||||
"//test/xts/tools/lite/hctest/include",
|
||||
"//third_party/googletest/googletest/include",
|
||||
"//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//base/tee/tee_client/frameworks/build/lite:libteec_vendor",
|
||||
"//third_party/bounds_checking_function:libsec_static",
|
||||
]
|
||||
|
||||
cflags = [ "-Wno-error" ]
|
||||
ldflags = [
|
||||
"-lstdc++",
|
||||
"-lm",
|
||||
"-lpthread",
|
||||
]
|
||||
}
|
||||
|
||||
hcpptest_suite("tee_test_time_api") {
|
||||
suite_name = "acts"
|
||||
|
||||
tee_dev_kit_dir = "//base/tee/tee_dev_kit"
|
||||
tee_test_root_dir = "//base/tee/tee_os_framework/test/xts"
|
||||
sources = [
|
||||
tee_test_root_dir + "/utils/public_test/public_test.cpp",
|
||||
tee_test_root_dir + "/utils/session_mgr/client_session_mgr.cpp",
|
||||
|
||||
tee_test_root_dir + "/ca/time_api/src/tee_test_time_api.cpp",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
tee_dev_kit_dir + "/sdk/include/TA",
|
||||
tee_dev_kit_dir + "/sdk/thirdparty/open_source/libboundscheck/include/libhwsecurec",
|
||||
tee_dev_kit_dir + "/sdk/include/CA",
|
||||
|
||||
tee_test_root_dir + "/utils",
|
||||
tee_test_root_dir + "/utils/include",
|
||||
tee_test_root_dir + "/utils/public_test",
|
||||
tee_test_root_dir + "/utils/cmd_id",
|
||||
tee_test_root_dir + "/ca/time_api/common",
|
||||
|
||||
"//test/xts/tools/lite/hctest/include",
|
||||
"//third_party/googletest/googletest/include",
|
||||
"//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//base/tee/tee_client/frameworks/build/lite:libteec_vendor",
|
||||
"//third_party/bounds_checking_function:libsec_static",
|
||||
]
|
||||
|
||||
cflags = [ "-Wno-error" ]
|
||||
ldflags = [
|
||||
"-lstdc++",
|
||||
"-lm",
|
||||
"-lpthread",
|
||||
]
|
||||
}
|
||||
|
||||
hcpptest_suite("tee_test_arithmetic_api") {
|
||||
suite_name = "acts"
|
||||
|
||||
tee_dev_kit_dir = "//base/tee/tee_dev_kit"
|
||||
tee_test_root_dir = "//base/tee/tee_os_framework/test/xts"
|
||||
sources = [
|
||||
tee_test_root_dir + "/utils/public_test/public_test.cpp",
|
||||
tee_test_root_dir + "/utils/session_mgr/client_session_mgr.cpp",
|
||||
|
||||
tee_test_root_dir + "/ca/arithmetic_api/src/tee_test_arithmetic_api.cpp",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
tee_dev_kit_dir + "/sdk/include/TA",
|
||||
tee_dev_kit_dir + "/sdk/thirdparty/open_source/libboundscheck/include/libhwsecurec",
|
||||
tee_dev_kit_dir + "/sdk/include/CA",
|
||||
|
||||
tee_test_root_dir + "/utils",
|
||||
tee_test_root_dir + "/utils/include",
|
||||
tee_test_root_dir + "/utils/public_test",
|
||||
tee_test_root_dir + "/utils/cmd_id",
|
||||
tee_test_root_dir + "/ca/arithmetic_api/common",
|
||||
|
||||
"//test/xts/tools/lite/hctest/include",
|
||||
"//third_party/googletest/googletest/include",
|
||||
"//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//base/tee/tee_client/frameworks/build/lite:libteec_vendor",
|
||||
"//third_party/bounds_checking_function:libsec_static",
|
||||
]
|
||||
|
||||
cflags = [ "-Wno-error" ]
|
||||
ldflags = [
|
||||
"-lstdc++",
|
||||
"-lm",
|
||||
"-lpthread",
|
||||
]
|
||||
}
|
||||
|
||||
hcpptest_suite("tee_test_crypto_api") {
|
||||
suite_name = "acts"
|
||||
|
||||
tee_dev_kit_dir = "//base/tee/tee_dev_kit"
|
||||
tee_test_root_dir = "//base/tee/tee_os_framework/test/xts"
|
||||
sources = [
|
||||
tee_test_root_dir + "/utils/public_test/public_test.cpp",
|
||||
tee_test_root_dir + "/utils/session_mgr/client_session_mgr.cpp",
|
||||
|
||||
tee_test_root_dir + "/ca/crypto_api/src/tee_test_crypto_api.cpp",
|
||||
tee_test_root_dir + "/ca/crypto_api/common/common_test.cpp",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
tee_dev_kit_dir + "/sdk/include/TA",
|
||||
tee_dev_kit_dir + "/sdk/thirdparty/open_source/libboundscheck/include/libhwsecurec",
|
||||
tee_dev_kit_dir + "/sdk/include/CA",
|
||||
|
||||
tee_test_root_dir + "/utils",
|
||||
tee_test_root_dir + "/utils/include",
|
||||
tee_test_root_dir + "/utils/public_test",
|
||||
tee_test_root_dir + "/utils/cmd_id",
|
||||
tee_test_root_dir + "/ca/crypto_api/common",
|
||||
|
||||
"//test/xts/tools/lite/hctest/include",
|
||||
"//third_party/googletest/googletest/include",
|
||||
"//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//base/tee/tee_client/frameworks/build/lite:libteec_vendor",
|
||||
"//third_party/bounds_checking_function:libsec_static",
|
||||
]
|
||||
|
||||
cflags = [ "-Wno-error" ]
|
||||
ldflags = [
|
||||
"-lstdc++",
|
||||
"-lm",
|
||||
"-lpthread",
|
||||
]
|
||||
}
|
||||
|
||||
hcpptest_suite("tee_test_drv") {
|
||||
suite_name = "acts"
|
||||
|
||||
tee_dev_kit_dir = "//base/tee/tee_dev_kit"
|
||||
tee_test_root_dir = "//base/tee/tee_os_framework/test/xts"
|
||||
sources = [
|
||||
tee_test_root_dir + "/utils/public_test/public_test.cpp",
|
||||
tee_test_root_dir + "/utils/session_mgr/client_session_mgr.cpp",
|
||||
|
||||
tee_test_root_dir + "/ca/tee_test_drv/src/tee_test_drv.cpp",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
tee_dev_kit_dir + "/sdk/include/TA",
|
||||
tee_dev_kit_dir + "/sdk/thirdparty/open_source/libboundscheck/include/libhwsecurec",
|
||||
tee_dev_kit_dir + "/sdk/include/CA",
|
||||
|
||||
tee_test_root_dir + "/utils",
|
||||
tee_test_root_dir + "/utils/include",
|
||||
tee_test_root_dir + "/utils/public_test",
|
||||
tee_test_root_dir + "/utils/cmd_id",
|
||||
tee_test_root_dir + "/ca/tee_test_drv/include",
|
||||
|
||||
"//test/xts/tools/lite/hctest/include",
|
||||
"//third_party/googletest/googletest/include",
|
||||
"//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//base/tee/tee_client/frameworks/build/lite:libteec_vendor",
|
||||
"//third_party/bounds_checking_function:libsec_static",
|
||||
]
|
||||
|
||||
cflags = [ "-Wno-error" ]
|
||||
ldflags = [
|
||||
"-lstdc++",
|
||||
"-lm",
|
||||
"-lpthread",
|
||||
]
|
||||
}
|
||||
|
||||
hcpptest_suite("tee_test_libc_api") {
|
||||
suite_name = "acts"
|
||||
|
||||
tee_dev_kit_dir = "//base/tee/tee_dev_kit"
|
||||
tee_test_root_dir = "//base/tee/tee_os_framework/test/xts"
|
||||
sources = [
|
||||
tee_test_root_dir + "/utils/public_test/public_test.cpp",
|
||||
tee_test_root_dir + "/utils/session_mgr/client_session_mgr.cpp",
|
||||
tee_test_root_dir + "/ca/libc_api/src/tee_test_libc_api.cpp",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
tee_dev_kit_dir + "/sdk/include/TA",
|
||||
tee_dev_kit_dir + "/sdk/thirdparty/open_source/libboundscheck/include/libhwsecurec",
|
||||
tee_dev_kit_dir + "/sdk/include/CA",
|
||||
|
||||
tee_test_root_dir + "/utils",
|
||||
tee_test_root_dir + "/utils/public_test",
|
||||
tee_test_root_dir + "/utils/cmd_id",
|
||||
tee_test_root_dir + "/utils/include",
|
||||
tee_test_root_dir + "/ca/libc_api/common",
|
||||
|
||||
"//test/xts/tools/lite/hctest/include",
|
||||
"//third_party/googletest/googletest/include",
|
||||
"//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//base/tee/tee_client/frameworks/build/lite:libteec_vendor",
|
||||
"//third_party/bounds_checking_function:libsec_static",
|
||||
]
|
||||
|
||||
cflags = [ "-Wno-error" ]
|
||||
ldflags = [
|
||||
"-lstdc++",
|
||||
"-lm",
|
||||
"-lpthread",
|
||||
]
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
|
||||
add_subdirectory(sample)
|
||||
add_subdirectory(client_api)
|
||||
add_subdirectory(tcf_api)
|
||||
add_subdirectory(tee_test_drv)
|
||||
add_subdirectory(arithmetic_api)
|
||||
add_subdirectory(time_api)
|
||||
add_subdirectory(crypto_api)
|
||||
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"description": "Config for tee test cases",
|
||||
"environment": [
|
||||
{
|
||||
"type": "device",
|
||||
"label": "ipcamera"
|
||||
}
|
||||
],
|
||||
"kits": [
|
||||
{
|
||||
"type": "MountKit",
|
||||
"server": "NfsServer",
|
||||
"mount": [
|
||||
{
|
||||
"source": "testcases/tee",
|
||||
"target": "/test_root/tee"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"driver": {
|
||||
"type": "CppTestLite",
|
||||
"execute": "/test_root/tee/tee_test_client_api.bin"
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
|
||||
|
||||
set(ca_sources)
|
||||
list(APPEND ca_sources
|
||||
src/tee_test_arithmetic_api.cpp
|
||||
)
|
||||
|
||||
ca_compile_pub(
|
||||
TEST_NAME
|
||||
arithmetic_api
|
||||
|
||||
SRC_LIST
|
||||
${ca_sources}
|
||||
|
||||
INCLUDE_DIRS
|
||||
common
|
||||
|
||||
COMPILE_OPTS
|
||||
COMPILE_DEFS
|
||||
)
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef __COMMON_TEST_H__
|
||||
#define __COMMON_TEST_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <tee_client_type.h>
|
||||
|
||||
#define ARITHMETIC_API_UUID \
|
||||
{ \
|
||||
0x9ac09588, 0xfed1, 0x4b1e, \
|
||||
{ \
|
||||
0xbb, 0x36, 0xd3, 0xe5, 0xa3, 0xf2, 0x6c, 0x39 \
|
||||
} \
|
||||
}
|
||||
|
||||
enum TEST_ARITHMETIC_API_CMD_ID {
|
||||
CMD_ID_TEST_BIG_INT_COMPUTE_FMM = 0,
|
||||
CMD_ID_TEST_BIG_INT_INIT_FMM_CONTEXT = 1,
|
||||
CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_FMM = 2,
|
||||
CMD_ID_TEST_BIG_INT_EXP_MOD = 3,
|
||||
CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_OCTET_STRING = 4,
|
||||
CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_S32 = 5,
|
||||
CMD_ID_TEST_BIG_INT_ADD_AND_SUB_MOD = 6,
|
||||
CMD_ID_TEST_BIG_INT_MUL_AND_INV_MOD = 7,
|
||||
CMD_ID_TEST_BIG_INT_MOD = 8,
|
||||
CMD_ID_TEST_BIG_INT_ADD_AND_SUB = 9,
|
||||
CMD_ID_TEST_BIG_INT_NEG = 10,
|
||||
CMD_ID_TEST_BIG_INT_MUL_AND_SQUARE = 11,
|
||||
CMD_ID_TEST_BIG_INT_DIV = 12,
|
||||
CMD_ID_TEST_BIG_INT_SHIFT_RIGHT = 13,
|
||||
CMD_ID_TEST_BIG_INT_GET_BIT = 14,
|
||||
CMD_ID_TEST_BIG_INT_GET_BIT_COUNT = 15,
|
||||
CMD_ID_TEST_BIG_INT_SET_BIT = 16,
|
||||
CMD_ID_TEST_BIG_INT_ASSIGN = 17,
|
||||
CMD_ID_TEST_BIG_INT_ABS = 18,
|
||||
CMD_ID_TEST_BIG_INT_RELATIVE_PRIME = 19,
|
||||
CMD_ID_TEST_BIG_INT_COMPUTE_EXTENTED_GCD = 20,
|
||||
CMD_ID_TEST_BIG_INT_IS_PROBABLE_PRIME = 21,
|
||||
CMD_ID_TEST_BIG_INT_CMP = 22,
|
||||
CMD_ID_TEST_BIG_INT_CMP_S32 = 23,
|
||||
CMD_ID_TEST_BIG_INT_INIT_FMM = 24,
|
||||
CMD_ID_TEST_BIG_INT_INIT = 25,
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,489 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <public_test.h>
|
||||
#include <test_log.h>
|
||||
#include <securec.h>
|
||||
#include <common_test.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <session_mgr/client_session_mgr.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
/**
|
||||
* @testcase.name : BigInt_ComputeFMM
|
||||
* @testcase.desc : test TEE_BigIntComputeFMM api
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_ComputeFMM, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_COMPUTE_FMM, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_InitFMMContext
|
||||
* @testcase.desc : test initialize context for FMM
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_InitFMMContext, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_INIT_FMM_CONTEXT, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_ConverterBetweenBigIntAndFMM
|
||||
* @testcase.desc : test converter between big int and FMM
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_ConverterBetweenBigIntAndFMM, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_FMM, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_ComputeExpMod
|
||||
* @testcase.desc : test TEE_BigIntExpMod api
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_ComputeExpMod, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_EXP_MOD, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_ConverterBetweenBigIntAndOctetString
|
||||
* @testcase.desc : test converter between big int and octet string
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_ConverterBetweenBigIntAndOctetString, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_OCTET_STRING, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_ComputeExpMod
|
||||
* @testcase.desc : test converter between big int and shortVal
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_ConverterBetweenBigIntAndShortVal, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_S32, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_AddAndSubMod
|
||||
* @testcase.desc : test compute add and sub mod
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_AddAndSubMod, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_ADD_AND_SUB_MOD, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_MulAndInvMod
|
||||
* @testcase.desc : test compute mul, square and inv mod
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_MulAndInvMod, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_MUL_AND_INV_MOD, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_InitMod
|
||||
* @testcase.desc : test TEE_BigIntMod api
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_InitMod, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_MOD, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_AddAndSub
|
||||
* @testcase.desc : test add and sub
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_AddAndSub, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_ADD_AND_SUB, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_Neg
|
||||
* @testcase.desc : test negate
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_Neg, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_NEG, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_MulAndSquare
|
||||
* @testcase.desc : test mul and square
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_MulAndSquare, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_MUL_AND_SQUARE, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_div
|
||||
* @testcase.desc : test div
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_div, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_DIV, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_ShiftRight
|
||||
* @testcase.desc : test shift right
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_ShiftRight, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_SHIFT_RIGHT, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_GetBit
|
||||
* @testcase.desc : test get bit
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_GetBit, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_GET_BIT, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_GetBitCount
|
||||
* @testcase.desc : test get bit counts
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_GetBitCount, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_GET_BIT_COUNT, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_SetBit
|
||||
* @testcase.desc : test set bit
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_SetBit, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_SET_BIT, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_AssignSrcToDest
|
||||
* @testcase.desc : test TEE_BigIntAssign api
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_AssignSrcToDest, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_ASSIGN, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_Abs
|
||||
* @testcase.desc : test abs
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_Abs, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_ABS, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_RelativePrime
|
||||
* @testcase.desc : test Relative Prime
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_RelativePrime, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_RELATIVE_PRIME, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_ComputeExtendedGcd
|
||||
* @testcase.desc : test compute extended gcd
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_ComputeExtendedGcd, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_COMPUTE_EXTENTED_GCD, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_ProbabilisticPrimality
|
||||
* @testcase.desc : test probabilistic primality
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_ProbabilisticPrimality, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_IS_PROBABLE_PRIME, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_Compare
|
||||
* @testcase.desc : test comparison
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_Compare, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_CMP, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_CompareWithShortVal
|
||||
* @testcase.desc : test comparison with shortVal
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_CompareWithShortVal, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_CMP_S32, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_InitializeFMM
|
||||
* @testcase.desc : test initialize bigIntFMM
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_InitializeFMM, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_INIT_FMM, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : BigInt_InitializeBigInt
|
||||
* @testcase.desc : test initialize bigInt
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, BigInt_InitializeBigInt, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_INIT, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
|
||||
|
||||
set(ca_sources)
|
||||
list(APPEND ca_sources
|
||||
common/common_test.cpp
|
||||
src/tee_test_crypto_api.cpp
|
||||
)
|
||||
|
||||
ca_compile_pub(
|
||||
TEST_NAME
|
||||
crypto_api
|
||||
|
||||
SRC_LIST
|
||||
${ca_sources}
|
||||
|
||||
INCLUDE_DIRS
|
||||
common
|
||||
|
||||
COMPILE_OPTS
|
||||
COMPILE_DEFS
|
||||
)
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <common_test.h>
|
||||
#include <securec.h>
|
||||
|
||||
void CryptoTest::SetUp()
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TEEC_UUID testId = CRYPTO_API_UUID;
|
||||
ret = session.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
operation.started = 1;
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_WHOLE, TEEC_NONE, TEEC_NONE, TEEC_NONE);
|
||||
(void)memset_s(&testMem.sharedMem, FUN_NAME_LEN, 0, FUN_NAME_LEN);
|
||||
testMem.sharedMem.size = FUN_NAME_LEN;
|
||||
testMem.sharedMem.flags = TEEC_MEM_OUTPUT | TEEC_MEM_INPUT;
|
||||
ret = TEEC_AllocateSharedMemory(&session.context, &testMem.sharedMem);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
}
|
||||
|
||||
void CryptoTest::TearDown()
|
||||
{
|
||||
TEEC_ReleaseSharedMemory(&testMem.sharedMem);
|
||||
session.Destroy();
|
||||
}
|
||||
|
||||
TEEC_Result CryptoTest::InvokeTest(const char *casename)
|
||||
{
|
||||
int rc;
|
||||
rc = strcpy_s(reinterpret_cast<char*>(testMem.sharedMem.buffer), FUN_NAME_LEN, casename);
|
||||
if (rc != 0) {
|
||||
return TEEC_FAIL;
|
||||
}
|
||||
operation.params[0].memref.parent = &testMem.sharedMem;
|
||||
operation.params[0].memref.offset = 0;
|
||||
operation.params[0].memref.size = testMem.sharedMem.size;
|
||||
return TEEC_InvokeCommand(&session.session, CMD_RUN_BY_FUN_SEQ, &operation, &origin);
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef __CRYPTO_COMMON_TEST_H__
|
||||
#define __CRYPTO_COMMON_TEST_H__
|
||||
|
||||
#include <public_test.h>
|
||||
#include <session_mgr/client_session_mgr.h>
|
||||
|
||||
#define CRYPTO_API_UUID \
|
||||
{ \
|
||||
0x05050505, 0x0303, 0x0303, \
|
||||
{ \
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01 \
|
||||
} \
|
||||
}
|
||||
|
||||
#define FUN_NAME_LEN 64
|
||||
enum TEST_CRYPTO_API_CMD_ID {
|
||||
CMD_RUN_BY_FUN_SEQ = 0,
|
||||
};
|
||||
|
||||
class CryptoTest : public EmptyTest
|
||||
{
|
||||
protected:
|
||||
ClientSessionMgr session;
|
||||
TEEC_Operation operation = { 0 };
|
||||
uint32_t origin;
|
||||
ClientShareMemMgr testMem;
|
||||
|
||||
public:
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
TEEC_Result InvokeTest(const char *casename);
|
||||
};
|
||||
|
||||
#define CRYPTO_TEST_EQ(casename) \
|
||||
TEE_TEST(CryptoTest, casename, Function | MediumTest | Level0) \
|
||||
{ \
|
||||
TEEC_Result ret = InvokeTest(#casename); \
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS); \
|
||||
}
|
||||
|
||||
#define CRYPTO_TEST_NE(casename) \
|
||||
TEE_TEST(CryptoTest, casename, Function | MediumTest | Level0) \
|
||||
{ \
|
||||
TEEC_Result ret = InvokeTest(#casename); \
|
||||
ASSERT_NE(ret, TEEC_SUCCESS); \
|
||||
}
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,31 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2023 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
|
||||
|
||||
set(ca_sources)
|
||||
list(APPEND ca_sources
|
||||
src/tee_test_libc_api.cpp
|
||||
)
|
||||
|
||||
ca_compile_pub(
|
||||
TEST_NAME
|
||||
libc_api
|
||||
|
||||
SRC_LIST
|
||||
${ca_sources}
|
||||
|
||||
INCLUDE_DIRS
|
||||
common
|
||||
|
||||
COMPILE_OPTS
|
||||
COMPILE_DEFS
|
||||
)
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef __LIBC_COMMON_TEST_H__
|
||||
#define __LIBC_COMMON_TEST_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <tee_client_type.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
|
||||
#define LIBC_API_UUID \
|
||||
{ \
|
||||
0x534d4152, 0x542d, 0x4353, \
|
||||
{ \
|
||||
0x4c, 0x54, 0xd3, 0x01, 0x6a, 0x17, 0x1f, 0x0c \
|
||||
} \
|
||||
}
|
||||
|
||||
enum LibcCmdId {
|
||||
CMD_TEST_PTHREAD_ATTR = 0,
|
||||
CMD_TEST_PTHREAD_BASE_FUNC,
|
||||
CMD_TEST_PTHREAD_MUTEX_LOCK,
|
||||
CMD_TEST_PTHREAD_SPIN_LOCK,
|
||||
CMD_TEST_PTHREAD_COND,
|
||||
CMD_TEST_SEM,
|
||||
CMD_TEST_APPLY_AND_FREE_MEM,
|
||||
CMD_TEST_MMAP_AND_MUNMAP,
|
||||
CMD_TEST_LIBC_MATH,
|
||||
CMD_TEST_LIBC_STDLIB,
|
||||
CMD_TEST_LIBC_CTYPE,
|
||||
CMD_TEST_LIBC_TIME,
|
||||
CMD_TEST_LIBC_STDIO,
|
||||
CMD_TEST_LIBC_ERROR,
|
||||
CMD_TEST_LIBC_UNISTD,
|
||||
CMD_TEST_LIBC_LOCALE,
|
||||
CMD_TEST_LIBC_MULTIBYTE,
|
||||
CMD_TEST_LIBC_PRNG,
|
||||
CMD_TEST_LIBC_STRING,
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,364 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <public_test.h>
|
||||
#include <test_log.h>
|
||||
#include <securec.h>
|
||||
#include <common_test.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <session_mgr/client_session_mgr.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
|
||||
/**
|
||||
* @testcase.name : CasePthreadAttr
|
||||
* @testcase.desc : run case CasePthreadAttr
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, CasePthreadAttr, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = LIBC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_PTHREAD_ATTR, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : CasePthreadBaseFunc
|
||||
* @testcase.desc : run case CasePthreadBaseFunc
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, CasePthreadBaseFunc, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = LIBC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_PTHREAD_BASE_FUNC, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : CasePthreadMutexLock
|
||||
* @testcase.desc : run case CasePthreadMutexLock
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, CasePthreadMutexLock, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = LIBC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_PTHREAD_MUTEX_LOCK, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : CasePthreadSpinLock
|
||||
* @testcase.desc : run case CasePthreadSpinLock
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, CasePthreadSpinLock, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = LIBC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_PTHREAD_SPIN_LOCK, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : CasePthreadCond
|
||||
* @testcase.desc : run case CasePthreadCond
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, CasePthreadCond, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = LIBC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_PTHREAD_COND, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : CaseSem
|
||||
* @testcase.desc : run case CaseSem
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, CaseSem, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = LIBC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_SEM, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : CaseApplyAndFreeMem
|
||||
* @testcase.desc : run case CaseApplyAndFreeMem
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, CaseApplyAndFreeMem, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = LIBC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_APPLY_AND_FREE_MEM, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : CaseMmapAndMunmap
|
||||
* @testcase.desc : run case CaseMmapAndMunmap
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, CaseMmapAndMunmap, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = LIBC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_MMAP_AND_MUNMAP, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : CaseLibcMath
|
||||
* @testcase.desc : run case CaseLibcMath
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, CaseLibcMath, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = LIBC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_MATH, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : CaseLibcStdlib
|
||||
* @testcase.desc : run case CaseLibcStdlib
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, CaseLibcStdlib, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = LIBC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_STDLIB, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : CaseLibcCtype
|
||||
* @testcase.desc : run case CaseLibcCtype
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, CaseLibcCtype, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = LIBC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_CTYPE, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : CaseLibcTime
|
||||
* @testcase.desc : run case CaseLibcTime
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, CaseLibcTime, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = LIBC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_TIME, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : CaseLibcStdio
|
||||
* @testcase.desc : run case CaseLibcStdio
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, CaseLibcStdio, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = LIBC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_STDIO, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : CaseLibcError
|
||||
* @testcase.desc : run case CaseLibcError
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, CaseLibcError, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = LIBC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_ERROR, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : CaseLibcUnistd
|
||||
* @testcase.desc : run case CaseLibcUnistd
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, CaseLibcUnistd, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = LIBC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_UNISTD, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : CaseLibcLocale
|
||||
* @testcase.desc : run case CaseLibcLocale
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, CaseLibcLocale, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = LIBC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_LOCALE, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : CaseLibcMultiByte
|
||||
* @testcase.desc : run case CaseLibcMultiByte
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, CaseLibcMultiByte, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = LIBC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_MULTIBYTE, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : CaseLibcPrng
|
||||
* @testcase.desc : run case CaseLibcPrng
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, CaseLibcPrng, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = LIBC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_PRNG, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : CaseLibcString
|
||||
* @testcase.desc : run case CaseLibcString
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, CaseLibcString, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = LIBC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_STRING, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
|
||||
MESSAGE( STATUS "__ANDROID_API__ = ${__ANDROID_API__}.")
|
||||
|
||||
set(ca_sources)
|
||||
list(APPEND ca_sources
|
||||
src/common_test.cpp
|
||||
src/property/get_prop_as_string_test.cpp
|
||||
src/property/get_prop_as_bool_test.cpp
|
||||
src/property/get_prop_as_u32_test.cpp
|
||||
src/property/get_prop_as_u64_test.cpp
|
||||
src/property/get_prop_as_binaryblock_test.cpp
|
||||
src/property/get_prop_as_uuid_test.cpp
|
||||
src/property/get_prop_as_identity_test.cpp
|
||||
src/property/get_prop_with_enumerator_test.cpp
|
||||
src/mem/tee_malloc_test.cpp
|
||||
src/mem/tee_realloc_test.cpp
|
||||
src/mem/tee_memmove_test.cpp
|
||||
src/mem/tee_memfill_test.cpp
|
||||
src/mem/tee_free_test.cpp
|
||||
src/mem/tee_memcompare_test.cpp
|
||||
src/mem/tee_checkmemaccessrights_test.cpp
|
||||
src/mem/tee_instance_test.cpp
|
||||
src/other/internal_client_api_test.cpp
|
||||
src/other/tee_panic_test.cpp
|
||||
)
|
||||
|
||||
ca_compile_pub(
|
||||
TEST_NAME
|
||||
tcf_api
|
||||
|
||||
SRC_LIST
|
||||
${ca_sources}
|
||||
|
||||
INCLUDE_DIRS
|
||||
common
|
||||
|
||||
COMPILE_OPTS
|
||||
COMPILE_DEFS
|
||||
)
|
||||
|
||||
@@ -1,299 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef __TCF_COMMON_TEST_H__
|
||||
#define __TCF_COMMON_TEST_H__
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <stdint.h>
|
||||
#include <tee_client_type.h>
|
||||
|
||||
#define TESTSIZE 16
|
||||
#define BIG_SIZE 1024
|
||||
#define MAX_SHARE_SIZE 0x100000
|
||||
|
||||
#define ENUMERATOR1 1
|
||||
#define MAX_ENUMERATOR 1023
|
||||
|
||||
#define EXPECTBUFFER_ZERO ""
|
||||
#define EXPECTBUFFER_A "AAAAAAAAAAAAAAAA"
|
||||
#define EXPECTBUFFER_A_LESS "AAAAAAAAAAAAAAA"
|
||||
#define EXPECTBUFFER_B "BBBBBBBBBBBBBBBB"
|
||||
#define EXPECTBUFFER_OVERLAP "AAAAAAAAABBBBBBB"
|
||||
|
||||
// ALL_PROPERTY_NAMES
|
||||
#define GPD_CLIENT_IDENTITY "gpd.client.identity"
|
||||
#define GPD_CLIENT_ENDIAN "gpd.client.endian"
|
||||
#define GPD_TA_APPID "gpd.ta.appID"
|
||||
#define GPD_TA_SERVICENAME "gpd.ta.service_name"
|
||||
#define GPD_TA_DATASIZE "gpd.ta.dataSize"
|
||||
#define GPD_TA_INSTANCEKEEPALIVE "gpd.ta.instanceKeepAlive"
|
||||
#define GPD_TA_MULTISESSION "gpd.ta.multiSession"
|
||||
#define GPD_TA_SINGLEINSTANCE "gpd.ta.singleInstance"
|
||||
#define GPD_TA_STACKSIZE "gpd.ta.stackSize"
|
||||
#define GPD_TA_VERSION "gpd.ta.version"
|
||||
#define GPD_TA_DESCRIPTION "gpd.ta.description"
|
||||
#define GPD_TA_ENDIAN "gpd.ta.endian"
|
||||
#define GPD_TEE_ARITH_MAXBIGINTSIZE "gpd.tee.arith.maxBigIntSize"
|
||||
#define GPD_TEE_SYSTEM_TIME_PROTECTIONLEVEL "gpd.tee.systemTime.protectionLevel"
|
||||
#define GPD_TEE_TA_PERSISTENT_TIME_PROTECTIONLEVEL "gpd.tee.TAPersistentTime.protectionLevel"
|
||||
#define GPD_TEE_APIVERSION "gpd.tee.apiversion"
|
||||
#define GPD_TEE_INTERNALCORE_VERSION "gpd.tee.internalCore.version"
|
||||
#define GPD_TEE_DESCRIPTION "gpd.tee.description"
|
||||
#define GPD_TEE_DEVICEID "gpd.tee.deviceID"
|
||||
#define GPD_TEE_CRYPTOGRAPHY_ECC "gpd.tee.cryptography.ecc"
|
||||
#define GPD_TEE_CRYPTOGRAPHY_NIST "gpd.tee.cryptography.nist"
|
||||
#define GPD_TEE_CRYPTOGRAPHY_BSI_R "gpd.tee.cryptography.bsi-r"
|
||||
#define GPD_TEE_CRYPTOGRAPHY_BSI_T "gpd.tee.cryptography.bsi-t"
|
||||
#define GPD_TEE_CRYPTOGRAPHY_IETF "gpd.tee.cryptography.ietf"
|
||||
#define GPD_TEE_CRYPTOGRAPHY_OCTA "gpd.tee.cryptography.octa"
|
||||
#define GPD_TEE_ANTIROLLBACK_PROTECTIONLEVEL "gpd.tee.trustedStorage.antiRollback.protectionLevel"
|
||||
#define GPD_TEE_ROLLBACKDETECT_PROTECTIONLEVEL "gpd.tee.trustedStorage.rollbackDetection.protectionLevel"
|
||||
#define GPD_TEE_TRUSTEDOS_IMP_VERSION "gpd.tee.trustedos.implementation.version"
|
||||
#define GPD_TEE_TRUSTEDOS_IMP_BINARYVERSION "gpd.tee.trustedos.implementation.binaryversion"
|
||||
#define GPD_TEE_TRUSTEDOS_MANUFACTURER "gpd.tee.trustedos.manufacturer"
|
||||
#define GPD_TEE_FIRMWARE_IMP_VERSION "gpd.tee.firmware.implementation.version"
|
||||
#define GPD_TEE_FIRMWARE_IMP_BINARYVERSION "gpd.tee.firmware.implementation.binaryversion"
|
||||
#define GPD_TEE_FIRMWARE_MANUFACTURER "gpd.tee.firmware.manufacturer"
|
||||
#define GPD_TEE_EVENT_MAXSOURCES "gpd.tee.event.maxSources"
|
||||
#define GPD_TEE_API_LEVEL "gpd.tee.api_level"
|
||||
#define PROPERTY_NAME_UNKNOWN "unknown"
|
||||
#define SMC_TA_TESTBINARYBLOCK "smc.ta.testbinaryblock"
|
||||
#define SMC_TA_TESTIDENTITY "smc.ta.identity"
|
||||
#define SMC_TA_TESTU64 "smc.ta.testu64"
|
||||
|
||||
// ALL_PROPERTY_VALUES
|
||||
#define VALUE_PREDEFINED_BINARY_BLOCK "VGhpcy"
|
||||
#define VALUE_PREDEFINED_SERVICENAME "TCF_test"
|
||||
#define VALUE_PREDEFINED_BOOLEAN "true"
|
||||
#define VALUE_PREDEFINED_FALSE "false"
|
||||
#define VALUE_PREDEFINED_DATASIZE 819200
|
||||
#define VALUE_PREDEFINED_STACKSIZE 81920
|
||||
#define VALUE_PREDEFINED_TA_VERSION "0"
|
||||
#define VALUE_PREDEFINED_TA_DESCRIPTION "test ta"
|
||||
#define VALUE_PREDEFINED_CLIENT_IDENTITY "identity:0:00000000-0000-0000-6100-000000000000"
|
||||
#define VALUE_PREDEFINED_CLIENT_ENDIAN 0
|
||||
#define VALUE_PREDEFINED_STRING "test string"
|
||||
#define VALUE_PREDEFINED_U64 5147483647
|
||||
#define VALUE_PREDEFINED_UUID "534d4152-542d-4353-4c54-d3016a171f01"
|
||||
|
||||
#define TEE_INTERNAL_CORE_MAJOR_VERSION 1
|
||||
#define TEE_INTERNAL_CORE_MINOR_VERSION 2
|
||||
#define TEE_INTERNAL_CORE_MAINTENANCE_VERSION 0
|
||||
#define TEE_INTERNAL_CORE_RESERVED_VERSION 0
|
||||
// TEE_API_VERSION should match with TEE_INTERNAL_CORE_VERSION
|
||||
#define TEE_API_VERSION "v1.2.0"
|
||||
#define TEE_INTERNAL_CORE_VERSION \
|
||||
((TEE_INTERNAL_CORE_MAJOR_VERSION << 24) | (TEE_INTERNAL_CORE_MINOR_VERSION << 16) | \
|
||||
(TEE_INTERNAL_CORE_MAINTENANCE_VERSION << 8) | TEE_INTERNAL_CORE_RESERVED_VERSION)
|
||||
#define TEE_BUILD_VER "B309"
|
||||
#define TEE_IMP_VERSION "TEE-1.0.0"
|
||||
#define TEE_MANUFACTURER "TEE"
|
||||
#define TEE_FIRMWARE_IMP_VERSION "ATF-1.5"
|
||||
#define TEE_FIRMWARE_MANUFACTURER "TEE"
|
||||
#define TEE_TIME_PROTECT_LEVEL 100
|
||||
#define TA_TIME_PROTECT_LEVEL 100
|
||||
#define MAX_BIG_INT_SIZE 32
|
||||
#define API_LEVEL1_2 3
|
||||
#define CIPHER_LAYER_VERSION 3
|
||||
#define TEE_MAX_API_LEVEL_CONFIG ((CIPHER_LAYER_VERSION << 16) | API_LEVEL1_2)
|
||||
|
||||
typedef enum {
|
||||
TEE_PROPSET_CURRENT_CLIENT = 0xFFFFFFFE,
|
||||
TEE_PROPSET_CURRENT_TA = 0xFFFFFFFF,
|
||||
TEE_PROPSET_IMPLEMENTATION = 0xFFFFFFFD,
|
||||
TEE_PROPSET_ZERO = 0x0,
|
||||
} ALL_PROP_SETS;
|
||||
|
||||
typedef struct {
|
||||
uint32_t login;
|
||||
TEEC_UUID uuid;
|
||||
} TEEC_Identity;
|
||||
|
||||
#define TCF_API_UUID_1 \
|
||||
{ \
|
||||
0x534d4152, 0x542d, 0x4353, \
|
||||
{ \
|
||||
0x4c, 0x54, 0xd3, 0x01, 0x6a, 0x17, 0x1f, 0x01 \
|
||||
} \
|
||||
}
|
||||
|
||||
#define TCF_API_UUID_2 \
|
||||
{ \
|
||||
0x534D4152, 0x542D, 0x4353, \
|
||||
{ \
|
||||
0x4C, 0x54, 0xd3, 0x01, 0x6a, 0x17, 0x1f, 0x02 \
|
||||
} \
|
||||
}
|
||||
|
||||
#define UUID_TA_NOT_EXIST \
|
||||
{ \
|
||||
0x534D4152, 0x542D, 0x4353, \
|
||||
{ \
|
||||
0x4C, 0x54, 0x2D, 0x54, 0x41, 0x2D, 0x53, 0x5B \
|
||||
} \
|
||||
}
|
||||
|
||||
struct TestData {
|
||||
uint32_t cmd;
|
||||
uint32_t caseId;
|
||||
ALL_PROP_SETS propSet;
|
||||
uint32_t enumerator;
|
||||
uint32_t origin;
|
||||
char inBuffer[BIG_SIZE];
|
||||
uint32_t inBufferLen;
|
||||
char outBuffer[BIG_SIZE];
|
||||
uint32_t outBufferLen;
|
||||
TEEC_UUID uuid;
|
||||
};
|
||||
typedef struct TestData TestData;
|
||||
|
||||
struct TestMemData {
|
||||
size_t oldSize;
|
||||
size_t newSize;
|
||||
uint32_t oldAddr;
|
||||
uint32_t newAddr;
|
||||
uint32_t caseId;
|
||||
uint32_t origin;
|
||||
uint32_t accessFlags;
|
||||
size_t inMemSize;
|
||||
uint32_t inHint;
|
||||
char *testBuffer;
|
||||
};
|
||||
typedef struct TestMemData TestMemData;
|
||||
|
||||
typedef enum {
|
||||
HINT_RESERVE = 0x80000000,
|
||||
TEE_MALLOC_FILL_ZERO = 0,
|
||||
TEE_MALLOC_NO_FILL = 1,
|
||||
TEE_MALLOC_NO_SHARE = 2,
|
||||
} ALL_MEMORY_HINTS;
|
||||
|
||||
#define TEE_MEMORY_ACCESS_READ 0x00000001
|
||||
#define TEE_MEMORY_ACCESS_WRITE 0x00000002
|
||||
#define TEE_MEMORY_ACCESS_ANY_OWNER 0x00000004
|
||||
|
||||
class TCF1Test : public ::testing::Test {
|
||||
private:
|
||||
static TEEC_Context context;
|
||||
static TEEC_Session session;
|
||||
|
||||
public:
|
||||
static void SetUpTestCase() {}
|
||||
static void TearDownTestCase() {}
|
||||
|
||||
TEEC_Context *GetContext()
|
||||
{
|
||||
return &TCF1Test::context;
|
||||
}
|
||||
TEEC_Session *GetSession()
|
||||
{
|
||||
return &TCF1Test::session;
|
||||
}
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
class TCF2Test : public ::testing::Test {
|
||||
private:
|
||||
static TEEC_Context context;
|
||||
static TEEC_Session session;
|
||||
|
||||
public:
|
||||
static void SetUpTestCase() {}
|
||||
static void TearDownTestCase() {}
|
||||
|
||||
TEEC_Context *GetContext()
|
||||
{
|
||||
return &TCF2Test::context;
|
||||
}
|
||||
TEEC_Session *GetSession()
|
||||
{
|
||||
return &TCF2Test::session;
|
||||
}
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
class TCF2TA2TATest : public ::testing::Test {
|
||||
private:
|
||||
static TEEC_Context context;
|
||||
static TEEC_Session session;
|
||||
static TEEC_Session session2;
|
||||
|
||||
public:
|
||||
static void SetUpTestCase() {}
|
||||
static void TearDownTestCase() {}
|
||||
|
||||
TEEC_Context *GetContext()
|
||||
{
|
||||
return &TCF2TA2TATest::context;
|
||||
}
|
||||
TEEC_Session *GetSession()
|
||||
{
|
||||
return &TCF2TA2TATest::session;
|
||||
}
|
||||
TEEC_Session *GetSession2()
|
||||
{
|
||||
return &TCF2TA2TATest::session2;
|
||||
}
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
class TCF1ENUM_Test : public ::testing::Test {
|
||||
private:
|
||||
static TEEC_Context context;
|
||||
static TEEC_Session session;
|
||||
|
||||
public:
|
||||
TestData value = { 0 };
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
|
||||
TEEC_Context *GetContext()
|
||||
{
|
||||
return &TCF1ENUM_Test::context;
|
||||
}
|
||||
TEEC_Session *GetSession()
|
||||
{
|
||||
return &TCF1ENUM_Test::session;
|
||||
}
|
||||
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
TEEC_Result Invoke_GetPropertyAsX(TEEC_Context *context, TEEC_Session *session, TestData *testData);
|
||||
TEEC_Result Invoke_AllocatePropertyEnumerator(TEEC_Session *session, TestData *testData);
|
||||
TEEC_Result Invoke_Operate_PropertyEnumerator(TEEC_Session *session, TestData *testData);
|
||||
TEEC_Result Invoke_Malloc(TEEC_Session *session, uint32_t commandID, TestMemData *testData, uint32_t *origin);
|
||||
TEEC_Result Invoke_Realloc(TEEC_Session *session, uint32_t commandID, TestMemData *testData, char *output);
|
||||
TEEC_Result Invoke_MemMove_Or_Fill(TEEC_Session *session, uint32_t commandID, TestMemData *testData, char *output);
|
||||
TEEC_Result Invoke_Free(TEEC_Session *session, uint32_t commandID, uint32_t caseNum, uint32_t *origin);
|
||||
TEEC_Result Invoke_MemCompare(TEEC_Session *session, uint32_t commandID, TestMemData *testData, char *buffer1,
|
||||
char *buffer2);
|
||||
TEEC_Result Invoke_CheckMemoryAccessRights(TEEC_Session *session, uint32_t commandID, TestMemData *testData);
|
||||
TEEC_Result Invoke_SetInstanceData(TEEC_Session *session, uint32_t commandID, char *buffer, uint32_t caseNum,
|
||||
uint32_t *origin);
|
||||
TEEC_Result Invoke_GetInstanceData(TEEC_Session *session, uint32_t commandID, char *buffer, uint32_t *bufSize,
|
||||
uint32_t *origin);
|
||||
TEEC_Result Invoke_OpenTASession(TEEC_Session *session, uint32_t commandID, uint32_t *ta2taSession,
|
||||
TestData *testData, uint32_t *origin);
|
||||
TEEC_Result Invoke_CloseTASession(TEEC_Session *session, uint32_t commandID, uint32_t ta2taSession,
|
||||
uint32_t *origin);
|
||||
TEEC_Result Invoke_InvokeTACommand(TEEC_Session *session, uint32_t commandID, uint32_t ta2taSession,
|
||||
TestData *testData, uint32_t *origin);
|
||||
TEEC_Result Invoke_Panic(TEEC_Session *session, uint32_t commandID, TEEC_Result panicCode, uint32_t *origin);
|
||||
uint32_t get_ta_data_size(TEEC_Context *context, TEEC_Session *session);
|
||||
uint32_t get_ta_stack_size(TEEC_Context *context, TEEC_Session *session);
|
||||
#endif
|
||||
@@ -1,568 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <test_defines.h>
|
||||
#include <common_test.h>
|
||||
#include <securec.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <test_log.h>
|
||||
#include <test_tcf_cmdid.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
|
||||
TEEC_Context TCF1Test::context = { 0 };
|
||||
TEEC_Session TCF1Test::session = { 0 };
|
||||
|
||||
void TCF1Test::SetUp()
|
||||
{
|
||||
TEEC_Operation operation = { 0 };
|
||||
TEEC_Result ret = TEEC_InitializeContext(NULL, &context);
|
||||
ABORT_UNLESS(ret != TEEC_SUCCESS);
|
||||
operation.started = 1;
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_NONE, TEEC_NONE, TEEC_NONE, TEEC_NONE);
|
||||
TEEC_UUID uuid = TCF_API_UUID_1;
|
||||
|
||||
ret = TEEC_OpenSession(&context, &session, &uuid, TEEC_LOGIN_IDENTIFY, NULL, &operation, NULL);
|
||||
ABORT_UNLESS(ret != TEEC_SUCCESS);
|
||||
}
|
||||
|
||||
void TCF1Test::TearDown()
|
||||
{
|
||||
TEEC_CloseSession(&session);
|
||||
TEEC_FinalizeContext(&context);
|
||||
}
|
||||
|
||||
TEEC_Context TCF2Test::context = { 0 };
|
||||
TEEC_Session TCF2Test::session = { 0 };
|
||||
|
||||
void TCF2Test::SetUp()
|
||||
{
|
||||
TEEC_Operation operation = { 0 };
|
||||
|
||||
TEEC_Result ret = TEEC_InitializeContext(NULL, &context);
|
||||
ABORT_UNLESS(ret != TEEC_SUCCESS);
|
||||
|
||||
operation.started = 1;
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_NONE, TEEC_NONE, TEEC_NONE, TEEC_NONE);
|
||||
|
||||
TEEC_UUID uuid = TCF_API_UUID_2;
|
||||
ret = TEEC_OpenSession(&context, &session, &uuid, TEEC_LOGIN_IDENTIFY, NULL, &operation, NULL);
|
||||
ABORT_UNLESS(ret != TEEC_SUCCESS);
|
||||
}
|
||||
|
||||
void TCF2Test::TearDown()
|
||||
{
|
||||
TEEC_CloseSession(&session);
|
||||
TEEC_FinalizeContext(&context);
|
||||
}
|
||||
|
||||
TEEC_Context TCF2TA2TATest::context = { 0 };
|
||||
TEEC_Session TCF2TA2TATest::session = { 0 };
|
||||
TEEC_Session TCF2TA2TATest::session2 = { 0 };
|
||||
|
||||
void TCF2TA2TATest::SetUp()
|
||||
{
|
||||
TEEC_Operation operation = { 0 };
|
||||
|
||||
TEEC_Result ret = TEEC_InitializeContext(NULL, &context);
|
||||
ABORT_UNLESS(ret != TEEC_SUCCESS);
|
||||
|
||||
operation.started = 1;
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_NONE, TEEC_NONE, TEEC_NONE, TEEC_NONE);
|
||||
|
||||
TEEC_UUID uuid2 = TCF_API_UUID_1; // this is TA2 UUID
|
||||
ret = TEEC_OpenSession(&context, &session2, &uuid2, TEEC_LOGIN_IDENTIFY, NULL, &operation, NULL);
|
||||
ABORT_UNLESS(ret != TEEC_SUCCESS);
|
||||
|
||||
TEEC_UUID uuid = TCF_API_UUID_2; // this is TA1 UUID
|
||||
ret = TEEC_OpenSession(&context, &session, &uuid, TEEC_LOGIN_IDENTIFY, NULL, &operation, NULL);
|
||||
ABORT_UNLESS(ret != TEEC_SUCCESS);
|
||||
}
|
||||
|
||||
void TCF2TA2TATest::TearDown()
|
||||
{
|
||||
TEEC_CloseSession(&session);
|
||||
TEEC_CloseSession(&session2);
|
||||
TEEC_FinalizeContext(&context);
|
||||
}
|
||||
|
||||
TEEC_Context TCF1ENUM_Test::context = { 0 };
|
||||
TEEC_Session TCF1ENUM_Test::session = { 0 };
|
||||
|
||||
void TCF1ENUM_Test::SetUpTestCase()
|
||||
{
|
||||
TEEC_Operation operation = { 0 };
|
||||
|
||||
TEEC_Result ret = TEEC_InitializeContext(NULL, &context);
|
||||
ABORT_UNLESS(ret != TEEC_SUCCESS);
|
||||
|
||||
operation.started = 1;
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_NONE, TEEC_NONE, TEEC_NONE, TEEC_NONE);
|
||||
|
||||
TEEC_UUID uuid = TCF_API_UUID_1;
|
||||
ret = TEEC_OpenSession(&context, &session, &uuid, TEEC_LOGIN_IDENTIFY, NULL, &operation, NULL);
|
||||
ABORT_UNLESS(ret != TEEC_SUCCESS);
|
||||
}
|
||||
|
||||
void TCF1ENUM_Test::TearDownTestCase()
|
||||
{
|
||||
TEEC_CloseSession(&session);
|
||||
TEEC_FinalizeContext(&context);
|
||||
}
|
||||
|
||||
void TCF1ENUM_Test::SetUp()
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
// alloc PropertyEnumerator
|
||||
value.cmd = CMD_TEE_AllocatePropertyEnumerator;
|
||||
ret = Invoke_AllocatePropertyEnumerator(GetSession(), &value);
|
||||
ABORT_UNLESS(ret != TEEC_SUCCESS);
|
||||
}
|
||||
|
||||
void TCF1ENUM_Test::TearDown()
|
||||
{
|
||||
value.cmd = CMD_TEE_FreePropertyEnumerator;
|
||||
Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
}
|
||||
|
||||
TEEC_Result Invoke_GetPropertyAsX(TEEC_Context *context, TEEC_Session *session, TestData *testData)
|
||||
{
|
||||
TEEC_Result result = TEEC_FAIL;
|
||||
int rc;
|
||||
TEEC_Operation operation = { 0 };
|
||||
TEEC_SharedMemory shareMemInput, shareMemOutput;
|
||||
|
||||
// allocate the share memorys
|
||||
shareMemInput.size = BIG_SIZE;
|
||||
shareMemInput.flags = TEEC_MEM_INOUT;
|
||||
result = TEEC_AllocateSharedMemory(context, &shareMemInput);
|
||||
if (result != TEEC_SUCCESS) {
|
||||
TEST_PRINT_ERROR("alloc shareMemInput fail!\n");
|
||||
return TEEC_FAIL;
|
||||
}
|
||||
|
||||
shareMemOutput.size = BIG_SIZE;
|
||||
shareMemOutput.flags = TEEC_MEM_INOUT;
|
||||
result = TEEC_AllocateSharedMemory(context, &shareMemOutput);
|
||||
if (result != TEEC_SUCCESS) {
|
||||
TEST_PRINT_ERROR("alloc shareMemOutput fail!\n");
|
||||
TEEC_ReleaseSharedMemory(&shareMemInput);
|
||||
return TEEC_FAIL;
|
||||
}
|
||||
|
||||
// Invoke command
|
||||
operation.started = 1;
|
||||
operation.paramTypes =
|
||||
TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_PARTIAL_INPUT, TEEC_MEMREF_PARTIAL_OUTPUT, TEEC_NONE);
|
||||
if (testData->enumerator != 0)
|
||||
operation.params[0].value.a = testData->enumerator;
|
||||
else
|
||||
operation.params[0].value.a = testData->propSet;
|
||||
|
||||
operation.params[0].value.b = testData->caseId;
|
||||
(void)memset_s(shareMemInput.buffer, BIG_SIZE, 0, BIG_SIZE);
|
||||
rc = memcpy_s(shareMemInput.buffer, shareMemInput.size, testData->inBuffer, testData->inBufferLen);
|
||||
if (rc != TEEC_SUCCESS) {
|
||||
TEST_PRINT_ERROR("memcpy_s inBuffer to shareMemInput fail!\n");
|
||||
goto clean;
|
||||
}
|
||||
|
||||
operation.params[1].memref.parent = &shareMemInput;
|
||||
operation.params[1].memref.size = shareMemInput.size;
|
||||
operation.params[1].memref.offset = 0;
|
||||
operation.params[2].memref.parent = &shareMemOutput;
|
||||
operation.params[2].memref.size = shareMemOutput.size;
|
||||
operation.params[2].memref.offset = 0;
|
||||
|
||||
result = TEEC_InvokeCommand(session, testData->cmd, &operation, &testData->origin);
|
||||
testData->outBufferLen = operation.params[2].memref.size;
|
||||
rc = memcpy_s(testData->outBuffer, BIG_SIZE, shareMemOutput.buffer, testData->outBufferLen);
|
||||
if (rc != TEEC_SUCCESS) {
|
||||
TEST_PRINT_ERROR("memcpy_s shareMemOutput to outBuffer fail! rc = 0x%x\n", rc);
|
||||
}
|
||||
|
||||
clean:
|
||||
TEEC_ReleaseSharedMemory(&shareMemInput);
|
||||
TEEC_ReleaseSharedMemory(&shareMemOutput);
|
||||
return result;
|
||||
}
|
||||
|
||||
TEEC_Result Invoke_AllocatePropertyEnumerator(TEEC_Session *session, TestData *testData)
|
||||
{
|
||||
TEEC_Result result;
|
||||
TEEC_Operation operation = { 0 };
|
||||
|
||||
// Invoke command
|
||||
operation.started = 1;
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_OUTPUT, TEEC_NONE, TEEC_NONE, TEEC_NONE);
|
||||
operation.params[0].value.a = 0;
|
||||
operation.params[0].value.b = testData->caseId;
|
||||
result = TEEC_InvokeCommand(session, testData->cmd, &operation, &testData->origin);
|
||||
|
||||
testData->enumerator = operation.params[0].value.a;
|
||||
return result;
|
||||
}
|
||||
|
||||
TEEC_Result Invoke_Operate_PropertyEnumerator(TEEC_Session *session, TestData *testData)
|
||||
{
|
||||
TEEC_Result result;
|
||||
TEEC_Operation operation = { 0 };
|
||||
// Invoke command
|
||||
operation.started = 1;
|
||||
switch (testData->cmd) {
|
||||
case CMD_TEE_FreePropertyEnumerator:
|
||||
case CMD_TEE_ResetPropertyEnumerator:
|
||||
case CMD_TEE_GetNextPropertyEnumerator:
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE, TEEC_NONE, TEEC_NONE);
|
||||
operation.params[0].value.a = testData->enumerator;
|
||||
operation.params[0].value.b = testData->cmd;
|
||||
break;
|
||||
case CMD_TEE_StartPropertyEnumerator:
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_VALUE_INPUT, TEEC_NONE, TEEC_NONE);
|
||||
operation.params[0].value.a = testData->enumerator;
|
||||
operation.params[1].value.a = testData->propSet;
|
||||
break;
|
||||
case CMD_TEE_GetPropertyNameEnumerator:
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_OUTPUT, TEEC_NONE, TEEC_NONE);
|
||||
operation.params[0].value.a = testData->enumerator;
|
||||
operation.params[0].value.b = testData->caseId;
|
||||
operation.params[1].tmpref.buffer = testData->outBuffer;
|
||||
operation.params[1].tmpref.size = testData->outBufferLen;
|
||||
break;
|
||||
default:
|
||||
TEST_PRINT_ERROR("not support this test command! cmdId: 0x%x", testData->cmd);
|
||||
return TEEC_FAIL;
|
||||
}
|
||||
|
||||
result = TEEC_InvokeCommand(session, testData->cmd, &operation, &testData->origin);
|
||||
if (testData->cmd == CMD_TEE_GetPropertyNameEnumerator)
|
||||
testData->outBufferLen = operation.params[1].tmpref.size;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
TEEC_Result Invoke_Malloc(TEEC_Session *session, uint32_t commandID, TestMemData *testData, uint32_t *origin)
|
||||
{
|
||||
TEEC_Result result;
|
||||
TEEC_Operation operation = { 0 };
|
||||
|
||||
// Invoke command
|
||||
operation.started = 1;
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_OUTPUT, TEEC_NONE, TEEC_NONE);
|
||||
operation.params[0].value.a = testData->inMemSize;
|
||||
operation.params[0].value.b = testData->inHint;
|
||||
operation.params[1].tmpref.buffer = testData->testBuffer;
|
||||
operation.params[1].tmpref.size = MAX_SHARE_SIZE;
|
||||
|
||||
result = TEEC_InvokeCommand(session, commandID, &operation, origin);
|
||||
return result;
|
||||
}
|
||||
|
||||
TEEC_Result Invoke_Realloc(TEEC_Session *session, uint32_t commandID, TestMemData *testData, char *output)
|
||||
{
|
||||
TEEC_Result result;
|
||||
TEEC_Operation operation = { 0 };
|
||||
char *buffer = NULL;
|
||||
uint32_t bufSize = testData->oldSize > testData->newSize ? testData->oldSize : testData->newSize;
|
||||
|
||||
if (bufSize > MAX_SHARE_SIZE)
|
||||
bufSize = TESTSIZE;
|
||||
|
||||
buffer = reinterpret_cast<char *>(malloc(bufSize));
|
||||
if (buffer == NULL) {
|
||||
TEST_PRINT_ERROR("malloc buffer fail!\n");
|
||||
return TEEC_FAIL;
|
||||
}
|
||||
|
||||
// Invoke command
|
||||
operation.started = 1;
|
||||
operation.paramTypes =
|
||||
TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_OUTPUT, TEEC_VALUE_OUTPUT, TEEC_VALUE_INPUT);
|
||||
operation.params[0].value.a = testData->oldSize;
|
||||
operation.params[0].value.b = testData->newSize;
|
||||
operation.params[1].tmpref.buffer = buffer;
|
||||
operation.params[1].tmpref.size = bufSize;
|
||||
operation.params[3].value.a = testData->caseId;
|
||||
|
||||
result = TEEC_InvokeCommand(session, commandID, &operation, &testData->origin);
|
||||
testData->oldAddr = operation.params[2].value.a;
|
||||
testData->newAddr = operation.params[2].value.b;
|
||||
int rc = memcpy_s(output, bufSize, buffer, operation.params[1].tmpref.size);
|
||||
if (rc != 0) {
|
||||
TEST_PRINT_ERROR("memcpy_s output failed, rc=0x%x\n", rc);
|
||||
return TEEC_FAIL;
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
return result;
|
||||
}
|
||||
|
||||
TEEC_Result Invoke_MemMove_Or_Fill(TEEC_Session *session, uint32_t commandID, TestMemData *testData, char *output)
|
||||
{
|
||||
TEEC_Result result;
|
||||
TEEC_Operation operation = { 0 };
|
||||
char *buffer = NULL;
|
||||
uint32_t bufSize = testData->oldSize;
|
||||
buffer = reinterpret_cast<char*>(malloc(bufSize));
|
||||
if (buffer == NULL) {
|
||||
TEST_PRINT_ERROR("malloc buffer fail!\n");
|
||||
return TEEC_FAIL;
|
||||
}
|
||||
|
||||
// Invoke command
|
||||
operation.started = 1;
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_OUTPUT, TEEC_NONE, TEEC_NONE);
|
||||
operation.params[0].value.a = testData->oldSize;
|
||||
operation.params[0].value.b = testData->caseId;
|
||||
operation.params[1].tmpref.buffer = buffer;
|
||||
operation.params[1].tmpref.size = bufSize;
|
||||
|
||||
result = TEEC_InvokeCommand(session, commandID, &operation, &testData->origin);
|
||||
int rc = memcpy_s(output, testData->oldSize, buffer, operation.params[1].tmpref.size);
|
||||
if (rc != 0) {
|
||||
TEST_PRINT_ERROR("memcpy_s uuid to tee failed, rc=0x%x\n", rc);
|
||||
return TEEC_FAIL;
|
||||
}
|
||||
free(buffer);
|
||||
return result;
|
||||
}
|
||||
|
||||
TEEC_Result Invoke_Free(TEEC_Session *session, uint32_t commandID, uint32_t caseNum, uint32_t *origin)
|
||||
{
|
||||
TEEC_Result result;
|
||||
TEEC_Operation operation = { 0 };
|
||||
|
||||
// Invoke command
|
||||
operation.started = 1;
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE, TEEC_NONE, TEEC_NONE);
|
||||
operation.params[0].value.a = caseNum;
|
||||
|
||||
result = TEEC_InvokeCommand(session, commandID, &operation, origin);
|
||||
return result;
|
||||
}
|
||||
|
||||
TEEC_Result Invoke_MemCompare(TEEC_Session *session, uint32_t commandID, TestMemData *testData, char *buffer1,
|
||||
char *buffer2)
|
||||
{
|
||||
TEEC_Result result = TEEC_SUCCESS;
|
||||
TEEC_Operation operation = { 0 };
|
||||
|
||||
// Invoke command
|
||||
operation.started = 1;
|
||||
operation.paramTypes =
|
||||
TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_NONE);
|
||||
operation.params[0].value.a = testData->oldSize;
|
||||
operation.params[0].value.b = testData->caseId;
|
||||
operation.params[1].tmpref.buffer = buffer1;
|
||||
operation.params[1].tmpref.size = testData->oldSize > 0 ? testData->oldSize : TESTSIZE;
|
||||
operation.params[2].tmpref.buffer = buffer2;
|
||||
operation.params[2].tmpref.size = testData->oldSize > 0 ? testData->oldSize : TESTSIZE;
|
||||
|
||||
result = TEEC_InvokeCommand(session, commandID, &operation, &testData->origin);
|
||||
return result;
|
||||
}
|
||||
|
||||
TEEC_Result Invoke_CheckMemoryAccessRights(TEEC_Session *session, uint32_t commandID, TestMemData *testData)
|
||||
{
|
||||
TEEC_Result result;
|
||||
TEEC_Operation operation = { 0 };
|
||||
char *buffer = NULL;
|
||||
uint32_t bufSize = testData->oldSize;
|
||||
buffer = reinterpret_cast<char*>(malloc(bufSize));
|
||||
if (buffer == NULL) {
|
||||
TEST_PRINT_ERROR("malloc buffer fail!\n");
|
||||
return TEEC_FAIL;
|
||||
}
|
||||
// Invoke command
|
||||
operation.started = 1;
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_OUTPUT, TEEC_VALUE_INPUT, TEEC_NONE);
|
||||
operation.params[0].value.a = testData->accessFlags;
|
||||
operation.params[0].value.b = testData->oldSize;
|
||||
operation.params[1].tmpref.buffer = buffer;
|
||||
operation.params[1].tmpref.size = bufSize;
|
||||
operation.params[2].value.a = testData->caseId;
|
||||
|
||||
result = TEEC_InvokeCommand(session, commandID, &operation, &testData->origin);
|
||||
free(buffer);
|
||||
return result;
|
||||
}
|
||||
|
||||
TEEC_Result Invoke_SetInstanceData(TEEC_Session *session, uint32_t commandID, char *buffer, uint32_t caseNum,
|
||||
uint32_t *origin)
|
||||
{
|
||||
TEEC_Result result = TEEC_SUCCESS;
|
||||
TEEC_Operation operation = { 0 };
|
||||
|
||||
// Invoke command
|
||||
operation.started = 1;
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_NONE, TEEC_NONE);
|
||||
operation.params[0].value.a = caseNum;
|
||||
operation.params[1].tmpref.buffer = buffer;
|
||||
operation.params[1].tmpref.size = strlen(buffer) + 1;
|
||||
|
||||
result = TEEC_InvokeCommand(session, commandID, &operation, origin);
|
||||
return result;
|
||||
}
|
||||
|
||||
TEEC_Result Invoke_GetInstanceData(TEEC_Session *session, uint32_t commandID, char *buffer, uint32_t *bufSize,
|
||||
uint32_t *origin)
|
||||
{
|
||||
TEEC_Result result = TEEC_SUCCESS;
|
||||
TEEC_Operation operation = { 0 };
|
||||
|
||||
// Invoke command
|
||||
operation.started = 1;
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_OUTPUT, TEEC_NONE, TEEC_NONE, TEEC_NONE);
|
||||
operation.params[0].tmpref.buffer = buffer;
|
||||
operation.params[0].tmpref.size = *bufSize;
|
||||
|
||||
result = TEEC_InvokeCommand(session, commandID, &operation, origin);
|
||||
*bufSize = operation.params[0].tmpref.size;
|
||||
return result;
|
||||
}
|
||||
|
||||
static void retrieveUint32toBuffer(uint8_t *buffer, uint32_t i)
|
||||
{
|
||||
buffer[3] = i & 0xff;
|
||||
buffer[2] = (i >> 8) & 0xff;
|
||||
buffer[1] = (i >> 16) & 0xff;
|
||||
buffer[0] = (i >> 24) & 0xff;
|
||||
}
|
||||
|
||||
static void retrieveUint16toBuffer(uint8_t *buffer, uint16_t i)
|
||||
{
|
||||
buffer[1] = i & 0xff;
|
||||
buffer[0] = (i >> 8) & 0xff;
|
||||
}
|
||||
|
||||
TEEC_Result Invoke_OpenTASession(TEEC_Session *session, uint32_t commandID, uint32_t *ta2taSession, TestData *testData,
|
||||
uint32_t *origin)
|
||||
{
|
||||
TEEC_Result result = TEEC_SUCCESS;
|
||||
TEEC_Operation operation = { 0 };
|
||||
uint8_t tempBuffer[16];
|
||||
int rc;
|
||||
|
||||
retrieveUint32toBuffer(tempBuffer, testData->uuid.timeLow);
|
||||
retrieveUint16toBuffer(tempBuffer + 4, testData->uuid.timeMid);
|
||||
retrieveUint16toBuffer(tempBuffer + 6, testData->uuid.timeHiAndVersion);
|
||||
rc = memcpy_s(tempBuffer + 8, 8, &(testData->uuid.clockSeqAndNode), 8);
|
||||
if (rc != 0) {
|
||||
TEST_PRINT_ERROR("memcpy_s uuid to tee failed, rc=0x%x\n", rc);
|
||||
return TEEC_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
// Invoke command
|
||||
operation.started = 1;
|
||||
operation.paramTypes =
|
||||
TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_VALUE_OUTPUT, TEEC_MEMREF_TEMP_INOUT);
|
||||
operation.params[0].value.a = testData->caseId;
|
||||
operation.params[1].tmpref.buffer = tempBuffer;
|
||||
operation.params[1].tmpref.size = sizeof(tempBuffer);
|
||||
operation.params[3].tmpref.buffer = testData->inBuffer;
|
||||
operation.params[3].tmpref.size = testData->inBufferLen;
|
||||
|
||||
result = TEEC_InvokeCommand(session, commandID, &operation, origin);
|
||||
*ta2taSession = operation.params[2].value.a;
|
||||
testData->origin = operation.params[2].value.b;
|
||||
testData->inBufferLen = operation.params[3].tmpref.size;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
TEEC_Result Invoke_CloseTASession(TEEC_Session *session, uint32_t commandID, uint32_t ta2taSession, uint32_t *origin)
|
||||
{
|
||||
TEEC_Result result = TEEC_SUCCESS;
|
||||
TEEC_Operation operation = { 0 };
|
||||
|
||||
// Invoke command
|
||||
operation.started = 1;
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE, TEEC_NONE, TEEC_NONE);
|
||||
operation.params[0].value.a = ta2taSession;
|
||||
|
||||
result = TEEC_InvokeCommand(session, commandID, &operation, origin);
|
||||
return result;
|
||||
}
|
||||
|
||||
TEEC_Result Invoke_InvokeTACommand(TEEC_Session *session, uint32_t commandID, uint32_t ta2taSession, TestData *testData,
|
||||
uint32_t *origin)
|
||||
{
|
||||
TEEC_Result result = TEEC_SUCCESS;
|
||||
TEEC_Operation operation = { 0 };
|
||||
|
||||
// Invoke command
|
||||
operation.started = 1;
|
||||
operation.paramTypes =
|
||||
TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INOUT, TEEC_VALUE_OUTPUT, TEEC_MEMREF_TEMP_OUTPUT);
|
||||
operation.params[0].value.a = testData->caseId;
|
||||
operation.params[0].value.b = ta2taSession;
|
||||
operation.params[1].tmpref.buffer = testData->inBuffer;
|
||||
operation.params[1].tmpref.size = testData->inBufferLen;
|
||||
operation.params[3].tmpref.buffer = testData->outBuffer;
|
||||
operation.params[3].tmpref.size = testData->outBufferLen;
|
||||
result = TEEC_InvokeCommand(session, commandID, &operation, origin);
|
||||
testData->origin = operation.params[2].value.a;
|
||||
testData->inBufferLen = operation.params[1].tmpref.size;
|
||||
testData->outBufferLen = operation.params[3].tmpref.size;
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t get_ta_data_size(TEEC_Context *context, TEEC_Session *session)
|
||||
{
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU32;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_DATASIZE, sizeof(GPD_TA_DATASIZE));
|
||||
if (rc != 0) {
|
||||
TEST_PRINT_ERROR("memcpy_s for GPD_TA_DATASIZE fail,rc=0x%x\n", rc);
|
||||
return -1;
|
||||
}
|
||||
value.inBufferLen = sizeof(GPD_TA_DATASIZE);
|
||||
Invoke_GetPropertyAsX(context, session, &value);
|
||||
|
||||
return atoi(value.outBuffer);
|
||||
}
|
||||
|
||||
uint32_t get_ta_stack_size(TEEC_Context *context, TEEC_Session *session)
|
||||
{
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU32;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_STACKSIZE, sizeof(GPD_TA_STACKSIZE));
|
||||
if (rc != 0) {
|
||||
TEST_PRINT_ERROR("memcpy_s for GPD_TA_STACKSIZE fail,rc=0x%x\n", rc);
|
||||
return -1;
|
||||
}
|
||||
value.inBufferLen = sizeof(GPD_TA_STACKSIZE);
|
||||
|
||||
Invoke_GetPropertyAsX(context, session, &value);
|
||||
return atoi(value.outBuffer);
|
||||
}
|
||||
|
||||
TEEC_Result Invoke_Panic(TEEC_Session *session, uint32_t commandID, TEEC_Result panicCode, uint32_t *origin)
|
||||
{
|
||||
TEEC_Result result;
|
||||
TEEC_Operation operation = { 0 };
|
||||
|
||||
// Invoke command
|
||||
operation.started = 1;
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE, TEEC_NONE, TEEC_NONE);
|
||||
operation.params[0].value.a = panicCode;
|
||||
|
||||
result = TEEC_InvokeCommand(session, commandID, &operation, origin);
|
||||
return result;
|
||||
}
|
||||
@@ -1,251 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <common_test.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <securec.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <test_defines.h>
|
||||
#include <test_log.h>
|
||||
#include <test_tcf_cmdid.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
/**
|
||||
* @testcase.name : TEE_CheckMemoryAccessRights_With_Access_Read_Flag
|
||||
* @testcase.desc : test TA call TEE_CheckMemoryAccessRights to check buffer whether has Access_Read right
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_Access_Read_Flag, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.accessFlags = TEE_MEMORY_ACCESS_READ;
|
||||
ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_CheckMemoryAccessRights_With_Access_Write_Flag
|
||||
* @testcase.desc : test TA call TEE_CheckMemoryAccessRights to check buffer whether has Access_Write right
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_Access_Write_Flag, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.accessFlags = TEE_MEMORY_ACCESS_WRITE;
|
||||
ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_CheckMemoryAccessRights_With_Access_AnyOwner_Flag
|
||||
* @testcase.desc : test TA call TEE_CheckMemoryAccessRights to check buffer whether has Access_AnyOwner right
|
||||
* @testcase.expect : return TEEC_ERROR_ACCESS_DENIED
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_Access_AnyOwner_Flag, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.accessFlags = TEE_MEMORY_ACCESS_ANY_OWNER;
|
||||
ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ACCESS_DENIED);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_CheckMemoryAccessRights_With_FlagIsZero
|
||||
* @testcase.desc : test TA call TEE_CheckMemoryAccessRights to check buffer while flag is zero
|
||||
* @testcase.expect : return TEEC_ERROR_ACCESS_DENIED
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_FlagIsZero, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.accessFlags = 0;
|
||||
ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ACCESS_DENIED);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_CheckMemoryAccessRights_With_BufferIsNull
|
||||
* @testcase.desc : test TA call TEE_CheckMemoryAccessRights to check buffer while assigned buffer is null
|
||||
* @testcase.expect : return TEEC_ERROR_ACCESS_DENIED
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_BufferIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.accessFlags = TEE_MEMORY_ACCESS_READ;
|
||||
value.caseId = INPUT_ISNULL;
|
||||
ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ACCESS_DENIED);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_CheckMemoryAccessRights_With_BufferIsFree
|
||||
* @testcase.desc : test TA call TEE_CheckMemoryAccessRights to check buffer while assigned buffer is freeed
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_BufferIsFree, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.accessFlags = TEE_MEMORY_ACCESS_READ;
|
||||
value.caseId = BUFFER_IS_FREE;
|
||||
ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_CheckMemoryAccessRights_With_BufferIsParam
|
||||
* @testcase.desc : test TA call TEE_CheckMemoryAccessRights to check buffer while assigned buffer is param type
|
||||
* @testcase.expect : return TEEC_ERROR_ACCESS_DENIED
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_BufferIsParam, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.accessFlags = TEE_MEMORY_ACCESS_READ;
|
||||
value.caseId = BUFFER_IS_PARAM;
|
||||
ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ACCESS_DENIED);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_CheckMemoryAccessRights_With_BufferIsNotMalloc
|
||||
* @testcase.desc : test TA call TEE_CheckMemoryAccessRights while buffer is not alloced,it is on stack
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_BufferIsNotMalloc, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.accessFlags = TEE_MEMORY_ACCESS_READ | TEE_MEMORY_ACCESS_WRITE;
|
||||
value.caseId = BUFFER_ISNOT_MALLOC;
|
||||
ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_CheckMemoryAccessRights_With_SizeIsZero
|
||||
* @testcase.desc : test TA call TEE_CheckMemoryAccessRights to check buffer while size is zero
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_SizeIsZero, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.accessFlags = TEE_MEMORY_ACCESS_READ | TEE_MEMORY_ACCESS_WRITE;
|
||||
value.caseId = OUTPUTBUFFERSIZE_ISZERO;
|
||||
ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_CheckMemoryAccessRights_With_SizeIsTooBig
|
||||
* @testcase.desc : test TA call TEE_CheckMemoryAccessRights to check buffer while size is too big
|
||||
* @testcase.expect : return TEEC_ERROR_ACCESS_DENIED
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_SizeIsTooBig, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.accessFlags = TEE_MEMORY_ACCESS_READ | TEE_MEMORY_ACCESS_WRITE;
|
||||
value.caseId = BUFFERSIZE_ISTOOBIG;
|
||||
ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ACCESS_DENIED);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_CheckMemoryAccessRights_With_GlobalVar
|
||||
* @testcase.desc : test TA call TEE_CheckMemoryAccessRights while buffer is global variable
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_GlobalVar, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.accessFlags = TEE_MEMORY_ACCESS_READ | TEE_MEMORY_ACCESS_WRITE;
|
||||
value.caseId = BUFFER_IS_GLOBALVAR;
|
||||
ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_CheckMemoryAccessRights_With_ReadRight_GlobalConstVar
|
||||
* @testcase.desc : test TA call TEE_CheckMemoryAccessRights while buffer is global variable
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_ReadRight_GlobalConstVar, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.accessFlags = TEE_MEMORY_ACCESS_READ;
|
||||
value.caseId = BUFFER_IS_GLOBALCONSTVAR;
|
||||
ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_CheckMemoryAccessRights_With_WriteRight_GlobalConstVar
|
||||
* @testcase.desc : test TA call TEE_CheckMemoryAccessRights while buffer is global variable
|
||||
* @testcase.expect : return TEEC_ERROR_ACCESS_DENIED
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_WriteRight_GlobalConstVar, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.accessFlags = TEE_MEMORY_ACCESS_WRITE;
|
||||
value.caseId = BUFFER_IS_GLOBALCONSTVAR;
|
||||
ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ACCESS_DENIED);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <common_test.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <securec.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <test_defines.h>
|
||||
#include <test_log.h>
|
||||
#include <test_tcf_cmdid.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
/**
|
||||
* @testcase.name : TEE_Free_With_BufferIsNull
|
||||
* @testcase.desc : test TA call TEE_Free to while buff is null
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Free_With_BufferIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t origin;
|
||||
uint32_t caseId = INPUT_ISNULL;
|
||||
|
||||
ret = Invoke_Free(GetSession(), CMD_TEE_Free, caseId, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Free_With_BufferIsNotMalloc
|
||||
* @testcase.desc : test TA call TEE_Free to while buff is not alloc, it is on stack
|
||||
* @testcase.expect : return TEEC_ERROR_TARGET_DEAD, ta will crash
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Free_With_BufferIsNotMalloc, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t origin;
|
||||
uint32_t caseId = BUFFER_ISNOT_MALLOC;
|
||||
|
||||
ret = Invoke_Free(GetSession(), CMD_TEE_Free, caseId, &origin);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_TARGET_DEAD);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <common_test.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <securec.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <test_defines.h>
|
||||
#include <test_log.h>
|
||||
#include <test_tcf_cmdid.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
/**
|
||||
* @testcase.name : TEE_Set_And_GetInstanceData_With_Success
|
||||
* @testcase.desc : test TA call TEE_SetInstanceData and TEE_GetInstanceData to use instance data
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Set_And_GetInstanceData_With_Success, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t origin;
|
||||
char inBuf[] = { 'T', 'E', 'E', 'A', '\0', };
|
||||
char outBuf[BIG_SIZE] = { 0 };
|
||||
uint32_t caseId = 0;
|
||||
uint32_t outLen = sizeof(outBuf);
|
||||
|
||||
ret = Invoke_SetInstanceData(GetSession(), CMD_TEE_SetInstanceData, inBuf, caseId, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
|
||||
ret = Invoke_GetInstanceData(GetSession(), CMD_TEE_GetInstanceData, outBuf, &outLen, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(inBuf, outBuf);
|
||||
ASSERT_EQ(outLen, strlen(inBuf) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Set_And_GetInstanceData_With_InstanceDataIsNull
|
||||
* @testcase.desc : test TA call TEE_SetInstanceData and TEE_GetInstanceData to use instance data is null
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Set_And_GetInstanceData_With_InstanceDataIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t origin;
|
||||
char inBuf[] = { 'T', 'E', 'E', 'A', '\0', };
|
||||
char outBuf[BIG_SIZE] = { 0 };
|
||||
uint32_t caseId = INPUT_ISNULL;
|
||||
uint32_t outLen = sizeof(outBuf);
|
||||
|
||||
ret = Invoke_SetInstanceData(GetSession(), CMD_TEE_SetInstanceData, inBuf, caseId, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
|
||||
ret = Invoke_GetInstanceData(GetSession(), CMD_TEE_GetInstanceData, outBuf, &outLen, &origin);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_GENERIC);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Set_And_GetInstanceData_With_GetSizeTooShort
|
||||
* @testcase.desc : test TA call TEE_SetInstanceData and TEE_GetInstanceData to use instancedata while get size
|
||||
* too short
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Set_And_GetInstanceData_With_GetSizeTooShort, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t origin;
|
||||
char inBuf[] = { 'T', 'E', 'E', 'A', '\0', };
|
||||
char outBuf[BIG_SIZE] = { 0 };
|
||||
uint32_t caseId = 0;
|
||||
uint32_t outLen = strlen(inBuf) - 1;
|
||||
|
||||
ret = Invoke_SetInstanceData(GetSession(), CMD_TEE_SetInstanceData, inBuf, caseId, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
|
||||
ret = Invoke_GetInstanceData(GetSession(), CMD_TEE_GetInstanceData, outBuf, &outLen, &origin);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(outLen, strlen(inBuf) + 1);
|
||||
}
|
||||
@@ -1,221 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <common_test.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <securec.h>
|
||||
#include <stdlib.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <test_defines.h>
|
||||
#include <test_log.h>
|
||||
#include <test_tcf_cmdid.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
/**
|
||||
* @testcase.name : TEE_Malloc_With_TEE_MALLOC_FILL_ZERO
|
||||
* @testcase.desc : test TA call TEE_Malloc to alloc buffer 10 bytes with hint is TEE_MALLOC_FILL_ZERO
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Malloc_With_TEE_MALLOC_FILL_ZERO, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t origin;
|
||||
char *buffer = reinterpret_cast<char *>(malloc(MAX_SHARE_SIZE));
|
||||
ASSERT_STRNE(buffer, NULL);
|
||||
(void)memset_s(buffer, TESTSIZE, 0x41, TESTSIZE); // 0x41 = 'A'
|
||||
|
||||
TestMemData value = { 0 };
|
||||
value.inMemSize = TESTSIZE;
|
||||
value.inHint = TEE_MALLOC_FILL_ZERO;
|
||||
value.testBuffer = buffer;
|
||||
ret = Invoke_Malloc(GetSession(), CMD_TEE_Malloc, &value, &origin);
|
||||
EXPECT_EQ(ret, TEEC_SUCCESS);
|
||||
EXPECT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
EXPECT_STREQ(buffer, EXPECTBUFFER_ZERO);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Malloc_With_TEE_MALLOC_NO_FILL
|
||||
* @testcase.desc : test TA call TEE_Malloc to alloc buffer 10 bytes with hint is TEE_MALLOC_NO_FILL
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Malloc_With_TEE_MALLOC_NO_FILL, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t origin;
|
||||
char *buffer = reinterpret_cast<char *>(malloc(MAX_SHARE_SIZE));
|
||||
ASSERT_STRNE(buffer, NULL);
|
||||
(void)memset_s(buffer, TESTSIZE, 0x41, TESTSIZE); // 0x41 = 'A'
|
||||
|
||||
TestMemData value = { 0 };
|
||||
value.inMemSize = TESTSIZE;
|
||||
value.inHint = TEE_MALLOC_NO_FILL;
|
||||
value.testBuffer = buffer;
|
||||
ret = Invoke_Malloc(GetSession(), CMD_TEE_Malloc, &value, &origin);
|
||||
EXPECT_EQ(ret, TEEC_SUCCESS);
|
||||
EXPECT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
EXPECT_STRNE(buffer, EXPECTBUFFER_A);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Malloc_With_TEE_MALLOC_NO_SHARE
|
||||
* @testcase.desc : test TA call TEE_Malloc to alloc buffer 10 bytes with hint is TEE_MALLOC_NO_SHARE
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Malloc_With_TEE_MALLOC_NO_SHARE, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t origin;
|
||||
char *buffer = reinterpret_cast<char *>(malloc(MAX_SHARE_SIZE));
|
||||
ASSERT_STRNE(buffer, NULL);
|
||||
(void)memset_s(buffer, TESTSIZE, 0x41, TESTSIZE); // 0x41 = 'A'
|
||||
|
||||
TestMemData value = { 0 };
|
||||
value.inMemSize = TESTSIZE;
|
||||
value.inHint = TEE_MALLOC_NO_SHARE;
|
||||
value.testBuffer = buffer;
|
||||
ret = Invoke_Malloc(GetSession(), CMD_TEE_Malloc, &value, &origin);
|
||||
EXPECT_EQ(ret, TEEC_SUCCESS);
|
||||
EXPECT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
EXPECT_STRNE(buffer, EXPECTBUFFER_A);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Malloc_With_TEE_MALLOC_NO_FILL_And_NO_SHARE
|
||||
* @testcase.desc : test TA call TEE_Malloc to alloc 10 bytes with hint is TEE_MALLOC_NO_FILL|TEE_MALLOC_NO_SHARE
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Malloc_With_TEE_MALLOC_NO_FILL_And_NO_SHARE, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t origin;
|
||||
char *buffer = reinterpret_cast<char *>(malloc(MAX_SHARE_SIZE));
|
||||
ASSERT_STRNE(buffer, NULL);
|
||||
(void)memset_s(buffer, TESTSIZE, 0x41, TESTSIZE); // 0x41 = 'A'
|
||||
|
||||
TestMemData value = { 0 };
|
||||
value.inMemSize = TESTSIZE;
|
||||
value.inHint = TEE_MALLOC_NO_FILL | TEE_MALLOC_NO_SHARE;
|
||||
value.testBuffer = buffer;
|
||||
ret = Invoke_Malloc(GetSession(), CMD_TEE_Malloc, &value, &origin);
|
||||
EXPECT_EQ(ret, TEEC_SUCCESS);
|
||||
EXPECT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
EXPECT_STRNE(buffer, EXPECTBUFFER_A);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Malloc_With_HINT_RESERVE
|
||||
* @testcase.desc : test TA call TEE_Malloc to alloc buffer 10 bytes with hint is HINT_RESERVE
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Malloc_With_HINT_RESERVE, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t origin;
|
||||
char *buffer = reinterpret_cast<char *>(malloc(MAX_SHARE_SIZE));
|
||||
ASSERT_STRNE(buffer, NULL);
|
||||
(void)memset_s(buffer, TESTSIZE, 0x41, TESTSIZE); // 0x41 = 'A'
|
||||
|
||||
TestMemData value = { 0 };
|
||||
value.inMemSize = TESTSIZE;
|
||||
value.inHint = HINT_RESERVE;
|
||||
value.testBuffer = buffer;
|
||||
ret = Invoke_Malloc(GetSession(), CMD_TEE_Malloc, &value, &origin);
|
||||
EXPECT_EQ(ret, TEEC_SUCCESS);
|
||||
EXPECT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
EXPECT_STRNE(buffer, EXPECTBUFFER_A);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Malloc_With_SIZEIsZero
|
||||
* @testcase.desc : test TA call TEE_Malloc to alloc buffer with size is zero
|
||||
* @testcase.expect : return TEEC_ERROR_OUT_OF_MEMORY
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Malloc_With_SizeIsZero, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t origin;
|
||||
char *buffer = reinterpret_cast<char *>(malloc(MAX_SHARE_SIZE));
|
||||
ASSERT_STRNE(buffer, NULL);
|
||||
(void)memset_s(buffer, TESTSIZE, 0x0, TESTSIZE);
|
||||
|
||||
TestMemData value = { 0 };
|
||||
value.inMemSize = 0;
|
||||
value.inHint = TEE_MALLOC_FILL_ZERO;
|
||||
value.testBuffer = buffer;
|
||||
ret = Invoke_Malloc(GetSession(), CMD_TEE_Malloc, &value, &origin);
|
||||
EXPECT_EQ(ret, TEEC_ERROR_OUT_OF_MEMORY);
|
||||
EXPECT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Malloc_With_SizeExceedHeapLimit
|
||||
* @testcase.desc : test TA call TEE_Malloc to alloc buffer with size exceed heaplimit
|
||||
* @testcase.expect : return TEEC_ERROR_OUT_OF_MEMORY
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Malloc_With_SizeExceedHeapLimit, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t origin;
|
||||
char *buffer = reinterpret_cast<char *>(malloc(MAX_SHARE_SIZE));
|
||||
ASSERT_STRNE(buffer, NULL);
|
||||
(void)memset_s(buffer, TESTSIZE, 0x0, TESTSIZE);
|
||||
|
||||
uint32_t dateSize = get_ta_data_size(GetContext(), GetSession());
|
||||
EXPECT_GT(dateSize, 0);
|
||||
|
||||
uint32_t stackSize = get_ta_stack_size(GetContext(), GetSession());
|
||||
EXPECT_GT(stackSize, 0);
|
||||
|
||||
TestMemData value = { 0 };
|
||||
value.inMemSize = dateSize + stackSize;
|
||||
value.inHint = TEE_MALLOC_FILL_ZERO;
|
||||
value.testBuffer = buffer;
|
||||
ret = Invoke_Malloc(GetSession(), CMD_TEE_Malloc, &value, &origin);
|
||||
EXPECT_EQ(ret, TEEC_ERROR_OUT_OF_MEMORY);
|
||||
EXPECT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Malloc_With_MAXDataSize
|
||||
* @testcase.desc : test TA call TEE_Malloc to alloc buffer with size is max data size
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_Malloc_With_MAXDataSize, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t origin;
|
||||
char *buffer = reinterpret_cast<char *>(malloc(MAX_SHARE_SIZE));
|
||||
ASSERT_STRNE(buffer, NULL);
|
||||
(void)memset_s(buffer, TESTSIZE, 0x41, TESTSIZE); // 0x41 = 'A'
|
||||
|
||||
uint32_t dateSize = get_ta_data_size(GetContext(), GetSession());
|
||||
EXPECT_GT(dateSize, 0);
|
||||
|
||||
TestMemData value = { 0 };
|
||||
value.inMemSize = dateSize;
|
||||
value.inHint = TEE_MALLOC_FILL_ZERO;
|
||||
value.testBuffer = buffer;
|
||||
ret = Invoke_Malloc(GetSession(), CMD_TEE_Malloc, &value, &origin);
|
||||
EXPECT_EQ(ret, TEEC_SUCCESS);
|
||||
EXPECT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
EXPECT_STREQ(buffer, EXPECTBUFFER_ZERO);
|
||||
free(buffer);
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <common_test.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <securec.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <test_defines.h>
|
||||
#include <test_log.h>
|
||||
#include <test_tcf_cmdid.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
/**
|
||||
* @testcase.name : TEE_MemCompare_With_Same
|
||||
* @testcase.desc : test TA call TEE_MemCompare to compare buffer1 and buffer2
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_MemCompare_With_Same, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t i;
|
||||
TestMemData value = { 0 };
|
||||
char buf1[TESTSIZE] = { 0 };
|
||||
char buf2[TESTSIZE] = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
for (i = 0; i < TESTSIZE; i++) {
|
||||
buf1[i] = (char)'A';
|
||||
buf2[i] = (char)'A';
|
||||
}
|
||||
ret = Invoke_MemCompare(GetSession(), CMD_TEE_MemCompare, &value, buf1, buf2);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_MemCompare_With_Buffer1LessBuffer2
|
||||
* @testcase.desc : test TA call TEE_MemCompare to compare buffer1 and buffer2, buffer1 < buffer2
|
||||
* @testcase.expect : return -1
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_MemCompare_With_Buffer1LessBuffer2, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t i;
|
||||
TestMemData value = { 0 };
|
||||
char buf1[TESTSIZE] = { 0 };
|
||||
char buf2[TESTSIZE] = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
for (i = 0; i < TESTSIZE - 1; i++) {
|
||||
buf1[i] = (char)'A';
|
||||
buf2[i] = (char)'A';
|
||||
}
|
||||
buf1[TESTSIZE - 1] = (char)'A';
|
||||
buf2[TESTSIZE - 1] = (char)'B';
|
||||
|
||||
ret = Invoke_MemCompare(GetSession(), CMD_TEE_MemCompare, &value, buf1, buf2);
|
||||
ASSERT_EQ(ret, -1);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_MemCompare_With_Buffer1GreaterBuffer2
|
||||
* @testcase.desc : test TA call TEE_MemCompare to compare buffer1 and buffer2, buffer1 > buffer2
|
||||
* @testcase.expect : return -1
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_MemCompare_With_Buffer1GreaterBuffer2, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t i;
|
||||
TestMemData value = { 0 };
|
||||
char buf1[TESTSIZE] = { 0 };
|
||||
char buf2[TESTSIZE] = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
for (i = 0; i < TESTSIZE - 1; i++) {
|
||||
buf1[i] = (char)'A';
|
||||
buf2[i] = (char)'A';
|
||||
}
|
||||
buf1[TESTSIZE - 1] = (char)'B';
|
||||
buf2[TESTSIZE - 1] = (char)'A';
|
||||
|
||||
ret = Invoke_MemCompare(GetSession(), CMD_TEE_MemCompare, &value, buf1, buf2);
|
||||
ASSERT_EQ(ret, 1);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_MemCompare_With_Buffer1IsNull
|
||||
* @testcase.desc : test TA call TEE_MemCompare compare while buffer1 is null
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_MemCompare_With_Buffer1IsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t i;
|
||||
TestMemData value = { 0 };
|
||||
char buf1[TESTSIZE] = { 0 };
|
||||
char buf2[TESTSIZE] = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
for (i = 0; i < TESTSIZE; i++) {
|
||||
buf1[i] = (char)'A';
|
||||
buf2[i] = (char)'A';
|
||||
}
|
||||
value.caseId = INPUT_ISNULL;
|
||||
ret = Invoke_MemCompare(GetSession(), CMD_TEE_MemCompare, &value, buf1, buf2);
|
||||
ASSERT_EQ(ret, -1);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_MemCompare_With_Buffer2IsNull
|
||||
* @testcase.desc : test TA call TEE_MemCompare compare while buffer2 is null
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_MemCompare_With_Buffer2IsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t i;
|
||||
TestMemData value = { 0 };
|
||||
char buf1[TESTSIZE] = { 0 };
|
||||
char buf2[TESTSIZE] = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
for (i = 0; i < TESTSIZE; i++) {
|
||||
buf1[i] = (char)'A';
|
||||
buf2[i] = (char)'A';
|
||||
}
|
||||
value.caseId = OUTPUT_ISNULL;
|
||||
ret = Invoke_MemCompare(GetSession(), CMD_TEE_MemCompare, &value, buf1, buf2);
|
||||
ASSERT_EQ(ret, 1);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_MemCompare_With_SizeIsZero
|
||||
* @testcase.desc : test TA call TEE_MemCompare compare while size is zero
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_MemCompare_With_SizeIsZero, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t i;
|
||||
TestMemData value = { 0 };
|
||||
char buf1[TESTSIZE] = { 0 };
|
||||
char buf2[TESTSIZE] = { 0 };
|
||||
|
||||
value.oldSize = 0;
|
||||
for (i = 0; i < TESTSIZE; i++) {
|
||||
buf1[i] = (char)'A';
|
||||
buf2[i] = (char)'B';
|
||||
}
|
||||
|
||||
ret = Invoke_MemCompare(GetSession(), CMD_TEE_MemCompare, &value, buf1, buf2);
|
||||
ASSERT_EQ(ret, 0);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <common_test.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <securec.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <test_defines.h>
|
||||
#include <test_log.h>
|
||||
#include <test_tcf_cmdid.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
/**
|
||||
* @testcase.name : TEE_MemFill_With_Success
|
||||
* @testcase.desc : test TA call TEE_MemFill to fill buffer with char assigned in TA
|
||||
* @testcase.expect : return TEEC_SUCCESS, buffer is filled match expect
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_MemFill_With_Success, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
char outBuf[TESTSIZE + 1] = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
ret = Invoke_MemMove_Or_Fill(GetSession(), CMD_TEE_MemFill, &value, outBuf);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(outBuf, EXPECTBUFFER_A);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_MemFill_With_BufferIsNull
|
||||
* @testcase.desc : test TA call TEE_MemFill while buffer is null
|
||||
* @testcase.expect : return TEEC_SUCCESS, buffer is not filled and is 0
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_MemFill_With_BufferIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
char outBuf[TESTSIZE] = { 0 };
|
||||
uint32_t i;
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.caseId = INPUT_ISNULL;
|
||||
ret = Invoke_MemMove_Or_Fill(GetSession(), CMD_TEE_MemFill, &value, outBuf);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
for (i = 0; i < TESTSIZE; i++) {
|
||||
ASSERT_EQ(outBuf[i], 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_MemFill_With_SizeIsZero
|
||||
* @testcase.desc : test TA call TEE_MemFill while size is zero
|
||||
* @testcase.expect : return TEEC_SUCCESS, buffer is not filled and is 0
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_MemFill_With_SizeIsZero, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
char outBuf[TESTSIZE] = { 0 };
|
||||
uint32_t i;
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.caseId = OUTPUTBUFFERSIZE_ISZERO;
|
||||
ret = Invoke_MemMove_Or_Fill(GetSession(), CMD_TEE_MemFill, &value, outBuf);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
for (i = 0; i < TESTSIZE; i++) {
|
||||
ASSERT_EQ(outBuf[i], 0);
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <common_test.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <securec.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <test_defines.h>
|
||||
#include <test_log.h>
|
||||
#include <test_tcf_cmdid.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
/**
|
||||
* @testcase.name : TEE_MemMove_With_Success
|
||||
* @testcase.desc : test TA call TEE_MemMove to move buffer from src to dest
|
||||
* @testcase.expect : return TEEC_SUCCESS, dest buffer is same as src buffer
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_MemMove_With_Success, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
char outBuf[TESTSIZE + 1] = {0};
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
ret = Invoke_MemMove_Or_Fill(GetSession(), CMD_TEE_MemMove, &value, outBuf);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(outBuf, EXPECTBUFFER_A);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_MemMove_With_SrcBufferIsNull
|
||||
* @testcase.desc : test TA call TEE_MemMove to move buffer while srcbuffer is null
|
||||
* @testcase.expect : return TEEC_SUCCESS, dest buffer is not same as src buffer
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_MemMove_With_SrcBufferIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
char outBuf[TESTSIZE + 1] = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.caseId = INPUT_ISNULL;
|
||||
ret = Invoke_MemMove_Or_Fill(GetSession(), CMD_TEE_MemMove, &value, outBuf);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(outBuf, EXPECTBUFFER_B);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_MemMove_With_DestBufferIsNull
|
||||
* @testcase.desc : test TA call TEE_MemMove to move buffer while destbuffer is null
|
||||
* @testcase.expect : return TEEC_SUCCESS, dest buffer is not same as src buffer
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_MemMove_With_DestBufferIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
char outBuf[TESTSIZE + 1] = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.caseId = OUTPUT_ISNULL;
|
||||
ret = Invoke_MemMove_Or_Fill(GetSession(), CMD_TEE_MemMove, &value, outBuf);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(outBuf, EXPECTBUFFER_B);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_MemMove_With_SizeIsZero
|
||||
* @testcase.desc : test TA call TEE_MemMove to move buffer while size is zero
|
||||
* @testcase.expect : return TEEC_SUCCESS, dest buffer is not same as src buffer
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_MemMove_With_SizeIsZero, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
char outBuf[TESTSIZE + 1] = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.caseId = OUTPUTBUFFERSIZE_ISZERO;
|
||||
ret = Invoke_MemMove_Or_Fill(GetSession(), CMD_TEE_MemMove, &value, outBuf);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(outBuf, EXPECTBUFFER_B);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_MemMove_With_DestIsSameAsSrc
|
||||
* @testcase.desc : test TA call TEE_MemMove to move buffer while destbuffer addr is same as srcbuffer addr
|
||||
* @testcase.expect : return TEEC_SUCCESS, dest buffer is not same as src buffer
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_MemMove_With_DestIsSameAsSrc, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
char outBuf[TESTSIZE + 1] = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.caseId = DESTANDSRC_ISSAME;
|
||||
ret = Invoke_MemMove_Or_Fill(GetSession(), CMD_TEE_MemMove, &value, outBuf);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(outBuf, EXPECTBUFFER_B);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_MemMove_With_Overlap
|
||||
* @testcase.desc : test TA call TEE_MemMove to move buffer while src buffer and dest buffer is overlap
|
||||
* @testcase.expect : return TEEC_SUCCESS, dest buffer is same as src buffer
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_MemMove_With_Overlap, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
char outBuf[TESTSIZE + 1] = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.caseId = DESTANDSRC_OVERLAP;
|
||||
ret = Invoke_MemMove_Or_Fill(GetSession(), CMD_TEE_MemMove, &value, outBuf);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(outBuf, EXPECTBUFFER_OVERLAP);
|
||||
}
|
||||
@@ -1,187 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <common_test.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <securec.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <test_defines.h>
|
||||
#include <test_log.h>
|
||||
#include <test_tcf_cmdid.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Realloc_With_SameSize
|
||||
* @testcase.desc : test TA call TEE_Realloc to alloc buffer with newsize is same as oldsize
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Realloc_With_SameSize, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
char outBuf[TESTSIZE + 1] = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.newSize = TESTSIZE;
|
||||
ret = Invoke_Realloc(GetSession(), CMD_TEE_Realloc, &value, outBuf);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(value.oldAddr, value.newAddr);
|
||||
ASSERT_STREQ(outBuf, EXPECTBUFFER_A);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Realloc_With_LessSize
|
||||
* @testcase.desc : test TA call TEE_Realloc to alloc buffer with newsize is less than oldsize
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Realloc_With_LessSize, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
char outBuf[TESTSIZE] = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.newSize = TESTSIZE - 1;
|
||||
ret = Invoke_Realloc(GetSession(), CMD_TEE_Realloc, &value, outBuf);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(value.oldAddr, value.newAddr);
|
||||
ASSERT_STREQ(outBuf, EXPECTBUFFER_A_LESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Realloc_With_GreaterSize
|
||||
* @testcase.desc : test TA call TEE_Realloc to alloc buffer with newsize is greater than oldsize
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Realloc_With_GreaterSize, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
char outBuf[BIG_SIZE] = { 0 };
|
||||
uint32_t i;
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.newSize = BIG_SIZE;
|
||||
ret = Invoke_Realloc(GetSession(), CMD_TEE_Realloc, &value, outBuf);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(outBuf, EXPECTBUFFER_A);
|
||||
|
||||
for (i = TESTSIZE; i < BIG_SIZE; i++) {
|
||||
ASSERT_EQ(outBuf[i], 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Realloc_With_NewSizeIsZero
|
||||
* @testcase.desc : test TA call TEE_Realloc to alloc buffer with newsize is 0
|
||||
* @testcase.expect : return TEEC_ERROR_OUT_OF_MEMORY
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Realloc_With_NewSizeIsZero, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
char outBuf[TESTSIZE] = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.newSize = 0;
|
||||
ret = Invoke_Realloc(GetSession(), CMD_TEE_Realloc, &value, outBuf);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_OUT_OF_MEMORY);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Realloc_With_SizeExceedHeapLimit
|
||||
* @testcase.desc : test TA call TEE_Realloc to alloc buffer with newsize exceed heaplimit
|
||||
* @testcase.expect : return TEEC_ERROR_OUT_OF_MEMORY
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Realloc_With_SizeExceedHeapLimit, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
char outBuf[TESTSIZE] = { 0 };
|
||||
|
||||
uint32_t dateSize = get_ta_data_size(GetContext(), GetSession());
|
||||
ASSERT_GT(dateSize, 0);
|
||||
|
||||
uint32_t stackSize = get_ta_stack_size(GetContext(), GetSession());
|
||||
ASSERT_GT(stackSize, 0);
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.newSize = dateSize + stackSize;
|
||||
ret = Invoke_Realloc(GetSession(), CMD_TEE_Realloc, &value, outBuf);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_OUT_OF_MEMORY);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Realloc_With_BufferIsNull
|
||||
* @testcase.desc : test TA call TEE_Realloc to alloc buffer with buffer is null
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Realloc_With_BufferIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
char outBuf[TESTSIZE + 1] = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.newSize = TESTSIZE;
|
||||
value.caseId = INPUT_ISNULL;
|
||||
ret = Invoke_Realloc(GetSession(), CMD_TEE_Realloc, &value, outBuf);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_NE(value.oldAddr, value.newAddr);
|
||||
ASSERT_STREQ(outBuf, EXPECTBUFFER_A);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Realloc_With_BufferIsNotMalloc
|
||||
* @testcase.desc : test TA call TEE_Realloc to alloc buffer with buffer is malloc, it is on stack
|
||||
* @testcase.expect : return TEEC_ERROR_TARGET_DEAD
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Realloc_With_BufferIsNotMalloc, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
char outBuf[TESTSIZE] = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.newSize = TESTSIZE;
|
||||
value.caseId = BUFFER_ISNOT_MALLOC;
|
||||
ret = Invoke_Realloc(GetSession(), CMD_TEE_Realloc, &value, outBuf);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_TARGET_DEAD);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Realloc_With_BufferIsFree
|
||||
* @testcase.desc : test TA call TEE_Realloc to alloc buffer with buffer is freeed
|
||||
* @testcase.expect : return TEEC_ERROR_TARGET_DEAD, ta will crash
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_Realloc_With_BufferIsFree, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestMemData value = { 0 };
|
||||
char outBuf[TESTSIZE] = { 0 };
|
||||
|
||||
value.oldSize = TESTSIZE;
|
||||
value.newSize = TESTSIZE;
|
||||
value.caseId = BUFFER_IS_FREE;
|
||||
ret = Invoke_Realloc(GetSession(), CMD_TEE_Realloc, &value, outBuf);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_TARGET_DEAD);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
@@ -1,508 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <common_test.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <securec.h>
|
||||
#include <session_mgr/client_session_mgr.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <test_defines.h>
|
||||
#include <test_log.h>
|
||||
#include <test_tcf_cmdid.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
|
||||
static char g_teeOutput[] = "TEEMEM_OUTPUT";
|
||||
static char g_teeInout[] = "the param is TEEMEM_INOUT";
|
||||
static uint32_t g_teeOutputLen;
|
||||
static uint32_t g_teeInoutLen;
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_OpenTASession_With_Success
|
||||
* @testcase.desc : test TA call TEE_OpenTASession to call other TA
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2TA2TATest, TEE_OpenTASession_With_Success, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t ta2taSession;
|
||||
uint32_t origin = 0;
|
||||
TestData value = { 0 };
|
||||
value.caseId = 0;
|
||||
value.uuid = TCF_API_UUID_1; // this uuid is for ta2
|
||||
g_teeInoutLen = strlen(g_teeInout) + 1;
|
||||
|
||||
value.inBufferLen = BIG_SIZE;
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE);
|
||||
ASSERT_NE(ta2taSession, 0);
|
||||
|
||||
ASSERT_STREQ(value.inBuffer, g_teeInout);
|
||||
ASSERT_EQ(value.inBufferLen, g_teeInoutLen);
|
||||
|
||||
ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_OpenTASession_With_UUIDIsNULL
|
||||
* @testcase.desc : test TA call TEE_OpenTASession to call other TA while uuid is null
|
||||
* @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS
|
||||
*/
|
||||
TEE_TEST(TCF2TA2TATest, TEE_OpenTASession_With_UUIDIsNULL, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t ta2taSession;
|
||||
uint32_t origin = 0;
|
||||
TestData value = { 0 };
|
||||
value.caseId = INPUT_ISNULL;
|
||||
value.uuid = TCF_API_UUID_1; // this uuid is for ta2
|
||||
|
||||
value.inBufferLen = BIG_SIZE;
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_OpenTASession_With_OriginIsNULL
|
||||
* @testcase.desc : test TA call TEE_OpenTASession to call other TA while origin is null
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2TA2TATest, TEE_OpenTASession_With_OriginIsNULL, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t ta2taSession;
|
||||
uint32_t origin = 0;
|
||||
TestData value = { 0 };
|
||||
value.caseId = RETURNORIGIN_ISNULL;
|
||||
value.uuid = TCF_API_UUID_1; // this uuid is for ta2
|
||||
|
||||
value.inBufferLen = BIG_SIZE;
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_NE(ta2taSession, 0);
|
||||
|
||||
ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_OpenTASession_With_SessionIsNULL
|
||||
* @testcase.desc : test TA call TEE_OpenTASession to call other TA while session is null
|
||||
* @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS
|
||||
*/
|
||||
TEE_TEST(TCF2TA2TATest, TEE_OpenTASession_With_SessionIsNULL, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t ta2taSession;
|
||||
uint32_t origin = 0;
|
||||
TestData value = { 0 };
|
||||
value.caseId = OUTPUT_ISNULL;
|
||||
value.uuid = TCF_API_UUID_1; // this uuid is for ta2
|
||||
|
||||
value.inBufferLen = BIG_SIZE;
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_OpenTASession_With_NoAvailableSession
|
||||
* @testcase.desc : test TA call TEE_OpenTASession to call other TA while session is null
|
||||
* @testcase.expect : return TEEC_ERROR_BUSY
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_OpenTASession_With_NoAvailableSession, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t ta2taSession;
|
||||
uint32_t origin = 0;
|
||||
TestData value = { 0 };
|
||||
value.caseId = 0;
|
||||
|
||||
value.uuid = TCF_API_UUID_2; // this uuid is for ta2, this is a single session ta
|
||||
ClientSessionMgr sess;
|
||||
ret = sess.Start(&value.uuid);
|
||||
EXPECT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
value.inBufferLen = BIG_SIZE;
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin);
|
||||
sess.Destroy();
|
||||
ASSERT_EQ(ret, TEEC_ERROR_BUSY);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_OpenTASession_With_MaxSession
|
||||
* @testcase.desc : test TA call TEE_OpenTASession to call other TA to reach max session
|
||||
* @testcase.expect : return TEEC_ERROR_SESSION_MAXIMUM
|
||||
*/
|
||||
TEE_TEST(TCF2TA2TATest, TEE_OpenTASession_With_MaxSession, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t ta2taSession[8] = { 0 };
|
||||
uint32_t origin = 0;
|
||||
TestData value = { 0 };
|
||||
value.caseId = 0;
|
||||
value.uuid = TCF_API_UUID_1; // this uuid is for ta2
|
||||
int i;
|
||||
value.inBufferLen = BIG_SIZE;
|
||||
|
||||
for (i = 0; i <= 6; i++) {
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession[i], &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE);
|
||||
ASSERT_NE(ta2taSession[i], 0);
|
||||
if (i >= 1)
|
||||
ASSERT_NE(ta2taSession[i], ta2taSession[i - 1]);
|
||||
}
|
||||
|
||||
// ta2 has reach max session,so this time will open session fail
|
||||
value.inBufferLen = BIG_SIZE;
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession[i], &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_SESSION_MAXIMUM);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(ta2taSession[i], 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_OpenTASession_With_UUIDIsNotExist
|
||||
* @testcase.desc : test TA call TEE_OpenTASession to call other TA while uuid is not exist
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF2TA2TATest, TEE_OpenTASession_With_UUIDIsNotExist, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t ta2taSession;
|
||||
uint32_t origin = 0;
|
||||
TestData value = { 0 };
|
||||
value.caseId = 0;
|
||||
value.uuid = UUID_TA_NOT_EXIST; // this uuid is for ta2
|
||||
|
||||
value.inBufferLen = BIG_SIZE;
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_OpenTASession_With_TA2Crash
|
||||
* @testcase.desc : test TA call TEE_OpenTASession to call other TA while ta2 is crashed
|
||||
* @testcase.expect : return TEEC_ERROR_TARGET_DEAD
|
||||
*/
|
||||
TEE_TEST(TCF2TA2TATest, TEE_OpenTASession_With_TA2Crash, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t ta2taSession;
|
||||
uint32_t origin = 0;
|
||||
TestData value = { 0 };
|
||||
value.caseId = TA_CRASH_FLAG;
|
||||
value.uuid = TCF_API_UUID_1; // this uuid is for ta2
|
||||
|
||||
value.inBufferLen = BIG_SIZE;
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_TARGET_DEAD);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_OpenTASession_With_BufferNoFillNoShare
|
||||
* @testcase.desc : test TA call TEE_OpenTASession to call other TA while buffer hint is
|
||||
* TEE_MALLOC_NO_FILL|TEE_MALLOC_NO_SHARE
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2TA2TATest, TEE_OpenTASession_With_BufferNoFillNoShare, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t ta2taSession;
|
||||
uint32_t origin = 0;
|
||||
TestData value = { 0 };
|
||||
value.uuid = TCF_API_UUID_1; // this uuid is for ta2
|
||||
g_teeInoutLen = strlen(g_teeInout) + 1;
|
||||
|
||||
value.caseId = BUFFER_NOFILLNOSHARE;
|
||||
value.inBufferLen = BIG_SIZE;
|
||||
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE);
|
||||
ASSERT_NE(ta2taSession, 0);
|
||||
|
||||
ASSERT_STREQ(value.inBuffer, g_teeInout);
|
||||
ASSERT_EQ(value.inBufferLen, g_teeInoutLen);
|
||||
|
||||
ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_CloseTASession_With_MaxSession
|
||||
* @testcase.desc : test TA call TEE_CloseTASession when TA to reach max session, then can open new session to ta2
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2TA2TATest, TEE_CloseTASession_With_MaxSession, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t ta2taSession[8] = { 0 };
|
||||
uint32_t origin = 0;
|
||||
TestData value = { 0 };
|
||||
value.uuid = TCF_API_UUID_1; // this uuid is for ta2
|
||||
int i;
|
||||
value.inBufferLen = BIG_SIZE;
|
||||
|
||||
for (i = 0; i <= 6; i++) {
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession[i], &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE);
|
||||
ASSERT_NE(ta2taSession[i], 0);
|
||||
if (i >= 1)
|
||||
ASSERT_NE(ta2taSession[i], ta2taSession[i - 1]);
|
||||
}
|
||||
|
||||
// ta2 has reach max session,so this time will open session fail
|
||||
value.inBufferLen = BIG_SIZE;
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession[7], &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_SESSION_MAXIMUM);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(ta2taSession[7], 0);
|
||||
|
||||
// close one session of ta2
|
||||
ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession[6], &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
|
||||
// ta2 has close one session, so this time will open session success
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession[6], &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE);
|
||||
ASSERT_NE(ta2taSession[6], 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_InvokeTACommand_With_PARAM_TYPE_MEMREF
|
||||
* @testcase.desc : test TA call TEE_InvokeTACommand to pass memref params to other TA
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2TA2TATest, TEE_InvokeTACommand_With_PARAM_TYPE_MEMREF, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t ta2taSession;
|
||||
uint32_t origin = 0;
|
||||
TestData value = { 0 };
|
||||
value.uuid = TCF_API_UUID_1; // this uuid is for ta2
|
||||
g_teeOutputLen = strlen(g_teeOutput) + 1;
|
||||
g_teeInoutLen = strlen(g_teeInout) + 1;
|
||||
value.inBufferLen = BIG_SIZE;
|
||||
value.outBufferLen = BIG_SIZE;
|
||||
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE);
|
||||
ASSERT_NE(ta2taSession, 0);
|
||||
|
||||
(void)memset_s(value.inBuffer, BIG_SIZE, 0x41, BIG_SIZE);
|
||||
|
||||
ret = Invoke_InvokeTACommand(GetSession(), CMD_TEE_InvokeTACommand, ta2taSession, &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE);
|
||||
|
||||
ASSERT_STREQ(value.inBuffer, g_teeInout);
|
||||
ASSERT_EQ(value.inBufferLen, g_teeInoutLen);
|
||||
ASSERT_STREQ(value.outBuffer, g_teeOutput);
|
||||
ASSERT_EQ(value.outBufferLen, g_teeOutputLen);
|
||||
|
||||
ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_InvokeTACommand_With_SessionIsNull
|
||||
* @testcase.desc : test TA call TEE_InvokeTACommand to other TA while session is null
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF2TA2TATest, TEE_InvokeTACommand_With_SessionIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t ta2taSession;
|
||||
uint32_t origin = 0;
|
||||
TestData value = { 0 };
|
||||
value.uuid = TCF_API_UUID_1; // this uuid is for ta2
|
||||
value.inBufferLen = BIG_SIZE;
|
||||
value.outBufferLen = BIG_SIZE;
|
||||
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE);
|
||||
ASSERT_NE(ta2taSession, 0);
|
||||
|
||||
value.caseId = INPUT_ISNULL;
|
||||
ret = Invoke_InvokeTACommand(GetSession(), CMD_TEE_InvokeTACommand, ta2taSession, &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
|
||||
ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_InvokeTACommand_With_OriginIsNull
|
||||
* @testcase.desc : test TA call TEE_InvokeTACommand to other TA while origin is null
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2TA2TATest, TEE_InvokeTACommand_With_OriginIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t ta2taSession;
|
||||
uint32_t origin = 0;
|
||||
TestData value = { 0 };
|
||||
value.uuid = TCF_API_UUID_1; // this uuid is for ta2
|
||||
g_teeOutputLen = strlen(g_teeOutput) + 1;
|
||||
g_teeInoutLen = strlen(g_teeInout) + 1;
|
||||
value.inBufferLen = BIG_SIZE;
|
||||
value.outBufferLen = BIG_SIZE;
|
||||
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE);
|
||||
ASSERT_NE(ta2taSession, 0);
|
||||
|
||||
value.caseId = OUTPUT_ISNULL;
|
||||
(void)memset_s(value.inBuffer, BIG_SIZE, 0x41, BIG_SIZE);
|
||||
ret = Invoke_InvokeTACommand(GetSession(), CMD_TEE_InvokeTACommand, ta2taSession, &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
|
||||
ASSERT_STREQ(value.inBuffer, g_teeInout);
|
||||
ASSERT_EQ(value.inBufferLen, g_teeInoutLen);
|
||||
ASSERT_STREQ(value.outBuffer, g_teeOutput);
|
||||
ASSERT_EQ(value.outBufferLen, g_teeOutputLen);
|
||||
|
||||
ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_InvokeTACommand_With_TA2Crash
|
||||
* @testcase.desc : test TA call TEE_InvokeTACommand to other TA while ta2 is crash
|
||||
* @testcase.expect : return TEEC_ERROR_TARGET_DEAD
|
||||
*/
|
||||
TEE_TEST(TCF2TA2TATest, TEE_InvokeTACommand_With_TA2Crash, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t ta2taSession;
|
||||
uint32_t origin = 0;
|
||||
TestData value = { 0 };
|
||||
value.uuid = TCF_API_UUID_1; // this uuid is for ta2
|
||||
value.inBufferLen = BIG_SIZE;
|
||||
value.outBufferLen = BIG_SIZE;
|
||||
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE);
|
||||
ASSERT_NE(ta2taSession, 0);
|
||||
|
||||
value.caseId = TA_CRASH_FLAG;
|
||||
ret = Invoke_InvokeTACommand(GetSession(), CMD_TEE_InvokeTACommand, ta2taSession, &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_TARGET_DEAD);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
|
||||
ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_InvokeTACommand_With_MaxShareBufferSize
|
||||
* @testcase.desc : test TA call TEE_InvokeTACommand to pass memref to other TA while buffer size is MAX_SHARE_SIZE
|
||||
* @testcase.expect : return TEEC_ERROR_GENERIC
|
||||
*/
|
||||
TEE_TEST(TCF2TA2TATest, TEE_InvokeTACommand_With_MaxShareBufferSize, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t ta2taSession;
|
||||
uint32_t origin = 0;
|
||||
TestData value = { 0 };
|
||||
value.uuid = TCF_API_UUID_1; // this uuid is for ta2
|
||||
value.inBufferLen = BIG_SIZE;
|
||||
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE);
|
||||
ASSERT_NE(ta2taSession, 0);
|
||||
|
||||
value.caseId = BUFFERSIZE_ISTOOBIG;
|
||||
value.outBufferLen = BIG_SIZE;
|
||||
ret = Invoke_InvokeTACommand(GetSession(), CMD_TEE_InvokeTACommand, ta2taSession, &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_GENERIC);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
|
||||
ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_InvokeTACommand_With_BufferNoFillNoShare
|
||||
* @testcase.desc : test TA call TEE_InvokeTACommand to pass memref to TA2 while buffer hint is
|
||||
* TEE_MALLOC_NO_FILL|TEE_MALLOC_NO_SHARE
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2TA2TATest, TEE_InvokeTACommand_With_BufferNoFillNoShare, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t ta2taSession;
|
||||
uint32_t origin = 0;
|
||||
TestData value = { 0 };
|
||||
value.uuid = TCF_API_UUID_1; // this uuid is for ta2
|
||||
value.inBufferLen = BIG_SIZE;
|
||||
value.outBufferLen = BIG_SIZE;
|
||||
g_teeInoutLen = strlen(g_teeInout) + 1;
|
||||
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE);
|
||||
ASSERT_NE(ta2taSession, 0);
|
||||
|
||||
value.caseId = BUFFER_NOFILLNOSHARE;
|
||||
ret = Invoke_InvokeTACommand(GetSession(), CMD_TEE_InvokeTACommand, ta2taSession, &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE);
|
||||
|
||||
ASSERT_STREQ(value.inBuffer, g_teeInout);
|
||||
ASSERT_EQ(value.inBufferLen, g_teeInoutLen);
|
||||
|
||||
ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <common_test.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <securec.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <test_defines.h>
|
||||
#include <test_log.h>
|
||||
#include <test_tcf_cmdid.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace testing::ext;
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Panic_With_Normal
|
||||
* @testcase.desc : test TA call TEE_Panic to make ta panic
|
||||
* @testcase.expect : return TEEC_ERROR_TARGET_DEAD
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_Panic_With_Normal, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t origin;
|
||||
TEEC_Result panicCode = TEEC_ERROR_GENERIC;
|
||||
|
||||
ret = Invoke_Panic(GetSession(), CMD_TEE_Panic, panicCode, &origin);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_TARGET_DEAD);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TEE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_Panic_With_MultiSession
|
||||
* @testcase.desc : test TA call TEE_Panic to make a multisession ta panic
|
||||
* @testcase.expect : return TEEC_ERROR_TARGET_DEAD,invoke other tasession will return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF2TA2TATest, TEE_Panic_With_MultiSession, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t ta2taSession[8] = { 0 };
|
||||
uint32_t origin = 0;
|
||||
int i;
|
||||
TestData value = { 0 };
|
||||
value.caseId = 0;
|
||||
value.uuid = TCF_API_UUID_1; // this uuid is for ta2
|
||||
value.inBufferLen = BIG_SIZE;
|
||||
value.outBufferLen = BIG_SIZE;
|
||||
|
||||
for (i = 0; i <= 6; i++) {
|
||||
ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession[i], &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE);
|
||||
ASSERT_NE(ta2taSession[i], 0);
|
||||
if (i >= 1)
|
||||
ASSERT_NE(ta2taSession[i], ta2taSession[i - 1]);
|
||||
}
|
||||
|
||||
// make ta2 one session panic
|
||||
TEEC_Result panicCode = TEEC_ERROR_GENERIC;
|
||||
ret = Invoke_Panic(GetSession2(), CMD_TEE_Panic, panicCode, &origin);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_TARGET_DEAD);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TEE);
|
||||
|
||||
for (i = 0; i <= 6; i++) {
|
||||
ret = Invoke_InvokeTACommand(GetSession(), CMD_TEE_InvokeTACommand, ta2taSession[i], &value, &origin);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TEE);
|
||||
}
|
||||
}
|
||||
@@ -1,220 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <common_test.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <securec.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <test_defines.h>
|
||||
#include <test_log.h>
|
||||
#include <test_tcf_cmdid.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBinaryBlock_WithoutEnum_TestBinaryBlock
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBinaryBlock to get value of SMC_TA_TESTBINARYBLOCK
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBinaryBlock_WithoutEnum_TestBinaryBlock, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBinaryBlock;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, SMC_TA_TESTBINARYBLOCK, sizeof(SMC_TA_TESTBINARYBLOCK));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(SMC_TA_TESTBINARYBLOCK);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_BINARY_BLOCK);
|
||||
ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_BINARY_BLOCK));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBinaryBlock_WithoutEnum_NameIsNull
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBinaryBlock for name is null
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBinaryBlock_WithoutEnum_NameIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBinaryBlock;
|
||||
value.caseId = INPUT_ISNULL;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBinaryBlock_WithoutEnum_NameIsZero
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBinaryBlock for name value is zero
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBinaryBlock_WithoutEnum_NameIsZero, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBinaryBlock;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBinaryBlock_WithoutEnum_ValueBufferIsNULL
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBinaryBlock for value buffer is null
|
||||
* @testcase.expect : return TEEC_ERROR_SHORT_BUFFER
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBinaryBlock_WithoutEnum_ValueBufferIsNULL, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBinaryBlock;
|
||||
value.caseId = OUTPUT_ISNULL;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, SMC_TA_TESTBINARYBLOCK, sizeof(SMC_TA_TESTBINARYBLOCK));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(SMC_TA_TESTBINARYBLOCK);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBinaryBlock_WithoutEnum_ValueBufferSizeIsNULL
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBinaryBlock for value buffer size is null
|
||||
* @testcase.expect : return TEEC_ERROR_SHORT_BUFFER
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBinaryBlock_WithoutEnum_ValueBufferSizeIsNULL, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBinaryBlock;
|
||||
value.caseId = OUTPUTBUFFERSIZE_ISNULL;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, SMC_TA_TESTBINARYBLOCK, sizeof(SMC_TA_TESTBINARYBLOCK));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(SMC_TA_TESTBINARYBLOCK);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBinaryBlock_WithoutEnum_ValueBufferSizeIsZero
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBinaryBlock for value buffer size is zero
|
||||
* @testcase.expect : return TEEC_ERROR_SHORT_BUFFER
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBinaryBlock_WithoutEnum_ValueBufferSizeIsZero, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBinaryBlock;
|
||||
value.caseId = OUTPUTBUFFERSIZE_ISZERO;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, SMC_TA_TESTBINARYBLOCK, sizeof(SMC_TA_TESTBINARYBLOCK));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(SMC_TA_TESTBINARYBLOCK);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBinaryBlock_WithoutEnum_BufferTooShort
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBinaryBlock while out buffer is too short
|
||||
* @testcase.expect : return TEEC_ERROR_SHORT_BUFFER
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBinaryBlock_WithoutEnum_BufferTooShort, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBinaryBlock;
|
||||
value.caseId = OUTPUTBUFFERSIZE_TOOSHORT;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, SMC_TA_TESTBINARYBLOCK, sizeof(SMC_TA_TESTBINARYBLOCK));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(SMC_TA_TESTBINARYBLOCK);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_BINARY_BLOCK));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBinaryBlock_WithoutEnum_NameNotFound
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBinaryBlock while Name Not Found
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBinaryBlock_WithoutEnum_NameNotFound, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBinaryBlock;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, PROPERTY_NAME_UNKNOWN, sizeof(PROPERTY_NAME_UNKNOWN));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(PROPERTY_NAME_UNKNOWN);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBinaryBlock_WithoutEnum_NameNotBinaryBlock
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBinaryBlock while Name type is not BinaryBlock
|
||||
* @testcase.expect : return TEEC_ERROR_BAD_FORMAT
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBinaryBlock_WithoutEnum_NameNotBinaryBlock, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBinaryBlock;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_SINGLEINSTANCE, sizeof(GPD_TA_SINGLEINSTANCE));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_SINGLEINSTANCE);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_BAD_FORMAT);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
@@ -1,341 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <test_defines.h>
|
||||
#include <common_test.h>
|
||||
#include <securec.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <test_log.h>
|
||||
#include <test_tcf_cmdid.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_GPD_TA_SINGLEINSTANCE
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBool to get value of GPD_TA_SINGLEINSTANCE
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_GPD_TA_SINGLEINSTANCE, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBool;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_SINGLEINSTANCE, sizeof(GPD_TA_SINGLEINSTANCE));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_SINGLEINSTANCE);
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_BOOLEAN);
|
||||
ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_BOOLEAN));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_GPD_TA_MULTISESSION
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBool to get value of GPD_TA_MULTISESSION
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_GPD_TA_MULTISESSION, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBool;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_MULTISESSION, sizeof(GPD_TA_MULTISESSION));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_MULTISESSION);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_BOOLEAN);
|
||||
ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_BOOLEAN));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_GPD_TA_INSTANCEKEEPALIVE
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBool to get value of GPD_TA_INSTANCEKEEPALIVE
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_GPD_TA_INSTANCEKEEPALIVE, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBool;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_INSTANCEKEEPALIVE, sizeof(GPD_TA_INSTANCEKEEPALIVE));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_INSTANCEKEEPALIVE);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_FALSE);
|
||||
ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_FALSE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_ECC
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBool to get value of GPD_TEE_CRYPTOGRAPHY_ECC
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_ECC, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBool;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_CRYPTOGRAPHY_ECC, sizeof(GPD_TEE_CRYPTOGRAPHY_ECC));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_CRYPTOGRAPHY_ECC);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_FALSE);
|
||||
ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_FALSE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_NIST
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBool to get value of GPD_TEE_CRYPTOGRAPHY_NIST
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_NIST, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBool;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_CRYPTOGRAPHY_NIST, sizeof(GPD_TEE_CRYPTOGRAPHY_NIST));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_CRYPTOGRAPHY_NIST);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_FALSE);
|
||||
ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_FALSE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_BSI_R
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBool to get value of GPD_TEE_CRYPTOGRAPHY_BSI_R
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_BSI_R, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBool;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_CRYPTOGRAPHY_BSI_R, sizeof(GPD_TEE_CRYPTOGRAPHY_BSI_R));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_CRYPTOGRAPHY_BSI_R);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_FALSE);
|
||||
ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_FALSE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_BSI_T
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBool to get value of GPD_TEE_CRYPTOGRAPHY_BSI_T
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_BSI_T, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBool;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_CRYPTOGRAPHY_BSI_T, sizeof(GPD_TEE_CRYPTOGRAPHY_BSI_T));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_CRYPTOGRAPHY_BSI_T);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_FALSE);
|
||||
ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_FALSE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_IETF
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBool to get value of GPD_TEE_CRYPTOGRAPHY_IETF
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_IETF, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBool;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_CRYPTOGRAPHY_IETF, sizeof(GPD_TEE_CRYPTOGRAPHY_IETF));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_CRYPTOGRAPHY_IETF);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_FALSE);
|
||||
ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_FALSE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_OCTA
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBool to get value of GPD_TEE_CRYPTOGRAPHY_OCTA
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_OCTA, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBool;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_CRYPTOGRAPHY_OCTA, sizeof(GPD_TEE_CRYPTOGRAPHY_OCTA));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_CRYPTOGRAPHY_OCTA);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_FALSE);
|
||||
ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_FALSE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_NameIsNull
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBool for name is null
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_NameIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBool;
|
||||
value.caseId = INPUT_ISNULL;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_NameIsZero
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBool for name value is zero
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_NameIsZero, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBool;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_ValueIsNull
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBool for value is null
|
||||
* @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_ValueIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBool;
|
||||
value.caseId = OUTPUT_ISNULL;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_MULTISESSION, sizeof(GPD_TA_MULTISESSION));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_MULTISESSION);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_NameNotFound
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBool while Name Not Found
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_NameNotFound, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBool;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, PROPERTY_NAME_UNKNOWN, sizeof(PROPERTY_NAME_UNKNOWN));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(PROPERTY_NAME_UNKNOWN);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_NameNotBool
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsBool while Name type is not bool
|
||||
* @testcase.expect : return TEEC_ERROR_BAD_FORMAT
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_NameNotBool, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsBool;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_STACKSIZE, sizeof(GPD_TA_STACKSIZE));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_STACKSIZE);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_BAD_FORMAT);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <common_test.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <securec.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <test_defines.h>
|
||||
#include <test_log.h>
|
||||
#include <test_tcf_cmdid.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsIdentity_WithoutEnum_SMC_TA_TESTIDENTITY
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsIdentity to get value of SMC_TA_TESTIDENTITY
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_GetPropertyAsIdentity_WithoutEnum_SMC_TA_TESTIDENTITY, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsIdentity;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, SMC_TA_TESTIDENTITY, sizeof(SMC_TA_TESTIDENTITY));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(SMC_TA_TESTIDENTITY);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsIdentity_WithoutEnum_NameIsNull
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsIdentity for name is null
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_GetPropertyAsIdentity_WithoutEnum_NameIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsIdentity;
|
||||
value.caseId = INPUT_ISNULL;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsIdentity_WithoutEnum_NameIsZero
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsIdentity for name value is zero
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_GetPropertyAsIdentity_WithoutEnum_NameIsZero, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsIdentity;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsIdentity_WithoutEnum_ValueBufferIsNULL
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsIdentity for value buffer is null
|
||||
* @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_GetPropertyAsIdentity_WithoutEnum_ValueBufferIsNULL, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsIdentity;
|
||||
value.caseId = OUTPUT_ISNULL;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, SMC_TA_TESTIDENTITY, sizeof(SMC_TA_TESTIDENTITY));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(SMC_TA_TESTIDENTITY);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsIdentity_WithoutEnum_NameNotFound
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsIdentity while Name Not Found
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_GetPropertyAsIdentity_WithoutEnum_NameNotFound, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsIdentity;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, PROPERTY_NAME_UNKNOWN, sizeof(PROPERTY_NAME_UNKNOWN));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(PROPERTY_NAME_UNKNOWN);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsIdentity_WithoutEnum_NameNotIdentity
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsIdentity while Name type is not Identity
|
||||
* @testcase.expect : return TEEC_ERROR_BAD_FORMAT
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_GetPropertyAsIdentity_WithoutEnum_NameNotIdentity, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsIdentity;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_SINGLEINSTANCE, sizeof(GPD_TA_SINGLEINSTANCE));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_SINGLEINSTANCE);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_BAD_FORMAT);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsIdentity_WithoutEnum_NameNotUUID2
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsIdentity while Name type is not UUID, is string
|
||||
* @testcase.expect : return TEEC_ERROR_BAD_FORMAT
|
||||
*/
|
||||
TEE_TEST(TCF2Test, TEE_GetPropertyAsIdentity_WithoutEnum_NameNotUUID2, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsIdentity;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_DESCRIPTION, sizeof(GPD_TEE_DESCRIPTION));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_DESCRIPTION);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_BAD_FORMAT);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
@@ -1,510 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <test_defines.h>
|
||||
#include <common_test.h>
|
||||
#include <securec.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <test_log.h>
|
||||
#include <test_tcf_cmdid.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TA_APPID
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TA_APPID
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TA_APPID, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_APPID, sizeof(GPD_TA_APPID));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_APPID);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_UUID);
|
||||
ASSERT_EQ(value.outBufferLen, BIG_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TA_SERVICENAME
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TA_SERVICENAME
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND, can not get value
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TA_SERVICENAME, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_SERVICENAME, sizeof(GPD_TA_SERVICENAME));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_SERVICENAME);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_CLIENT_IDENTITY
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_CLIENT_IDENTITY
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_CLIENT_IDENTITY, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.propSet = TEE_PROPSET_CURRENT_CLIENT;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_CLIENT_IDENTITY, sizeof(GPD_CLIENT_IDENTITY));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_CLIENT_IDENTITY);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_CLIENT_IDENTITY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_CLIENT_IDENTITY_PropsetIsWrong
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_CLIENT_IDENTITY, Propset is wrong
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND, can not get value
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_CLIENT_IDENTITY_PropsetIsWrong,
|
||||
Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_CLIENT_IDENTITY, sizeof(GPD_CLIENT_IDENTITY));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_CLIENT_IDENTITY);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TA_VERSION
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TA_VERSION
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TA_VERSION, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_VERSION, sizeof(GPD_TA_VERSION));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_VERSION);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_TA_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TA_DESCRIPTION
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TA_DESCRIPTION
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TA_DESCRIPTION, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_DESCRIPTION, sizeof(GPD_TA_DESCRIPTION));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_DESCRIPTION);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_TA_DESCRIPTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_APIVERSION
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TEE_APIVERSION
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_APIVERSION, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_APIVERSION, sizeof(GPD_TEE_APIVERSION));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_APIVERSION);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, TEE_API_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_DESCRIPTION
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TEE_DESCRIPTION
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_DESCRIPTION, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_DESCRIPTION, sizeof(GPD_TEE_DESCRIPTION));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_DESCRIPTION);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, TEE_BUILD_VER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_TRUSTEDOS_IMP_VERSION
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TEE_TRUSTEDOS_IMP_VERSION
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_TRUSTEDOS_IMP_VERSION, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_TRUSTEDOS_IMP_VERSION, sizeof(GPD_TEE_TRUSTEDOS_IMP_VERSION));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_TRUSTEDOS_IMP_VERSION);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, TEE_IMP_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_TRUSTEDOS_IMP_BINARYVERSION
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TEE_TRUSTEDOS_IMP_BINARYVERSION
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_TRUSTEDOS_IMP_BINARYVERSION,
|
||||
Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_TRUSTEDOS_IMP_BINARYVERSION,
|
||||
sizeof(GPD_TEE_TRUSTEDOS_IMP_BINARYVERSION));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_TRUSTEDOS_IMP_BINARYVERSION);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, TEE_IMP_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_FIRMWARE_IMP_VERSION
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TEE_FIRMWARE_IMP_VERSION
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_FIRMWARE_IMP_VERSION, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_FIRMWARE_IMP_VERSION, sizeof(GPD_TEE_FIRMWARE_IMP_VERSION));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_FIRMWARE_IMP_VERSION);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, TEE_FIRMWARE_IMP_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_FIRMWARE_IMP_BINARYVERSION
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TEE_FIRMWARE_IMP_BINARYVERSION
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_FIRMWARE_IMP_BINARYVERSION,
|
||||
Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_FIRMWARE_IMP_BINARYVERSION,
|
||||
sizeof(GPD_TEE_FIRMWARE_IMP_BINARYVERSION));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_FIRMWARE_IMP_BINARYVERSION);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, TEE_FIRMWARE_IMP_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_TRUSTEDOS_MANUFACTURER
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TEE_TRUSTEDOS_MANUFACTURER
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_TRUSTEDOS_MANUFACTURER, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_TRUSTEDOS_MANUFACTURER, sizeof(GPD_TEE_TRUSTEDOS_MANUFACTURER));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_TRUSTEDOS_MANUFACTURER);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, TEE_MANUFACTURER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_FIRMWARE_MANUFACTURER
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TEE_FIRMWARE_MANUFACTURER
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_FIRMWARE_MANUFACTURER, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_FIRMWARE_MANUFACTURER, sizeof(GPD_TEE_FIRMWARE_MANUFACTURER));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_FIRMWARE_MANUFACTURER);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_STREQ(value.outBuffer, TEE_FIRMWARE_MANUFACTURER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_PropsetIsZero
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString while Propset Is Zero
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_PropsetIsZero, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.propSet = TEE_PROPSET_ZERO;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_APPID, sizeof(GPD_TA_APPID));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_APPID);
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_NameIsNULL
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString while name is null
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_NameIsNULL, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.caseId = INPUT_ISNULL;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_NameIsZero
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString while name value is zero
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_NameIsZero, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_ValueBufferIsNULL
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString while value buffer is null
|
||||
* @testcase.expect : return TEEC_ERROR_SHORT_BUFFER
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_ValueBufferIsNULL, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.caseId = OUTPUT_ISNULL;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_APPID, sizeof(GPD_TA_APPID));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_APPID);
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_ValueBufferSizeIsNULL
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString while value buffer size is null
|
||||
* @testcase.expect : return TEEC_ERROR_SHORT_BUFFER
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_ValueBufferSizeIsNULL, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.caseId = OUTPUTBUFFERSIZE_ISNULL;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_APPID, sizeof(GPD_TA_APPID));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_APPID);
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_ValueBufferSizeIsZero
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString while value buffer size is zero
|
||||
* @testcase.expect : return TEEC_ERROR_SHORT_BUFFER
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_ValueBufferSizeIsZero, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.caseId = OUTPUTBUFFERSIZE_ISZERO;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_APPID, sizeof(GPD_TA_APPID));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_APPID);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_NameNotFound
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString while Name Not Found
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_NameNotFound, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, PROPERTY_NAME_UNKNOWN, sizeof(PROPERTY_NAME_UNKNOWN));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(PROPERTY_NAME_UNKNOWN);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsString_WithoutEnum_BufferTooShort
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsString while out buffer is too short
|
||||
* @testcase.expect : return TEEC_ERROR_SHORT_BUFFER
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_BufferTooShort, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsString;
|
||||
value.caseId = OUTPUTBUFFERSIZE_TOOSHORT;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_APPID, sizeof(GPD_TA_APPID));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_APPID);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
@@ -1,394 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <common_test.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <securec.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <test_defines.h>
|
||||
#include <test_log.h>
|
||||
#include <test_tcf_cmdid.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TA_DATASIZE
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TA_DATASIZE
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TA_DATASIZE, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU32;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_DATASIZE, sizeof(GPD_TA_DATASIZE));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_DATASIZE);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(atoi(value.outBuffer), VALUE_PREDEFINED_DATASIZE);
|
||||
ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TA_STACKSIZE
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TA_STACKSIZE
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TA_STACKSIZE, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU32;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_STACKSIZE, sizeof(GPD_TA_STACKSIZE));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_STACKSIZE);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(atoi(value.outBuffer), VALUE_PREDEFINED_STACKSIZE);
|
||||
ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_CLIENT_ENDIAN
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_CLIENT_ENDIAN
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_CLIENT_ENDIAN, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU32;
|
||||
value.propSet = TEE_PROPSET_CURRENT_CLIENT;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_CLIENT_ENDIAN, sizeof(GPD_CLIENT_ENDIAN));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_CLIENT_ENDIAN);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(atoi(value.outBuffer), VALUE_PREDEFINED_CLIENT_ENDIAN);
|
||||
ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_INTERNALCORE_VERSION
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TEE_INTERNALCORE_VERSION
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_INTERNALCORE_VERSION, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU32;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_INTERNALCORE_VERSION, sizeof(GPD_TEE_INTERNALCORE_VERSION));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_INTERNALCORE_VERSION);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(atoi(value.outBuffer), TEE_INTERNAL_CORE_VERSION);
|
||||
ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_SYSTEM_TIME_PROTECTIONLEVEL
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TEE_SYSTEM_TIME_PROTECTIONLEVEL
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_SYSTEM_TIME_PROTECTIONLEVEL, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU32;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_SYSTEM_TIME_PROTECTIONLEVEL,
|
||||
sizeof(GPD_TEE_SYSTEM_TIME_PROTECTIONLEVEL));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_SYSTEM_TIME_PROTECTIONLEVEL);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(atoi(value.outBuffer), TEE_TIME_PROTECT_LEVEL);
|
||||
ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_TA_PERSISTENT_TIME_PROTECTIONLEVEL
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TEE_TA_PERSISTENT_TIME_PROTECTIONLEVEL
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_TA_PERSISTENT_TIME_PROTECTIONLEVEL,
|
||||
Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU32;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_TA_PERSISTENT_TIME_PROTECTIONLEVEL,
|
||||
sizeof(GPD_TEE_TA_PERSISTENT_TIME_PROTECTIONLEVEL));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_TA_PERSISTENT_TIME_PROTECTIONLEVEL);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(atoi(value.outBuffer), TA_TIME_PROTECT_LEVEL);
|
||||
ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_ARITH_MAXBIGINTSIZE
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TEE_ARITH_MAXBIGINTSIZE
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_ARITH_MAXBIGINTSIZE, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU32;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_ARITH_MAXBIGINTSIZE, sizeof(GPD_TEE_ARITH_MAXBIGINTSIZE));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_ARITH_MAXBIGINTSIZE);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(atoi(value.outBuffer), MAX_BIG_INT_SIZE);
|
||||
ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_ANTIROLLBACK_PROTECTIONLEVEL
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TEE_ANTIROLLBACK_PROTECTIONLEVEL
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_ANTIROLLBACK_PROTECTIONLEVEL,
|
||||
Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU32;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_ANTIROLLBACK_PROTECTIONLEVEL,
|
||||
sizeof(GPD_TEE_ANTIROLLBACK_PROTECTIONLEVEL));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_ANTIROLLBACK_PROTECTIONLEVEL);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(atoi(value.outBuffer), 0);
|
||||
ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_ROLLBACKDETECT_PROTECTIONLEVEL
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TEE_ROLLBACKDETECT_PROTECTIONLEVEL
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_ROLLBACKDETECT_PROTECTIONLEVEL,
|
||||
Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU32;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_ROLLBACKDETECT_PROTECTIONLEVEL,
|
||||
sizeof(GPD_TEE_ROLLBACKDETECT_PROTECTIONLEVEL));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_ROLLBACKDETECT_PROTECTIONLEVEL);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(atoi(value.outBuffer), 0);
|
||||
ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_EVENT_MAXSOURCES
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TEE_EVENT_MAXSOURCES
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_EVENT_MAXSOURCES, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU32;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_EVENT_MAXSOURCES, sizeof(GPD_TEE_EVENT_MAXSOURCES));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_EVENT_MAXSOURCES);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(atoi(value.outBuffer), 0);
|
||||
ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_API_LEVEL
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TEE_API_LEVEL
|
||||
* @testcase.expect : return TEEC_SUCCESS, get value is correct
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_API_LEVEL, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU32;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_API_LEVEL, sizeof(GPD_TEE_API_LEVEL));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TEE_API_LEVEL);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(atoi(value.outBuffer), TEE_MAX_API_LEVEL_CONFIG);
|
||||
ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_NameIsNull
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU32 for name is null
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_NameIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU32;
|
||||
value.caseId = INPUT_ISNULL;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_NameIsZero
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU32 for name value is zero
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_NameIsZero, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU32;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_ValueIsNull
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU32 for value is null
|
||||
* @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_ValueIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU32;
|
||||
value.caseId = OUTPUT_ISNULL;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_DATASIZE, sizeof(GPD_TA_DATASIZE));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_DATASIZE);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_NameNotFound
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU32 while Name Not Found
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_NameNotFound, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU32;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, PROPERTY_NAME_UNKNOWN, sizeof(PROPERTY_NAME_UNKNOWN));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(PROPERTY_NAME_UNKNOWN);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_NameNotU32
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU32 while Name type is not U32
|
||||
* @testcase.expect : return TEEC_ERROR_BAD_FORMAT
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_NameNotU32, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU32;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_DESCRIPTION, sizeof(GPD_TA_DESCRIPTION));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_DESCRIPTION);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_BAD_FORMAT);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <common_test.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <securec.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <test_defines.h>
|
||||
#include <test_log.h>
|
||||
#include <test_tcf_cmdid.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU64_WithoutEnum_TESTU64
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU64 to get value of SMC_TA_TESTU64
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU64_WithoutEnum_TESTU64, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU64;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, SMC_TA_TESTU64, sizeof(SMC_TA_TESTU64));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(SMC_TA_TESTU64);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(atoll(value.outBuffer), VALUE_PREDEFINED_U64);
|
||||
ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU64_WithoutEnum_NameIsNull
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU64 for name is null
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU64_WithoutEnum_NameIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU64;
|
||||
value.caseId = INPUT_ISNULL;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU64_WithoutEnum_NameIsZero
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU64 for name value is zero
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU64_WithoutEnum_NameIsZero, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU64;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU64_WithoutEnum_ValueIsNull
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU64 for value is null
|
||||
* @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU64_WithoutEnum_ValueIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU64;
|
||||
value.caseId = OUTPUT_ISNULL;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_DATASIZE, sizeof(GPD_TA_DATASIZE));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_DATASIZE);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU64_WithoutEnum_NameNotFound
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU64 while Name Not Found
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU64_WithoutEnum_NameNotFound, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU64;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, PROPERTY_NAME_UNKNOWN, sizeof(PROPERTY_NAME_UNKNOWN));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(PROPERTY_NAME_UNKNOWN);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsU64_WithoutEnum_NameNotU64
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsU64 while Name type is not U64
|
||||
* @testcase.expect : return TEEC_ERROR_BAD_FORMAT
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsU64_WithoutEnum_NameNotU64, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsU64;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_DESCRIPTION, sizeof(GPD_TA_DESCRIPTION));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_DESCRIPTION);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_BAD_FORMAT);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <common_test.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <securec.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <test_defines.h>
|
||||
#include <test_log.h>
|
||||
#include <test_tcf_cmdid.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsUUID_WithoutEnum_GPD_TA_APPID
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsUUID to get value of GPD_TA_APPID
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsUUID_WithoutEnum_GPD_TA_APPID, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsUUID;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_APPID, sizeof(GPD_TA_APPID));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_APPID);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsUUID_WithoutEnum_NameIsNull
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsUUID for name is null
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsUUID_WithoutEnum_NameIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsUUID;
|
||||
value.caseId = INPUT_ISNULL;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsUUID_WithoutEnum_NameIsZero
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsUUID for name value is zero
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsUUID_WithoutEnum_NameIsZero, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsUUID;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsUUID_WithoutEnum_ValueBufferIsNULL
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsUUID for value buffer is null
|
||||
* @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsUUID_WithoutEnum_ValueBufferIsNULL, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsUUID;
|
||||
value.caseId = OUTPUT_ISNULL;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_APPID, sizeof(GPD_TA_APPID));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_APPID);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsUUID_WithoutEnum_NameNotFound
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsUUID while Name Not Found
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsUUID_WithoutEnum_NameNotFound, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsUUID;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, PROPERTY_NAME_UNKNOWN, sizeof(PROPERTY_NAME_UNKNOWN));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(PROPERTY_NAME_UNKNOWN);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsUUID_WithoutEnum_NameNotUUID
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsUUID while Name type is not UUID
|
||||
* @testcase.expect : return TEEC_ERROR_BAD_FORMAT
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsUUID_WithoutEnum_NameNotUUID, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsUUID;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_SINGLEINSTANCE, sizeof(GPD_TA_SINGLEINSTANCE));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_SINGLEINSTANCE);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_BAD_FORMAT);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyAsUUID_WithoutEnum_NameNotUUID2
|
||||
* @testcase.desc : test TA call TEE_GetPropertyAsUUID while Name type is not UUID, is string
|
||||
* @testcase.expect : return TEEC_ERROR_BAD_FORMAT
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyAsUUID_WithoutEnum_NameNotUUID2, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
int rc;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_GetPropertyAsUUID;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_DESCRIPTION, sizeof(GPD_TA_DESCRIPTION));
|
||||
ASSERT_EQ(rc, 0);
|
||||
value.inBufferLen = sizeof(GPD_TA_DESCRIPTION);
|
||||
|
||||
ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_BAD_FORMAT);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
@@ -1,603 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <common_test.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <securec.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <test_defines.h>
|
||||
#include <test_log.h>
|
||||
#include <test_tcf_cmdid.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
|
||||
struct unIntMapping {
|
||||
char *name;
|
||||
uint32_t cmd;
|
||||
ALL_PROP_SETS propSet;
|
||||
char *expectResult;
|
||||
uint32_t expectLen;
|
||||
};
|
||||
|
||||
struct intMapping {
|
||||
char *name;
|
||||
uint32_t cmd;
|
||||
ALL_PROP_SETS propSet;
|
||||
uint64_t expectResult;
|
||||
};
|
||||
|
||||
struct unIntMapping g_unIntMap[] = {
|
||||
// bool
|
||||
{ (char*)GPD_TA_INSTANCEKEEPALIVE, CMD_TEE_GetPropertyAsBool, TEE_PROPSET_CURRENT_TA,
|
||||
(char*)VALUE_PREDEFINED_FALSE, sizeof(VALUE_PREDEFINED_FALSE) },
|
||||
{ (char*)GPD_TA_MULTISESSION, CMD_TEE_GetPropertyAsBool, TEE_PROPSET_CURRENT_TA,
|
||||
(char*)VALUE_PREDEFINED_BOOLEAN, sizeof(VALUE_PREDEFINED_BOOLEAN) },
|
||||
{ (char*)GPD_TA_SINGLEINSTANCE, CMD_TEE_GetPropertyAsBool, TEE_PROPSET_CURRENT_TA,
|
||||
(char*)VALUE_PREDEFINED_BOOLEAN, sizeof(VALUE_PREDEFINED_BOOLEAN) },
|
||||
{ (char*)GPD_TEE_CRYPTOGRAPHY_ECC, CMD_TEE_GetPropertyAsBool, TEE_PROPSET_IMPLEMENTATION,
|
||||
(char*)VALUE_PREDEFINED_FALSE, sizeof(VALUE_PREDEFINED_FALSE) },
|
||||
{ (char*)GPD_TEE_CRYPTOGRAPHY_NIST, CMD_TEE_GetPropertyAsBool, TEE_PROPSET_IMPLEMENTATION,
|
||||
(char*)VALUE_PREDEFINED_FALSE, sizeof(VALUE_PREDEFINED_FALSE) },
|
||||
{ (char*)GPD_TEE_CRYPTOGRAPHY_BSI_R, CMD_TEE_GetPropertyAsBool, TEE_PROPSET_IMPLEMENTATION,
|
||||
(char*)VALUE_PREDEFINED_FALSE, sizeof(VALUE_PREDEFINED_FALSE) },
|
||||
{ (char*)GPD_TEE_CRYPTOGRAPHY_BSI_T, CMD_TEE_GetPropertyAsBool, TEE_PROPSET_IMPLEMENTATION,
|
||||
(char*)VALUE_PREDEFINED_FALSE, sizeof(VALUE_PREDEFINED_FALSE) },
|
||||
{ (char*)GPD_TEE_CRYPTOGRAPHY_IETF, CMD_TEE_GetPropertyAsBool, TEE_PROPSET_IMPLEMENTATION,
|
||||
(char*)VALUE_PREDEFINED_FALSE, sizeof(VALUE_PREDEFINED_FALSE) },
|
||||
{ (char*)GPD_TEE_CRYPTOGRAPHY_OCTA, CMD_TEE_GetPropertyAsBool, TEE_PROPSET_IMPLEMENTATION,
|
||||
(char*)VALUE_PREDEFINED_FALSE, sizeof(VALUE_PREDEFINED_FALSE) },
|
||||
|
||||
// binaryblock
|
||||
{ (char*)SMC_TA_TESTBINARYBLOCK, CMD_TEE_GetPropertyAsBinaryBlock, TEE_PROPSET_CURRENT_TA,
|
||||
(char*)VALUE_PREDEFINED_BINARY_BLOCK, sizeof(VALUE_PREDEFINED_BINARY_BLOCK) },
|
||||
|
||||
// uuid
|
||||
{ (char*)GPD_TA_APPID, CMD_TEE_GetPropertyAsUUID, TEE_PROPSET_CURRENT_TA, NULL, 0 },
|
||||
// do not test GPD_TEE_DEVICEID
|
||||
{ (char*)GPD_TEE_DEVICEID, CMD_TEE_GetPropertyAsUUID, TEE_PROPSET_IMPLEMENTATION, NULL, 0 },
|
||||
|
||||
// string
|
||||
// this only test get uuid as string
|
||||
{ (char*)GPD_TA_APPID, CMD_TEE_GetPropertyAsString,
|
||||
TEE_PROPSET_CURRENT_TA, (char*)VALUE_PREDEFINED_UUID, BIG_SIZE },
|
||||
{ (char*)GPD_CLIENT_IDENTITY, CMD_TEE_GetPropertyAsString,
|
||||
TEE_PROPSET_CURRENT_CLIENT, (char*)VALUE_PREDEFINED_CLIENT_IDENTITY, BIG_SIZE },
|
||||
{ (char*)GPD_TA_VERSION, CMD_TEE_GetPropertyAsString,
|
||||
TEE_PROPSET_CURRENT_TA, (char*)VALUE_PREDEFINED_TA_VERSION, BIG_SIZE },
|
||||
{ (char*)GPD_TA_DESCRIPTION, CMD_TEE_GetPropertyAsString,
|
||||
TEE_PROPSET_CURRENT_TA, (char*)VALUE_PREDEFINED_TA_DESCRIPTION, BIG_SIZE },
|
||||
{ (char*)GPD_TEE_APIVERSION, CMD_TEE_GetPropertyAsString,
|
||||
TEE_PROPSET_IMPLEMENTATION, (char*)TEE_API_VERSION, BIG_SIZE },
|
||||
{ (char*)GPD_TEE_DESCRIPTION, CMD_TEE_GetPropertyAsString,
|
||||
TEE_PROPSET_IMPLEMENTATION, (char*)TEE_BUILD_VER, BIG_SIZE },
|
||||
{ (char*)GPD_TEE_TRUSTEDOS_IMP_VERSION, CMD_TEE_GetPropertyAsString,
|
||||
TEE_PROPSET_IMPLEMENTATION, (char*)TEE_IMP_VERSION, BIG_SIZE },
|
||||
{ (char*)GPD_TEE_TRUSTEDOS_IMP_BINARYVERSION, CMD_TEE_GetPropertyAsString,
|
||||
TEE_PROPSET_IMPLEMENTATION, (char*)TEE_IMP_VERSION, BIG_SIZE },
|
||||
{ (char*)GPD_TEE_FIRMWARE_IMP_VERSION, CMD_TEE_GetPropertyAsString,
|
||||
TEE_PROPSET_IMPLEMENTATION, (char*)TEE_FIRMWARE_IMP_VERSION, BIG_SIZE },
|
||||
{ (char*)GPD_TEE_FIRMWARE_IMP_BINARYVERSION, CMD_TEE_GetPropertyAsString,
|
||||
TEE_PROPSET_IMPLEMENTATION, (char*)TEE_FIRMWARE_IMP_VERSION, BIG_SIZE },
|
||||
{ (char*)GPD_TEE_TRUSTEDOS_MANUFACTURER, CMD_TEE_GetPropertyAsString,
|
||||
TEE_PROPSET_IMPLEMENTATION, (char*)TEE_MANUFACTURER, BIG_SIZE },
|
||||
{ (char*)GPD_TEE_FIRMWARE_MANUFACTURER, CMD_TEE_GetPropertyAsString,
|
||||
TEE_PROPSET_IMPLEMENTATION, (char*)TEE_FIRMWARE_MANUFACTURER, BIG_SIZE },
|
||||
{ (char*)GPD_TEE_DEVICEID, CMD_TEE_GetPropertyAsString,
|
||||
TEE_PROPSET_IMPLEMENTATION, (char*)TEE_FIRMWARE_MANUFACTURER, BIG_SIZE },
|
||||
};
|
||||
|
||||
struct intMapping g_intMap[] = {
|
||||
// int32
|
||||
{ (char*)GPD_TA_DATASIZE, CMD_TEE_GetPropertyAsU32,
|
||||
TEE_PROPSET_CURRENT_TA, VALUE_PREDEFINED_DATASIZE },
|
||||
{ (char*)GPD_TA_STACKSIZE, CMD_TEE_GetPropertyAsU32,
|
||||
TEE_PROPSET_CURRENT_TA, VALUE_PREDEFINED_STACKSIZE },
|
||||
{ (char*)GPD_TA_ENDIAN, CMD_TEE_GetPropertyAsU32,
|
||||
TEE_PROPSET_CURRENT_TA, 0 },
|
||||
{ (char*)GPD_CLIENT_ENDIAN, CMD_TEE_GetPropertyAsU32,
|
||||
TEE_PROPSET_CURRENT_CLIENT, VALUE_PREDEFINED_CLIENT_ENDIAN },
|
||||
{ (char*)GPD_TEE_INTERNALCORE_VERSION, CMD_TEE_GetPropertyAsU32,
|
||||
TEE_PROPSET_IMPLEMENTATION, TEE_INTERNAL_CORE_VERSION },
|
||||
{ (char*)GPD_TEE_SYSTEM_TIME_PROTECTIONLEVEL, CMD_TEE_GetPropertyAsU32,
|
||||
TEE_PROPSET_IMPLEMENTATION, TEE_TIME_PROTECT_LEVEL },
|
||||
{ (char*)GPD_TEE_TA_PERSISTENT_TIME_PROTECTIONLEVEL, CMD_TEE_GetPropertyAsU32,
|
||||
TEE_PROPSET_IMPLEMENTATION, TA_TIME_PROTECT_LEVEL },
|
||||
{ (char*)GPD_TEE_ARITH_MAXBIGINTSIZE, CMD_TEE_GetPropertyAsU32,
|
||||
TEE_PROPSET_IMPLEMENTATION, MAX_BIG_INT_SIZE },
|
||||
{ (char*)GPD_TEE_ANTIROLLBACK_PROTECTIONLEVEL, CMD_TEE_GetPropertyAsU32,
|
||||
TEE_PROPSET_IMPLEMENTATION, 0 },
|
||||
{ (char*)GPD_TEE_ROLLBACKDETECT_PROTECTIONLEVEL, CMD_TEE_GetPropertyAsU32,
|
||||
TEE_PROPSET_IMPLEMENTATION, 0 },
|
||||
{ (char*)GPD_TEE_EVENT_MAXSOURCES, CMD_TEE_GetPropertyAsU32,
|
||||
TEE_PROPSET_IMPLEMENTATION, 0 },
|
||||
{ (char*)GPD_TEE_API_LEVEL, CMD_TEE_GetPropertyAsU32,
|
||||
TEE_PROPSET_IMPLEMENTATION, TEE_MAX_API_LEVEL_CONFIG },
|
||||
// int64
|
||||
{ (char*)SMC_TA_TESTU64, CMD_TEE_GetPropertyAsU64,
|
||||
TEE_PROPSET_CURRENT_TA, VALUE_PREDEFINED_U64 },
|
||||
};
|
||||
|
||||
TEEC_Result GetPropertyFromUnIntMap(TEEC_Context *context, TEEC_Session *session, TestData *val, int *flag)
|
||||
{
|
||||
TEEC_Result result;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < (sizeof(g_unIntMap) / sizeof(g_unIntMap[0])); i++) {
|
||||
if (strncmp(val->inBuffer, g_unIntMap[i].name, val->inBufferLen) == 0) {
|
||||
*flag = 1;
|
||||
val->cmd = g_unIntMap[i].cmd;
|
||||
result = Invoke_GetPropertyAsX(context, session, val);
|
||||
if (result != TEEC_SUCCESS || val->origin != TEEC_ORIGIN_TRUSTED_APP) {
|
||||
TEST_PRINT_ERROR("getProperty from Enumerator with %s is fail! result = 0x%x\n", val->inBuffer, result);
|
||||
return result;
|
||||
}
|
||||
if (val->cmd != CMD_TEE_GetPropertyAsUUID) {
|
||||
if (val->outBufferLen != g_unIntMap[i].expectLen ||
|
||||
(strncmp(val->outBuffer, g_unIntMap[i].expectResult, g_unIntMap[i].expectLen) != 0)) {
|
||||
TEST_PRINT_ERROR("getProperty from Enumerator with %s is fail! outlen=0x%x, expect outlen=0x%x\n",
|
||||
val->inBuffer, val->outBufferLen, g_unIntMap[i].expectLen);
|
||||
TEST_PRINT_ERROR("outbuffer=%s, expect outbuffer=%s\n", val->outBuffer, g_unIntMap[i].expectResult);
|
||||
return TEEC_ERROR_GENERIC;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return TEEC_SUCCESS;
|
||||
}
|
||||
|
||||
TEEC_Result GetPropertyFromIntMap(TEEC_Context *context, TEEC_Session *session, TestData *val, int *flag)
|
||||
{
|
||||
TEEC_Result result;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < (sizeof(g_intMap) / sizeof(g_intMap[0])); i++) {
|
||||
if (strncmp(val->inBuffer, g_intMap[i].name, val->inBufferLen) == 0) {
|
||||
*flag = 1;
|
||||
val->cmd = g_intMap[i].cmd;
|
||||
result = Invoke_GetPropertyAsX(context, session, val);
|
||||
if (result != TEEC_SUCCESS || val->origin != TEEC_ORIGIN_TRUSTED_APP) {
|
||||
TEST_PRINT_ERROR("getProperty from Enumerator with %s is fail! result = 0x%x\n", val->inBuffer, result);
|
||||
return result;
|
||||
}
|
||||
if (val->cmd == CMD_TEE_GetPropertyAsU32) {
|
||||
if (atoi(val->outBuffer) != (uint32_t)g_intMap[i].expectResult) {
|
||||
TEST_PRINT_ERROR("getProperty from Enumerator with %s is fail! out=0x%x, expect out=0x%x\n",
|
||||
val->inBuffer, atoi(val->outBuffer), (uint32_t)g_intMap[i].expectResult);
|
||||
return TEEC_ERROR_GENERIC;
|
||||
}
|
||||
} else {
|
||||
if (atoll(val->outBuffer) != g_intMap[i].expectResult) {
|
||||
TEST_PRINT_ERROR("getProperty from Enumerator with %s is fail! out=0x%llx, expect out=0x%lu\n",
|
||||
val->inBuffer, atoll(val->outBuffer), g_intMap[i].expectResult);
|
||||
return TEEC_ERROR_GENERIC;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return TEEC_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetProperty_WithEnum_TEE_PROPSET_CURRENT_TA
|
||||
* @testcase.desc : test TA call TEE_AllocatePropertyEnumerator, TEE_StartPropertyEnumerator, TEE_GetPropertyName,
|
||||
* TEE_GetNextProperty and TEE_GetPropertyAsX API to get all kinds of property from Enumerator for
|
||||
* TEE_PROPSET_CURRENT_TA
|
||||
* @testcase.expect : process success
|
||||
*/
|
||||
TEE_TEST(TCF1ENUM_Test, TEE_GetProperty_WithEnum_TEE_PROPSET_CURRENT_TA, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result result, ret;
|
||||
int rc, count = 0, findFlag = 0;
|
||||
|
||||
// start PropertyEnumerator this api has no return value
|
||||
value.cmd = CMD_TEE_StartPropertyEnumerator;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
|
||||
do {
|
||||
value.cmd = CMD_TEE_GetPropertyNameEnumerator;
|
||||
value.outBufferLen = BIG_SIZE;
|
||||
result = Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
if ((count != 0) && (result == TEEC_ERROR_ITEM_NOT_FOUND))
|
||||
break;
|
||||
ASSERT_EQ(result, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, value.outBuffer, value.outBufferLen);
|
||||
value.inBufferLen = value.outBufferLen;
|
||||
ASSERT_EQ(rc, 0);
|
||||
count++;
|
||||
|
||||
ret = GetPropertyFromUnIntMap(GetContext(), GetSession(), &value, &findFlag);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
if (findFlag != 1) {
|
||||
ret = GetPropertyFromIntMap(GetContext(), GetSession(), &value, &findFlag);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
}
|
||||
|
||||
if (findFlag == 0) {
|
||||
TEST_PRINT_ERROR("get PropertyName from Enumerator is undefined!\n");
|
||||
ASSERT_FALSE(1);
|
||||
}
|
||||
|
||||
value.cmd = CMD_TEE_GetNextPropertyEnumerator;
|
||||
Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
findFlag = 0;
|
||||
} while (result != TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetProperty_WithEnum_TEE_PROPSET_CURRENT_CLIENT
|
||||
* @testcase.desc : test TA call TEE_AllocatePropertyEnumerator, TEE_StartPropertyEnumerator, TEE_GetPropertyName,
|
||||
* TEE_GetNextProperty and TEE_GetPropertyAsX API to get all kinds of property from Enumerator for
|
||||
* TEE_PROPSET_CURRENT_CLIENT
|
||||
* @testcase.expect : process success
|
||||
*/
|
||||
TEE_TEST(TCF1ENUM_Test, TEE_GetProperty_WithEnum_TEE_PROPSET_CURRENT_CLIENT, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result result, ret;
|
||||
int rc, count = 0, findFlag = 0;
|
||||
|
||||
// start PropertyEnumerator this api has no return value
|
||||
value.cmd = CMD_TEE_StartPropertyEnumerator;
|
||||
value.propSet = TEE_PROPSET_CURRENT_CLIENT;
|
||||
Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
|
||||
do {
|
||||
value.cmd = CMD_TEE_GetPropertyNameEnumerator;
|
||||
value.outBufferLen = BIG_SIZE;
|
||||
result = Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
if ((count != 0) && (result == TEEC_ERROR_ITEM_NOT_FOUND))
|
||||
break;
|
||||
ASSERT_EQ(result, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, value.outBuffer, value.outBufferLen);
|
||||
value.inBufferLen = value.outBufferLen;
|
||||
ASSERT_EQ(rc, 0);
|
||||
count++;
|
||||
|
||||
ret = GetPropertyFromUnIntMap(GetContext(), GetSession(), &value, &findFlag);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
if (findFlag != 1) {
|
||||
ret = GetPropertyFromIntMap(GetContext(), GetSession(), &value, &findFlag);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
}
|
||||
|
||||
if (findFlag == 0) {
|
||||
TEST_PRINT_ERROR("get PropertyName from Enumerator is undefined!\n");
|
||||
ASSERT_FALSE(1);
|
||||
}
|
||||
|
||||
value.cmd = CMD_TEE_GetNextPropertyEnumerator;
|
||||
Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
findFlag = 0;
|
||||
} while (result != TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetProperty_WithEnum_TEE_PROPSET_IMPLEMENTATION
|
||||
* @testcase.desc : test TA call TEE_AllocatePropertyEnumerator, TEE_StartPropertyEnumerator, TEE_GetPropertyName,
|
||||
* TEE_GetNextProperty and TEE_GetPropertyAsX API to get all kinds of property from Enumerator for
|
||||
* TEE_PROPSET_IMPLEMENTATION
|
||||
* @testcase.expect : process success
|
||||
*/
|
||||
TEE_TEST(TCF1ENUM_Test, TEE_GetProperty_WithEnum_TEE_PROPSET_IMPLEMENTATION, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result result, ret;
|
||||
int rc, count = 0, findFlag = 0;
|
||||
|
||||
// start PropertyEnumerator this api has no return value
|
||||
value.cmd = CMD_TEE_StartPropertyEnumerator;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
|
||||
do {
|
||||
value.cmd = CMD_TEE_GetPropertyNameEnumerator;
|
||||
value.outBufferLen = BIG_SIZE;
|
||||
result = Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
if ((count != 0) && (result == TEEC_ERROR_ITEM_NOT_FOUND))
|
||||
break;
|
||||
ASSERT_EQ(result, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, value.outBuffer, value.outBufferLen);
|
||||
value.inBufferLen = value.outBufferLen;
|
||||
ASSERT_EQ(rc, 0);
|
||||
count++;
|
||||
|
||||
ret = GetPropertyFromUnIntMap(GetContext(), GetSession(), &value, &findFlag);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
if (findFlag != 1) {
|
||||
ret = GetPropertyFromIntMap(GetContext(), GetSession(), &value, &findFlag);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
}
|
||||
|
||||
if (findFlag == 0) {
|
||||
TEST_PRINT_ERROR("get PropertyName from Enumerator is undefined!\n");
|
||||
ASSERT_FALSE(1);
|
||||
}
|
||||
|
||||
value.cmd = CMD_TEE_GetNextPropertyEnumerator;
|
||||
Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
findFlag = 0;
|
||||
} while (result != TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetProperty_WithEnum_WithResetEnum
|
||||
* @testcase.desc : test TA call TEE_AllocatePropertyEnumerator , TEE_StartPropertyEnumerator,
|
||||
* TEE_ResetPropertyEnumerator, TEE_GetPropertyName, TEE_GetNextProperty and TEE_GetPropertyAsX
|
||||
* API to get all kinds of property from Enumerator for TEE_PROPSET_CURRENT_CLIENT
|
||||
* @testcase.expect : process success
|
||||
*/
|
||||
TEE_TEST(TCF1ENUM_Test, TEE_GetProperty_WithEnum_WithResetEnum, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result result, ret;
|
||||
int rc, count = 0, findFlag = 0;
|
||||
|
||||
// start PropertyEnumerator this api has no return value
|
||||
value.cmd = CMD_TEE_StartPropertyEnumerator;
|
||||
value.propSet = TEE_PROPSET_CURRENT_CLIENT;
|
||||
Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
|
||||
do {
|
||||
value.cmd = CMD_TEE_GetPropertyNameEnumerator;
|
||||
value.outBufferLen = BIG_SIZE;
|
||||
result = Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
if ((count != 0) && (result == TEEC_ERROR_ITEM_NOT_FOUND))
|
||||
break;
|
||||
ASSERT_EQ(result, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
rc = memcpy_s(value.inBuffer, BIG_SIZE, value.outBuffer, value.outBufferLen);
|
||||
value.inBufferLen = value.outBufferLen;
|
||||
ASSERT_EQ(rc, 0);
|
||||
count++;
|
||||
|
||||
ret = GetPropertyFromUnIntMap(GetContext(), GetSession(), &value, &findFlag);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
if (findFlag != 1) {
|
||||
ret = GetPropertyFromIntMap(GetContext(), GetSession(), &value, &findFlag);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
}
|
||||
|
||||
if (findFlag == 0) {
|
||||
TEST_PRINT_ERROR("get PropertyName from Enumerator is undefined!\n");
|
||||
ASSERT_FALSE(1);
|
||||
}
|
||||
|
||||
value.cmd = CMD_TEE_GetNextPropertyEnumerator;
|
||||
Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
findFlag = 0;
|
||||
} while (result != TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
|
||||
// reset PropertyEnumerator this api has no return value
|
||||
value.cmd = CMD_TEE_ResetPropertyEnumerator;
|
||||
value.propSet = TEE_PROPSET_IMPLEMENTATION;
|
||||
Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
|
||||
// get PropertyEnumerator after reset
|
||||
value.cmd = CMD_TEE_GetPropertyNameEnumerator;
|
||||
value.outBufferLen = BIG_SIZE;
|
||||
result = Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
ASSERT_EQ(result, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_AllocatePropertyEnumerator_EnumIsNull
|
||||
* @testcase.desc : test TA call TEE_AllocatePropertyEnumerator while Enumerator is NULL
|
||||
* property from TEE_PROPSET_CURRENT_TA
|
||||
* @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_AllocatePropertyEnumerator_EnumIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_AllocatePropertyEnumerator;
|
||||
value.caseId = OUTPUT_ISNULL;
|
||||
ret = Invoke_AllocatePropertyEnumerator(GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_AllocatePropertyEnumerator_MaxEnum
|
||||
* @testcase.desc : test TA call TEE_AllocatePropertyEnumerator alloc PropertyEnumerator reach max numbers limit
|
||||
* property from TEE_PROPSET_CURRENT_TA
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_AllocatePropertyEnumerator_MaxEnum, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestData value = { 0 };
|
||||
value.cmd = CMD_TEE_AllocatePropertyEnumerator;
|
||||
|
||||
for (int i = 1; i <= MAX_ENUMERATOR; i++) {
|
||||
ret = Invoke_AllocatePropertyEnumerator(GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
// then alloc 1024th Enumerator,should fail
|
||||
ret = Invoke_AllocatePropertyEnumerator(GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_OUT_OF_MEMORY);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(value.enumerator, 0);
|
||||
|
||||
// intend to free enumerator which NO is MAX_ENUMERATOR
|
||||
value.enumerator = MAX_ENUMERATOR;
|
||||
value.cmd = CMD_TEE_FreePropertyEnumerator;
|
||||
Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
|
||||
value.cmd = CMD_TEE_AllocatePropertyEnumerator;
|
||||
ret = Invoke_AllocatePropertyEnumerator(GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
ASSERT_EQ(value.enumerator, MAX_ENUMERATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyName_BufferIsNull
|
||||
* @testcase.desc : test TA call TEE_GetPropertyName while output buffer is null
|
||||
* @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS
|
||||
*/
|
||||
TEE_TEST(TCF1ENUM_Test, TEE_GetPropertyName_BufferIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
// get Property from Enumerator
|
||||
value.cmd = CMD_TEE_GetPropertyNameEnumerator;
|
||||
value.caseId = OUTPUT_ISNULL;
|
||||
value.outBufferLen = BIG_SIZE;
|
||||
ret = Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyName_BufferSizeIsNull
|
||||
* @testcase.desc : test TA call TEE_GetPropertyName while output buffer size is null
|
||||
* @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS
|
||||
*/
|
||||
TEE_TEST(TCF1ENUM_Test, TEE_GetPropertyName_BufferSizeIsNull, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
// get Property from Enumerator
|
||||
value.cmd = CMD_TEE_GetPropertyNameEnumerator;
|
||||
value.caseId = OUTPUTBUFFERSIZE_ISNULL;
|
||||
value.outBufferLen = BIG_SIZE;
|
||||
ret = Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyName_BufferSizeTooShort
|
||||
* @testcase.desc : test TA call TEE_GetPropertyName while output buffer size too short
|
||||
* @testcase.expect : return TEEC_ERROR_SHORT_BUFFER
|
||||
*/
|
||||
TEE_TEST(TCF1ENUM_Test, TEE_GetPropertyName_BufferSizeTooShort, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
|
||||
// start PropertyEnumerator this api has no return value
|
||||
value.cmd = CMD_TEE_StartPropertyEnumerator;
|
||||
value.propSet = TEE_PROPSET_CURRENT_TA;
|
||||
Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
|
||||
// get Property from Enumerator
|
||||
value.cmd = CMD_TEE_GetPropertyNameEnumerator;
|
||||
value.caseId = OUTPUTBUFFERSIZE_TOOSHORT;
|
||||
value.outBufferLen = BIG_SIZE;
|
||||
ret = Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER);
|
||||
ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyName_EnumeratorNotAlloc
|
||||
* @testcase.desc : test TA call TEE_GetPropertyName while Enumerator is not alloc
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyName_EnumeratorNotAlloc, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestData value = { 0 };
|
||||
|
||||
// get Property from Enumerator
|
||||
value.cmd = CMD_TEE_GetPropertyNameEnumerator;
|
||||
value.enumerator = ENUMERATOR1;
|
||||
value.outBufferLen = BIG_SIZE;
|
||||
ret = Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
EXPECT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
EXPECT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetPropertyName_EnumeratorNotStart
|
||||
* @testcase.desc : test TA call TEE_GetPropertyName while Enumerator is not start
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetPropertyName_EnumeratorNotStart, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestData value = { 0 };
|
||||
|
||||
// alloc PropertyEnumerator
|
||||
value.cmd = CMD_TEE_AllocatePropertyEnumerator;
|
||||
ret = Invoke_AllocatePropertyEnumerator(GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
EXPECT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
EXPECT_EQ(value.enumerator, ENUMERATOR1);
|
||||
|
||||
// get Property from Enumerator
|
||||
value.cmd = CMD_TEE_GetPropertyNameEnumerator;
|
||||
value.outBufferLen = BIG_SIZE;
|
||||
ret = Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
EXPECT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
EXPECT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
|
||||
value.cmd = CMD_TEE_FreePropertyEnumerator;
|
||||
Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetNextProperty_EnumeratorNotAlloc
|
||||
* @testcase.desc : test TA call TEE_GetPropertyName while Enumerator is not alloc
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetNextProperty_EnumeratorNotAlloc, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestData value = { 0 };
|
||||
|
||||
// get next Property from Enumerator
|
||||
value.cmd = CMD_TEE_GetNextPropertyEnumerator;
|
||||
value.enumerator = ENUMERATOR1;
|
||||
value.outBufferLen = BIG_SIZE;
|
||||
ret = Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
EXPECT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
EXPECT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TEE_GetNextProperty_EnumeratorNotStart
|
||||
* @testcase.desc : test TA call TEE_GetPropertyName while Enumerator is not start
|
||||
* @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND
|
||||
*/
|
||||
TEE_TEST(TCF1Test, TEE_GetNextProperty_EnumeratorNotStart, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TestData value = { 0 };
|
||||
|
||||
// alloc PropertyEnumerator
|
||||
value.cmd = CMD_TEE_AllocatePropertyEnumerator;
|
||||
ret = Invoke_AllocatePropertyEnumerator(GetSession(), &value);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
EXPECT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
EXPECT_EQ(value.enumerator, ENUMERATOR1);
|
||||
|
||||
// get next Property from Enumerator
|
||||
value.cmd = CMD_TEE_GetNextPropertyEnumerator;
|
||||
value.outBufferLen = BIG_SIZE;
|
||||
ret = Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
EXPECT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND);
|
||||
EXPECT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
|
||||
value.cmd = CMD_TEE_FreePropertyEnumerator;
|
||||
Invoke_Operate_PropertyEnumerator(GetSession(), &value);
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
|
||||
set(ca_sources)
|
||||
list(APPEND ca_sources
|
||||
src/tee_test_drv.cpp
|
||||
)
|
||||
|
||||
ca_compile_pub(
|
||||
TEST_NAME
|
||||
tee_test_drv
|
||||
|
||||
SRC_LIST
|
||||
${ca_sources}
|
||||
|
||||
INCLUDE_DIRS
|
||||
include
|
||||
|
||||
COMPILE_OPTS
|
||||
COMPILE_DEFS
|
||||
)
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef __TEE_TEST_DRV_H__
|
||||
#define __TEE_TEST_DRV_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
#define DRVCALLER_UUID \
|
||||
{ \
|
||||
0x534d4152, 0x542d, 0x4353, \
|
||||
{ \
|
||||
0xb9, 0x19, 0xd3, 0x01, 0x6a, 0x17, 0x1f, 0xc9 \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <public_test.h>
|
||||
#include <test_log.h>
|
||||
#include <securec.h>
|
||||
|
||||
#include "tee_test_drv.h"
|
||||
#include <session_mgr/client_session_mgr.h>
|
||||
#include <test_drv_cmdid.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace testing::ext;
|
||||
/**
|
||||
* @testcase.name : DrvAPITest_Drv_Virt_To_Phys
|
||||
* @testcase.desc : test drv call drv_virt_to_phys api
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, DrvAPITest_Drv_Virt_To_Phys, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t origin;
|
||||
ClientSessionMgr sess;
|
||||
TEEC_UUID testId = DRVCALLER_UUID;
|
||||
ret = sess.Start(&testId);
|
||||
EXPECT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, DRVTEST_COMMAND_DRVVIRTTOPHYS, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : DrvAPITest_Copy_From_Client
|
||||
* @testcase.desc : test drv call copy_from_client api
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, DrvAPITest_Copy_From_Client, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t origin;
|
||||
ClientSessionMgr sess;
|
||||
TEEC_UUID testId = DRVCALLER_UUID;
|
||||
ret = sess.Start(&testId);
|
||||
EXPECT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, DRVTEST_COMMAND_COPYFROMCLIENT, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : DrvAPITest_Copy_To_Client
|
||||
* @testcase.desc : test drv call copy_to_client api
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, DrvAPITest_Copy_To_Client, Function | MediumTest | Level0)
|
||||
{
|
||||
TEEC_Result ret;
|
||||
uint32_t origin;
|
||||
ClientSessionMgr sess;
|
||||
TEEC_UUID testId = DRVCALLER_UUID;
|
||||
ret = sess.Start(&testId);
|
||||
EXPECT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, DRVTEST_COMMAND_COPYTOCLIENT, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
|
||||
|
||||
set(ca_sources)
|
||||
list(APPEND ca_sources
|
||||
src/tee_test_time_api.cpp
|
||||
)
|
||||
|
||||
ca_compile_pub(
|
||||
TEST_NAME
|
||||
time_api
|
||||
|
||||
SRC_LIST
|
||||
${ca_sources}
|
||||
|
||||
INCLUDE_DIRS
|
||||
common
|
||||
|
||||
COMPILE_OPTS
|
||||
COMPILE_DEFS
|
||||
)
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef __COMMON_TEST_H__
|
||||
#define __COMMON_TEST_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <tee_client_type.h>
|
||||
|
||||
#define ARITHMETIC_API_UUID \
|
||||
{ \
|
||||
0xe7d4c078, 0xb19f, 0x4f97, \
|
||||
{ \
|
||||
0xa2, 0x2d, 0xf4, 0xaf, 0xd6, 0xae, 0x7a, 0x0e \
|
||||
} \
|
||||
}
|
||||
|
||||
enum TEST_TIME_API_CMD_ID {
|
||||
CMD_ID_TEST_GET_SYSTEM_TIME = 0,
|
||||
CMD_ID_TEST_GET_REE_TIME,
|
||||
CMD_ID_TEST_TEE_WAIT,
|
||||
CMD_ID_ONLY_GET_PERSISTENT_TIME,
|
||||
CMD_ID_TEST_GET_PERSISTENT_TIME,
|
||||
CMD_ID_TEST_SET_PERSISTENT_TIME, // 5
|
||||
CMD_ID_TEST_PERSISTENT_TIME_WITH_EXCEPTION,
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,170 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <public_test.h>
|
||||
#include <test_log.h>
|
||||
#include <securec.h>
|
||||
#include <common_test.h>
|
||||
#include <tee_client_api.h>
|
||||
#include <tee_client_type.h>
|
||||
#include <session_mgr/client_session_mgr.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
/**
|
||||
* @testcase.name : GetSystemTime
|
||||
* @testcase.desc : test TEE_GetSystemTime api
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, TEE_GetSystemTime, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
TEEC_Operation operation = {0};
|
||||
operation.started = 1;
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_NONE, TEEC_VALUE_OUTPUT, TEEC_NONE, TEEC_NONE);
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_GET_SYSTEM_TIME, &operation, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
uint32_t time1 = operation.params[1].value.a;
|
||||
|
||||
sleep(3); // wait for 3s
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_GET_SYSTEM_TIME, &operation, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
uint32_t time2 = operation.params[1].value.a;
|
||||
ASSERT_LT(time1, time2);
|
||||
sess.Destroy();
|
||||
}
|
||||
#if 0
|
||||
/**
|
||||
* @testcase.name : TeeWait
|
||||
* @testcase.desc : test TEE_Wait api
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, TeeWait, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_TEE_WAIT, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : GetPersistentTime
|
||||
* @testcase.desc : test get persistent time
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, GetPersistentTime, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_GET_PERSISTENT_TIME, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : SetPersistentTime
|
||||
* @testcase.desc : test set persistent time
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, SetPersistentTime, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_SET_PERSISTENT_TIME, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : TestPersistentTimeWithException
|
||||
* @testcase.desc : test set and get persistent time with exception
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, TestPersistentTimeWithException, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_PERSISTENT_TIME_WITH_EXCEPTION, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* @testcase.name : OnlyGetPersistentTime
|
||||
* @testcase.desc : test only get persistent time
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, OnlyGetPersistentTime, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_ONLY_GET_PERSISTENT_TIME, NULL, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
sess.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testcase.name : GetReeTime
|
||||
* @testcase.desc : test TEE_GetREETime api
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TEE_TEST(EmptyTest, GetReeTime, Function | MediumTest | Level0)
|
||||
{
|
||||
ClientSessionMgr sess;
|
||||
uint32_t origin;
|
||||
TEEC_UUID testId = ARITHMETIC_API_UUID;
|
||||
TEEC_Result ret = sess.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
TEEC_Operation operation = {0};
|
||||
operation.started = 1;
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_NONE, TEEC_VALUE_OUTPUT, TEEC_NONE, TEEC_NONE);
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_GET_REE_TIME, &operation, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
uint32_t time1 = operation.params[1].value.a;
|
||||
|
||||
sleep(3); // wait for 3s
|
||||
ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_GET_REE_TIME, &operation, &origin);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
|
||||
uint32_t time2 = operation.params[1].value.a;
|
||||
ASSERT_LT(time1, time2);
|
||||
sess.Destroy();
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
|
||||
|
||||
set(ca_sources)
|
||||
list(APPEND ca_sources
|
||||
common/common_test.cpp
|
||||
src/tee_test_trusted_storage_api.cpp
|
||||
)
|
||||
|
||||
ca_compile_pub(
|
||||
TEST_NAME
|
||||
trusted_storage_api
|
||||
|
||||
SRC_LIST
|
||||
${ca_sources}
|
||||
|
||||
INCLUDE_DIRS
|
||||
common
|
||||
|
||||
COMPILE_OPTS
|
||||
COMPILE_DEFS
|
||||
)
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <common_test.h>
|
||||
|
||||
void TrustedStorageTest::SetUp()
|
||||
{
|
||||
TEEC_Result ret;
|
||||
TEEC_UUID testId = TRUSTED_STORAGE_API_UUID;
|
||||
ret = session.Start(&testId);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
operation.started = 1;
|
||||
operation.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_WHOLE, TEEC_NONE, TEEC_NONE, TEEC_NONE);
|
||||
(void)memset_s(&testMem.sharedMem, FUN_NAME_LEN, 0, FUN_NAME_LEN);
|
||||
testMem.sharedMem.size = FUN_NAME_LEN;
|
||||
testMem.sharedMem.flags = TEEC_MEM_OUTPUT | TEEC_MEM_INPUT;
|
||||
ret = TEEC_AllocateSharedMemory(&session.context, &testMem.sharedMem);
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS);
|
||||
}
|
||||
|
||||
void TrustedStorageTest::TearDown()
|
||||
{
|
||||
TEEC_ReleaseSharedMemory(&testMem.sharedMem);
|
||||
session.Destroy();
|
||||
}
|
||||
|
||||
TEEC_Result TrustedStorageTest::InvokeTest(const char *casename)
|
||||
{
|
||||
int rc = strcpy_s(reinterpret_cast<char*>(testMem.sharedMem.buffer), FUN_NAME_LEN, casename);
|
||||
if (rc != 0) {
|
||||
return TEEC_FAIL;
|
||||
}
|
||||
operation.params[0].memref.parent = &testMem.sharedMem;
|
||||
operation.params[0].memref.offset = 0;
|
||||
operation.params[0].memref.size = testMem.sharedMem.size;
|
||||
return TEEC_InvokeCommand(&session.session, CMD_RUN_BY_FUN_SEQ, &operation, &origin);
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef __TRUSTED_STORAGE_COMMON_TEST_H__
|
||||
#define __TRUSTED_STORAGE_COMMON_TEST_H__
|
||||
|
||||
#include <public_test.h>
|
||||
#include <session_mgr/client_session_mgr.h>
|
||||
|
||||
#define TRUSTED_STORAGE_API_UUID \
|
||||
{ \
|
||||
0x09090909, 0x0808, 0x0707, \
|
||||
{ \
|
||||
0x03, 0x03, 0x03, 0x03, 0x05, 0x07, 0x09, 0x01 \
|
||||
} \
|
||||
}
|
||||
|
||||
#define FUN_NAME_LEN 64
|
||||
enum TEST_TRUSTED_STORAGE_API_CMD_ID {
|
||||
CMD_RUN_BY_FUN_SEQ = 0,
|
||||
};
|
||||
|
||||
class TrustedStorageTest : public EmptyTest {
|
||||
protected:
|
||||
ClientSessionMgr session;
|
||||
TEEC_Operation operation = { 0 };
|
||||
uint32_t origin;
|
||||
ClientShareMemMgr testMem;
|
||||
|
||||
public:
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
TEEC_Result InvokeTest(const char *casename);
|
||||
};
|
||||
|
||||
#define TRUSTED_STORAGE_TEST_EQ(casename) \
|
||||
TEE_TEST(TrustedStorageTest, casename, Function | MediumTest | Level0) \
|
||||
{ \
|
||||
TEEC_Result ret = InvokeTest(#casename); \
|
||||
ASSERT_EQ(ret, TEEC_SUCCESS); \
|
||||
}
|
||||
|
||||
#define TRUSTED_STORAGE_TEST_NE(casename) \
|
||||
TEE_TEST(TrustedStorageTest, casename, Function | MediumTest | Level0) \
|
||||
{ \
|
||||
TEEC_Result ret = InvokeTest(#casename); \
|
||||
ASSERT_NE(ret, TEEC_SUCCESS); \
|
||||
}
|
||||
#endif
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <common_test.h>
|
||||
|
||||
using namespace testing::ext;
|
||||
/**
|
||||
* @testcase.name : CaseCreatePersistentObjectAndDelete
|
||||
* @testcase.desc : test GP interfaces
|
||||
* TEE_CreatePersistentObject, TEE_CloseAndDeletePersistentObject1,
|
||||
* TEE_WriteObjectData, TEE_ReadObjectData, TEE_SeekObjectData,
|
||||
* TEE_OpenPersistentObject, TEE_CloseObject
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TRUSTED_STORAGE_TEST_EQ(CaseCreatePersistentObjectAndDelete);
|
||||
|
||||
/**
|
||||
* @testcase.name : CaseRenameObjectAndGetInfo
|
||||
* @testcase.desc : test GP interfaces
|
||||
* TEE_TruncateObjectData, TEE_RenamePersistentObject, GetObjectInfo,
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TRUSTED_STORAGE_TEST_EQ(CaseRenameObjectAndGetInfo);
|
||||
|
||||
/**
|
||||
* @testcase.name : CaseEnumerateDeleteAllObject
|
||||
* @testcase.desc : test GP interfaces
|
||||
* TEE_AllocatePersistentObjectEnumerator, TEE_FreePersistentObjectEnumerator,
|
||||
* TEE_ResetPersistentObjectEnumerator, TEE_StartPersistentObjectEnumerator,
|
||||
* TEE_GetNextPersistentObject
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TRUSTED_STORAGE_TEST_EQ(CaseEnumerateDeleteAllObject);
|
||||
|
||||
/**
|
||||
* @testcase.name : CaseRestrictObjectUsage
|
||||
* @testcase.desc : test GP interfaces
|
||||
* TEE_AllocateTransientObject, TEE_FreeTransientObject,
|
||||
* TEE_RestrictObjectUsage1, TEE_ResetTransientObject
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TRUSTED_STORAGE_TEST_EQ(CaseRestrictObjectUsage);
|
||||
|
||||
/**
|
||||
* @testcase.name : CasePopulateAndCopyObject
|
||||
* @testcase.desc : test GP interfaces
|
||||
* TEE_InitRefAttribute, TEE_InitValueAttribute,
|
||||
* TEE_PopulateTransientObject, TEE_CopyObjectAttributes1,
|
||||
* TEE_GetObjectBufferAttribute, TEE_GetObjectValueAttribute
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TRUSTED_STORAGE_TEST_EQ(CasePopulateAndCopyObject);
|
||||
|
||||
/**
|
||||
* @testcase.name : CaseGenerateKey
|
||||
* @testcase.desc : test GP interfaces TEE_GenerateKey
|
||||
* @testcase.expect : return TEEC_SUCCESS
|
||||
*/
|
||||
TRUSTED_STORAGE_TEST_EQ(CaseGenerateKey);
|
||||
@@ -1,25 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
|
||||
|
||||
set(TEE_TEST_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(REPO_ROOT_DIR ${TEE_TEST_ROOT_DIR}/../../../..)
|
||||
set(TEE_DEV_KIT_DIR ${TEE_TEST_ROOT_DIR}/../../tee_dev_kit)
|
||||
|
||||
set(TEE_BUILD_OUT_DIR ${TEE_TEST_ROOT_DIR}/output)
|
||||
set(LIBRARY_OUTPUT_PATH ${TEE_BUILD_OUT_DIR})
|
||||
|
||||
if ("${TARGET_IS_ARM64}" STREQUAL "")
|
||||
set(TARGET_IS_ARM64 n)
|
||||
endif()
|
||||
|
||||
include(${TEE_TEST_ROOT_DIR}/cmake/ta.cmake)
|
||||
@@ -1,93 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
|
||||
include(${TEE_DEV_KIT_DIR}/ddk/build/cmake/common.cmake)
|
||||
|
||||
set(PUB_DRV_INCLUDE_DIRS)
|
||||
list(APPEND PUB_DRV_INCLUDE_DIRS
|
||||
${TEE_DEV_KIT_DIR}/ddk/include
|
||||
${TEE_DEV_KIT_DIR}/sdk/include/TA
|
||||
${TEE_DEV_KIT_DIR}/sdk/include/TA/ext
|
||||
${TEE_TEST_ROOT_DIR}/utils/include
|
||||
${TEE_TEST_ROOT_DIR}/utils/cmd_id
|
||||
/usr/include/aarch64-linux-android
|
||||
)
|
||||
|
||||
set(PUB_DRV_COMPILE_OPTS)
|
||||
list(APPEND PUB_DRV_COMPILE_OPTS
|
||||
-Wall
|
||||
-Werror
|
||||
-fstack-protector-all
|
||||
--target=aarch64-linux-android21
|
||||
-fvisibility=default
|
||||
-fno-exceptions
|
||||
-fno-common
|
||||
)
|
||||
|
||||
set(PUB_DRV_COMPILE_DEFS)
|
||||
list(APPEND PUB_DRV_COMPILE_DEFS
|
||||
# Test Macros Here
|
||||
)
|
||||
|
||||
macro(drv_compile_pub)
|
||||
cmake_parse_arguments(
|
||||
DRV
|
||||
""
|
||||
""
|
||||
"ELF_NAME;SRC_LIST;INCLUDE_DIRS;COMPILE_OPTS;COMPILE_DEFS"
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
message("DRV_ELF_NAME = ${DRV_ELF_NAME}")
|
||||
message("DRV_SRC_LIST = ${DRV_SRC_LIST}")
|
||||
message("DRV_INCLUDE_DIRS = ${DRV_INCLUDE_DIRS}")
|
||||
message("DRV_COMPILE_OPTS = ${DRV_COMPILE_OPTS}")
|
||||
message("DRV_COMPILE_DEFS = ${DRV_COMPILE_DEFS}")
|
||||
|
||||
add_executable(${DRV_ELF_NAME})
|
||||
target_sources(${DRV_ELF_NAME} PRIVATE
|
||||
${DRV_SRC_LIST}
|
||||
)
|
||||
|
||||
target_include_directories(${DRV_ELF_NAME} PRIVATE
|
||||
${DRV_INCLUDE_DIRS}
|
||||
${PUB_DRV_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_compile_options(${DRV_ELF_NAME} PRIVATE
|
||||
${DRV_COMPILE_OPTS}
|
||||
${PUB_DRV_COMPILE_OPTS}
|
||||
)
|
||||
|
||||
target_compile_definitions(${DRV_ELF_NAME} PRIVATE
|
||||
${DRV_COMPILE_DEFS}
|
||||
${PUB_DRV_COMPILE_DEFS}
|
||||
)
|
||||
|
||||
target_link_options(${DRV_ELF_NAME} PRIVATE
|
||||
-v
|
||||
-s
|
||||
-nostdlib
|
||||
-Wl,--discard-all
|
||||
-Wl,-z,text
|
||||
-Wl,-z,now
|
||||
-Wl,-z,relro
|
||||
-Wl,-shared
|
||||
-Wl,-z,noexecstack
|
||||
)
|
||||
target_link_directories(${DRV_ELF_NAME} PRIVATE
|
||||
${TEE_TEST_ROOT_DIR}/bin
|
||||
)
|
||||
|
||||
target_link_libraries(${DRV_ELF_NAME} PRIVATE
|
||||
)
|
||||
endmacro()
|
||||
@@ -1,77 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
|
||||
include(${TEE_DEV_KIT_DIR}/sdk/build/cmake/common.cmake)
|
||||
|
||||
set(PUB_TA_INCLUDE_DIRS)
|
||||
list(APPEND PUB_TA_INCLUDE_DIRS
|
||||
${TEE_TEST_ROOT_DIR}/utils/include
|
||||
${TEE_TEST_ROOT_DIR}/utils/cmd_id
|
||||
)
|
||||
|
||||
macro(ta_compile_pub)
|
||||
cmake_parse_arguments(
|
||||
TA
|
||||
""
|
||||
""
|
||||
"ELF_NAME;SRC_LIST;INCLUDE_DIRS;COMPILE_OPTS;COMPILE_DEFS"
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
add_library(${TA_ELF_NAME} SHARED)
|
||||
target_sources(${TA_ELF_NAME} PRIVATE
|
||||
${TA_SRC_LIST}
|
||||
${SDK_C_SOURCES}
|
||||
)
|
||||
|
||||
target_include_directories(${TA_ELF_NAME} PRIVATE
|
||||
${PUB_TA_INCLUDE_DIRS}
|
||||
${TA_INCLUDE_DIRS}
|
||||
${COMMON_INCLUDES}
|
||||
)
|
||||
|
||||
target_compile_options(${TA_ELF_NAME} PRIVATE
|
||||
${TA_COMPILE_OPTS}
|
||||
${COMMON_CFLAGS}
|
||||
)
|
||||
|
||||
target_compile_definitions(${TA_ELF_NAME} PRIVATE
|
||||
${TA_COMPILE_DEFS}
|
||||
)
|
||||
|
||||
target_link_options(${TA_ELF_NAME} PRIVATE
|
||||
-v
|
||||
${COMMON_LDFLAGS}
|
||||
)
|
||||
|
||||
target_link_directories(${TA_ELF_NAME} PRIVATE
|
||||
${TEE_TEST_ROOT_DIR}/bin
|
||||
)
|
||||
|
||||
target_link_libraries(${TA_ELF_NAME} PRIVATE
|
||||
)
|
||||
endmacro()
|
||||
|
||||
macro(ta_entry_check)
|
||||
cmake_parse_arguments(
|
||||
SIGN
|
||||
""
|
||||
""
|
||||
"TARGET_NAME"
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
TARGET ${SIGN_TARGET_NAME} POST_BUILD
|
||||
COMMAND sh $ENV{TEE_BUILD_PATH}/build/tools/ta_entry_check.sh ${CMAKE_READELF} ${TEE_BUILD_OUT_DIR}/lib${SIGN_TARGET_NAME}.so n y ${TARGET_IS_ARM64}
|
||||
)
|
||||
endmacro()
|
||||
@@ -1,13 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
|
||||
add_subdirectory(drv_test_module)
|
||||
@@ -1,35 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
|
||||
|
||||
set(drv_sources)
|
||||
list(APPEND drv_sources
|
||||
src/drv_test_module.c
|
||||
)
|
||||
|
||||
list(APPEND header_dir
|
||||
include
|
||||
)
|
||||
|
||||
drv_compile_pub(
|
||||
ELF_NAME
|
||||
drv_test_module.elf
|
||||
|
||||
SRC_LIST
|
||||
${drv_sources}
|
||||
|
||||
INCLUDE_DIRS
|
||||
${header_dir}
|
||||
|
||||
COMPILE_OPTS
|
||||
COMPILE_DEFS
|
||||
)
|
||||
@@ -1,22 +0,0 @@
|
||||
perm1,1
|
||||
perm2,2
|
||||
perm3,3
|
||||
perm4,4
|
||||
perm5,5
|
||||
perm6,6
|
||||
perm7,7
|
||||
perm8,8
|
||||
perm9,9
|
||||
perm10,10
|
||||
iomap_perm,11
|
||||
SHARE_BUFFER_TEST_ID,0x10
|
||||
ARGS_TEST_ID,0x11
|
||||
BUFFER_TEST_ID,0x12
|
||||
RETURN_EXCEPTION_ID,0x13
|
||||
SLEEP_TEST_ID,0x14
|
||||
MAX_BUFFER_TEST_ID,0x15
|
||||
CRASH_TEST_ID,0x16
|
||||
NO_PARAM_TEST_ID,0x17
|
||||
CALL_OTHER_DRV_TEST_ID,0x18
|
||||
STRING_TEST_ID,0x19
|
||||
IOMAP_TEST_ID,0x1a
|
||||
|
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
Licensed under the Mulan PSL v2.
|
||||
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
You may obtain a copy of Mulan PSL v2 at:
|
||||
http://license.coscl.org.cn/MulanPSL2
|
||||
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
PURPOSE.
|
||||
See the Mulan PSL v2 for more details.
|
||||
-->
|
||||
|
||||
<drv_perm>
|
||||
<drv_basic_info thread_limit="8" upgrade="true" virt2phys="true" />
|
||||
</drv_perm>
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef __DRV_TEST_MODULE_H__
|
||||
#define __DRV_TEST_MODULE_H__
|
||||
#include <stdint.h>
|
||||
#include <tee_defines.h>
|
||||
|
||||
#define DRV_NAME_MAX_LEN 32U
|
||||
#define DRV_RESERVED_NUM 8U
|
||||
#define driver_log(fmt, args...) tee_print(LOG_LEVEL_ERROR, "%s %d: %s" fmt " ", TAG_ERROR, __LINE__, g_log_tag, ##args)
|
||||
|
||||
struct drv_data {
|
||||
int32_t fd; /* unique label which alloced by driver framework */
|
||||
uint32_t taskid; /* caller taskid */
|
||||
void *private_data; /* the private data associated with this fd */
|
||||
struct tee_uuid uuid; /* caller uuid */
|
||||
};
|
||||
|
||||
struct share_buffer_arg {
|
||||
uint64_t addr;
|
||||
uint32_t len;
|
||||
uint32_t share_token;
|
||||
};
|
||||
|
||||
typedef int32_t (*init_func)(void);
|
||||
|
||||
typedef int32_t (*suspned_func)(void);
|
||||
typedef int32_t (*resume_func)(void);
|
||||
|
||||
typedef int64_t (*ioctl_func)(struct drv_data *drv, uint32_t cmd, unsigned long args, uint32_t args_len);
|
||||
typedef int64_t (*open_func)(struct drv_data *drv, unsigned long args, uint32_t args_len);
|
||||
typedef int64_t (*close_func)(struct drv_data *drv);
|
||||
|
||||
struct tee_driver_module {
|
||||
init_func init;
|
||||
ioctl_func ioctl;
|
||||
open_func open;
|
||||
close_func close;
|
||||
suspned_func suspend;
|
||||
resume_func resume;
|
||||
suspned_func suspend_s4;
|
||||
resume_func resume_s4;
|
||||
uint64_t reserved[DRV_RESERVED_NUM]; /* has not used, just reserved */
|
||||
};
|
||||
|
||||
#define tee_driver_declare(name, init, open, ioctl, close, suspend, resume, suspend_s4, resume_s4) \
|
||||
__attribute__((visibility("default"))) const struct tee_driver_module g_driver_##name = { \
|
||||
init, ioctl, open, close, suspend, resume, suspend_s4, resume_s4, {0} }
|
||||
|
||||
#endif /* __DRV_TEST_MODULE_H__ */
|
||||
@@ -1,6 +0,0 @@
|
||||
gpd.ta.appID: 11112222-0000-0000-0000-111111111111
|
||||
gpd.ta.service_name: drv_test_module
|
||||
gpd.ta.instanceKeepAlive: false
|
||||
gpd.ta.dataSize: 1048576
|
||||
gpd.ta.stackSize: 8192
|
||||
gpd.ta.target_type: 1
|
||||
@@ -1,262 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <malloc.h>
|
||||
#include <securec.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "drv_addr_share.h"
|
||||
#include "drv_param_ops.h"
|
||||
#include "drv_test_module.h"
|
||||
#include "tee_log.h"
|
||||
#include "test_drv_cmdid.h"
|
||||
|
||||
#define TOKEN_BUF_SIZE 0x1000
|
||||
#define BUFFER_SIZE 1024
|
||||
|
||||
const char *g_log_tag = "[32-1 drv] ";
|
||||
|
||||
static int64_t virt2phys_test()
|
||||
{
|
||||
uint64_t va;
|
||||
uint64_t pa = drv_virt_to_phys((uintptr_t)&va);
|
||||
if (pa == 0) {
|
||||
driver_log("drv virt_to phys failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
driver_log("drv virt_to phys success\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t copy_from_client_exception_test(struct share_buffer_arg *input_arg, char *temp_buffer)
|
||||
{
|
||||
driver_log("copy from client exception test begin\n");
|
||||
int32_t ret = copy_from_client(0, input_arg->len, (uintptr_t)temp_buffer, input_arg->len);
|
||||
ret &= copy_from_client(input_arg->addr, 0, (uintptr_t)temp_buffer, input_arg->len);
|
||||
ret &= copy_from_client(input_arg->addr, input_arg->len, 0, input_arg->len);
|
||||
ret &= copy_from_client(input_arg->addr, input_arg->len, (uintptr_t)temp_buffer, 0);
|
||||
ret &= copy_from_client(input_arg->addr, input_arg->len, (uintptr_t)temp_buffer, input_arg->len - 1);
|
||||
if (ret == 0) {
|
||||
driver_log("copy from client exception test FAIL\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
driver_log("copy from client exception test SUCC\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t copy_from_client_test(struct share_buffer_arg *input_arg, char *temp_buffer, uint32_t size)
|
||||
{
|
||||
driver_log("copy from client test begin\n");
|
||||
int32_t ret;
|
||||
char drvcaller_input[] = "the param is drvcaller_input";
|
||||
uint32_t drvcaller_input_len;
|
||||
drvcaller_input_len = strlen(drvcaller_input) + 1;
|
||||
|
||||
ret = copy_from_client(input_arg->addr, input_arg->len, (uintptr_t)temp_buffer, size);
|
||||
if (ret != 0 || strncmp(drvcaller_input, (char *)temp_buffer, drvcaller_input_len) != 0 ||
|
||||
input_arg->len != BUFFER_SIZE) {
|
||||
driver_log("test copy_from_client failed,ret = 0x%x, received buffer is: %s, received lens is: %d\n", ret,
|
||||
temp_buffer, input_arg->len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (copy_from_client_exception_test(input_arg, temp_buffer) != 0) {
|
||||
return -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t copy_to_client_exception_test(struct share_buffer_arg *input_arg, char *temp_buffer)
|
||||
{
|
||||
driver_log("copy to client exception test begin\n");
|
||||
int32_t ret = copy_to_client(0, input_arg->len, input_arg->addr, input_arg->len);
|
||||
ret &= copy_to_client((uintptr_t)temp_buffer, 0, input_arg->addr, input_arg->len);
|
||||
ret &= copy_to_client((uintptr_t)temp_buffer, input_arg->len, 0, input_arg->len);
|
||||
ret &= copy_to_client((uintptr_t)temp_buffer, input_arg->len, input_arg->addr, 0);
|
||||
ret &= copy_to_client((uintptr_t)temp_buffer, input_arg->len, input_arg->addr, input_arg->len - 1);
|
||||
if (ret == 0) {
|
||||
driver_log("copy to client exception test FAIL\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
driver_log("copy to client exception test SUCC\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t copy_to_client_test(struct share_buffer_arg *input_arg, char *temp_buffer, uint32_t size)
|
||||
{
|
||||
driver_log("copy to client test begin\n");
|
||||
int32_t ret;
|
||||
static char drv_output[] = "DRVMEM_OUTPUT";
|
||||
uint32_t drv_output_len;
|
||||
drv_output_len = strlen(drv_output) + 1;
|
||||
ret = strcpy_s(temp_buffer, drv_output_len, drv_output);
|
||||
if (ret != 0) {
|
||||
driver_log("strcpy_s failed,ret = 0x%x\n", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = copy_to_client((uintptr_t)temp_buffer, size, input_arg->addr, input_arg->len);
|
||||
if (ret != 0) {
|
||||
driver_log("test copy_to_client failed,ret = 0x%x\n", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (copy_to_client_exception_test(input_arg, temp_buffer) != 0) {
|
||||
return -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t init_test(void)
|
||||
{
|
||||
driver_log("driver init test end\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t ioctl_test(struct drv_data *drv, uint32_t cmd, unsigned long args, uint32_t args_len)
|
||||
{
|
||||
(void)args;
|
||||
(void)args_len;
|
||||
int64_t ret = 0;
|
||||
if (drv == NULL) {
|
||||
driver_log("ioctl invalid drv\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct share_buffer_arg *input_arg = (struct share_buffer_arg *)args;
|
||||
uint32_t size = input_arg->len;
|
||||
char *temp_buffer = malloc(size);
|
||||
if (temp_buffer == NULL) {
|
||||
driver_log("malloc temp buffer failed\n");
|
||||
return -1;
|
||||
}
|
||||
(void)memset_s(temp_buffer, size, 0x0, size);
|
||||
|
||||
switch (cmd) {
|
||||
case DRVTEST_COMMAND_DRVVIRTTOPHYS:
|
||||
ret = virt2phys_test();
|
||||
break;
|
||||
case DRVTEST_COMMAND_COPYFROMCLIENT:
|
||||
ret = copy_from_client_test(input_arg, temp_buffer, size);
|
||||
break;
|
||||
case DRVTEST_COMMAND_COPYTOCLIENT:
|
||||
ret = copy_to_client_test(input_arg, temp_buffer, size);
|
||||
break;
|
||||
default:
|
||||
driver_log("cmd:0x%x not support\n", cmd);
|
||||
free(temp_buffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
free(temp_buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uint32_t *buf_init(uint32_t args)
|
||||
{
|
||||
uint32_t *buf = (uint32_t *)malloc(TOKEN_BUF_SIZE * sizeof(uint32_t));
|
||||
if (buf == NULL) {
|
||||
driver_log("alloc buf failed\n");
|
||||
return NULL;
|
||||
}
|
||||
(void)memset_s(buf, TOKEN_BUF_SIZE * sizeof(uint32_t), 0x0, TOKEN_BUF_SIZE * sizeof(uint32_t));
|
||||
|
||||
int32_t i;
|
||||
for (i = 0; i < TOKEN_BUF_SIZE; i++)
|
||||
buf[i] = args;
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
int64_t open_test(struct drv_data *drv, unsigned long args, uint32_t args_len)
|
||||
{
|
||||
if (drv == NULL) {
|
||||
driver_log("open invalid drv\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (args == 0 && args_len == 0) {
|
||||
driver_log("input NULL param\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (args_len < sizeof(uint32_t) || args == 0) {
|
||||
driver_log("open invalid drv\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
char open_succ[10] = { "hello" };
|
||||
driver_log("%s", open_succ);
|
||||
|
||||
uint32_t *input = (uint32_t *)(uintptr_t)args;
|
||||
if (*input == UINT32_MAX) {
|
||||
driver_log("open test input args is UINT32_MAX, just retrun -1\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t *buf = buf_init(*input);
|
||||
if (buf == NULL) {
|
||||
return -1;
|
||||
}
|
||||
drv->private_data = buf;
|
||||
driver_log("driver open test begin: fd=%d args=0x%x", drv->fd, *input);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t close_test(struct drv_data *drv)
|
||||
{
|
||||
if (drv == NULL) {
|
||||
driver_log("close invalid drv\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
driver_log("driver close test begin: fd:%d", drv->fd);
|
||||
if (drv->private_data != NULL) {
|
||||
driver_log("free private data in close\n");
|
||||
free(drv->private_data);
|
||||
drv->private_data = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t suspend_test(void)
|
||||
{
|
||||
driver_log("suspend test begin\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t resume_test(void)
|
||||
{
|
||||
driver_log("resume test begin\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t suspend_s4_test(void)
|
||||
{
|
||||
driver_log("suspend_s4 test begin\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t resume_s4_test(void)
|
||||
{
|
||||
driver_log("resume_s4 test begin\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
tee_driver_declare(drv_test_module, init_test, open_test, ioctl_test, close_test, suspend_test, resume_test,
|
||||
suspend_s4_test, resume_s4_test);
|
||||
@@ -1,19 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
|
||||
|
||||
add_subdirectory(test_client_api)
|
||||
add_subdirectory(test_tcf2_api)
|
||||
add_subdirectory(test_tcf_api)
|
||||
add_subdirectory(test_driver_ta)
|
||||
add_subdirectory(test_arithmetic_api)
|
||||
add_subdirectory(test_time_api)
|
||||
@@ -1,19 +0,0 @@
|
||||
; Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
; Licensed under the Mulan PSL v2.
|
||||
; You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
; You may obtain a copy of Mulan PSL v2 at:
|
||||
; http://license.coscl.org.cn/MulanPSL2
|
||||
; THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
; IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
; PURPOSE.
|
||||
; See the Mulan PSL v2 for more details.
|
||||
;
|
||||
|
||||
[signSecPublicCfg]
|
||||
secSignType = 1
|
||||
|
||||
secSignServerIp =
|
||||
|
||||
secSignKey =
|
||||
|
||||
configPath =
|
||||
@@ -1,39 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
|
||||
set(TARGET_NAME test_arithmetic_api.elf)
|
||||
|
||||
list(APPEND ta_src
|
||||
src/test_arithmetic_api_base.c
|
||||
src/test_arithmetic_api_main.c
|
||||
src/test_basic_arithmetic_operation.c
|
||||
src/test_converter_function.c
|
||||
src/test_fast_modular_multiplication_operation.c
|
||||
src/test_logical_operation.c
|
||||
src/test_modular_arithmetic_operation.c
|
||||
src/test_other_arithmetic_operation.c
|
||||
)
|
||||
|
||||
ta_compile_pub(
|
||||
ELF_NAME
|
||||
${TARGET_NAME}
|
||||
|
||||
SRC_LIST
|
||||
${ta_src}
|
||||
|
||||
INCLUDE_DIRS
|
||||
|
||||
COMPILE_OPTS
|
||||
|
||||
COMPILE_DEFS
|
||||
API_LEVEL=3
|
||||
)
|
||||
@@ -1,7 +0,0 @@
|
||||
gpd.ta.appID: 9ac09588-fed1-4b1e-bb36-d3e5a3f26c39
|
||||
gpd.ta.service_name: test_arithmetic_api
|
||||
gpd.ta.singleInstance: true
|
||||
gpd.ta.multiSession: true
|
||||
gpd.ta.instanceKeepAlive: false
|
||||
gpd.ta.dataSize: 819200
|
||||
gpd.ta.stackSize: 81920
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <tee_ext_api.h>
|
||||
#include <tee_log.h>
|
||||
#include <securec.h>
|
||||
#include <tee_arith_api.h>
|
||||
#include <tee_mem_mgmt_api.h>
|
||||
#include "test_arithmetic_api_base.h"
|
||||
|
||||
TEE_BigInt* AllocateAndInitialize(uint32_t bitSize)
|
||||
{
|
||||
uint32_t length = TEE_BigIntSizeInU32(bitSize);
|
||||
TEE_BigInt *bigInt = (TEE_BigInt *)TEE_Malloc(length * sizeof(TEE_BigInt), 0);
|
||||
if (bigInt == NULL) {
|
||||
tloge("AllocateAndInitialize : TEE_Malloc returned NULL.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TEE_BigIntInit(bigInt, length);
|
||||
return bigInt;
|
||||
}
|
||||
|
||||
TEE_BigInt *CreateBigInt(uint32_t size, uint8_t *buffer)
|
||||
{
|
||||
TEE_BigInt *bigInt = (TEE_BigInt *)TEE_Malloc(TEE_BigIntSizeInU32(size * BIT_OF_CHAR) * sizeof(uint32_t), 0);
|
||||
if (bigInt == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEE_BigIntInit(bigInt, TEE_BigIntSizeInU32(size * BIT_OF_CHAR));
|
||||
if (buffer != NULL) {
|
||||
TEE_BigIntConvertFromOctetString(bigInt, buffer, size, 0);
|
||||
}
|
||||
return bigInt;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntInit()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
uint32_t length = TEE_BigIntSizeInU32(SIZE_256);
|
||||
TEE_BigInt *bigInt = (TEE_BigInt *)TEE_Malloc(length * sizeof(TEE_BigInt), 0);
|
||||
if (bigInt == NULL) {
|
||||
tloge("AllocateAndInitializeFMM : TEE_Malloc returned NULL.");
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
TEE_BigIntInit(bigInt, length);
|
||||
if (TEE_BigIntCmpS32(bigInt, 0) != 0) {
|
||||
tloge("BigIntInit fail.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
TEE_Free(bigInt);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef __TEST_ARITHMETIC_API_BASE_H__
|
||||
#define __TEST_ARITHMETIC_API_BASE_H__
|
||||
|
||||
#include <tee_arith_api.h>
|
||||
|
||||
#define NUM_TWO 2
|
||||
#define NUM_THREE 3
|
||||
#define NUM_FIVE 5
|
||||
#define BIT_OF_CHAR 8
|
||||
#define SIZE_256 256
|
||||
#define MAX_BITS_PER_VARIABLE 2048
|
||||
#define RESULT_SIZE (MAX_BITS_PER_VARIABLE / 8)
|
||||
|
||||
enum TEST_ARITHMETIC_API_CMD_ID {
|
||||
CMD_ID_TEST_BIG_INT_COMPUTE_FMM = 0,
|
||||
CMD_ID_TEST_BIG_INT_INIT_FMM_CONTEXT = 1,
|
||||
CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_FMM = 2,
|
||||
CMD_ID_TEST_BIG_INT_EXP_MOD = 3,
|
||||
CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_OCTET_STRING = 4,
|
||||
CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_S32 = 5,
|
||||
CMD_ID_TEST_BIG_INT_ADD_AND_SUB_MOD = 6,
|
||||
CMD_ID_TEST_BIG_INT_MUL_AND_INV_MOD = 7,
|
||||
CMD_ID_TEST_BIG_INT_MOD = 8,
|
||||
CMD_ID_TEST_BIG_INT_ADD_AND_SUB = 9,
|
||||
CMD_ID_TEST_BIG_INT_NEG = 10,
|
||||
CMD_ID_TEST_BIG_INT_MUL_AND_SQUARE = 11,
|
||||
CMD_ID_TEST_BIG_INT_DIV = 12,
|
||||
CMD_ID_TEST_BIG_INT_SHIFT_RIGHT = 13,
|
||||
CMD_ID_TEST_BIG_INT_GET_BIT = 14,
|
||||
CMD_ID_TEST_BIG_INT_GET_BIT_COUNT = 15,
|
||||
CMD_ID_TEST_BIG_INT_SET_BIT = 16,
|
||||
CMD_ID_TEST_BIG_INT_ASSIGN = 17,
|
||||
CMD_ID_TEST_BIG_INT_ABS = 18,
|
||||
CMD_ID_TEST_BIG_INT_RELATIVE_PRIME = 19,
|
||||
CMD_ID_TEST_BIG_INT_COMPUTE_EXTENTED_GCD = 20,
|
||||
CMD_ID_TEST_BIG_INT_IS_PROBABLE_PRIME = 21,
|
||||
CMD_ID_TEST_BIG_INT_CMP = 22,
|
||||
CMD_ID_TEST_BIG_INT_CMP_S32 = 23,
|
||||
CMD_ID_TEST_BIG_INT_INIT_FMM = 24,
|
||||
CMD_ID_TEST_BIG_INT_INIT = 25,
|
||||
};
|
||||
|
||||
|
||||
TEE_BigInt *AllocateAndInitialize(uint32_t bitSize);
|
||||
TEE_BigInt *CreateBigInt(uint32_t size, uint8_t *buffer);
|
||||
TEE_Result TestBigIntInit();
|
||||
|
||||
#endif
|
||||
@@ -1,129 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <tee_ext_api.h>
|
||||
#include <tee_log.h>
|
||||
#include <securec.h>
|
||||
#include "test_converter_function.h"
|
||||
#include "test_arithmetic_api_base.h"
|
||||
#include "test_basic_arithmetic_operation.h"
|
||||
#include "test_modular_arithmetic_operation.h"
|
||||
#include "test_logical_operation.h"
|
||||
#include "test_other_arithmetic_operation.h"
|
||||
#include "test_fast_modular_multiplication_operation.h"
|
||||
|
||||
#define CA_VENDOR "/vendor/bin/tee_test_arithmetic_api"
|
||||
#define CA_SYSTEM "/system/bin/tee_test_arithmetic_api"
|
||||
#define CA_UID 0
|
||||
|
||||
typedef TEE_Result (* TestArithmeticApiFunc)(void);
|
||||
|
||||
typedef struct {
|
||||
uint32_t cmdId;
|
||||
TestArithmeticApiFunc func;
|
||||
} TestFunctionWithCmd;
|
||||
|
||||
static TestFunctionWithCmd g_CmdList[] = {
|
||||
{CMD_ID_TEST_BIG_INT_COMPUTE_FMM, TestBigIntComputeFMM}, // 0
|
||||
{CMD_ID_TEST_BIG_INT_INIT_FMM_CONTEXT, TestBigIntInitFMMContext},
|
||||
{CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_FMM, TestConverterBigIntAndFMM},
|
||||
{CMD_ID_TEST_BIG_INT_EXP_MOD, TestBigIntExpMod},
|
||||
{CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_OCTET_STRING, TestConverterBetweenBitInAndOctetString},
|
||||
{CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_S32, TestConverterBetweenBitInAndS32}, // 5
|
||||
{CMD_ID_TEST_BIG_INT_ADD_AND_SUB_MOD, TestBigIntAddAndSubMod},
|
||||
{CMD_ID_TEST_BIG_INT_MUL_AND_INV_MOD, TestBigIntMulAndInvMod},
|
||||
{CMD_ID_TEST_BIG_INT_MOD, TestBigIntMod},
|
||||
{CMD_ID_TEST_BIG_INT_ADD_AND_SUB, TestBigIntAddAndSub},
|
||||
{CMD_ID_TEST_BIG_INT_NEG, TestBigIntNeg}, // 10
|
||||
{CMD_ID_TEST_BIG_INT_MUL_AND_SQUARE, TestBigIntMulAndSquare},
|
||||
{CMD_ID_TEST_BIG_INT_DIV, TestBigIntDiv},
|
||||
{CMD_ID_TEST_BIG_INT_SHIFT_RIGHT, TestBigIntShiftRight},
|
||||
{CMD_ID_TEST_BIG_INT_GET_BIT, TestBigIntGetBit},
|
||||
{CMD_ID_TEST_BIG_INT_GET_BIT_COUNT, TestBigIntGetBitCount}, // 15
|
||||
{CMD_ID_TEST_BIG_INT_SET_BIT, TestBigIntSetBit},
|
||||
{CMD_ID_TEST_BIG_INT_ASSIGN, TestBigIntAssign},
|
||||
{CMD_ID_TEST_BIG_INT_ABS, TestBigIntAbs},
|
||||
{CMD_ID_TEST_BIG_INT_RELATIVE_PRIME, TestBigIntRelativePrime},
|
||||
{CMD_ID_TEST_BIG_INT_COMPUTE_EXTENTED_GCD, TestBigIntComputeExtentedGcd}, // 20
|
||||
{CMD_ID_TEST_BIG_INT_IS_PROBABLE_PRIME, TestBigIntIsProbablePrime},
|
||||
{CMD_ID_TEST_BIG_INT_CMP, TestBigIntCmp},
|
||||
{CMD_ID_TEST_BIG_INT_CMP_S32, TestBigIntCmpS32},
|
||||
{CMD_ID_TEST_BIG_INT_INIT_FMM, TestBigIntInitFMM},
|
||||
{CMD_ID_TEST_BIG_INT_INIT, TestBigIntInit},
|
||||
};
|
||||
|
||||
static TEE_Result TestArithmeticApi(uint32_t cmdId)
|
||||
{
|
||||
uint32_t count = sizeof(g_CmdList) / sizeof(g_CmdList[0]);
|
||||
tlogi("[TestArithmeticApi]: g_CmdList count = %d, cmdId = %d\n", count, cmdId);
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
if (g_CmdList[i].cmdId == cmdId) {
|
||||
return g_CmdList[i].func();
|
||||
}
|
||||
}
|
||||
|
||||
tlogi("unknown command id, cmdId: %u\n", cmdId);
|
||||
return TEE_ERROR_INVALID_CMD;
|
||||
}
|
||||
|
||||
|
||||
TEE_Result TA_CreateEntryPoint(void)
|
||||
{
|
||||
tlogi("---- TA_CreateEntryPoint ---------");
|
||||
TEE_Result ret = AddCaller_CA_exec(CA_VENDOR, CA_UID);
|
||||
if (ret != TEE_SUCCESS) {
|
||||
tloge("Arithmetic TA Add caller failed, ret = 0x%x", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = AddCaller_CA_exec(CA_SYSTEM, CA_UID);
|
||||
if (ret != TEE_SUCCESS) {
|
||||
tloge("Arithmetic TA Add caller failed, ret = 0x%x", ret);
|
||||
return ret;
|
||||
}
|
||||
return TEE_SUCCESS;
|
||||
}
|
||||
|
||||
TEE_Result TA_OpenSessionEntryPoint(uint32_t parmType, TEE_Param params[4], void **sessionContext)
|
||||
{
|
||||
(void)parmType;
|
||||
(void)params;
|
||||
(void)sessionContext;
|
||||
tlogi("---- TA_OpenSessionEntryPoint --------");
|
||||
|
||||
return TEE_SUCCESS;
|
||||
}
|
||||
|
||||
TEE_Result TA_InvokeCommandEntryPoint(void *sessionContext, uint32_t cmdId, uint32_t parmType, TEE_Param params[4])
|
||||
{
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
(void)sessionContext;
|
||||
(void)params;
|
||||
(void)parmType;
|
||||
|
||||
ret = TestArithmeticApi(cmdId);
|
||||
if (ret != TEE_SUCCESS)
|
||||
tloge("Arithmetic TA invoke command for value failed! cmdId: %u, ret: 0x%x", cmdId, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void TA_CloseSessionEntryPoint(void *sessionContext)
|
||||
{
|
||||
(void)sessionContext;
|
||||
tlogi("------ TA_CloseSessionEntryPoint -----");
|
||||
}
|
||||
|
||||
void TA_DestroyEntryPoint(void)
|
||||
{
|
||||
tlogi("------ TA_DestroyEntryPoint ----");
|
||||
}
|
||||
@@ -1,250 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain g_longVal1 copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <tee_ext_api.h>
|
||||
#include <tee_log.h>
|
||||
#include <securec.h>
|
||||
#include <tee_arith_api.h>
|
||||
#include <tee_mem_mgmt_api.h>
|
||||
#include "test_arithmetic_api_base.h"
|
||||
|
||||
static uint8_t g_longVal1[] = {
|
||||
0x6A, 0xA2, 0xC3, 0xD4, 0x94, 0xFD, 0xB7, 0xE2, 0xF0, 0xFC, 0x91, 0x72, 0xC1, 0x50, 0x2A, 0x2C,
|
||||
0x9A, 0xA3, 0x71, 0xF0, 0x92, 0xC0, 0xA3, 0xC9, 0x00, 0xC3, 0x51, 0xC8, 0x9D, 0x7B, 0x06, 0x7C,
|
||||
0x94, 0x4F, 0x30, 0x49, 0x92, 0x5D, 0xB4, 0x27, 0xBA, 0x58, 0x1D, 0xFC, 0xF5, 0x83, 0xAA, 0xDD,
|
||||
0x54, 0x02, 0x64, 0x22, 0x6A, 0x4E, 0xD0, 0x77, 0xA6, 0xE8, 0xEB, 0x39, 0x13, 0xE3, 0x42, 0x6B,
|
||||
0xDF, 0x75, 0x08, 0xAC, 0xE9, 0xB0, 0xAE, 0x61, 0x31, 0x90, 0xDD, 0x02, 0x77, 0xF1, 0x88, 0x89,
|
||||
0x79, 0x90, 0x6C, 0xD8, 0x5A, 0x8B, 0x1A, 0x5B, 0x13, 0xE9, 0x80, 0xC0, 0x50, 0xDA, 0x8F, 0x71,
|
||||
0x8F, 0x64, 0x44, 0xFA, 0xDB, 0xDC, 0x1F, 0x95, 0x2E, 0x88, 0x73, 0x3F, 0x75, 0x8D, 0x71, 0x6B,
|
||||
0x8F, 0xF6, 0x7E, 0x57, 0xC3, 0x6B, 0x9B, 0xD3, 0xCA, 0x01, 0x25, 0xFC, 0x0C, 0xD2, 0xFB, 0x4F,
|
||||
0x93, 0x05, 0xA0, 0x6B, 0xFA, 0x2F, 0xA2, 0x51, 0x35, 0xEF, 0x13, 0xBD, 0x81, 0x7A, 0x88, 0x07,
|
||||
0x7C, 0xA2, 0xB8, 0x0F, 0xD1, 0xC2, 0xF6, 0x9A, 0x66, 0x77, 0xA4, 0x5F, 0xE8, 0x6A, 0x5B, 0x1B,
|
||||
0x93, 0x05, 0x7C, 0x4F, 0xD5, 0xDA, 0x66, 0xA8, 0x52, 0x80, 0x5B, 0xB3, 0xB6, 0x27, 0xEC, 0x1B,
|
||||
0x35, 0xD2, 0x7C, 0x67, 0x2A, 0x33, 0xD0, 0xDF, 0x83, 0x74, 0x11, 0xF5, 0xFF, 0xE4, 0x21, 0x8E,
|
||||
0x3D, 0x6E, 0x4F, 0x43, 0x4F, 0x86, 0x55, 0x32, 0x27, 0x99, 0x94, 0x6E, 0x70, 0xA4, 0x51, 0x5E,
|
||||
0xD9, 0x2D, 0x5C, 0x91, 0x0E, 0x2F, 0x5F, 0xF7, 0x16, 0xBA, 0x71, 0xBD, 0x95, 0x5D, 0x89, 0xF5,
|
||||
0x01, 0x7F, 0x00, 0xEB, 0x30, 0x81, 0x22, 0x23, 0xCE, 0x21, 0x69, 0xAB, 0x16, 0xBC, 0x25, 0x98,
|
||||
0x8E, 0x52, 0x32, 0x06, 0xC0, 0x22, 0xAD, 0xEA, 0x49, 0xF9, 0xCA, 0xE0, 0x73, 0x71, 0x02, 0xA5,
|
||||
};
|
||||
|
||||
static uint8_t g_longVal2[] = {
|
||||
0x71, 0x1A, 0x84, 0x69, 0x8E, 0x93, 0x53, 0x79, 0x90, 0x63, 0x80, 0x40, 0x05, 0x95, 0xEC, 0x2F,
|
||||
0xFC, 0x6E, 0x7D, 0xD4, 0x10, 0xF7, 0x68, 0x1B, 0x1A, 0xB7, 0x3D, 0x83, 0x38, 0x3E, 0x84, 0xB8,
|
||||
0x9C, 0x4A, 0x6F, 0x04, 0xB3, 0x4D, 0x3E, 0x9D, 0x57, 0xF5, 0xE6, 0x42, 0x43, 0xEA, 0x9E, 0x5D,
|
||||
0x65, 0xAF, 0x59, 0x63, 0xC4, 0xAE, 0xD6, 0xAA, 0x9F, 0x9D, 0x7B, 0x5A, 0x75, 0xB0, 0x21, 0xAE,
|
||||
0x99, 0xA6, 0xCE, 0x40, 0x39, 0x14, 0xEA, 0x43, 0x3B, 0x08, 0xB9, 0x7D, 0xCB, 0x95, 0x3C, 0x32,
|
||||
0xA4, 0x99, 0xE9, 0x3E, 0xDF, 0xC2, 0x27, 0x9F, 0x53, 0xAA, 0xB5, 0xB7, 0x99, 0xA3, 0xB5, 0xF5,
|
||||
0xA7, 0x02, 0x31, 0x20, 0x71, 0x0D, 0x73, 0x4F, 0xA3, 0x5E, 0x44, 0x94, 0x7F, 0x08, 0x4D, 0x13,
|
||||
0x58, 0xED, 0x03, 0x69, 0xFB, 0xBE, 0x5D, 0xE5, 0x23, 0xA4, 0x0D, 0xFC, 0x05, 0xB3, 0xA1, 0x23,
|
||||
0x18, 0x58, 0x1D, 0x03, 0xE9, 0xDE, 0xEC, 0x13, 0x8C, 0x44, 0x35, 0x50, 0x6F, 0x5D, 0x8E, 0xA5,
|
||||
0xF3, 0xB1, 0xF7, 0x76, 0x07, 0x4E, 0xC7, 0x49, 0x85, 0x13, 0xA1, 0xD8, 0x3C, 0xAF, 0x77, 0x2D,
|
||||
0xC7, 0x9E, 0x8E, 0x8F, 0x16, 0xA8, 0x9E, 0x72, 0x7A, 0xC8, 0xF3, 0x39, 0x81, 0x66, 0xCC, 0xB4,
|
||||
0x07, 0x02, 0xE1, 0x1E, 0x11, 0xA1, 0x37, 0x22, 0x8F, 0xA5, 0xF3, 0x12, 0xBE, 0x79, 0xFC, 0x20,
|
||||
0x71, 0x26, 0x3D, 0x6B, 0x87, 0xC1, 0xCF, 0x1D, 0x62, 0xCB, 0xD8, 0x96, 0x0E, 0x11, 0xB5, 0x08,
|
||||
0x37, 0x64, 0xBF, 0xB3, 0xF2, 0x62, 0xAC, 0x46, 0xC2, 0x01, 0xE1, 0xE0, 0x7E, 0xFB, 0x6A, 0x8D,
|
||||
0x85, 0x26, 0xD0, 0x1C, 0x3D, 0x59, 0x31, 0xF1, 0x3B, 0x91, 0xA8, 0x13, 0xBA, 0x58, 0x04, 0xE6,
|
||||
0x20, 0xAA, 0xE9, 0x31, 0x21, 0xFF, 0x16, 0xBC, 0x3C, 0xCD, 0xC4, 0x52, 0x0E, 0x82, 0x1D, 0xB7,
|
||||
};
|
||||
|
||||
static uint8_t g_checkAddVal[] = {
|
||||
0xDB, 0xBD, 0x48, 0x3E, 0x23, 0x91, 0x0B, 0x5C, 0x81, 0x60, 0x11, 0xB2, 0xC6, 0xE6, 0x16, 0x5C,
|
||||
0x97, 0x11, 0xEF, 0xC4, 0xA3, 0xB8, 0x0B, 0xE4, 0x1B, 0x7A, 0x8F, 0x4B, 0xD5, 0xB9, 0x8B, 0x35,
|
||||
0x30, 0x99, 0x9F, 0x4E, 0x45, 0xAA, 0xF2, 0xC5, 0x12, 0x4E, 0x04, 0x3F, 0x39, 0x6E, 0x49, 0x3A,
|
||||
0xB9, 0xB1, 0xBD, 0x86, 0x2E, 0xFD, 0xA7, 0x22, 0x46, 0x86, 0x66, 0x93, 0x89, 0x93, 0x64, 0x1A,
|
||||
0x79, 0x1B, 0xD6, 0xED, 0x22, 0xC5, 0x98, 0xA4, 0x6C, 0x99, 0x96, 0x80, 0x43, 0x86, 0xC4, 0xBC,
|
||||
0x1E, 0x2A, 0x56, 0x17, 0x3A, 0x4D, 0x41, 0xFA, 0x67, 0x94, 0x36, 0x77, 0xEA, 0x7E, 0x45, 0x67,
|
||||
0x36, 0x66, 0x76, 0x1B, 0x4C, 0xE9, 0x92, 0xE4, 0xD1, 0xE6, 0xB7, 0xD3, 0xF4, 0x95, 0xBE, 0x7E,
|
||||
0xE8, 0xE3, 0x81, 0xC1, 0xBF, 0x29, 0xF9, 0xB8, 0xED, 0xA5, 0x33, 0xF8, 0x12, 0x86, 0x9C, 0x72,
|
||||
0xAB, 0x5D, 0xBD, 0x6F, 0xE4, 0x0E, 0x8E, 0x64, 0xC2, 0x33, 0x49, 0x0D, 0xF0, 0xD8, 0x16, 0xAD,
|
||||
0x70, 0x54, 0xAF, 0x85, 0xD9, 0x11, 0xBD, 0xE3, 0xEB, 0x8B, 0x46, 0x38, 0x25, 0x19, 0xD2, 0x49,
|
||||
0x5A, 0xA4, 0x0A, 0xDE, 0xEC, 0x83, 0x05, 0x1A, 0xCD, 0x49, 0x4E, 0xED, 0x37, 0x8E, 0xB8, 0xCF,
|
||||
0x3C, 0xD5, 0x5D, 0x85, 0x3B, 0xD5, 0x08, 0x02, 0x13, 0x1A, 0x05, 0x08, 0xBE, 0x5E, 0x1D, 0xAE,
|
||||
0xAE, 0x94, 0x8C, 0xAE, 0xD7, 0x48, 0x24, 0x4F, 0x8A, 0x65, 0x6D, 0x04, 0x7E, 0xB6, 0x06, 0x67,
|
||||
0x10, 0x92, 0x1C, 0x45, 0x00, 0x92, 0x0C, 0x3D, 0xD8, 0xBC, 0x53, 0x9E, 0x14, 0x58, 0xF4, 0x82,
|
||||
0x86, 0xA5, 0xD1, 0x07, 0x6D, 0xDA, 0x54, 0x15, 0x09, 0xB3, 0x11, 0xBE, 0xD1, 0x14, 0x2A, 0x7E,
|
||||
0xAE, 0xFD, 0x1B, 0x37, 0xE2, 0x21, 0xC4, 0xA6, 0x86, 0xC7, 0x8F, 0x32, 0x81, 0xF3, 0x20, 0x5C,
|
||||
};
|
||||
|
||||
static uint8_t g_shortVal1[] = {
|
||||
0x60, 0x13, 0x16, 0xE1, 0xFB, 0xFF, 0x59, 0xF9, 0xC6, 0x15, 0x45, 0xCA, 0x9C, 0xE2, 0x10, 0xA1,
|
||||
0xC1, 0xE6, 0xC1, 0xFB, 0x4A, 0xA3, 0x14, 0xCD, 0x76, 0xDE, 0x45, 0xB7, 0x99, 0xB5, 0x56, 0x9B,
|
||||
0xCC, 0x39, 0xA4, 0x09, 0x09, 0x16, 0x51, 0xB7, 0x74, 0x9C, 0xCE, 0x11, 0x36, 0xFE, 0x37, 0xAC,
|
||||
0xF1, 0x02, 0xC4, 0x5B, 0x8E, 0x7A, 0x81, 0x6E, 0x36, 0x85, 0x9B, 0x68, 0x73, 0x85, 0x96, 0xD8,
|
||||
0x74, 0x9C, 0xEA, 0x11, 0x53, 0xDF, 0xB4, 0x59, 0xAF, 0x90, 0x71, 0x32, 0x4A, 0x16, 0xF3, 0x7B,
|
||||
0x45, 0x3B, 0xF7, 0x53, 0x3B, 0x72, 0x1D, 0xA5, 0xB9, 0xB9, 0x89, 0x63, 0x7E, 0x44, 0x5A, 0xB1,
|
||||
0x1A, 0x42, 0x28, 0x0E, 0x85, 0xB1, 0x44, 0x86, 0xB0, 0x94, 0x0E, 0x4A, 0xCE, 0xF6, 0x5A, 0xB8,
|
||||
0x4D, 0xAA, 0x49, 0xE4, 0x92, 0xF4, 0x0C, 0x92, 0xCF, 0x7C, 0x4D, 0xE0, 0xF6, 0xDA, 0x7A, 0xCF
|
||||
};
|
||||
|
||||
static uint8_t g_shortVal2[] = {
|
||||
0x46, 0x6B, 0xA2, 0xBA, 0xA0, 0xE2, 0x03, 0x91, 0x67, 0xF8, 0x7C, 0x69, 0x04, 0x9B, 0x23, 0xF3,
|
||||
0xAE, 0x2A, 0x06, 0x2D, 0x5F, 0x2B, 0x76, 0x19, 0xCC, 0x19, 0xDD, 0xCB, 0x57, 0x63, 0x58, 0x2A,
|
||||
0xE7, 0xB9, 0x42, 0xB0, 0x33, 0x33, 0xA6, 0x17, 0x0B, 0xE4, 0x4B, 0xC3, 0x70, 0x7C, 0x74, 0xFF,
|
||||
0x11, 0xEA, 0xDE, 0x5A, 0x5B, 0xD1, 0x2C, 0xBD, 0x48, 0x8E, 0x85, 0xBB, 0x54, 0xEC, 0xBC, 0x6E,
|
||||
0x73, 0x25, 0xF2, 0x58, 0xE3, 0x05, 0x49, 0x31, 0x3E, 0x95, 0xF4, 0x85, 0xAE, 0xD4, 0xB4, 0x51,
|
||||
0xA7, 0xD3, 0xC1, 0x4E, 0x1A, 0xAF, 0x83, 0xEE, 0xC1, 0x35, 0xF8, 0x74, 0xF5, 0x33, 0x0C, 0x2E,
|
||||
0x32, 0xD2, 0x5A, 0x8E, 0x4A, 0x78, 0x07, 0xD9, 0x53, 0x65, 0x7D, 0xCA, 0x9A, 0xEB, 0xBB, 0x94,
|
||||
0x78, 0xC2, 0x2B, 0x8F, 0xF8, 0x03, 0x37, 0x44, 0x1A, 0x58, 0xE2, 0xE0, 0xA8, 0xD6, 0xEE, 0x8D
|
||||
};
|
||||
|
||||
static uint8_t g_shortVal3[] = {
|
||||
0x22, 0x4A, 0x5A, 0xD4, 0x82, 0x4E, 0xB4, 0x91, 0xEC, 0xF2, 0xC7, 0xD6, 0x3F, 0xA0, 0x7D, 0x86,
|
||||
0x42, 0xFB, 0x22, 0xFD, 0xEE, 0x1F, 0xC8, 0xCC, 0x3F, 0x75, 0x79, 0x3A, 0x96, 0x1D, 0x07, 0x53,
|
||||
0xF9, 0xD9, 0x63, 0xEE, 0x4A, 0xD9, 0xEF, 0xF8, 0x5B, 0x58, 0x4B, 0xCE, 0xD9, 0xB6, 0xE3, 0xB6,
|
||||
0x31, 0xCD, 0x18, 0x61, 0x3F, 0x48, 0x9A, 0xF2, 0x5D, 0x09, 0x0D, 0x30, 0x3F, 0xDF, 0xAF, 0x51,
|
||||
0xAE, 0xE5, 0x13, 0xAC, 0xC6, 0xC5, 0x3D, 0x73, 0xDF, 0xFF, 0x16, 0x4F, 0x2D, 0xF0, 0x98, 0x92,
|
||||
0xB0, 0x2B, 0x14, 0x1D, 0x60, 0xB1, 0xF6, 0x60, 0x6B, 0x13, 0x69, 0xE5, 0xD0, 0x01, 0xFA, 0x2D,
|
||||
0xA0, 0xC8, 0x0A, 0x21, 0x27, 0xD6, 0x89, 0x31, 0x99, 0x2C, 0x2C, 0x36, 0x6B, 0x17, 0x04, 0xFF,
|
||||
0xE8, 0x8A, 0xB8, 0xE0, 0x38, 0x70, 0x85, 0xF9, 0x87, 0xF8, 0x4A, 0xE7, 0x3B, 0xA9, 0x3C, 0x0A
|
||||
};
|
||||
|
||||
static uint8_t g_checkMulVal[] = {
|
||||
0x1a, 0x6D, 0x9D, 0x4E, 0x7A, 0x16, 0x88, 0x7B, 0xD2, 0x20, 0xA5, 0xCD, 0xF8, 0x26, 0x98, 0x73,
|
||||
0x10, 0x8C, 0x8D, 0x58, 0xFC, 0xFD, 0x9B, 0x22, 0x88, 0xF2, 0x96, 0xBB, 0xC8, 0x43, 0x6A, 0x90,
|
||||
0xE1, 0x72, 0xAE, 0x99, 0x27, 0xEC, 0x03, 0x2F, 0x99, 0x0D, 0x26, 0xF6, 0x33, 0xD1, 0x62, 0xD6,
|
||||
0x27, 0x33, 0x04, 0x61, 0x48, 0xF2, 0x30, 0x18, 0x56, 0x81, 0x5D, 0x35, 0x26, 0x0D, 0x1C, 0x0D,
|
||||
0x29, 0xE9, 0x8B, 0xC5, 0x6F, 0x71, 0xF3, 0x35, 0xB9, 0x7E, 0xA0, 0x00, 0xEE, 0x66, 0x16, 0x1C,
|
||||
0x41, 0x18, 0x02, 0x29, 0xE8, 0x07, 0x88, 0xBE, 0x5B, 0x06, 0x10, 0xAC, 0x74, 0x30, 0x30, 0xA2,
|
||||
0x00, 0xE5, 0x66, 0x90, 0xD7, 0xDB, 0xB3, 0x64, 0xF3, 0x8A, 0x04, 0x14, 0x67, 0x1A, 0x99, 0x1B,
|
||||
0x5C, 0x8C, 0x9C, 0x50, 0x18, 0x1E, 0x99, 0x7A, 0x1A, 0xAC, 0x43, 0x6A, 0x77, 0x54, 0x83, 0x88,
|
||||
0x0F, 0xDF, 0xC0, 0xE3, 0x53, 0xEB, 0x2F, 0xE5, 0x0D, 0x0D, 0x5C, 0x2E, 0xB9, 0xA6, 0xD0, 0x59,
|
||||
0xEC, 0x69, 0xE6, 0x38, 0x42, 0xB3, 0xFD, 0xA7, 0xF0, 0xD0, 0xD6, 0xC3, 0x03, 0xA5, 0x6F, 0x50,
|
||||
0x35, 0x5A, 0xAB, 0xAE, 0x01, 0xE8, 0x1D, 0xCF, 0x4B, 0x4B, 0x12, 0x17, 0x11, 0xD7, 0xD8, 0x8A,
|
||||
0x99, 0x99, 0xA3, 0x09, 0x47, 0x99, 0x0B, 0x02, 0x47, 0x32, 0xBE, 0xDB, 0x79, 0x7E, 0x40, 0xE9,
|
||||
0xE2, 0x26, 0x3D, 0xA7, 0x33, 0xB0, 0x04, 0xD4, 0x28, 0x9A, 0xB6, 0x42, 0x39, 0x21, 0x35, 0xA1,
|
||||
0x19, 0x28, 0x76, 0x0C, 0x7E, 0xC8, 0xC5, 0x28, 0x13, 0x01, 0x16, 0x7B, 0xD5, 0x88, 0x37, 0xA2,
|
||||
0x31, 0x1B, 0x9B, 0x05, 0x42, 0x05, 0x7A, 0xE4, 0xF5, 0xF6, 0x9A, 0xFE, 0x5C, 0xCA, 0x70, 0xDE,
|
||||
0x7B, 0x3E, 0xB0, 0xFF, 0x11, 0xC2, 0x51, 0x1A, 0xB0, 0xA9, 0xF8, 0xC1, 0x95, 0x8C, 0x16, 0x03
|
||||
};
|
||||
|
||||
TEE_Result TestBigIntAddAndSub()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
TEE_BigInt *op1 = CreateBigInt(sizeof(g_longVal1), g_longVal1);
|
||||
TEE_BigInt *op2 = CreateBigInt(sizeof(g_longVal2), g_longVal2);
|
||||
|
||||
TEE_BigInt *addDest = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigInt *addCheck = CreateBigInt(sizeof(g_checkAddVal), g_checkAddVal);
|
||||
TEE_BigIntAdd(addDest, op1, op2);
|
||||
if (TEE_BigIntCmp(addDest, addCheck) != 0) {
|
||||
tloge("BigIntAdd failed.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
goto CLEANUP;
|
||||
}
|
||||
|
||||
TEE_BigInt *subDest = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigIntSub(subDest, addDest, op1);
|
||||
if (TEE_BigIntCmp(subDest, op2) != 0) {
|
||||
tloge("BigIntSubMod failed.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
TEE_Free(subDest);
|
||||
|
||||
CLEANUP:
|
||||
TEE_Free(op1);
|
||||
TEE_Free(op2);
|
||||
TEE_Free(addCheck);
|
||||
TEE_Free(addDest);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntNeg()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
TEE_BigInt *op1 = CreateBigInt(sizeof(g_longVal1), g_longVal1);
|
||||
TEE_BigInt *negDest = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigInt *addForNegCheck = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigIntNeg(negDest, op1);
|
||||
TEE_BigIntAdd(addForNegCheck, negDest, op1);
|
||||
if (TEE_BigIntCmpS32(addForNegCheck, 0) != 0) {
|
||||
tloge("BigIntNeg failed.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
TEE_Free(op1);
|
||||
TEE_Free(negDest);
|
||||
TEE_Free(addForNegCheck);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntMulAndSquare()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
TEE_BigInt *op1 = CreateBigInt(sizeof(g_shortVal1), g_shortVal1);
|
||||
TEE_BigInt *op2 = CreateBigInt(sizeof(g_shortVal2), g_shortVal2);
|
||||
|
||||
TEE_BigInt *mulDest = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigInt *mulCheck = CreateBigInt(sizeof(g_checkMulVal), g_checkMulVal);
|
||||
TEE_BigIntMul(mulDest, op1, op2);
|
||||
if (TEE_BigIntCmp(mulDest, mulCheck) != 0) {
|
||||
tloge("BigIntMul failed.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
goto CLEANUP;
|
||||
}
|
||||
|
||||
TEE_BigInt *squareDest = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigInt *mulForsquareCheck = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigIntSquare(squareDest, op1);
|
||||
TEE_BigIntMul(mulForsquareCheck, op1, op1);
|
||||
if (TEE_BigIntCmp(squareDest, mulForsquareCheck) != 0) {
|
||||
tloge("BigIntSquare failed.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
TEE_Free(squareDest);
|
||||
TEE_Free(mulForsquareCheck);
|
||||
|
||||
CLEANUP:
|
||||
TEE_Free(op1);
|
||||
TEE_Free(op2);
|
||||
TEE_Free(mulDest);
|
||||
TEE_Free(mulCheck);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntDiv()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
TEE_BigInt *op1 = CreateBigInt(sizeof(g_shortVal1), g_shortVal1);
|
||||
TEE_BigInt *op2 = CreateBigInt(sizeof(g_shortVal2), g_shortVal2);
|
||||
TEE_BigInt *op3 = CreateBigInt(sizeof(g_shortVal3), g_shortVal3);
|
||||
|
||||
TEE_BigInt *mulDest = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigInt *dividend = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigInt *destR = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigInt *destQ = CreateBigInt(RESULT_SIZE, 0);
|
||||
|
||||
TEE_BigIntMul(mulDest, op1, op2);
|
||||
TEE_BigIntAdd(dividend, mulDest, op3); // dividend = (op1*op2) + op3
|
||||
TEE_BigIntDiv(destQ, destR, dividend, op1);
|
||||
|
||||
if (TEE_BigIntCmp(destQ, op2) != 0 || TEE_BigIntCmp(destR, op3) != 0) {
|
||||
tloge("TEE_BigIntDiv failed.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
TEE_Free(op1);
|
||||
TEE_Free(op2);
|
||||
TEE_Free(op3);
|
||||
TEE_Free(mulDest);
|
||||
TEE_Free(dividend);
|
||||
TEE_Free(destR);
|
||||
TEE_Free(destQ);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef __TEST_BASIC_ARITHMETIC_OPERATION_H__
|
||||
#define __TEST_BASIC_ARITHMETIC_OPERATION_H__
|
||||
|
||||
#include <tee_ext_api.h>
|
||||
|
||||
TEE_Result TestBigIntAddAndSub();
|
||||
TEE_Result TestBigIntNeg();
|
||||
TEE_Result TestBigIntMulAndSquare();
|
||||
TEE_Result TestBigIntDiv();
|
||||
|
||||
#endif
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <tee_ext_api.h>
|
||||
#include <tee_log.h>
|
||||
#include <securec.h>
|
||||
#include <tee_arith_api.h>
|
||||
#include <tee_mem_mgmt_api.h>
|
||||
#include "test_arithmetic_api_base.h"
|
||||
|
||||
TEE_Result TestConverterBetweenBitInAndOctetString()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_BigInt *bigInt = AllocateAndInitialize(SIZE_256);
|
||||
if (bigInt == NULL) {
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
const uint8_t string[] = "tempString";
|
||||
TEE_Result ret = TEE_BigIntConvertFromOctetString((TEE_BigInt *)bigInt, string, sizeof(string), -1);
|
||||
if (ret != TEE_SUCCESS) {
|
||||
tloge("BigIntConvertFromOctetString failed, ret = 0x%x", ret);
|
||||
goto CLEANUP;
|
||||
}
|
||||
|
||||
uint8_t buffer[SIZE_256] = {0};
|
||||
size_t bufferLen = sizeof(buffer);
|
||||
ret = TEE_BigIntConvertToOctetString(buffer, &bufferLen, bigInt);
|
||||
if (ret != TEE_SUCCESS) {
|
||||
tloge("BigIntConvertToOctetString failed, ret = 0x%x", ret);
|
||||
goto CLEANUP;
|
||||
}
|
||||
if (strcmp((const char *)buffer, (const char *)string) != 0) {
|
||||
tloge("convert failed. string is %s; buffer is %s;", string, buffer);
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
tlogi("after convert buffer is %s", buffer);
|
||||
|
||||
CLEANUP:
|
||||
TEE_Free(bigInt);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
TEE_Result TestConverterBetweenBitInAndS32()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_BigInt *bigInt = AllocateAndInitialize(SIZE_256);
|
||||
if (bigInt == NULL) {
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
const int32_t shortVal = 1234;
|
||||
TEE_BigIntConvertFromS32(bigInt, shortVal);
|
||||
|
||||
int32_t value;
|
||||
TEE_Result ret = TEE_BigIntConvertToS32(&value, bigInt);
|
||||
if (ret != TEE_SUCCESS) {
|
||||
tloge("BigIntConvertToS32 failed, ret = 0x%x", ret);
|
||||
goto CLEANUP;
|
||||
}
|
||||
if (value != shortVal) {
|
||||
tloge("convert failed. value is %d; shortVal is %d", value, shortVal);
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
tlogi("after convert value is %d", value);
|
||||
|
||||
CLEANUP:
|
||||
TEE_Free(bigInt);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef __TEST_CONVERTER_FUNCTION_H__
|
||||
#define __TEST_CONVERTER_FUNCTION_H__
|
||||
|
||||
#include <tee_ext_api.h>
|
||||
|
||||
TEE_Result TestConverterBetweenBitInAndOctetString();
|
||||
TEE_Result TestConverterBetweenBitInAndS32();
|
||||
|
||||
#endif
|
||||
@@ -1,209 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain longVal1 copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <tee_ext_api.h>
|
||||
#include <tee_log.h>
|
||||
#include <securec.h>
|
||||
#include <tee_arith_api.h>
|
||||
#include <tee_mem_mgmt_api.h>
|
||||
#include "test_arithmetic_api_base.h"
|
||||
|
||||
static uint8_t g_modValue[] = {
|
||||
0x40, 0x84, 0xB4, 0xAF, 0xF9, 0x13, 0xE0, 0x2B, 0xFF, 0x2D, 0x30, 0x21, 0x7C, 0x94, 0xD2, 0x8F,
|
||||
0x89, 0x47, 0x9F, 0x7E, 0x14, 0xC1, 0xB4, 0xD7, 0x64, 0x97, 0x33, 0x65, 0x26, 0x62, 0x86, 0xED
|
||||
};
|
||||
static uint8_t g_bigIntValue[] = {
|
||||
0x1C, 0xE1, 0x0C, 0xAE, 0x61, 0xBE, 0xE9, 0xD5, 0x5D, 0xB0, 0xC0, 0x93, 0x5F, 0x78, 0x8C, 0x3C,
|
||||
0xA1, 0x44, 0x3B, 0x6F, 0x08, 0xC6, 0x6A, 0x7E, 0x87, 0x32, 0xE9, 0x37, 0xB5, 0xE6, 0x87, 0x6E,
|
||||
};
|
||||
|
||||
static TEE_BigIntFMM* AllocateAndInitializeFMM(uint32_t modulusSizeInBits)
|
||||
{
|
||||
uint32_t length = TEE_BigIntFMMSizeInU32(modulusSizeInBits);
|
||||
TEE_BigIntFMM *bigIntFMM = (TEE_BigIntFMM *)TEE_Malloc(length * sizeof(TEE_BigIntFMM), 0);
|
||||
if (bigIntFMM == NULL) {
|
||||
tloge("AllocateAndInitializeFMM : TEE_Malloc returned NULL.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TEE_BigIntInitFMM(bigIntFMM, length);
|
||||
return bigIntFMM;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntInitFMM()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
uint32_t length = TEE_BigIntFMMSizeInU32(SIZE_256);
|
||||
const uint32_t checkLength = 10;
|
||||
if (length != checkLength) {
|
||||
tloge("BigIntFMMSizeInU32 fail. length = %d", length);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
TEE_BigIntFMM *bigIntFMM = (TEE_BigIntFMM *)TEE_Malloc(length * sizeof(TEE_BigIntFMM), 0);
|
||||
if (bigIntFMM == NULL) {
|
||||
tloge("AllocateAndInitializeFMM : TEE_Malloc returned NULL.");
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
TEE_BigIntInitFMM(bigIntFMM, length);
|
||||
TEE_Free(bigIntFMM);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, TEE_SUCCESS);
|
||||
return TEE_SUCCESS;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntInitFMMContext()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
uint32_t length = TEE_BigIntFMMContextSizeInU32(SIZE_256);
|
||||
const uint32_t checkLength = 10;
|
||||
if (length != checkLength) {
|
||||
tloge("BigIntFMMContextSizeInU32 fail. length = %d", length);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
TEE_BigIntFMMContext *bigIntFMMContext = TEE_Malloc(length * sizeof(TEE_BigIntFMMContext), 0);
|
||||
if (bigIntFMMContext == NULL) {
|
||||
tloge("CmdTEEBigIntInitFMMContext: TEE_Malloc returned NULL.");
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
TEE_BigIntFMMContext *bigIntFMMContext1 = TEE_Malloc(length * sizeof(TEE_BigIntFMMContext), 0);
|
||||
if (bigIntFMMContext1 == NULL) {
|
||||
tloge("CmdTEEBigIntInitFMMContext: TEE_Malloc returned NULL.");
|
||||
TEE_Free(bigIntFMMContext);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
const uint8_t p1Value[] = {
|
||||
0x40, 0x84, 0xB4, 0xAF, 0xF9, 0x13, 0xE0, 0x2B, 0xFF, 0x2D, 0x30, 0x21, 0x7C, 0x94, 0xD2, 0x8F,
|
||||
0x89, 0x47, 0x9F, 0x7E, 0x14, 0xC1, 0xB4, 0xD7, 0x64, 0x97, 0x33, 0x65, 0x26, 0x62, 0x86, 0xED
|
||||
};
|
||||
TEE_BigInt *bigInt = CreateBigInt(sizeof(p1Value), (uint8_t *)p1Value);
|
||||
TEE_BigIntInitFMMContext(bigIntFMMContext, length, bigInt);
|
||||
|
||||
TEE_Result ret = TEE_BigIntInitFMMContext1(bigIntFMMContext1, length, bigInt);
|
||||
if (ret != TEE_SUCCESS) {
|
||||
tloge("TEE_BigIntInitFMMContext1 test failed. ret = 0x%x", ret);
|
||||
}
|
||||
TEE_Free(bigIntFMMContext);
|
||||
TEE_Free(bigIntFMMContext1);
|
||||
TEE_Free(bigInt);
|
||||
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
TEE_Result TestConverterBigIntAndFMM()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
|
||||
TEE_BigInt *bigInt = CreateBigInt(sizeof(g_bigIntValue), g_bigIntValue);
|
||||
if (bigInt == NULL) {
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
TEE_BigInt *modulus = CreateBigInt(sizeof(g_modValue), g_modValue);
|
||||
if (modulus == NULL) {
|
||||
TEE_Free(bigInt);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
TEE_BigInt *bigIntFMM = AllocateAndInitializeFMM(SIZE_256);
|
||||
if (bigIntFMM == NULL) {
|
||||
TEE_Free(modulus);
|
||||
TEE_Free(bigInt);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
uint32_t length = TEE_BigIntFMMContextSizeInU32(SIZE_256);
|
||||
TEE_BigIntFMMContext *bigIntFMMContext = TEE_Malloc(length * sizeof(TEE_BigIntFMMContext), 0);
|
||||
if (bigIntFMMContext == NULL) {
|
||||
tloge("CmdTEEBigIntInitFMMContext: TEE_Malloc returned NULL.");
|
||||
TEE_Free(bigInt);
|
||||
TEE_Free(modulus);
|
||||
TEE_Free(bigIntFMM);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
TEE_BigIntInitFMMContext(bigIntFMMContext, length, modulus);
|
||||
TEE_BigIntConvertToFMM(bigIntFMM, bigInt, modulus, bigIntFMMContext);
|
||||
|
||||
TEE_BigInt *convertedBigInt = CreateBigInt(RESULT_SIZE, 0);
|
||||
if (convertedBigInt == NULL) {
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
goto CLEAN_UP;
|
||||
}
|
||||
TEE_BigIntConvertFromFMM(convertedBigInt, bigIntFMM, modulus, bigIntFMMContext);
|
||||
int32_t isSame = TEE_BigIntCmp(convertedBigInt, bigInt);
|
||||
if (isSame != 0) {
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
TEE_Free(convertedBigInt);
|
||||
|
||||
CLEAN_UP:
|
||||
TEE_Free(bigIntFMMContext);
|
||||
TEE_Free(bigIntFMM);
|
||||
TEE_Free(bigInt);
|
||||
TEE_Free(modulus);
|
||||
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntComputeFMM()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
TEE_BigInt *bigInt = AllocateAndInitialize(SIZE_256);
|
||||
if (bigInt == NULL)
|
||||
return TEE_ERROR_GENERIC;
|
||||
|
||||
TEE_BigIntFMM *destBigIntFMM = AllocateAndInitializeFMM(SIZE_256);
|
||||
if (destBigIntFMM == NULL) {
|
||||
TEE_Free(bigInt);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
TEE_BigIntFMM *op1BigIntFMM = AllocateAndInitializeFMM(SIZE_256);
|
||||
if (op1BigIntFMM == NULL) {
|
||||
TEE_Free(bigInt);
|
||||
TEE_Free(destBigIntFMM);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
TEE_BigIntFMM *op2BigIntFMM = AllocateAndInitializeFMM(SIZE_256);
|
||||
if (op2BigIntFMM == NULL) {
|
||||
TEE_Free(bigInt);
|
||||
TEE_Free(destBigIntFMM);
|
||||
TEE_Free(op1BigIntFMM);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
uint32_t length = TEE_BigIntFMMContextSizeInU32(SIZE_256);
|
||||
TEE_BigIntFMMContext *bigIntFMMContext = TEE_Malloc(length * sizeof(TEE_BigIntFMMContext), 0);
|
||||
if (bigIntFMMContext == NULL) {
|
||||
tloge("CmdTEEBigIntInitFMMContext: TEE_Malloc returned NULL.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
goto CLEAN_UP;
|
||||
}
|
||||
|
||||
tlogi("after TEE_BigIntFMMContextSizeInU32, length = %u", length);
|
||||
TEE_BigIntComputeFMM(destBigIntFMM, op1BigIntFMM, op2BigIntFMM, bigInt, bigIntFMMContext);
|
||||
TEE_Free(bigIntFMMContext);
|
||||
|
||||
CLEAN_UP:
|
||||
TEE_Free(bigInt);
|
||||
TEE_Free(destBigIntFMM);
|
||||
TEE_Free(op1BigIntFMM);
|
||||
TEE_Free(op2BigIntFMM);
|
||||
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef __TEST_FAST_MODULAR_MULTIPLICATION_OPERATION_H__
|
||||
#define __TEST_FAST_MODULAR_MULTIPLICATION_OPERATION_H__
|
||||
|
||||
#include <tee_ext_api.h>
|
||||
|
||||
TEE_Result TestBigIntInitFMM();
|
||||
TEE_Result TestBigIntInitFMMContext();
|
||||
TEE_Result TestConverterBigIntAndFMM();
|
||||
TEE_Result TestBigIntComputeFMM();
|
||||
|
||||
#endif
|
||||
@@ -1,216 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain longVal1 copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <tee_ext_api.h>
|
||||
#include <tee_log.h>
|
||||
#include <securec.h>
|
||||
#include <tee_arith_api.h>
|
||||
#include <tee_mem_mgmt_api.h>
|
||||
#include "test_arithmetic_api_base.h"
|
||||
|
||||
TEE_Result TestBigIntCmp()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
const uint8_t op1Value[] = {
|
||||
0x6A, 0xA2, 0xC3, 0xD4, 0x94, 0xFD, 0xB7, 0xE2, 0xF0, 0xFC, 0x91, 0x72, 0xC1, 0x50, 0x2A, 0x2C
|
||||
};
|
||||
const uint8_t op2Value[] = {
|
||||
0x35, 0x51, 0x61, 0xEA, 0x4A, 0x7E, 0xDB, 0xF1, 0x78, 0x7E, 0x48, 0xB9, 0x60, 0xA8, 0x15, 0x16
|
||||
};
|
||||
|
||||
TEE_BigInt *op1 = CreateBigInt(sizeof(op1Value), (uint8_t *)op1Value);
|
||||
TEE_BigInt *op2 = CreateBigInt(sizeof(op2Value), (uint8_t *)op2Value);
|
||||
int32_t result = TEE_BigIntCmp(op1, op2);
|
||||
if (result < 0) {
|
||||
tloge("BigIntCmp fail.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
TEE_Free(op1);
|
||||
TEE_Free(op2);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntCmpS32()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
const uint8_t opValue[] = {
|
||||
0x6A, 0xA2, 0xC3, 0xD4, 0x94, 0xFD, 0xB7, 0xE2, 0xF0, 0xFC, 0x91, 0x72, 0xC1, 0x50, 0x2A, 0x2C
|
||||
};
|
||||
|
||||
TEE_BigInt *op = CreateBigInt(sizeof(opValue), (uint8_t *)opValue);
|
||||
int32_t result = TEE_BigIntCmpS32(op, 0);
|
||||
if (result < 0) {
|
||||
tloge("BigIntCmpS32 fail.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
TEE_Free(op);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntShiftRight()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
const uint8_t opValue[] = {
|
||||
0x6A, 0xA2, 0xC3, 0xD4, 0x94, 0xFD, 0xB7, 0xE2, 0xF0, 0xFC, 0x91, 0x72, 0xC1, 0x50, 0x2A, 0x2C
|
||||
};
|
||||
const uint8_t checkValue[] = {
|
||||
0x35, 0x51, 0x61, 0xEA, 0x4A, 0x7E, 0xDB, 0xF1, 0x78, 0x7E, 0x48, 0xB9, 0x60, 0xA8, 0x15, 0x16
|
||||
};
|
||||
TEE_BigInt *dest = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigInt *op = CreateBigInt(sizeof(opValue), (uint8_t *)opValue);
|
||||
TEE_BigInt *check = CreateBigInt(sizeof(checkValue), (uint8_t *)checkValue);
|
||||
TEE_BigIntShiftRight(dest, op, 1);
|
||||
if (TEE_BigIntCmp(dest, check) != 0) {
|
||||
tloge("BigIntShiftRight fail.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
TEE_Free(dest);
|
||||
TEE_Free(op);
|
||||
TEE_Free(check);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntGetBit()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
const uint8_t opValue[] = {0x01, 0x11, 0x01, 0x11};
|
||||
const uint32_t bitIndex = 4;
|
||||
|
||||
TEE_BigInt *src = CreateBigInt(sizeof(opValue), (uint8_t *)opValue);
|
||||
bool bitValue = TEE_BigIntGetBit(src, bitIndex);
|
||||
if (bitValue) { // expect bitValue is 0.
|
||||
tloge("BigIntGetBit failed.");
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
TEE_Free(src);
|
||||
return TEE_SUCCESS;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntGetBitCount()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
const uint8_t opValue[] = {0x01, 0x11, 0x11, 0x10};
|
||||
const uint32_t check = 25;
|
||||
TEE_BigInt *src = CreateBigInt(sizeof(opValue), (uint8_t *)opValue);
|
||||
uint32_t count = TEE_BigIntGetBitCount(src);
|
||||
if (count != check) {
|
||||
tloge("BigIntGetBitCount fail. count = %d.", count);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
TEE_Free(src);
|
||||
return TEE_SUCCESS;
|
||||
}
|
||||
|
||||
#if defined(API_LEVEL) && (API_LEVEL >= API_LEVEL1_2)
|
||||
TEE_Result TestBigIntSetBit()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
const uint8_t opValue[] = {0x01, 0x11, 0x01, 0x11};
|
||||
const uint32_t bitIndex = 4;
|
||||
TEE_BigInt *src = CreateBigInt(sizeof(opValue), (uint8_t *)opValue);
|
||||
|
||||
uint32_t value = TEE_BigIntGetBit(src, bitIndex);
|
||||
value = (value == 1 ? 0 : 1);
|
||||
TEE_Result ret = TEE_BigIntSetBit(src, bitIndex, value); // action return overflow
|
||||
if (ret != TEE_SUCCESS) {
|
||||
tloge("error occurs in set bit operation. ret = 0x%x", ret);
|
||||
TEE_Free(src);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (value != TEE_BigIntGetBit(src, bitIndex)) {
|
||||
tloge("BigIntSetBit test failed.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
TEE_Free(src);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntAssign()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
uint8_t srcValue[] = "srcValue";
|
||||
uint8_t destValue[] = "destValue";
|
||||
TEE_BigInt *src = CreateBigInt(sizeof(srcValue), srcValue);
|
||||
TEE_BigInt *dest = CreateBigInt(sizeof(destValue), destValue);
|
||||
if (TEE_BigIntAssign(dest, src) != TEE_SUCCESS) {
|
||||
tloge("TEE_BigIntAssign test failed.\n");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
goto CLEANUP;
|
||||
}
|
||||
|
||||
if (TEE_BigIntCmp(dest, src) != 0) {
|
||||
tloge("TEE_BigIntAssign test failed after cmp...\n");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
CLEANUP:
|
||||
TEE_Free(src);
|
||||
TEE_Free(dest);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntAbs()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
uint8_t absValue[] = "absValue";
|
||||
int32_t value = -99;
|
||||
int32_t adsValue = 0 - value;
|
||||
TEE_BigInt *src = CreateBigInt(sizeof(absValue), 0);
|
||||
TEE_BigIntConvertFromS32(src, value);
|
||||
|
||||
TEE_BigInt *absDest = CreateBigInt(sizeof(absValue), absValue);
|
||||
TEE_BigIntAbs(absDest, src);
|
||||
if (TEE_BigIntCmpS32(absDest, adsValue) != 0) {
|
||||
tloge("BigIntAbs fail.");
|
||||
TEE_Free(src);
|
||||
TEE_Free(absDest);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
TEE_Free(src);
|
||||
TEE_Free(absDest);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, TEE_SUCCESS);
|
||||
return TEE_SUCCESS;
|
||||
}
|
||||
#else
|
||||
TEE_Result TestBigIntSetBit()
|
||||
{
|
||||
tlogi("API_LEVEL is %d, [%s] is not supported. Return success.", API_LEVEL, __FUNCTION__);
|
||||
return TEE_SUCCESS;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntAssign()
|
||||
{
|
||||
tlogi("API_LEVEL is %d, [%s] is not supported. Return success.", API_LEVEL, __FUNCTION__);
|
||||
return TEE_SUCCESS;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntAbs()
|
||||
{
|
||||
tlogi("API_LEVEL is %d, [%s] is not supported. Return success.", API_LEVEL, __FUNCTION__);
|
||||
return TEE_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef __TEST_LOGICAL_OPERATION_H__
|
||||
#define __TEST_LOGICAL_OPERATION_H__
|
||||
|
||||
#include <tee_ext_api.h>
|
||||
|
||||
TEE_Result TestBigIntCmp();
|
||||
TEE_Result TestBigIntCmpS32();
|
||||
TEE_Result TestBigIntShiftRight();
|
||||
TEE_Result TestBigIntGetBit();
|
||||
TEE_Result TestBigIntGetBitCount();
|
||||
TEE_Result TestBigIntSetBit();
|
||||
TEE_Result TestBigIntAssign();
|
||||
TEE_Result TestBigIntAbs();
|
||||
|
||||
#endif
|
||||
@@ -1,314 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain g_value1 copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <tee_ext_api.h>
|
||||
#include <tee_log.h>
|
||||
#include <securec.h>
|
||||
#include <tee_arith_api.h>
|
||||
#include <tee_mem_mgmt_api.h>
|
||||
#include "test_arithmetic_api_base.h"
|
||||
|
||||
static uint8_t g_value1[] = {
|
||||
0x94, 0x4E, 0xD0, 0x6B, 0x75, 0x9F, 0xE1, 0x83, 0xB8, 0x40, 0xCB, 0x46, 0x5D, 0x7D, 0xAC, 0x35,
|
||||
0x71, 0xF2, 0x0A, 0x49, 0x3E, 0x7F, 0x65, 0x26, 0xB8, 0x6E, 0x5A, 0x59, 0x84, 0x47, 0xC4, 0x2B,
|
||||
0x53, 0xB6, 0x1D, 0xA9, 0x21, 0xC2, 0x5F, 0x0E, 0x8B, 0x1F, 0x8F, 0x15, 0xBF, 0x2D, 0x0D, 0x5D,
|
||||
0x4E, 0x33, 0xB2, 0x29, 0x9C, 0x4E, 0x01, 0xCC, 0x9F, 0x64, 0xD8, 0x56, 0xFB, 0xFD, 0xE7, 0xDC,
|
||||
0x37, 0xB4, 0x3C, 0xD5, 0xA1, 0x35, 0xD0, 0xBC, 0xF7, 0x2F, 0x52, 0x18, 0x5E, 0x11, 0xFD, 0x2B,
|
||||
0xAC, 0x89, 0xC4, 0x43, 0xE1, 0x84, 0x6B, 0xE1, 0x86, 0x53, 0xA4, 0x19, 0x90, 0x5B, 0xA3, 0xA6,
|
||||
0x2A, 0x51, 0xE2, 0x95, 0xFA, 0xF2, 0x54, 0xDA, 0x9B, 0x18, 0x3A, 0x95, 0x68, 0xFD, 0x20, 0xB0,
|
||||
0x6B, 0xEB, 0xD9, 0xD7, 0xD2, 0x76, 0x9E, 0x17, 0xCF, 0xD2, 0x68, 0x83, 0x8C, 0x6F, 0xA1, 0xD1,
|
||||
0x24, 0xF1, 0xB4, 0xC9, 0x86, 0x57, 0x0C, 0xAC, 0x68, 0xC1, 0x6B, 0x65, 0xF2, 0x4F, 0xB7, 0xBB,
|
||||
0xD7, 0xA6, 0xB8, 0xF9, 0x2A, 0x86, 0x16, 0x13, 0xE3, 0x9D, 0x82, 0x9F, 0x58, 0xCE, 0x60, 0x81,
|
||||
0x0C, 0x87, 0x87, 0xAD, 0x6C, 0x9C, 0x92, 0x95, 0x2C, 0x59, 0x87, 0x93, 0xF7, 0xEB, 0xA9, 0x8D,
|
||||
0x38, 0xBF, 0x78, 0xD9, 0x03, 0x4A, 0xA6, 0xFF, 0xA6, 0xF7, 0xE1, 0x01, 0x39, 0xB2, 0x1A, 0xC3,
|
||||
0xC7, 0xAF, 0x02, 0xFE, 0x2E, 0xBE, 0xC4, 0x40, 0x1E, 0xFC, 0x54, 0xC9, 0x32, 0xB7, 0x6F, 0xE8,
|
||||
0x19, 0xA6, 0x5B, 0xC1, 0xE6, 0x95, 0x45, 0xE6, 0x0C, 0x81, 0xA7, 0xC7, 0x76, 0x5F, 0xA9, 0x85,
|
||||
0x23, 0x96, 0x06, 0x30, 0xE4, 0x09, 0x31, 0x58, 0x72, 0xAE, 0x72, 0xEB, 0xEC, 0x88, 0xCA, 0x6A,
|
||||
0xD9, 0xB6, 0x68, 0xBA, 0x4E, 0x92, 0xD6, 0xE5, 0x77, 0x64, 0x5A, 0xE9, 0x4A, 0x65, 0x37, 0x27
|
||||
};
|
||||
|
||||
static uint8_t g_value2[] = {
|
||||
0x52, 0xBD, 0x0E, 0x55, 0xE1, 0xD0, 0x2D, 0xA9, 0x6D, 0x08, 0x1C, 0x74, 0x44, 0x1B, 0x47, 0xEF,
|
||||
0x7B, 0x03, 0x45, 0x2F, 0x4C, 0x17, 0x41, 0x5A, 0x6C, 0x11, 0x02, 0x8E, 0x5D, 0x75, 0x64, 0x9E,
|
||||
0xAE, 0x2C, 0x19, 0x47, 0xD4, 0x7B, 0x1B, 0x95, 0xFD, 0x12, 0x46, 0xFF, 0x93, 0x3D, 0x3D, 0xDA,
|
||||
0xD2, 0xE6, 0xFB, 0x1A, 0x23, 0x72, 0x0B, 0xAD, 0xD1, 0x0A, 0x85, 0xE2, 0xD1, 0x29, 0x57, 0x9F,
|
||||
0xB7, 0xA5, 0x0B, 0x9F, 0xF4, 0x41, 0x81, 0xD6, 0xEC, 0xFE, 0xB0, 0xAE, 0x91, 0x22, 0x5D, 0xEB,
|
||||
0xF3, 0xAE, 0xC8, 0x4D, 0x71, 0xD4, 0xC9, 0xF5, 0x42, 0x2B, 0x77, 0x5C, 0x86, 0x21, 0x97, 0x72,
|
||||
0xF4, 0x18, 0xAA, 0x50, 0xDF, 0x80, 0x63, 0x11, 0x52, 0x51, 0xA3, 0xEC, 0x25, 0xAF, 0xD9, 0xCF,
|
||||
0xA7, 0x23, 0x3D, 0x5D, 0xCB, 0x0C, 0x4C, 0xB3, 0x75, 0xF8, 0x25, 0x7C, 0x0C, 0xF7, 0x6C, 0xF2,
|
||||
0xE6, 0xC9, 0x9E, 0x83, 0xB0, 0x8C, 0xD4, 0x87, 0xDB, 0x94, 0x9B, 0x6B, 0x7F, 0x59, 0xC2, 0x86,
|
||||
0x99, 0xA7, 0x64, 0xA2, 0x0A, 0x5D, 0x69, 0x57, 0x52, 0xD1, 0xF7, 0x74, 0x34, 0xF1, 0x09, 0x87,
|
||||
0x55, 0xAA, 0xBC, 0x8B, 0x3A, 0x64, 0xD5, 0xEA, 0xCE, 0x6C, 0x56, 0xA1, 0x51, 0x83, 0x2B, 0xEB,
|
||||
0x1A, 0x84, 0x9D, 0xA6, 0xB4, 0x7C, 0xA9, 0x1B, 0x48, 0x46, 0xD5, 0x73, 0x40, 0xEC, 0xDA, 0x2A,
|
||||
0xA8, 0x54, 0x23, 0x96, 0x36, 0xBE, 0x63, 0x26, 0xA5, 0xAC, 0xFC, 0xB5, 0x3A, 0xC7, 0xA7, 0x9A,
|
||||
0x09, 0x1E, 0xA1, 0xAA, 0x82, 0xCB, 0x00, 0x6D, 0x0F, 0xCE, 0xF9, 0x26, 0xEF, 0x7D, 0x39, 0xD6,
|
||||
0x3E, 0x89, 0x91, 0x60, 0x1F, 0xC4, 0x14, 0x6F, 0xD4, 0x88, 0x00, 0x1F, 0x8C, 0x05, 0x81, 0xF3,
|
||||
0x0F, 0x41, 0x92, 0xFE, 0x03, 0x01, 0xAD, 0x80, 0xAA, 0xB5, 0x5B, 0x54, 0x32, 0x8B, 0xBB, 0x11
|
||||
};
|
||||
|
||||
static uint8_t g_modulusVal[] = {
|
||||
0xAC, 0x09, 0xB8, 0xAC, 0x61, 0x73, 0x53, 0xF1, 0x4C, 0x1F, 0x9A, 0x44, 0x9A, 0xD6, 0x18, 0xF4,
|
||||
0x3C, 0x92, 0x45, 0x7A, 0xC1, 0xE4, 0xFD, 0x68, 0xCC, 0xBF, 0x89, 0x2E, 0x5E, 0x09, 0x0B, 0xE3,
|
||||
0x17, 0x61, 0x88, 0x20, 0xE3, 0x96, 0xE4, 0xAD, 0xC6, 0xB9, 0xC9, 0x02, 0x72, 0xC6, 0x99, 0x4C,
|
||||
0xFB, 0x8F, 0x99, 0xA6, 0x69, 0x9C, 0xBA, 0xD4, 0xF5, 0xDF, 0x4A, 0xBC, 0x0D, 0x9B, 0x9C, 0x05,
|
||||
0x7A, 0xC2, 0x93, 0xAB, 0x85, 0xD2, 0x6C, 0x4B, 0x01, 0x76, 0x66, 0x2D, 0xC4, 0x81, 0x64, 0x75,
|
||||
0xDA, 0x1E, 0x53, 0xAD, 0x00, 0xD6, 0x48, 0x3D, 0xB3, 0x0D, 0x74, 0x4A, 0xDA, 0x9E, 0xE5, 0x17,
|
||||
0xA3, 0xB1, 0xE3, 0x7E, 0xD6, 0x8F, 0x94, 0x67, 0x95, 0xDA, 0x29, 0x44, 0x33, 0xA9, 0x44, 0x96,
|
||||
0x9C, 0x2C, 0x89, 0xE3, 0x96, 0xBB, 0xD5, 0xF3, 0x29, 0x62, 0xAA, 0xAA, 0x83, 0xE2, 0xBD, 0x74,
|
||||
0xC4, 0x95, 0xA8, 0x2C, 0xB8, 0xD0, 0xF2, 0x8F, 0x9D, 0x33, 0xB4, 0x08, 0x52, 0xC5, 0xDF, 0xE1,
|
||||
0x32, 0x1C, 0x74, 0xB4, 0x6A, 0x30, 0xDF, 0xFE, 0x4E, 0x14, 0x86, 0x86, 0x75, 0xF8, 0xE5, 0x67,
|
||||
0x9A, 0x2D, 0x8A, 0xC4, 0x54, 0x36, 0xC2, 0xB3, 0xDB, 0xF6, 0x33, 0xF4, 0xD4, 0x8B, 0x9B, 0x4F,
|
||||
0x7D, 0xFF, 0x8F, 0x95, 0x39, 0x39, 0x60, 0xB2, 0x38, 0x3B, 0xF8, 0x06, 0xCC, 0xF4, 0x25, 0x00,
|
||||
0x6B, 0x11, 0xF2, 0xAA, 0x06, 0xC3, 0xEB, 0x3D, 0xFF, 0xF9, 0x8E, 0x89, 0xE2, 0x7A, 0x53, 0xA4,
|
||||
0x94, 0x23, 0x6C, 0x4A, 0xFB, 0xC6, 0x36, 0x51, 0xB0, 0xFD, 0xCC, 0x73, 0x53, 0x8F, 0xD2, 0x00,
|
||||
0x52, 0xFA, 0x2F, 0x34, 0xB8, 0x84, 0xAD, 0x32, 0x48, 0xB2, 0x49, 0x5C, 0xE5, 0xE2, 0xE0, 0xA1,
|
||||
0x9E, 0x76, 0x0D, 0x55, 0x0B, 0x3F, 0xFB, 0x28, 0x79, 0xCA, 0xE4, 0xF8, 0xCF, 0x8D, 0x52, 0x4D
|
||||
};
|
||||
|
||||
static uint8_t g_checkModVal[] = {
|
||||
0x94, 0x4E, 0xD0, 0x6B, 0x75, 0x9F, 0xE1, 0x83, 0xB8, 0x40, 0xCB, 0x46, 0x5D, 0x7D, 0xAC, 0x35,
|
||||
0x71, 0xF2, 0x0A, 0x49, 0x3E, 0x7F, 0x65, 0x26, 0xB8, 0x6E, 0x5A, 0x59, 0x84, 0x47, 0xC4, 0x2B,
|
||||
0x53, 0xB6, 0x1D, 0xA9, 0x21, 0xC2, 0x5F, 0x0E, 0x8B, 0x1F, 0x8F, 0x15, 0xBF, 0x2D, 0x0D, 0x5D,
|
||||
0x4E, 0x33, 0xB2, 0x29, 0x9C, 0x4E, 0x01, 0xCC, 0x9F, 0x64, 0xD8, 0x56, 0xFB, 0xFD, 0xE7, 0xDC,
|
||||
0x37, 0xB4, 0x3C, 0xD5, 0xA1, 0x35, 0xD0, 0xBC, 0xF7, 0x2F, 0x52, 0x18, 0x5E, 0x11, 0xFD, 0x2B,
|
||||
0xAC, 0x89, 0xC4, 0x43, 0xE1, 0x84, 0x6B, 0xE1, 0x86, 0x53, 0xA4, 0x19, 0x90, 0x5B, 0xA3, 0xA6,
|
||||
0x2A, 0x51, 0xE2, 0x95, 0xFA, 0xF2, 0x54, 0xDA, 0x9B, 0x18, 0x3A, 0x95, 0x68, 0xFD, 0x20, 0xB0,
|
||||
0x6B, 0xEB, 0xD9, 0xD7, 0xD2, 0x76, 0x9E, 0x17, 0xCF, 0xD2, 0x68, 0x83, 0x8C, 0x6F, 0xA1, 0xD1,
|
||||
0x24, 0xF1, 0xB4, 0xC9, 0x86, 0x57, 0x0C, 0xAC, 0x68, 0xC1, 0x6B, 0x65, 0xF2, 0x4F, 0xB7, 0xBB,
|
||||
0xD7, 0xA6, 0xB8, 0xF9, 0x2A, 0x86, 0x16, 0x13, 0xE3, 0x9D, 0x82, 0x9F, 0x58, 0xCE, 0x60, 0x81,
|
||||
0x0C, 0x87, 0x87, 0xAD, 0x6C, 0x9C, 0x92, 0x95, 0x2C, 0x59, 0x87, 0x93, 0xF7, 0xEB, 0xA9, 0x8D,
|
||||
0x38, 0xBF, 0x78, 0xD9, 0x03, 0x4A, 0xA6, 0xFF, 0xA6, 0xF7, 0xE1, 0x01, 0x39, 0xB2, 0x1A, 0xC3,
|
||||
0xC7, 0xAF, 0x02, 0xFE, 0x2E, 0xBE, 0xC4, 0x40, 0x1E, 0xFC, 0x54, 0xC9, 0x32, 0xB7, 0x6F, 0xE8,
|
||||
0x19, 0xA6, 0x5B, 0xC1, 0xE6, 0x95, 0x45, 0xE6, 0x0C, 0x81, 0xA7, 0xC7, 0x76, 0x5F, 0xA9, 0x85,
|
||||
0x23, 0x96, 0x06, 0x30, 0xE4, 0x09, 0x31, 0x58, 0x72, 0xAE, 0x72, 0xEB, 0xEC, 0x88, 0xCA, 0x6A,
|
||||
0xD9, 0xB6, 0x68, 0xBA, 0x4E, 0x92, 0xD6, 0xE5, 0x77, 0x64, 0x5A, 0xE9, 0x4A, 0x65, 0x37, 0x27,
|
||||
};
|
||||
|
||||
static uint8_t g_checkAddVal[] = {
|
||||
0x3B, 0x02, 0x26, 0x14, 0xF5, 0xFC, 0xBB, 0x3B, 0xD9, 0x29, 0x4D, 0x76, 0x06, 0xC2, 0xDB, 0x30,
|
||||
0xB0, 0x63, 0x09, 0xFD, 0xC8, 0xB1, 0xA9, 0x18, 0x57, 0xBF, 0xD3, 0xB9, 0x83, 0xB4, 0x1C, 0xE6,
|
||||
0xEA, 0x80, 0xAE, 0xD0, 0x12, 0xA6, 0x95, 0xF6, 0xC1, 0x78, 0x0D, 0x12, 0xDF, 0xA3, 0xB1, 0xEB,
|
||||
0x25, 0x8B, 0x13, 0x9D, 0x56, 0x23, 0x52, 0xA5, 0x7A, 0x90, 0x13, 0x7D, 0xBF, 0x8B, 0xA3, 0x76,
|
||||
0x74, 0x96, 0xB4, 0xCA, 0x0F, 0xA4, 0xE6, 0x48, 0xE2, 0xB7, 0x9C, 0x99, 0x2A, 0xB2, 0xF6, 0xA1,
|
||||
0xC6, 0x1A, 0x38, 0xE4, 0x52, 0x82, 0xED, 0x99, 0x15, 0x71, 0xA7, 0x2B, 0x3B, 0xDE, 0x56, 0x01,
|
||||
0x7A, 0xB8, 0xA9, 0x68, 0x03, 0xE3, 0x23, 0x84, 0x57, 0x8F, 0xB5, 0x3D, 0x5B, 0x03, 0xB5, 0xE9,
|
||||
0x76, 0xE2, 0x8D, 0x52, 0x06, 0xC7, 0x14, 0xD8, 0x1C, 0x67, 0xE3, 0x55, 0x15, 0x84, 0x51, 0x4F,
|
||||
0x47, 0x25, 0xAB, 0x20, 0x7E, 0x12, 0xEE, 0xA4, 0xA7, 0x22, 0x52, 0xC9, 0x1E, 0xE3, 0x9A, 0x61,
|
||||
0x3F, 0x31, 0xA8, 0xE6, 0xCA, 0xB2, 0x9F, 0x6C, 0xE8, 0x5A, 0xF3, 0x8D, 0x17, 0xC6, 0x84, 0xA0,
|
||||
0xC8, 0x04, 0xB9, 0x74, 0x52, 0xCA, 0xA5, 0xCC, 0x1E, 0xCF, 0xAA, 0x40, 0x74, 0xE3, 0x3A, 0x28,
|
||||
0xD5, 0x44, 0x86, 0xEA, 0x7E, 0x8D, 0xEF, 0x68, 0xB7, 0x02, 0xBE, 0x6D, 0xAD, 0xAA, 0xCF, 0xEE,
|
||||
0x04, 0xF1, 0x33, 0xEA, 0x5E, 0xB9, 0x3C, 0x28, 0xC4, 0xAF, 0xC2, 0xF4, 0x8B, 0x04, 0xC3, 0xDD,
|
||||
0x8E, 0xA1, 0x91, 0x21, 0x6D, 0x9A, 0x10, 0x01, 0x6B, 0x52, 0xD4, 0x7B, 0x12, 0x4D, 0x11, 0x5B,
|
||||
0x0F, 0x25, 0x68, 0x5C, 0x4B, 0x48, 0x98, 0x95, 0xFE, 0x84, 0x29, 0xAE, 0x92, 0xAB, 0x6B, 0xBC,
|
||||
0x4A, 0x81, 0xEE, 0x63, 0x46, 0x54, 0x89, 0x3D, 0xA8, 0x4E, 0xD1, 0x44, 0xAD, 0x63, 0x9F, 0xEB
|
||||
};
|
||||
|
||||
static uint8_t g_checkSubVal[] = {
|
||||
0x41, 0x91, 0xC2, 0x15, 0x93, 0xCF, 0xB3, 0xDA, 0x4B, 0x38, 0xAE, 0xD2, 0x19, 0x62, 0x64, 0x45,
|
||||
0xF6, 0xEE, 0xC5, 0x19, 0xF2, 0x68, 0x23, 0xCC, 0x4C, 0x5D, 0x57, 0xCB, 0x26, 0xD2, 0x5F, 0x8C,
|
||||
0xA5, 0x8A, 0x04, 0x61, 0x4D, 0x47, 0x43, 0x78, 0x8E, 0x0D, 0x48, 0x16, 0x2B, 0xEF, 0xCF, 0x82,
|
||||
0x7B, 0x4C, 0xB7, 0x0F, 0x78, 0xDB, 0xF6, 0x1E, 0xCE, 0x5A, 0x52, 0x74, 0x2A, 0xD4, 0x90, 0x3C,
|
||||
0x80, 0x0F, 0x31, 0x35, 0xAC, 0xF4, 0x4E, 0xE6, 0x0A, 0x30, 0xA1, 0x69, 0xCC, 0xEF, 0x9F, 0x3F,
|
||||
0xB8, 0xDA, 0xFB, 0xF6, 0x6F, 0xAF, 0xA1, 0xEC, 0x44, 0x28, 0x2C, 0xBD, 0x0A, 0x3A, 0x0C, 0x33,
|
||||
0x36, 0x39, 0x38, 0x45, 0x1B, 0x71, 0xF1, 0xC9, 0x48, 0xC6, 0x96, 0xA9, 0x43, 0x4D, 0x46, 0xE0,
|
||||
0xC4, 0xC8, 0x9C, 0x7A, 0x07, 0x6A, 0x51, 0x64, 0x59, 0xDA, 0x43, 0x07, 0x7F, 0x78, 0x34, 0xDE,
|
||||
0x3E, 0x28, 0x16, 0x45, 0xD5, 0xCA, 0x38, 0x24, 0x8D, 0x2C, 0xCF, 0xFA, 0x72, 0xF5, 0xF5, 0x35,
|
||||
0x3D, 0xFF, 0x54, 0x57, 0x20, 0x28, 0xAC, 0xBC, 0x90, 0xCB, 0x8B, 0x2B, 0x23, 0xDD, 0x56, 0xF9,
|
||||
0xB6, 0xDC, 0xCB, 0x22, 0x32, 0x37, 0xBC, 0xAA, 0x5D, 0xED, 0x30, 0xF2, 0xA6, 0x68, 0x7D, 0xA2,
|
||||
0x1E, 0x3A, 0xDB, 0x32, 0x4E, 0xCD, 0xFD, 0xE4, 0x5E, 0xB1, 0x0B, 0x8D, 0xF8, 0xC5, 0x40, 0x99,
|
||||
0x1F, 0x5A, 0xDF, 0x67, 0xF8, 0x00, 0x61, 0x19, 0x79, 0x4F, 0x58, 0x13, 0xF7, 0xEF, 0xC8, 0x4E,
|
||||
0x10, 0x87, 0xBA, 0x17, 0x63, 0xCA, 0x45, 0x78, 0xFC, 0xB2, 0xAE, 0xA0, 0x86, 0xE2, 0x6F, 0xAE,
|
||||
0xE5, 0x0C, 0x74, 0xD0, 0xC4, 0x45, 0x1C, 0xE8, 0x9E, 0x26, 0x72, 0xCC, 0x60, 0x83, 0x48, 0x77,
|
||||
0xCA, 0x74, 0xD5, 0xBC, 0x4B, 0x91, 0x29, 0x64, 0xCC, 0xAE, 0xFF, 0x95, 0x17, 0xD9, 0x7C, 0x16,
|
||||
};
|
||||
|
||||
static uint8_t g_checkMulVal[] = {
|
||||
0x9B, 0xD1, 0x3A, 0x5B, 0x6E, 0x30, 0xC9, 0x43, 0x94, 0x61, 0xB8, 0xC0, 0x6A, 0xC5, 0xD1, 0x63,
|
||||
0x34, 0x3D, 0x0D, 0x10, 0x73, 0x5B, 0xAD, 0xE0, 0xDA, 0x9E, 0x25, 0x47, 0xD7, 0x82, 0xDF, 0xF7,
|
||||
0x2B, 0xEC, 0x74, 0x5A, 0xEB, 0xE9, 0x98, 0x43, 0xEA, 0x43, 0xFE, 0xD2, 0x2E, 0x1F, 0x30, 0x15,
|
||||
0x0B, 0x86, 0x30, 0x77, 0x16, 0x45, 0x16, 0x64, 0x7B, 0xBD, 0x3F, 0x96, 0x57, 0x24, 0x41, 0x86,
|
||||
0x06, 0xEB, 0x52, 0x0C, 0x22, 0xA8, 0xCF, 0x92, 0x20, 0x26, 0xC5, 0x33, 0x77, 0x65, 0xCC, 0x5D,
|
||||
0x8F, 0xBE, 0x31, 0xD4, 0x1E, 0x3E, 0x8E, 0x38, 0x81, 0x24, 0xAF, 0x60, 0xB2, 0x86, 0x54, 0x8C,
|
||||
0xAE, 0x39, 0x97, 0x35, 0xE6, 0x65, 0x3E, 0x6B, 0xEE, 0xC2, 0xCF, 0x18, 0x0A, 0xBA, 0xA3, 0xA6,
|
||||
0x66, 0x8E, 0x64, 0x41, 0x9E, 0x50, 0xD2, 0x3E, 0x73, 0xE5, 0x57, 0x08, 0x6B, 0xFE, 0xD9, 0xBA,
|
||||
0x62, 0x3B, 0x70, 0xCC, 0xAF, 0xB3, 0x3F, 0x67, 0x24, 0xBC, 0x32, 0x42, 0x48, 0xE3, 0x74, 0x0A,
|
||||
0x63, 0xB1, 0xF1, 0xAB, 0xAD, 0x20, 0xFE, 0xB8, 0x66, 0x22, 0x1B, 0x68, 0x45, 0xAB, 0x6E, 0xC9,
|
||||
0x0C, 0x84, 0x93, 0x43, 0xA9, 0x51, 0x7E, 0x2A, 0xDC, 0x8D, 0xF0, 0xF4, 0x41, 0x0C, 0x50, 0x6F,
|
||||
0x99, 0x3C, 0xC2, 0x71, 0xE6, 0xD9, 0xF6, 0xC5, 0x75, 0x42, 0xFA, 0x71, 0xF6, 0x3B, 0xA1, 0x67,
|
||||
0x04, 0xA3, 0xDA, 0x9D, 0x3F, 0xBD, 0x87, 0x90, 0x37, 0x14, 0xB6, 0x3A, 0x04, 0xA6, 0x0F, 0x8F,
|
||||
0xF9, 0xA4, 0xCC, 0xE2, 0x3D, 0x9C, 0x71, 0x6E, 0xFB, 0x26, 0x52, 0xD4, 0x7A, 0x3D, 0xE2, 0xEB,
|
||||
0xDD, 0x1C, 0x6E, 0xD5, 0xF4, 0x98, 0x96, 0x75, 0xE0, 0xA8, 0xE0, 0x9E, 0xAB, 0x6D, 0x9F, 0x4C,
|
||||
0x1F, 0x05, 0xDA, 0xD9, 0x74, 0x5F, 0x3C, 0x4A, 0x5B, 0x51, 0x89, 0x61, 0x7F, 0x15, 0x3C, 0x2C,
|
||||
};
|
||||
|
||||
TEE_Result TestBigIntMod()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
TEE_BigInt *op = CreateBigInt(sizeof(g_value1), g_value1);
|
||||
TEE_BigInt *modulus = CreateBigInt(sizeof(g_modulusVal), g_modulusVal);
|
||||
TEE_BigInt *modDest = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigInt *modCheck = CreateBigInt(sizeof(g_checkModVal), g_checkModVal);
|
||||
|
||||
TEE_BigIntMod(modDest, op, modulus);
|
||||
if (TEE_BigIntCmp(modDest, modCheck) != 0) {
|
||||
tloge("BigIntMod failed.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
TEE_Free(op);
|
||||
TEE_Free(modulus);
|
||||
TEE_Free(modDest);
|
||||
TEE_Free(modCheck);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntAddAndSubMod()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
TEE_BigInt *op1 = CreateBigInt(sizeof(g_value1), g_value1);
|
||||
TEE_BigInt *op2 = CreateBigInt(sizeof(g_value2), g_value2);
|
||||
TEE_BigInt *modulus = CreateBigInt(sizeof(g_modulusVal), g_modulusVal);
|
||||
|
||||
TEE_BigInt *addDest = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigInt *addCheck = CreateBigInt(sizeof(g_checkAddVal), g_checkAddVal);
|
||||
TEE_BigIntAddMod(addDest, op1, op2, modulus);
|
||||
if (TEE_BigIntCmp(addDest, addCheck) != 0) {
|
||||
tloge("BigIntAddMod failed.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
goto CLEANUP;
|
||||
}
|
||||
|
||||
TEE_BigInt *subDest = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigInt *subCheck = CreateBigInt(sizeof(g_checkSubVal), g_checkSubVal);
|
||||
TEE_BigIntSubMod(subDest, op1, op2, modulus);
|
||||
if (TEE_BigIntCmp(subDest, subCheck) != 0) {
|
||||
tloge("BigIntSubMod failed.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
TEE_Free(subDest);
|
||||
TEE_Free(subCheck);
|
||||
|
||||
CLEANUP:
|
||||
TEE_Free(op1);
|
||||
TEE_Free(op2);
|
||||
TEE_Free(modulus);
|
||||
TEE_Free(addDest);
|
||||
TEE_Free(addCheck);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntMulAndInvMod()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
TEE_BigInt *op1 = CreateBigInt(sizeof(g_value1), g_value1);
|
||||
TEE_BigInt *op2 = CreateBigInt(sizeof(g_value2), g_value2);
|
||||
TEE_BigInt *modulus = CreateBigInt(sizeof(g_modulusVal), g_modulusVal);
|
||||
|
||||
TEE_BigInt *mulDest = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigInt *mulCheck = CreateBigInt(sizeof(g_checkMulVal), g_checkMulVal);
|
||||
TEE_BigIntMulMod(mulDest, op1, op2, modulus);
|
||||
if (TEE_BigIntCmp(mulDest, mulCheck) != 0) {
|
||||
tloge("BigIntMulMod failed.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
goto CLEANUP;
|
||||
}
|
||||
|
||||
TEE_BigInt *squareDest = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigInt *mulForsquareCheck = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigIntSquareMod(squareDest, op1, modulus);
|
||||
TEE_BigIntMulMod(mulForsquareCheck, op1, op1, modulus);
|
||||
int32_t isSame = TEE_BigIntCmp(squareDest, mulForsquareCheck);
|
||||
TEE_Free(squareDest);
|
||||
TEE_Free(mulForsquareCheck);
|
||||
if (isSame != 0) {
|
||||
tloge("BigIntSquareMod failed.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
goto CLEANUP;
|
||||
}
|
||||
|
||||
TEE_BigInt *invDest = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigInt *mulForinvCheck = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigIntInvMod(invDest, op1, modulus);
|
||||
TEE_BigIntMulMod(mulForinvCheck, invDest, op1, modulus);
|
||||
if (TEE_BigIntCmpS32(mulForinvCheck, 1) != 0) {
|
||||
tloge("BigIntInvMod failed.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
TEE_Free(invDest);
|
||||
TEE_Free(mulForinvCheck);
|
||||
|
||||
CLEANUP:
|
||||
TEE_Free(op1);
|
||||
TEE_Free(op2);
|
||||
TEE_Free(modulus);
|
||||
TEE_Free(mulDest);
|
||||
TEE_Free(mulCheck);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntExpMod()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
uint32_t length = TEE_BigIntFMMContextSizeInU32(SIZE_256);
|
||||
TEE_BigIntFMMContext *bigIntFMMContext = TEE_Malloc(length * sizeof(TEE_BigIntFMMContext), 0);
|
||||
if (bigIntFMMContext == NULL) {
|
||||
tloge("CmdTEEBigIntInitFMMContext: TEE_Malloc returned NULL.");
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
const uint8_t modValue[] = {0x01, 0x31};
|
||||
TEE_BigInt *modulus = CreateBigInt(sizeof(modValue), (uint8_t *)modValue);
|
||||
TEE_BigIntInitFMMContext(bigIntFMMContext, length, modulus);
|
||||
|
||||
const uint8_t desValue[] = "desValue";
|
||||
const uint8_t op1Value[] = {0x01, 0x01};
|
||||
const uint8_t op2Value[] = {0x01, 0x11};
|
||||
TEE_BigInt *des1 = CreateBigInt(sizeof(desValue), (uint8_t *)desValue);
|
||||
TEE_BigInt *des2 = CreateBigInt(sizeof(desValue), (uint8_t *)desValue);
|
||||
TEE_BigInt *op1 = CreateBigInt(sizeof(op1Value), (uint8_t *)op1Value);
|
||||
TEE_BigInt *op2 = CreateBigInt(sizeof(op2Value), (uint8_t *)op2Value);
|
||||
|
||||
if (TEE_BigIntExpMod(des1, op1, op2, modulus, bigIntFMMContext) != TEE_SUCCESS) {
|
||||
tloge("TEE_BigIntExpMod failed with fmm context.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
goto CLEAN_UP;
|
||||
}
|
||||
|
||||
if (TEE_BigIntExpMod(des2, op1, op2, modulus, NULL) != TEE_SUCCESS) {
|
||||
tloge("TEE_BigIntExpMod failed with null context.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
goto CLEAN_UP;
|
||||
}
|
||||
|
||||
if (TEE_BigIntCmp(des1, des2) != 0) {
|
||||
tloge("TEE_BigIntExpMod failed for different result.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
CLEAN_UP:
|
||||
TEE_Free(bigIntFMMContext);
|
||||
TEE_Free(modulus);
|
||||
TEE_Free(des1);
|
||||
TEE_Free(des2);
|
||||
TEE_Free(op1);
|
||||
TEE_Free(op2);
|
||||
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef __TEST_MODULAR_ARITHMETIC_OPERATION_H__
|
||||
#define __TEST_MODULAR_ARITHMETIC_OPERATION_H__
|
||||
|
||||
#include <tee_ext_api.h>
|
||||
|
||||
TEE_Result TestBigIntMod();
|
||||
TEE_Result TestBigIntAddAndSubMod();
|
||||
TEE_Result TestBigIntMulAndInvMod();
|
||||
TEE_Result TestBigIntExpMod();
|
||||
|
||||
#endif
|
||||
@@ -1,192 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain longVal1 copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <tee_ext_api.h>
|
||||
#include <tee_log.h>
|
||||
#include <securec.h>
|
||||
#include <tee_arith_api.h>
|
||||
#include <tee_mem_mgmt_api.h>
|
||||
#include "test_arithmetic_api_base.h"
|
||||
|
||||
// p1,p2 and p3 are primes
|
||||
static uint8_t g_p1Value[] = {
|
||||
0x55, 0xE6, 0xE0, 0xE3, 0x96, 0x50, 0x92, 0x4F, 0x8A, 0x53, 0x48, 0x83, 0xCA, 0xDD, 0x81, 0x2D,
|
||||
0x48, 0xBA, 0x7D, 0x71, 0x25, 0xDD, 0x54, 0xB1, 0x01, 0x71, 0x72, 0xFD, 0xC9, 0x11, 0xB4, 0x00,
|
||||
0x4B, 0x7C, 0xF4, 0x32, 0xEB, 0x20, 0x12, 0x8E, 0x8D, 0x9D, 0x02, 0x5A, 0xB9, 0xF9, 0xC2, 0xC2,
|
||||
0x1E, 0x41, 0x6A, 0xC3, 0xA9, 0x2B, 0x59, 0x21, 0x80, 0x7B, 0xF8, 0x23, 0x3A, 0x73, 0xBE, 0x87,
|
||||
0xF7, 0x91, 0xE6, 0xFC, 0x57, 0x15, 0x04, 0x78, 0xCA, 0xD2, 0x75, 0x6E, 0xD1, 0x4E, 0x83, 0x08,
|
||||
0x95, 0x60, 0x49, 0x97, 0xF0, 0x83, 0x74, 0xC8, 0xEF, 0x58, 0xFE, 0x0D, 0xAA, 0x4D, 0x81, 0x40,
|
||||
0xE0, 0x67, 0x60, 0x76, 0x71, 0xD7, 0xC2, 0x83, 0x7F, 0xF0, 0xC4, 0x1B, 0x2F, 0xCF, 0x3E, 0x3C,
|
||||
0x06, 0x07, 0x64, 0x40, 0xBA, 0x83, 0x3E, 0x80, 0x01, 0x9D, 0x52, 0xF6, 0x5F, 0xC5, 0xCF, 0xCB
|
||||
};
|
||||
|
||||
static uint8_t g_p2Value[] = {
|
||||
0x54, 0x5D, 0x1C, 0xAA, 0x75, 0xF2, 0xCB, 0x78, 0x97, 0x5A, 0x4D, 0x41, 0xAE, 0x9A, 0xDD, 0xB5,
|
||||
0x62, 0x10, 0x1F, 0x86, 0x64, 0x07, 0x98, 0x2D, 0x92, 0x00, 0x62, 0x26, 0x35, 0xE9, 0x63, 0xD4,
|
||||
0x96, 0x0B, 0x35, 0x25, 0x93, 0xAD, 0x26, 0x0F, 0xD0, 0xE6, 0x86, 0x9F, 0xD3, 0x7C, 0xEC, 0xD5,
|
||||
0x6E, 0x23, 0x44, 0x6B, 0xE6, 0x2E, 0xC8, 0x03, 0x5C, 0xB9, 0x63, 0xDF, 0x40, 0xB3, 0xA0, 0x1C,
|
||||
0x32, 0xB8, 0x0D, 0x06, 0x04, 0x51, 0xA5, 0x12, 0x75, 0x46, 0x61, 0x8C, 0x65, 0xC2, 0x39, 0x56,
|
||||
0x67, 0x3E, 0x51, 0x49, 0xF5, 0xAB, 0x34, 0xEE, 0xE8, 0x35, 0xDA, 0xB8, 0xDC, 0x2A, 0x96, 0x32,
|
||||
0xB6, 0x70, 0xB3, 0x49, 0xC2, 0x67, 0xBB, 0x08, 0x89, 0x18, 0x81, 0xED, 0x0F, 0xBE, 0x8C, 0xC1,
|
||||
0x39, 0x70, 0x36, 0x61, 0x3E, 0xF7, 0xF9, 0x6C, 0xF3, 0xE1, 0x74, 0x14, 0xC0, 0x49, 0x05, 0x89
|
||||
};
|
||||
|
||||
static uint8_t g_p3Value[] = {
|
||||
0x64, 0xDB, 0x43, 0xB6, 0x9E, 0xD9, 0x3A, 0x84, 0xFD, 0xA5, 0xD2, 0xB4, 0xC3, 0xB9, 0x0B, 0xAD,
|
||||
0x84, 0xF9, 0x30, 0x3F, 0xE1, 0xDE, 0x53, 0x3E, 0x20, 0x6E, 0x09, 0xD9, 0x59, 0x77, 0xC0, 0x8E,
|
||||
0x5D, 0xE4, 0x27, 0x15, 0xB6, 0x51, 0x98, 0x44, 0x71, 0x7E, 0x2B, 0x4E, 0x79, 0x27, 0x49, 0xAE,
|
||||
0x4C, 0xF5, 0xCC, 0x6F, 0xCF, 0xBF, 0x27, 0x7E, 0x07, 0x71, 0x4E, 0x48, 0x94, 0x7F, 0x60, 0xFD,
|
||||
0x32, 0x81, 0xFB, 0x44, 0x43, 0x04, 0xB1, 0xE0, 0xA2, 0x49, 0xEF, 0xAA, 0xC7, 0x8E, 0x9B, 0xC3,
|
||||
0x0C, 0x34, 0x33, 0xF4, 0x23, 0x84, 0x86, 0xAD, 0x70, 0xD9, 0x0F, 0xBE, 0xBC, 0x5A, 0xE6, 0x9E,
|
||||
0xC7, 0xB5, 0x15, 0x82, 0xE6, 0x17, 0x10, 0x06, 0x09, 0xC9, 0x9F, 0x9D, 0x99, 0xBA, 0x10, 0x63,
|
||||
0x27, 0x59, 0x46, 0xCF, 0x8B, 0x0C, 0x32, 0x0D, 0x0D, 0x9C, 0x82, 0x5A, 0x82, 0x17, 0x43, 0x03
|
||||
};
|
||||
|
||||
static uint8_t g_vCheckValue[] = {
|
||||
0x10, 0x69, 0x66, 0x78, 0x0E, 0xAE, 0xE1, 0x39, 0x02, 0x7C, 0xCE, 0x5B, 0x8F, 0x7C, 0xE5, 0x30,
|
||||
0x77, 0xA2, 0xF7, 0xE6, 0x75, 0xE8, 0x26, 0xD8, 0xAA, 0x37, 0xEB, 0x71, 0xF3, 0x0D, 0x94, 0xC5,
|
||||
0x11, 0xE1, 0x98, 0xF3, 0x65, 0xAA, 0x28, 0xE2, 0xE7, 0x2B, 0x15, 0x2C, 0x63, 0x77, 0x64, 0x40,
|
||||
0x22, 0xA8, 0xE4, 0xA7, 0xF5, 0x4E, 0x84, 0x51, 0xDE, 0x0A, 0x3C, 0x2F, 0x81, 0xD2, 0xDF, 0xE2,
|
||||
0x6C, 0x20, 0x23, 0x71, 0xB9, 0xA0, 0x0D, 0x00, 0x2A, 0x17, 0x55, 0x1C, 0xB5, 0xA1, 0x66, 0xBD,
|
||||
0xDE, 0xAC, 0x9D, 0x32, 0x30, 0xF9, 0xFF, 0x02, 0x8F, 0xD5, 0xC1, 0x1D, 0x4C, 0x91, 0x40, 0x46,
|
||||
0x62, 0xA7, 0x8E, 0xAB, 0x6B, 0x74, 0x4E, 0x44, 0x02, 0x08, 0xA4, 0x3D, 0x8B, 0xAB, 0x61, 0xAE,
|
||||
0xEE, 0xDC, 0x23, 0x4C, 0x70, 0x7A, 0x31, 0x2B, 0x5C, 0xDD, 0x31, 0x7C, 0x2B, 0x57, 0x69, 0xA3
|
||||
};
|
||||
|
||||
static uint8_t g_uCheckValue[] = {
|
||||
0x20, 0xb3, 0x43, 0x5f, 0x2a, 0x64, 0xb5, 0x6e, 0xd8, 0x63, 0x4e, 0xf3, 0xd4, 0xd3, 0x41, 0x1a,
|
||||
0xf1, 0x06, 0xb0, 0x28, 0xab, 0x05, 0x8d, 0x5b, 0xf5, 0xca, 0xa3, 0x1b, 0x90, 0x8d, 0x44, 0xae,
|
||||
0xd4, 0x26, 0x08, 0x6b, 0x1e, 0x65, 0xbf, 0xc9, 0x26, 0x46, 0xf2, 0xb6, 0xc4, 0xa7, 0x55, 0xdd,
|
||||
0x93, 0x42, 0xc0, 0xd4, 0x0c, 0xc9, 0x61, 0x74, 0xd6, 0x05, 0x45, 0x25, 0x70, 0x69, 0xc8, 0x7a,
|
||||
0x7c, 0x05, 0xec, 0xf1, 0xe3, 0x51, 0xf3, 0xb0, 0x8d, 0x6b, 0xbd, 0x8a, 0x57, 0xb0, 0x6c, 0x37,
|
||||
0x15, 0x56, 0x93, 0x90, 0x74, 0x6b, 0x88, 0x12, 0x51, 0x6c, 0xde, 0xd7, 0x98, 0x12, 0x6f, 0x02,
|
||||
0xca, 0x36, 0x63, 0xf5, 0x90, 0x87, 0x75, 0x95, 0x28, 0x9a, 0x6d, 0x19, 0xa0, 0xed, 0xa1, 0x53,
|
||||
0x6c, 0x71, 0xa4, 0x2b, 0x8d, 0xfc, 0x3f, 0xbb, 0xaa, 0xcb, 0x89, 0x24, 0xfd, 0xe8, 0x3e, 0x8a,
|
||||
};
|
||||
|
||||
TEE_Result TestBigIntRelativePrime()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
TEE_BigInt *p1 = CreateBigInt(sizeof(g_p1Value), g_p1Value);
|
||||
TEE_BigInt *p2 = CreateBigInt(sizeof(g_p2Value), g_p2Value);
|
||||
TEE_BigInt *tmp1 = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigInt *tmp2 = CreateBigInt(RESULT_SIZE, 0);
|
||||
|
||||
TEE_BigIntConvertFromS32(tmp1, NUM_THREE);
|
||||
TEE_BigIntMul(tmp1, tmp1, p1); // tmp1 = p1 * 3
|
||||
TEE_BigIntConvertFromS32(tmp2, NUM_FIVE);
|
||||
TEE_BigIntMul(tmp2, tmp2, p2); // temp2 = p2 * 5
|
||||
if (!TEE_BigIntRelativePrime(tmp1, tmp2)) {
|
||||
tloge("BigIntRelativePrime fail.\n");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
TEE_Free(p1);
|
||||
TEE_Free(p2);
|
||||
TEE_Free(tmp1);
|
||||
TEE_Free(tmp2);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntComputeExtentedGcd()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
|
||||
TEE_BigInt *p1 = CreateBigInt(sizeof(g_p1Value), g_p1Value);
|
||||
TEE_BigInt *p2 = CreateBigInt(sizeof(g_p2Value), g_p2Value);
|
||||
TEE_BigInt *p3 = CreateBigInt(sizeof(g_p3Value), g_p3Value);
|
||||
TEE_BigInt *a = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigInt *b = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigInt *u = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigInt *v = CreateBigInt(RESULT_SIZE, 0);
|
||||
TEE_BigInt *tmp1 = CreateBigInt(RESULT_SIZE * NUM_TWO, 0);
|
||||
TEE_BigInt *tmp2 = CreateBigInt(RESULT_SIZE * NUM_TWO, 0);
|
||||
TEE_BigInt *gcd = CreateBigInt(RESULT_SIZE, 0);
|
||||
|
||||
// a = p1 * p2 * 3
|
||||
TEE_BigIntMul(a, p1, p2);
|
||||
TEE_BigIntConvertFromS32(tmp1, NUM_THREE);
|
||||
TEE_BigIntMul(a, a, tmp1);
|
||||
|
||||
// b = p1 * p3 * 5
|
||||
TEE_BigIntMul(b, p1, p3);
|
||||
TEE_BigIntConvertFromS32(tmp2, NUM_FIVE);
|
||||
TEE_BigIntMul(b, b, tmp2);
|
||||
|
||||
// gdc (a,b) = gdc ((p1*p2*3),(p1*p3*5)) = p1
|
||||
TEE_BigIntComputeExtendedGcd(gcd, u, v, a, b);
|
||||
if (TEE_BigIntCmp(gcd, p1) != 0) {
|
||||
tloge("BigIntComputeExtendedGcd check gcd fail.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
goto CLEANUP;
|
||||
}
|
||||
|
||||
TEE_BigInt *uCheck = CreateBigInt(sizeof(g_uCheckValue), g_uCheckValue);
|
||||
TEE_BigInt *vCheck = CreateBigInt(sizeof(g_vCheckValue), g_vCheckValue);
|
||||
TEE_BigIntNeg(vCheck, vCheck); // turn v to negative
|
||||
if (TEE_BigIntCmp(v, vCheck) != 0 || TEE_BigIntCmp(u, uCheck) != 0) {
|
||||
tloge("BigIntComputeExtendedGcd check v or u fail.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
TEE_Free(uCheck);
|
||||
TEE_Free(vCheck);
|
||||
|
||||
CLEANUP:
|
||||
TEE_Free(p1);
|
||||
TEE_Free(p2);
|
||||
TEE_Free(p3);
|
||||
TEE_Free(a);
|
||||
TEE_Free(b);
|
||||
TEE_Free(u);
|
||||
TEE_Free(v);
|
||||
TEE_Free(tmp1);
|
||||
TEE_Free(tmp2);
|
||||
TEE_Free(gcd);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
TEE_Result TestBigIntIsProbablePrime()
|
||||
{
|
||||
tlogi("[%s] begin:", __FUNCTION__);
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
const uint32_t leastConfidenceLevel = 80;
|
||||
// p1 is a prime
|
||||
uint8_t g_p1Value[] = {
|
||||
0x40, 0x84, 0xB4, 0xAF, 0xF9, 0x13, 0xE0, 0x2B, 0xFF, 0x2D, 0x30, 0x21, 0x7C, 0x94, 0xD2, 0x8F,
|
||||
0x89, 0x47, 0x9F, 0x7E, 0x14, 0xC1, 0xB4, 0xD7, 0x64, 0x97, 0x33, 0x65, 0x26, 0x62, 0x86, 0xED
|
||||
};
|
||||
TEE_BigInt *p1 = CreateBigInt(sizeof(g_p1Value), g_p1Value);
|
||||
TEE_BigInt *tmp = CreateBigInt(RESULT_SIZE, 0);
|
||||
|
||||
if (!TEE_BigIntIsProbablePrime(p1, leastConfidenceLevel)) {
|
||||
tloge("check p1 is a prime fail.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
goto CLEANUP;
|
||||
}
|
||||
TEE_BigIntConvertFromS32(tmp, NUM_THREE);
|
||||
TEE_BigIntMul(p1, p1, tmp);
|
||||
// check that p1 is not a prime
|
||||
if (TEE_BigIntIsProbablePrime(p1, leastConfidenceLevel)) {
|
||||
tloge("check p1 is not a prime fail.");
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
CLEANUP:
|
||||
TEE_Free(p1);
|
||||
TEE_Free(tmp);
|
||||
tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef __TEST_OTHER_ARITHMETIC_OPERATION_H__
|
||||
#define __TEST_OTHER_ARITHMETIC_OPERATION_H__
|
||||
|
||||
#include <tee_ext_api.h>
|
||||
|
||||
TEE_Result TestBigIntRelativePrime();
|
||||
TEE_Result TestBigIntComputeExtentedGcd();
|
||||
TEE_Result TestBigIntIsProbablePrime();
|
||||
|
||||
#endif
|
||||
@@ -1,45 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
|
||||
set(TARGET_NAME test_crypto_api)
|
||||
|
||||
list(APPEND ta_src
|
||||
src/oh_crypto_entry.c
|
||||
src/cases/cases_ae_crypto_basic_cases.c
|
||||
src/cases/cases_asym_crypto_basic_cases.c
|
||||
src/cases/cases_asym_sign_basic_cases.c
|
||||
src/cases/cases_derive_basic_cases.c
|
||||
src/cases/cases_digest_crypto_basic_cases.c
|
||||
src/cases/cases_entry.c
|
||||
src/cases/cases_mac_crypto_basic_cases.c
|
||||
src/cases/cases_sym_crypto_basic_cases.c
|
||||
src/data/alg_map_data.c
|
||||
src/data/key_object_database.c
|
||||
src/monad/monad_actions.c
|
||||
src/monad/monad_inverse_map.c
|
||||
src/monad/monad_run.c
|
||||
)
|
||||
|
||||
ta_compile_pub(
|
||||
ELF_NAME
|
||||
${TARGET_NAME}
|
||||
|
||||
SRC_LIST
|
||||
${ta_src}
|
||||
|
||||
INCLUDE_DIRS
|
||||
|
||||
COMPILE_OPTS
|
||||
|
||||
COMPILE_DEFS
|
||||
API_LEVEL=3
|
||||
)
|
||||
@@ -1,7 +0,0 @@
|
||||
gpd.ta.appID: 05050505-0303-0303-0303-030303030301
|
||||
gpd.ta.service_name: test_crypto_api
|
||||
gpd.ta.singleInstance: true
|
||||
gpd.ta.multiSession: true
|
||||
gpd.ta.instanceKeepAlive: false
|
||||
gpd.ta.dataSize: 8192000
|
||||
gpd.ta.stackSize: 40960
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,630 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include "monad.h"
|
||||
#include "tee_log.h"
|
||||
|
||||
// Crypto_AsymEncrypt_Fun_001
|
||||
int CaseAsymEncryptRsaV15KeySize512Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_ed_rsa_v15"},
|
||||
.operaMaxKeySize = 512,
|
||||
.keySize = 512,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_0,
|
||||
.fwdKeyTypeName = "kt_rsa_pub",
|
||||
.bckKeyTypeName = "kt_rsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 64 - 11,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASEncryFwd,
|
||||
ASDecryBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymEncryptRsaV15KeySize512Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymEncrypt_Fun_001
|
||||
int CaseAsymEncryptRsaV15KeySize2048Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_ed_rsa_v15"},
|
||||
.operaMaxKeySize = 2048,
|
||||
.keySize = 2048,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_2,
|
||||
.fwdKeyTypeName = "kt_rsa_pub",
|
||||
.bckKeyTypeName = "kt_rsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 256 - 11,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASEncryFwd,
|
||||
ASDecryBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymEncryptRsaV15KeySize2048Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymEncrypt_Fun_002
|
||||
int CaseAsymEncryptRsaV15KeySize2048Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_ed_rsa_v15"},
|
||||
.operaMaxKeySize = 2048,
|
||||
.keySize = 2048,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_2,
|
||||
.fwdKeyTypeName = "kt_rsa_pub",
|
||||
.bckKeyTypeName = "kt_rsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 256 - 11,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymEncryptRsaV15KeySize2048Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymEncrypt_Fun_001
|
||||
int CaseAsymEncryptRsaV15KeySize4096Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_ed_rsa_v15"},
|
||||
.operaMaxKeySize = 4096,
|
||||
.keySize = 4096,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4,
|
||||
.fwdKeyTypeName = "kt_rsa_pair",
|
||||
.bckKeyTypeName = "kt_rsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 512 - 11,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASEncryFwd,
|
||||
ASDecryBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymEncryptRsaV15KeySize4096Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymEncrypt_Fun_002
|
||||
int CaseAsymEncryptRsaV15KeySize4096Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_ed_rsa_v15"},
|
||||
.operaMaxKeySize = 4096,
|
||||
.keySize = 4096,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4,
|
||||
.fwdKeyTypeName = "kt_rsa_pair",
|
||||
.bckKeyTypeName = "kt_rsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 512 - 11,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymEncryptRsaV15KeySize4096Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymEncrypt_Fun_003
|
||||
int CaseAsymEncryptRsaOaepSha384KeySize2048Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_ed_rsa_oaep_sha384"},
|
||||
.operaMaxKeySize = 2048,
|
||||
.keySize = 2048,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_1,
|
||||
.fwdKeyTypeName = "kt_rsa_pair",
|
||||
.bckKeyTypeName = "kt_rsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 256 - 98,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASEncryFwd,
|
||||
ASDecryBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymEncryptRsaOaepSha384KeySize2048Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymEncrypt_Fun_004
|
||||
int CaseAsymEncryptRsaOaepSha384KeySize2048Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_ed_rsa_oaep_sha384"},
|
||||
.operaMaxKeySize = 2048,
|
||||
.keySize = 2048,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_1,
|
||||
.fwdKeyTypeName = "kt_rsa_pair",
|
||||
.bckKeyTypeName = "kt_rsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 256 - 98,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymEncryptRsaOaepSha384KeySize2048Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymEncrypt_Fun_003
|
||||
int CaseAsymEncryptRsaOaepSha512KeySize4096Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_ed_rsa_oaep_sha512"},
|
||||
.operaMaxKeySize = 4096,
|
||||
.keySize = 4096,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4,
|
||||
.fwdKeyTypeName = "kt_rsa_pub",
|
||||
.bckKeyTypeName = "kt_rsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 512 - 130,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASEncryFwd,
|
||||
ASDecryBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymEncryptRsaOaepSha512KeySize4096Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymEncrypt_Fun_004
|
||||
int CaseAsymEncryptRsaOaepSha512KeySize4096Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_ed_rsa_oaep_sha512"},
|
||||
.operaMaxKeySize = 4096,
|
||||
.keySize = 4096,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4,
|
||||
.fwdKeyTypeName = "kt_rsa_pub",
|
||||
.bckKeyTypeName = "kt_rsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 512 - 130,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymEncryptRsaOaepSha512KeySize4096Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymEncrypt_Fun_006
|
||||
int CaseAsymEncryptRsaNopadKeySize2688Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_ed_rsa_nopad"},
|
||||
.operaMaxKeySize = 2688,
|
||||
.keySize = 2688,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_1,
|
||||
.fwdKeyTypeName = "kt_rsa_pair",
|
||||
.bckKeyTypeName = "kt_rsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 336,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymEncryptRsaNopadKeySize2688Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymEncrypt_Fun_006
|
||||
int CaseAsymEncryptRsaNopadKeySize2688Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_ed_rsa_nopad"},
|
||||
.operaMaxKeySize = 2688,
|
||||
.keySize = 2688,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_1,
|
||||
.fwdKeyTypeName = "kt_rsa_pair",
|
||||
.bckKeyTypeName = "kt_rsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 336,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymEncryptRsaNopadKeySize2688Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymEncrypt_Fun_006
|
||||
int CaseAsymEncryptRsaNopadKeySize4096Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_ed_rsa_nopad"},
|
||||
.operaMaxKeySize = 4096,
|
||||
.keySize = 4096,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4,
|
||||
.fwdKeyTypeName = "kt_rsa_pair",
|
||||
.bckKeyTypeName = "kt_rsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 512,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymEncryptRsaNopadKeySize4096Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymEncrypt_Fun_006
|
||||
int CaseAsymEncryptRsaNopadKeySize4096Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_ed_rsa_nopad"},
|
||||
.operaMaxKeySize = 4096,
|
||||
.keySize = 4096,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4,
|
||||
.fwdKeyTypeName = "kt_rsa_pair",
|
||||
.bckKeyTypeName = "kt_rsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 512,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymEncryptRsaNopadKeySize4096Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymEncrypt_Fun_007
|
||||
int CaseAsymEncryptSm2PkeDataSize64Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_ed_sm2_pke"},
|
||||
.operaMaxKeySize = 256,
|
||||
.keySize = 256,
|
||||
.fwdKeyTypeName = "kt_sm2_pke_pub",
|
||||
.bckKeyTypeName = "kt_sm2_pke_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 64,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymEncryptSm2PkeDataSize64Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymEncrypt_Fun_008
|
||||
int CaseAsymEncryptSm2PkeDataSize64Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_ed_sm2_pke"},
|
||||
.operaMaxKeySize = 256,
|
||||
.keySize = 256,
|
||||
.fwdKeyTypeName = "kt_sm2_pke_pub",
|
||||
.bckKeyTypeName = "kt_sm2_pke_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 64,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymEncryptSm2PkeDataSize64Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymEncrypt_Fun_007
|
||||
int CaseAsymEncryptSm2PkeDataSize470Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_ed_sm2_pke"},
|
||||
.operaMaxKeySize = 256,
|
||||
.keySize = 256,
|
||||
.fwdKeyTypeName = "kt_sm2_pke_pair",
|
||||
.bckKeyTypeName = "kt_sm2_pke_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 470,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymEncryptSm2PkeDataSize470Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymEncrypt_Fun_008
|
||||
int CaseAsymEncryptSm2PkeDataSize470Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_ed_sm2_pke"},
|
||||
.operaMaxKeySize = 256,
|
||||
.keySize = 256,
|
||||
.fwdKeyTypeName = "kt_sm2_pke_pair",
|
||||
.bckKeyTypeName = "kt_sm2_pke_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 470,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymEncryptSm2PkeDataSize470Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymEncrypt_Fun_007
|
||||
int CaseAsymEncryptSm2PkeDataSize1024Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_ed_sm2_pke"},
|
||||
.operaMaxKeySize = 256,
|
||||
.keySize = 256,
|
||||
.fwdKeyTypeName = "kt_sm2_pke_pub",
|
||||
.bckKeyTypeName = "kt_sm2_pke_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 1024,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymEncryptSm2PkeDataSize1024Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymEncrypt_Fun_008
|
||||
int CaseAsymEncryptSm2PkeDataSize1024Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_ed_sm2_pke"},
|
||||
.operaMaxKeySize = 256,
|
||||
.keySize = 256,
|
||||
.fwdKeyTypeName = "kt_sm2_pke_pub",
|
||||
.bckKeyTypeName = "kt_sm2_pke_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 1024,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
ASEncryFwd, ASDecryBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymEncryptSm2PkeDataSize1024Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,839 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include "monad.h"
|
||||
#include "tee_log.h"
|
||||
|
||||
// Crypto_AsymSign_Fun_001
|
||||
int CaseAsymSignRsaV15Sha384KeySize2048Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_rsa_v15_sha384"},
|
||||
.operaMaxKeySize = 2048,
|
||||
.keySize = 2048,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_3,
|
||||
.fwdKeyTypeName = "kt_rsa_pair",
|
||||
.bckKeyTypeName = "kt_rsa_pub",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 48,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd,
|
||||
ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignRsaV15Sha384KeySize2048Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_002
|
||||
int CaseAsymSignRsaV15Sha384KeySize2048Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_rsa_v15_sha384"},
|
||||
.operaMaxKeySize = 2048,
|
||||
.keySize = 2048,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_3,
|
||||
.fwdKeyTypeName = "kt_rsa_pair",
|
||||
.bckKeyTypeName = "kt_rsa_pub",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 48,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignRsaV15Sha384KeySize2048Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_001
|
||||
int CaseAsymSignRsaV15Sha512KeySize4096Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_rsa_v15_sha512"},
|
||||
.operaMaxKeySize = 4096,
|
||||
.keySize = 4096,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4,
|
||||
.fwdKeyTypeName = "kt_rsa_pair",
|
||||
.bckKeyTypeName = "kt_rsa_pub",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 64,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd,
|
||||
ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignRsaV15Sha512KeySize4096Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_002
|
||||
int CaseAsymSignRsaV15Sha512KeySize4096Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_rsa_v15_sha512"},
|
||||
.operaMaxKeySize = 4096,
|
||||
.keySize = 4096,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4,
|
||||
.fwdKeyTypeName = "kt_rsa_pair",
|
||||
.bckKeyTypeName = "kt_rsa_pub",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 64,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignRsaV15Sha512KeySize4096Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_003
|
||||
int CaseAsymSignRsaPssSha384KeySize2048Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_rsa_pss_SHA384"},
|
||||
.operaMaxKeySize = 2048,
|
||||
.keySize = 2048,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_3,
|
||||
.fwdKeyTypeName = "kt_rsa_pair",
|
||||
.bckKeyTypeName = "kt_rsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 48,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd,
|
||||
ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignRsaPssSha384KeySize2048Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_004
|
||||
int CaseAsymSignRsaPssSha384KeySize2048Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_rsa_pss_SHA384"},
|
||||
.operaMaxKeySize = 2048,
|
||||
.keySize = 2048,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_3,
|
||||
.fwdKeyTypeName = "kt_rsa_pair",
|
||||
.bckKeyTypeName = "kt_rsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 48,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignRsaPssSha384KeySize2048Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_003
|
||||
int CaseAsymSignRsaPssSha512KeySize4096Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_rsa_pss_SHA512"},
|
||||
.operaMaxKeySize = 4096,
|
||||
.keySize = 4096,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4,
|
||||
.fwdKeyTypeName = "kt_rsa_pair",
|
||||
.bckKeyTypeName = "kt_rsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 64,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd,
|
||||
ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignRsaPssSha512KeySize4096Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_004
|
||||
int CaseAsymSignRsaPssSha512KeySize4096Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_rsa_pss_SHA512"},
|
||||
.operaMaxKeySize = 4096,
|
||||
.keySize = 4096,
|
||||
.rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4,
|
||||
.fwdKeyTypeName = "kt_rsa_pair",
|
||||
.bckKeyTypeName = "kt_rsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 64,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignRsaPssSha512KeySize4096Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_005
|
||||
int CaseAsymSignEcdsaSha256KeySize256Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_ecdsa_sha256"},
|
||||
.operaMaxKeySize = 521,
|
||||
.keySize = 256,
|
||||
.ecKeyCurve = TEE_ECC_CURVE_NIST_P256,
|
||||
.fwdKeyTypeName = "kt_ecdsa_pair",
|
||||
.bckKeyTypeName = "kt_ecdsa_pub",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 32,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd,
|
||||
ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignEcdsaSha256KeySize256Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_006
|
||||
int CaseAsymSignEcdsaSha256KeySize256Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_ecdsa_sha256"},
|
||||
.operaMaxKeySize = 521,
|
||||
.keySize = 256,
|
||||
.ecKeyCurve = TEE_ECC_CURVE_NIST_P256,
|
||||
.fwdKeyTypeName = "kt_ecdsa_pair",
|
||||
.bckKeyTypeName = "kt_ecdsa_pub",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 32,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignEcdsaSha256KeySize256Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_005
|
||||
int CaseAsymSignEcdsaSha384KeySize384Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_ecdsa_sha384"},
|
||||
.operaMaxKeySize = 521,
|
||||
.keySize = 384,
|
||||
.ecKeyCurve = TEE_ECC_CURVE_NIST_P384,
|
||||
.fwdKeyTypeName = "kt_ecdsa_pair",
|
||||
.bckKeyTypeName = "kt_ecdsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 48,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd,
|
||||
ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignEcdsaSha384KeySize384Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_006
|
||||
int CaseAsymSignEcdsaSha384KeySize384Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_ecdsa_sha384"},
|
||||
.operaMaxKeySize = 521,
|
||||
.keySize = 384,
|
||||
.ecKeyCurve = TEE_ECC_CURVE_NIST_P384,
|
||||
.fwdKeyTypeName = "kt_ecdsa_pair",
|
||||
.bckKeyTypeName = "kt_ecdsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 48,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignEcdsaSha384KeySize384Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_005
|
||||
int CaseAsymSignEcdsaSha512KeySize521Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_ecdsa_sha512"},
|
||||
.operaMaxKeySize = 521,
|
||||
.keySize = 521,
|
||||
.ecKeyCurve = TEE_ECC_CURVE_NIST_P521,
|
||||
.fwdKeyTypeName = "kt_ecdsa_pair",
|
||||
.bckKeyTypeName = "kt_ecdsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 64,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd,
|
||||
ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignEcdsaSha512KeySize521Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_006
|
||||
int CaseAsymSignEcdsaSha512KeySize521Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_ecdsa_sha512"},
|
||||
.operaMaxKeySize = 521,
|
||||
.keySize = 521,
|
||||
.ecKeyCurve = TEE_ECC_CURVE_NIST_P521,
|
||||
.fwdKeyTypeName = "kt_ecdsa_pair",
|
||||
.bckKeyTypeName = "kt_ecdsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 64,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignEcdsaSha512KeySize521Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_007
|
||||
int CaseAsymSignEd25519DataSize64Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_ed25519"},
|
||||
.operaMaxKeySize = 256,
|
||||
.keySize = 256,
|
||||
.ecKeyCurve = TEE_ECC_CURVE_25519,
|
||||
.fwdKeyTypeName = "kt_ed25519_pair",
|
||||
.bckKeyTypeName = "kt_ed25519_pub",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 64,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd,
|
||||
ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignEd25519DataSize64Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_008
|
||||
int CaseAsymSignEd25519DataSize64Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_ed25519"},
|
||||
.operaMaxKeySize = 256,
|
||||
.keySize = 256,
|
||||
.ecKeyCurve = TEE_ECC_CURVE_25519,
|
||||
.fwdKeyTypeName = "kt_ed25519_pair",
|
||||
.bckKeyTypeName = "kt_ed25519_pub",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 64,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignEd25519DataSize64Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_007
|
||||
int CaseAsymSignEd25519DataSize470Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_ed25519"},
|
||||
.operaMaxKeySize = 256,
|
||||
.keySize = 256,
|
||||
.ecKeyCurve = TEE_ECC_CURVE_25519,
|
||||
.fwdKeyTypeName = "kt_ed25519_pair",
|
||||
.bckKeyTypeName = "kt_ed25519_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 470,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd,
|
||||
ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignEd25519DataSize470Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_008
|
||||
int CaseAsymSignEd25519DataSize470Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_ed25519"},
|
||||
.operaMaxKeySize = 256,
|
||||
.keySize = 256,
|
||||
.ecKeyCurve = TEE_ECC_CURVE_25519,
|
||||
.fwdKeyTypeName = "kt_ed25519_pair",
|
||||
.bckKeyTypeName = "kt_ed25519_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 470,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignEd25519DataSize470Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_007
|
||||
int CaseAsymSignEd25519DataSize1270Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_ed25519"},
|
||||
.operaMaxKeySize = 256,
|
||||
.keySize = 256,
|
||||
.ecKeyCurve = TEE_ECC_CURVE_25519,
|
||||
.fwdKeyTypeName = "kt_ed25519_pair",
|
||||
.bckKeyTypeName = "kt_ed25519_pub",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 1270,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd,
|
||||
ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignEd25519DataSize1270Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_008
|
||||
int CaseAsymSignEd25519DataSize1270Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_ed25519"},
|
||||
.operaMaxKeySize = 256,
|
||||
.keySize = 256,
|
||||
.ecKeyCurve = TEE_ECC_CURVE_25519,
|
||||
.fwdKeyTypeName = "kt_ed25519_pair",
|
||||
.bckKeyTypeName = "kt_ed25519_pub",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 1270,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignEd25519DataSize1270Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_007
|
||||
int CaseAsymSignEd25519DataSize4096Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_ed25519"},
|
||||
.operaMaxKeySize = 256,
|
||||
.keySize = 256,
|
||||
.ecKeyCurve = TEE_ECC_CURVE_25519,
|
||||
.fwdKeyTypeName = "kt_ed25519_pair",
|
||||
.bckKeyTypeName = "kt_ed25519_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 4096,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd,
|
||||
ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignEd25519DataSize4096Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_008
|
||||
int CaseAsymSignEd25519DataSize4096Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_ed25519"},
|
||||
.operaMaxKeySize = 256,
|
||||
.keySize = 256,
|
||||
.ecKeyCurve = TEE_ECC_CURVE_25519,
|
||||
.fwdKeyTypeName = "kt_ed25519_pair",
|
||||
.bckKeyTypeName = "kt_ed25519_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 4096,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignEd25519DataSize4096Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_009
|
||||
int CaseAsymSignSm2DsaSm3DataSize32Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_sm2_dsa_sm3"},
|
||||
.operaMaxKeySize = 256,
|
||||
.keySize = 256,
|
||||
.ecKeyCurve = TEE_ECC_CURVE_SM2,
|
||||
.fwdKeyTypeName = "kt_sm2_dsa_pair",
|
||||
.bckKeyTypeName = "kt_sm2_dsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 32,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd,
|
||||
ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignSm2DsaSm3DataSize32Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_010
|
||||
int CaseAsymSignSm2DsaSm3DataSize32Multi(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_sm2_dsa_sm3"},
|
||||
.operaMaxKeySize = 256,
|
||||
.keySize = 256,
|
||||
.ecKeyCurve = TEE_ECC_CURVE_SM2,
|
||||
.fwdKeyTypeName = "kt_sm2_dsa_pair",
|
||||
.bckKeyTypeName = "kt_sm2_dsa_pub",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 32,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
ASSignFwd, ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 9,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignSm2DsaSm3DataSize32Multi success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_AsymSign_Fun_009
|
||||
int CaseAsymSignSm2DsaSm3DataSize128Once(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"AS_sv_sm2_dsa_sm3"},
|
||||
.operaMaxKeySize = 256,
|
||||
.keySize = 256,
|
||||
.ecKeyCurve = TEE_ECC_CURVE_SM2,
|
||||
.fwdKeyTypeName = "kt_sm2_dsa_pair",
|
||||
.bckKeyTypeName = "kt_sm2_dsa_pair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 128,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
ASSignFwd,
|
||||
ASVerifyBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseAsymSignSm2DsaSm3DataSize128Once success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,342 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include "monad.h"
|
||||
#include "tee_log.h"
|
||||
|
||||
// Crypto_DR_Fun7.0.0_001
|
||||
int CaseDRDHKeySize512Pram512DataSize1024(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DR_dh"},
|
||||
.operaMaxKeySize = 512,
|
||||
.keySize = 512,
|
||||
.fwdKeyTypeName = "kt_dh_pair",
|
||||
.bckKeyTypeName = "kt_dh_pair",
|
||||
.dhGenKeySize = 512,
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 1024,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
DRDeriveFwd,
|
||||
DRDeriveBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_JF,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDRDHKeySize512Pram512DataSize1024 success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DR_Fun7.0.0_001
|
||||
int CaseDRDHKeySize1024Pram1024DataSize1024(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DR_dh"},
|
||||
.operaMaxKeySize = 1024,
|
||||
.keySize = 1024,
|
||||
.fwdKeyTypeName = "kt_dh_pair",
|
||||
.bckKeyTypeName = "kt_dh_pair",
|
||||
.dhGenKeySize = 1024,
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 1024,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
DRDeriveFwd,
|
||||
DRDeriveBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_JF,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDRDHKeySize1024Pram1024DataSize1024 success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DR_Fun7.0.0_002
|
||||
int CaseDREcdhNistP224DataSize14(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DR_ecdh"},
|
||||
.operaMaxKeySize = 224,
|
||||
.keySize = 224,
|
||||
.fwdKeyTypeName = "kt_ecdh_pair",
|
||||
.bckKeyTypeName = "kt_ecdh_pair",
|
||||
.ecKeyCurve = TEE_ECC_CURVE_NIST_P224,
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 10000,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
DRDeriveFwd,
|
||||
DRDeriveBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDREcdhNistP224DataSize14 success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DR_Fun7.0.0_002
|
||||
int CaseDREcdhNistP256DataSize128(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DR_ecdh"},
|
||||
.operaMaxKeySize = 521,
|
||||
.keySize = 256,
|
||||
.fwdKeyTypeName = "kt_ecdh_pair",
|
||||
.bckKeyTypeName = "kt_ecdh_pair",
|
||||
.ecKeyCurve = TEE_ECC_CURVE_NIST_P256,
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 128,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
DRDeriveFwd,
|
||||
DRDeriveBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDREcdhNistP256DataSize128 success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DR_Fun7.0.0_002
|
||||
int CaseDREcdhNistP384DataSize512(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DR_ecdh"},
|
||||
.operaMaxKeySize = 521,
|
||||
.keySize = 384,
|
||||
.fwdKeyTypeName = "kt_ecdh_pair",
|
||||
.bckKeyTypeName = "kt_ecdh_pair",
|
||||
.ecKeyCurve = TEE_ECC_CURVE_NIST_P384,
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 512,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
DRDeriveFwd,
|
||||
DRDeriveBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDREcdhNistP384DataSize512 success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DR_Fun7.0.0_002
|
||||
int CaseDREcdhNistP521DataSize1024(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DR_ecdh"},
|
||||
.operaMaxKeySize = 521,
|
||||
.keySize = 521,
|
||||
.fwdKeyTypeName = "kt_ecdh_pair",
|
||||
.bckKeyTypeName = "kt_ecdh_pair",
|
||||
.ecKeyCurve = TEE_ECC_CURVE_NIST_P521,
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 1024,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
DRDeriveFwd,
|
||||
DRDeriveBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDREcdhNistP521DataSize1024 success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DR_Fun7.0.0_002
|
||||
int CaseDREcdhNistP521DataSize4096(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DR_ecdh"},
|
||||
.operaMaxKeySize = 521,
|
||||
.keySize = 521,
|
||||
.fwdKeyTypeName = "kt_ecdh_pair",
|
||||
.bckKeyTypeName = "kt_ecdh_pair",
|
||||
.ecKeyCurve = TEE_ECC_CURVE_NIST_P521,
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 4096,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
DRDeriveFwd,
|
||||
DRDeriveBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDREcdhNistP521DataSize4096 success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DR_Fun7.0.0_002
|
||||
int CaseDREcdhNistP384DataSize10000(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DR_ecdh"},
|
||||
.operaMaxKeySize = 521,
|
||||
.keySize = 384,
|
||||
.fwdKeyTypeName = "kt_ecdh_pair",
|
||||
.bckKeyTypeName = "kt_ecdh_pair",
|
||||
.ecKeyCurve = TEE_ECC_CURVE_NIST_P384,
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 10000,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
DRDeriveFwd,
|
||||
DRDeriveBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDREcdhNistP384DataSize10000 success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DR_Fun7.0.0_003
|
||||
int CaseDRX25519DataSize1024(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DR_x25519"},
|
||||
.operaMaxKeySize = 256,
|
||||
.keySize = 256,
|
||||
.fwdKeyTypeName = "kt_x25519_keypair",
|
||||
.bckKeyTypeName = "kt_x25519_keypair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 1024,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
DRDeriveFwd,
|
||||
DRDeriveBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDRX25519DataSize1024 success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DR_Fun7.0.0_003
|
||||
int CaseDRX25519DataSize4096(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DR_x25519"},
|
||||
.operaMaxKeySize = 256,
|
||||
.keySize = 256,
|
||||
.fwdKeyTypeName = "kt_x25519_keypair",
|
||||
.bckKeyTypeName = "kt_x25519_keypair",
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = 4096,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc, GlbS1S2,
|
||||
DRDeriveFwd,
|
||||
DRDeriveBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 7,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDRX25519DataSize4096 success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,491 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include "monad.h"
|
||||
#include "tee_log.h"
|
||||
|
||||
/*
|
||||
* Case name meaning: Case&&algname&&Compute mode&&Compute times
|
||||
* Compute mode: number of calculateing steps, once means datasize is less than slicesize,
|
||||
multi means datasize is greater than slicesize
|
||||
* Compute times: algorithm calculation times, once means algorithm calculation once,
|
||||
multi means algorithm calculation multi times
|
||||
*/
|
||||
|
||||
// Crypto_DI_Fun_002
|
||||
int CaseDigestSha256OnceOnce(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DI_sha256"},
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = DATA50K_LE64B,
|
||||
.sliceSize = SLICELEN_50K,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc,
|
||||
DIDofinalFwd, DIDofinalBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 6,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDigestSha256OnceOnce success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DI_Fun_004
|
||||
int CaseDigestSha256OnceMulti(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DI_sha256"},
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = DATA50K_LE64B,
|
||||
.sliceSize = SLICELEN_50K,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc,
|
||||
DIDofinalFwd, DIDofinalFwd,
|
||||
DIDofinalBck, DIDofinalBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 8,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDigestSha256OnceMulti success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DI_Fun_001
|
||||
int CaseDigestSha256MultiOnce(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DI_sha256"},
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = DATA50K_GR64B,
|
||||
.sliceSize = SLICELEN_50K,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc,
|
||||
DIUpdateFwd, DIDofinalFwd,
|
||||
DIUpdateBck, DIDofinalBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 8,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDigestSha256MultiOnce success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DI_Fun_003
|
||||
int CaseDigestSha256MultiMulti(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DI_sha256"},
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = DATA50K_GR64B,
|
||||
.sliceSize = SLICELEN_50K,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc,
|
||||
DIUpdateFwd, DIDofinalFwd,
|
||||
DIUpdateFwd, DIDofinalFwd,
|
||||
DIUpdateBck, DIDofinalBck,
|
||||
DIUpdateBck, DIDofinalBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 12,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDigestSha256MultiMulti success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DI_Fun_002
|
||||
int CaseDigestSha384OnceOnce(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DI_sha384"},
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = DATA100K_LE1B,
|
||||
.sliceSize = SLICELEN_100K_GR200B,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc,
|
||||
DIDofinalFwd, DIDofinalBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 6,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDigestSha384OnceOnce success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
// Crypto_DI_Fun_004
|
||||
int CaseDigestSha384OnceMulti(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DI_sha384"},
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = DATA100K_LE1B,
|
||||
.sliceSize = SLICELEN_100K_GR200B,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc,
|
||||
DIDofinalFwd, DIDofinalFwd,
|
||||
DIDofinalBck, DIDofinalBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 8,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDigestSha384OnceMulti success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DI_Fun_001
|
||||
int CaseDigestSha384MultiOnce(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DI_sha384"},
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = DATA100K_GR500B,
|
||||
.sliceSize = SLICELEN_100K_GR200B,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc,
|
||||
DIUpdateFwd, DIDofinalFwd,
|
||||
DIUpdateBck, DIDofinalBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 8,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDigestSha384MultiOnce success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DI_Fun_003
|
||||
int CaseDigestSha384MultiMulti(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DI_sha384"},
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = DATA100K_GR500B,
|
||||
.sliceSize = SLICELEN_100K_GR200B,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc,
|
||||
DIUpdateFwd, DIDofinalFwd,
|
||||
DIUpdateFwd, DIDofinalFwd,
|
||||
DIUpdateBck, DIDofinalBck,
|
||||
DIUpdateBck, DIDofinalBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 12,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDigestSha384MultiMulti success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DI_Fun_002
|
||||
int CaseDigestSha512OnceOnce(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DI_sha512"},
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = DATA250K_LE128B,
|
||||
.sliceSize = SLICELEN_250K_GR200B,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc,
|
||||
DIDofinalFwd, DIDofinalBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 6,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDigestSha512OnceOnce success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DI_Fun_004
|
||||
int CaseDigestSha512OnceMulti(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DI_sha512"},
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = DATA250K_LE128B,
|
||||
.sliceSize = SLICELEN_250K_GR200B,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc,
|
||||
DIDofinalFwd, DIDofinalFwd,
|
||||
DIDofinalBck, DIDofinalBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 8,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDigestSha512OnceMulti success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DI_Fun_001
|
||||
int CaseDigestSha512MultiOnce(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DI_sha512"},
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = DATA250K_GR200B,
|
||||
.sliceSize = SLICELEN_250K_GR200B,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc,
|
||||
DIUpdateFwd, DIDofinalFwd,
|
||||
DIUpdateBck, DIDofinalBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 8,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDigestSha512MultiOnce success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DI_Fun_003
|
||||
int CaseDigestSha512MultiMulti(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DI_sha512"},
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = DATA250K_GR200B,
|
||||
.sliceSize = SLICELEN_250K_GR200B,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc,
|
||||
DIUpdateFwd, DIDofinalFwd,
|
||||
DIUpdateFwd, DIDofinalFwd,
|
||||
DIUpdateBck, DIDofinalBck,
|
||||
DIUpdateBck, DIDofinalBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 12,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDigestSha512MultiMulti success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DI_Fun_002
|
||||
int CaseDigestSM3OnceOnce(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DI_sm3"},
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = DATA500K_LE1B,
|
||||
.sliceSize = SLICELEN_500K,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc,
|
||||
DIDofinalFwd, DIDofinalBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 6,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDigestSM3OnceOnce success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DI_Fun_004
|
||||
int CaseDigestSM3OnceMulti(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DI_sm3"},
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = DATA500K_LE1B,
|
||||
.sliceSize = SLICELEN_500K,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc,
|
||||
DIDofinalFwd, DIDofinalFwd,
|
||||
DIDofinalBck, DIDofinalBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 8,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDigestSM3OnceMulti success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DI_Fun_001
|
||||
int CaseDigestSM3MultiOnce(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DI_sm3"},
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = DATA500K_GR1B,
|
||||
.sliceSize = SLICELEN_500K,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc,
|
||||
DIUpdateFwd, DIDofinalFwd,
|
||||
DIUpdateBck, DIDofinalBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 8,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDigestSM3MultiOnce success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Crypto_DI_Fun_003
|
||||
int CaseDigestSM3MultiMulti(void)
|
||||
{
|
||||
TestVector tv = {
|
||||
.algName = {"DI_sm3"},
|
||||
.fwdEngine = FWDENGINE,
|
||||
.bckEngine = BCKENGINE,
|
||||
.dataSize = DATA500K_GR1B,
|
||||
.sliceSize = SLICELEN_500K,
|
||||
.actions = {
|
||||
IRSetUp,
|
||||
GlbAlloc,
|
||||
DIUpdateFwd, DIDofinalFwd,
|
||||
DIUpdateFwd, DIDofinalFwd,
|
||||
DIUpdateBck, DIDofinalBck,
|
||||
DIUpdateBck, DIDofinalBck,
|
||||
GlbFree,
|
||||
IRTearDown, },
|
||||
.actionsSize = 12,
|
||||
.expRet = ER_OK,
|
||||
};
|
||||
tlogi("---------------********:sliceSize:%d, dataSize:%d\n", tv.sliceSize, tv.dataSize);
|
||||
int ret = MonadRun2(&tv);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadRun2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadRun2 success\n", __func__);
|
||||
tlogi("[%s]:--------------CaseDigestSM3MultiMulti success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,252 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef CASE_HEADER_H_
|
||||
#define CASE_HEADER_H_
|
||||
#include "test_crypto_data.h"
|
||||
#include "monad.h"
|
||||
enum {
|
||||
CASE_PRESET_RESULT = -1,
|
||||
CASE_RAN_FLAG_SET = 1,
|
||||
CASE_RAN_FLAG_CLEAR = 0,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char name[MAX_STRING_NAME_LEN];
|
||||
int (*entry)(void);
|
||||
uint8_t ranFlag;
|
||||
int ret;
|
||||
} CaseEntry;
|
||||
// cases_sym_encrypt_basic_cases.c
|
||||
int CaseSymEncryptAesEcbNopadKeySize128OnceOnce(void);
|
||||
int CaseSymEncryptAesEcbNopadKeySize128OnceMulti(void);
|
||||
int CaseSymEncryptAesEcbNopadKeySize128MultiOnce(void);
|
||||
int CaseSymEncryptAesEcbNopadKeySize128MultiMulti(void);
|
||||
int CaseSymEncryptAesCbcNopadKeySize192OnceOnce(void);
|
||||
int CaseSymEncryptAesCbcNopadKeySize192OnceMulti(void);
|
||||
int CaseSymEncryptAesCbcNopadKeySize192MultiOnce(void);
|
||||
int CaseSymEncryptAesCbcNopadKeySize192MultiMulti(void);
|
||||
int CaseSymEncryptAesCtrKeySize128OnceOnce(void);
|
||||
int CaseSymEncryptAesCtrKeySize128OnceMulti(void);
|
||||
int CaseSymEncryptAesCtrKeySize128MultiOnce(void);
|
||||
int CaseSymEncryptAesCtrKeySize128MultiMulti(void);
|
||||
int CaseSymEncryptAesXtsKeySize256OnceOnce(void);
|
||||
int CaseSymEncryptAesXtsKeySize256OnceMulti(void);
|
||||
int CaseSymEncryptAesXtsKeySize256MultiOnce(void);
|
||||
int CaseSymEncryptAesXtsKeySize256MultiMulti(void);
|
||||
int CaseSymEncryptAesCbcPkcs5KeySize256OnceOnce(void);
|
||||
int CaseSymEncryptAesCbcPkcs5KeySize256OnceMulti(void);
|
||||
int CaseSymEncryptAesCbcPkcs5KeySize256MultiOnce(void);
|
||||
int CaseSymEncryptAesCbcPkcs5KeySize256MultiMulti(void);
|
||||
int CaseSymEncryptSm4CbcNopadKeySize128OnceOnce(void);
|
||||
int CaseSymEncryptSm4CbcNopadKeySize128OnceMulti(void);
|
||||
int CaseSymEncryptSm4CbcNopadKeySize128MultiOnce(void);
|
||||
int CaseSymEncryptSm4CbcNopadKeySize128MultiMulti(void);
|
||||
int CaseSymEncryptSm4CtrKeySize128OnceOnce(void);
|
||||
int CaseSymEncryptSm4CtrKeySize128OnceMulti(void);
|
||||
int CaseSymEncryptSm4CtrKeySize128MultiOnce(void);
|
||||
int CaseSymEncryptSm4CtrKeySize128MultiMulti(void);
|
||||
int CaseSymEncryptSm4Cfb128KeySize128OnceOnce(void);
|
||||
int CaseSymEncryptSm4Cfb128KeySize128OnceMulti(void);
|
||||
int CaseSymEncryptSm4Cfb128KeySize128MultiOnce(void);
|
||||
int CaseSymEncryptSm4Cfb128KeySize128MultiMulti(void);
|
||||
int CaseSymEncryptSm4CbcPkcs7KeySize128OnceOnce(void);
|
||||
int CaseSymEncryptSm4CbcPkcs7KeySize128OnceMulti(void);
|
||||
int CaseSymEncryptSm4CbcPkcs7KeySize128MultiOnce(void);
|
||||
int CaseSymEncryptSm4CbcPkcs7KeySize128MultiMulti(void);
|
||||
|
||||
// cases_ae_crypto_basic_cases.c
|
||||
int CaseAEAesCcmK128N7T32Aad32MultiOnce(void);
|
||||
int CaseAEAesCcmK128N7T32Aad32MultiMulti(void);
|
||||
int CaseAEAesCcmK128N7T32Aad32update0Multi(void);
|
||||
int CaseAEAesCcmK128N7T32Aad32OnceOnce(void);
|
||||
int CaseAEAesCcmK128N7T32Aad32OnceMulti(void);
|
||||
int CaseAEAesCcmK192N8T48Aad288MultiOnce(void);
|
||||
int CaseAEAesCcmK192N8T48Aad288MultiMulti(void);
|
||||
int CaseAEAesCcmK192N8T48Aad288OnceOnce(void);
|
||||
int CaseAEAesCcmK192N8T48Aad288OnceMulti(void);
|
||||
int CaseAEAesCcmK256N9T64Aad512MultiOnce(void);
|
||||
int CaseAEAesCcmK256N9T64Aad512MultiMulti(void);
|
||||
int CaseAEAesCcmK256N13T128Aad512OnceOnce(void);
|
||||
int CaseAEAesCcmK256N13T128Aad512OnceMulti(void);
|
||||
int CaseAEAesCcmK128N10T80Aad4MMultiOnce(void);
|
||||
int CaseAEAesCcmK128N10T80Aad4MMultiMulti(void);
|
||||
int CaseAEAesCcmK192N11T96Aad32MultiOnce(void);
|
||||
int CaseAEAesCcmK192N11T96Aad32MultiMulti(void);
|
||||
int CaseAEAesCcmK256N12T112Aad288MultiOnce(void);
|
||||
int CaseAEAesCcmK256N12T112Aad288MultiMulti(void);
|
||||
int CaseAEAesCcmK128N13T128Aad512MultiOnce(void);
|
||||
int CaseAEAesCcmK128N13T128Aad512MultiMulti(void);
|
||||
int CaseAEAesCcmK128N7T32Aad512EncryptOnlyTAG(void);
|
||||
int CaseAEAesCcmK192N8T64NoAadOnce(void);
|
||||
int CaseAEAesCcmK192N8T64NoAadMulti(void);
|
||||
int CaseAEAesCcmK256N9T64Aad512DecryptOnlyTAG(void);
|
||||
int CaseAEAesGcmK128N7T96Aad32MultiOnce(void);
|
||||
int CaseAEAesGcmK128N7T96Aad32MultiMulti(void);
|
||||
int CaseAEAesGcmK128N7T96Aad32update0Multi(void);
|
||||
int CaseAEAesGcmK128N7T96Aad32OnceOnce(void);
|
||||
int CaseAEAesGcmK128N7T96Aad32OnceMulti(void);
|
||||
int CaseAEAesGcmK192N12T104Aad288MultiOnce(void);
|
||||
int CaseAEAesGcmK192N12T104Aad288MultiMulti(void);
|
||||
int CaseAEAesGcmK192N12T104Aad288OnceOnce(void);
|
||||
int CaseAEAesGcmK192N12T104Aad288OnceMulti(void);
|
||||
int CaseAEAesGcmK256N7T112Aad512MultiOnce(void);
|
||||
int CaseAEAesGcmK256N7T112Aad512MultiMulti(void);
|
||||
int CaseAEAesGcmK256N7T128Aad512OnceOnce(void);
|
||||
int CaseAEAesGcmK256N7T128Aad512OnceMulti(void);
|
||||
int CaseAEAesGcmK128N12T120Aad4MMultiOnce(void);
|
||||
int CaseAEAesGcmK128N12T120Aad4MMultiMulti(void);
|
||||
int CaseAEAesGcmK192N7T128Aad32MultiOnce(void);
|
||||
int CaseAEAesGcmK192N7T128Aad32MultiMulti(void);
|
||||
int CaseAEAesGcmK256N7T112Aad512DecryptOnlyTAG(void);
|
||||
int CaseAEAesGcmK192N12T96NoAadOnce(void);
|
||||
int CaseAEAesGcmK192N12T96NoAadMulti(void);
|
||||
int CaseAEAesGcmK128N7T104Aad512EncryptOnlyTAG(void);
|
||||
int CaseAESM4GcmK128N7T96Aad32MultiOnce(void);
|
||||
int CaseAESM4GcmK128N7T96Aad32MultiMulti(void);
|
||||
int CaseAESM4GcmK128N7T96Aad32OnceOnce(void);
|
||||
int CaseAESM4GcmK128N7T96Aad32OnceMulti(void);
|
||||
int CaseAESM4GcmK128N7T96Aad32update0Multi(void);
|
||||
int CaseAESM4GcmK128N12T104Aad288MultiOnce(void);
|
||||
int CaseAESM4GcmK128N12T104Aad288MultiMulti(void);
|
||||
int CaseAESM4GcmK128N12T104Aad288OnceOnce(void);
|
||||
int CaseAESM4GcmK128N12T104Aad288OnceMulti(void);
|
||||
int CaseAESM4GcmK128N7T112Aad512MultiOnce(void);
|
||||
int CaseAESM4GcmK128N7T112Aad512MultiMulti(void);
|
||||
int CaseAESM4GcmK128N7T128Aad512OnceOnce(void);
|
||||
int CaseAESM4GcmK128N7T128Aad512OnceMulti(void);
|
||||
int CaseAESM4GcmK128N12T120Aad4MMultiOnce(void);
|
||||
int CaseAESM4GcmK128N12T120Aad4MMultiMulti(void);
|
||||
int CaseAESM4GcmK128N7T128Aad32MultiOnce(void);
|
||||
int CaseAESM4GcmK128N7T128Aad32MultiMulti(void);
|
||||
int CaseAESM4GcmK128N7T112Aad512DecryptOnlyTAG(void);
|
||||
int CaseAESM4GcmK128N12T96NoAadOnce(void);
|
||||
int CaseAESM4GcmK128N12T96NoAadMulti(void);
|
||||
int CaseAESM4GcmK128N7T104Aad512EncryptOnlyTAG(void);
|
||||
|
||||
// cases_mac_crypto_basic_cases.c
|
||||
int CaseHmacSha256KeySize64OnceOnce(void);
|
||||
int CaseHmacSha256KeySize64OnceMulti(void);
|
||||
int CaseHmacSha256KeySize64MultiOnce(void);
|
||||
int CaseHmacSha256KeySize64MultiMulti(void);
|
||||
int CaseHmacSha384KeySize1024OnceOnce(void);
|
||||
int CaseHmacSha384KeySize1024OnceMulti(void);
|
||||
int CaseHmacSha384KeySize1024MultiOnce(void);
|
||||
int CaseHmacSha384KeySize1024MultiMulti(void);
|
||||
int CaseHmacSha512KeySize256OnceOnce(void);
|
||||
int CaseHmacSha512KeySize256OnceMulti(void);
|
||||
int CaseHmacSha512KeySize256MultiOnce(void);
|
||||
int CaseHmacSha512KeySize256MultiMulti(void);
|
||||
int CaseHmacSM3KeySize512OnceOnce(void);
|
||||
int CaseHmacSM3KeySize512OnceMulti(void);
|
||||
int CaseHmacSM3KeySize512MultiOnce(void);
|
||||
int CaseHmacSM3KeySize512MultiMulti(void);
|
||||
int CaseHmacSha256KeySize8192OnceOnce(void);
|
||||
int CaseHmacSha256KeySize8192OnceMulti(void);
|
||||
int CaseHmacSha256KeySize8192MultiOnce(void);
|
||||
int CaseHmacSha256KeySize8192MultiMulti(void);
|
||||
int CaseCmacAesCbcNopadKeySize128OnceOnce(void);
|
||||
int CaseCmacAesCbcNopadKeySize128OnceMulti(void);
|
||||
int CaseCmacAesCbcNopadKeySize128MultiOnce(void);
|
||||
int CaseCmacAesCbcNopadKeySize128MultiMulti(void);
|
||||
int CaseCmacAesCbcNopadKeySize192OnceOnce(void);
|
||||
int CaseCmacAesCbcNopadKeySize192OnceMulti(void);
|
||||
int CaseCmacAesCbcNopadKeySize192MultiOnce(void);
|
||||
int CaseCmacAesCbcNopadKeySize192MultiMulti(void);
|
||||
int CaseCmacAesCbcNopadKeySize256OnceOnce(void);
|
||||
int CaseCmacAesCbcNopadKeySize256OnceMulti(void);
|
||||
int CaseCmacAesCbcNopadKeySize256MultiOnce(void);
|
||||
int CaseCmacAesCbcNopadKeySize256MultiMulti(void);
|
||||
|
||||
// cases_asym_crypto_basic_cases.c
|
||||
int CaseAsymEncryptRsaV15KeySize512Once(void);
|
||||
int CaseAsymEncryptRsaV15KeySize2048Once(void);
|
||||
int CaseAsymEncryptRsaV15KeySize2048Multi(void);
|
||||
int CaseAsymEncryptRsaV15KeySize4096Once(void);
|
||||
int CaseAsymEncryptRsaV15KeySize4096Multi(void);
|
||||
int CaseAsymEncryptRsaOaepSha384KeySize2048Once(void);
|
||||
int CaseAsymEncryptRsaOaepSha384KeySize2048Multi(void);
|
||||
int CaseAsymEncryptRsaOaepSha512KeySize4096Once(void);
|
||||
int CaseAsymEncryptRsaOaepSha512KeySize4096Multi(void);
|
||||
int CaseAsymEncryptRsaNopadKeySize2688Once(void);
|
||||
int CaseAsymEncryptRsaNopadKeySize2688Multi(void);
|
||||
int CaseAsymEncryptRsaNopadKeySize4096Once(void);
|
||||
int CaseAsymEncryptRsaNopadKeySize4096Multi(void);
|
||||
int CaseAsymEncryptSm2PkeDataSize64Once(void);
|
||||
int CaseAsymEncryptSm2PkeDataSize64Multi(void);
|
||||
int CaseAsymEncryptSm2PkeDataSize470Once(void);
|
||||
int CaseAsymEncryptSm2PkeDataSize470Multi(void);
|
||||
int CaseAsymEncryptSm2PkeDataSize1024Once(void);
|
||||
int CaseAsymEncryptSm2PkeDataSize1024Multi(void);
|
||||
|
||||
// cases_asym_sign_basic_cases.c
|
||||
int CaseAsymSignRsaV15Sha384KeySize2048Once(void);
|
||||
int CaseAsymSignRsaV15Sha384KeySize2048Multi(void);
|
||||
int CaseAsymSignRsaV15Sha512KeySize4096Once(void);
|
||||
int CaseAsymSignRsaV15Sha512KeySize4096Multi(void);
|
||||
int CaseAsymSignRsaPssSha384KeySize2048Once(void);
|
||||
int CaseAsymSignRsaPssSha384KeySize2048Multi(void);
|
||||
int CaseAsymSignRsaPssSha512KeySize4096Once(void);
|
||||
int CaseAsymSignRsaPssSha512KeySize4096Multi(void);
|
||||
int CaseAsymSignEcdsaSha256KeySize256Once(void);
|
||||
int CaseAsymSignEcdsaSha256KeySize256Multi(void);
|
||||
int CaseAsymSignEcdsaSha384KeySize384Once(void);
|
||||
int CaseAsymSignEcdsaSha384KeySize384Multi(void);
|
||||
int CaseAsymSignEcdsaSha512KeySize521Once(void);
|
||||
int CaseAsymSignEcdsaSha512KeySize521Multi(void);
|
||||
int CaseAsymSignEd25519DataSize64Once(void);
|
||||
int CaseAsymSignEd25519DataSize64Multi(void);
|
||||
int CaseAsymSignEd25519DataSize470Once(void);
|
||||
int CaseAsymSignEd25519DataSize470Multi(void);
|
||||
int CaseAsymSignEd25519DataSize1270Once(void);
|
||||
int CaseAsymSignEd25519DataSize1270Multi(void);
|
||||
int CaseAsymSignEd25519DataSize4096Once(void);
|
||||
int CaseAsymSignEd25519DataSize4096Multi(void);
|
||||
int CaseAsymSignSm2DsaSm3DataSize32Once(void);
|
||||
int CaseAsymSignSm2DsaSm3DataSize32Multi(void);
|
||||
int CaseAsymSignSm2DsaSm3DataSize128Once(void);
|
||||
|
||||
// cases_digest_crypto_basic_cases.c
|
||||
int CaseDigestSha256OnceOnce(void);
|
||||
int CaseDigestSha256OnceMulti(void);
|
||||
int CaseDigestSha256MultiOnce(void);
|
||||
int CaseDigestSha256MultiMulti(void);
|
||||
int CaseDigestSha384OnceOnce(void);
|
||||
int CaseDigestSha384OnceMulti(void);
|
||||
int CaseDigestSha384MultiOnce(void);
|
||||
int CaseDigestSha384MultiMulti(void);
|
||||
int CaseDigestSha512OnceOnce(void);
|
||||
int CaseDigestSha512OnceMulti(void);
|
||||
int CaseDigestSha512MultiOnce(void);
|
||||
int CaseDigestSha512MultiMulti(void);
|
||||
int CaseDigestSM3OnceOnce(void);
|
||||
int CaseDigestSM3OnceMulti(void);
|
||||
int CaseDigestSM3MultiOnce(void);
|
||||
int CaseDigestSM3MultiMulti(void);
|
||||
|
||||
// cases_derive_basic_cases.c
|
||||
int CaseDREcdhNistP224DataSize14(void);
|
||||
int CaseDREcdhNistP256DataSize128(void);
|
||||
int CaseDREcdhNistP384DataSize512(void);
|
||||
int CaseDREcdhNistP521DataSize1024(void);
|
||||
int CaseDREcdhNistP521DataSize4096(void);
|
||||
int CaseDREcdhNistP384DataSize10000(void);
|
||||
int CaseDRDHKeySize512Pram512DataSize1024(void);
|
||||
int CaseDRDHKeySize1024Pram1024DataSize1024(void);
|
||||
int CaseDRX25519DataSize1024(void);
|
||||
int CaseDRX25519DataSize4096(void);
|
||||
|
||||
// cases_entry.c
|
||||
int RunCaseEntryById(uint32_t startId, uint32_t runCnt, uint32_t cf);
|
||||
int RunCaseEntryByName(const char *name, uint32_t runCnt, uint32_t cf);
|
||||
int GetRunCaseResult(uint32_t *runCnt, uint32_t *failCnt, uint32_t *passCnt);
|
||||
#endif // CASE_HEADER_H_
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,586 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include "test_crypto_api_types.h"
|
||||
#include "tee_log.h"
|
||||
|
||||
TestKeyItem g_testKeyItemList[MAX_TEST_KEY_ITEM_LIST_SIZE];
|
||||
size_t g_testKeyItemListSize = 0;
|
||||
|
||||
static int FindKeyItem(IntermediateReprestation *ir)
|
||||
{
|
||||
uint32_t keyType = ir->fwdKeyType;
|
||||
uint32_t keySize = ir->keySize;
|
||||
size_t i;
|
||||
for (i = 0; i < g_testKeyItemListSize; i++) {
|
||||
if (g_testKeyItemList[i].keyType == keyType && g_testKeyItemList[i].keySize == keySize) {
|
||||
tlogi("[%s]:find key item at %u\n", __func__, i);
|
||||
ir->tki = &(g_testKeyItemList[i]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
tlogi("[%s]:could not find key item, g_testKeyItemListSize = %u\n", __func__, g_testKeyItemListSize);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* DH算法Base和Prime参数定义
|
||||
*/
|
||||
static uint8_t g_base512[] = {
|
||||
0xd4, 0x07, 0xa9, 0x80, 0xaf, 0xc2, 0x7a, 0x5b, 0x61, 0x22, 0x76, 0x29, 0x1d, 0x65, 0x52, 0x59,
|
||||
0x7f, 0x4f, 0x17, 0x7a, 0xa1, 0xea, 0x04, 0x02, 0x8c, 0x8b, 0x01, 0x11, 0x72, 0x2b, 0x4d, 0xc3,
|
||||
0x78, 0xc0, 0x08, 0x11, 0x01, 0xcd, 0x45, 0xab, 0xb3, 0x05, 0x56, 0xcd, 0x72, 0x52, 0x16, 0x7c,
|
||||
0x74, 0xf1, 0x00, 0x77, 0xa4, 0xf3, 0x31, 0x83, 0x50, 0xc3, 0xed, 0x3b, 0xb5, 0xb5, 0x5d, 0x43
|
||||
};
|
||||
static uint8_t g_prime512[] = {
|
||||
0xfc, 0xf6, 0xd3, 0x9e, 0x31, 0x88, 0x25, 0x66, 0x30, 0x74, 0x1c, 0x03, 0x85, 0x6e, 0xbd, 0xea,
|
||||
0x02, 0x01, 0x0b, 0x77, 0x43, 0x35, 0xfe, 0x57, 0x9c, 0x60, 0xd5, 0x24, 0x22, 0xbe, 0x99, 0xeb,
|
||||
0x4f, 0x8f, 0x95, 0x77, 0xdc, 0x47, 0x6a, 0x5e, 0x31, 0x21, 0x6e, 0x9c, 0x00, 0x1b, 0x55, 0xa7,
|
||||
0xed, 0xc4, 0xcd, 0xf2, 0x31, 0xd2, 0x44, 0x60, 0x10, 0xd4, 0xb2, 0x6c, 0xb6, 0xf4, 0xb3, 0x73
|
||||
};
|
||||
static uint8_t g_base1024[] = {
|
||||
0xc4, 0x3b, 0x36, 0xc8, 0xe7, 0xa9, 0x60, 0xea, 0x35, 0x80, 0x6a, 0x02, 0x6a, 0x02, 0x02, 0xcb,
|
||||
0x21, 0x24, 0x3d, 0xb8, 0x3d, 0x01, 0x76, 0x63, 0x8a, 0xee, 0x95, 0x50, 0x94, 0x1d, 0x6f, 0x0c,
|
||||
0x6f, 0x84, 0x17, 0x16, 0x24, 0x00, 0x27, 0xe2, 0x01, 0x8a, 0xa8, 0xa4, 0xdf, 0x7e, 0xde, 0xb4,
|
||||
0x49, 0x20, 0x2c, 0x8f, 0x34, 0x3b, 0xa1, 0x4e, 0x6b, 0x02, 0x23, 0x11, 0x42, 0x9a, 0x9c, 0xba,
|
||||
0x22, 0x15, 0x06, 0x1c, 0x26, 0x39, 0x1c, 0xdb, 0x43, 0xd3, 0x2c, 0x75, 0x96, 0xaf, 0x97, 0xcf,
|
||||
0xa9, 0x32, 0xa1, 0xa7, 0x3f, 0x90, 0xa9, 0xa8, 0x1d, 0xb8, 0x48, 0xcc, 0x2e, 0x68, 0xc1, 0xf1,
|
||||
0x71, 0xd2, 0xfb, 0x4f, 0xda, 0x9c, 0x89, 0x02, 0xea, 0x89, 0x9b, 0xa2, 0xe9, 0x33, 0xc4, 0xfe,
|
||||
0x7a, 0x31, 0x39, 0x71, 0x12, 0x18, 0xb9, 0xbe, 0x33, 0x10, 0xcf, 0x1b, 0x65, 0xcb, 0xc1, 0x73
|
||||
};
|
||||
static uint8_t g_prime1024[] = {
|
||||
0xc4, 0xac, 0x0a, 0xd9, 0x6a, 0xf5, 0xb1, 0x93, 0x46, 0x43, 0xac, 0x5b, 0x2e, 0x45, 0x38, 0x29,
|
||||
0x4e, 0x24, 0xde, 0x8f, 0x80, 0x28, 0x6c, 0x4a, 0xef, 0xcb, 0xc2, 0x07, 0xe5, 0xae, 0xec, 0x4f,
|
||||
0x9a, 0x1b, 0x1b, 0x61, 0x35, 0xdb, 0xf9, 0x88, 0x83, 0x61, 0x4e, 0xca, 0x8e, 0x82, 0x43, 0xf9,
|
||||
0x56, 0x9f, 0x4c, 0xb0, 0x28, 0xbc, 0xa9, 0x9a, 0x23, 0x05, 0xbd, 0x08, 0x7d, 0xc6, 0x3b, 0x62,
|
||||
0x8f, 0x2a, 0x96, 0x30, 0xcf, 0x29, 0x6f, 0x1c, 0x18, 0x54, 0x57, 0x9f, 0xcb, 0xf3, 0xb0, 0x85,
|
||||
0xb9, 0xce, 0xea, 0xce, 0x71, 0x7a, 0x16, 0x05, 0xb3, 0xeb, 0xf4, 0xf6, 0x99, 0xd2, 0x7c, 0xe8,
|
||||
0x0e, 0x36, 0x01, 0x3f, 0x87, 0x6c, 0x4a, 0xfc, 0x45, 0x67, 0x09, 0x5c, 0xcb, 0x09, 0x9a, 0x5b,
|
||||
0x96, 0x61, 0xd3, 0x35, 0x1a, 0x04, 0x07, 0xa8, 0x68, 0xe4, 0xc4, 0xb1, 0x3b, 0x11, 0xd7, 0xa3
|
||||
};
|
||||
static uint8_t g_base2048[] = {
|
||||
0xc9, 0x16, 0xa6, 0x54, 0x91, 0xa7, 0x1c, 0xdf, 0x9b, 0xf9, 0x59, 0x07, 0x95, 0x06, 0x4f, 0xfa,
|
||||
0x95, 0x79, 0xc5, 0x20, 0x47, 0xa4, 0x75, 0xce, 0x49, 0xb5, 0x3c, 0xfa, 0x91, 0xd4, 0xd2, 0xb5,
|
||||
0xe5, 0x6b, 0x36, 0x24, 0x5f, 0x90, 0x8e, 0xfb, 0x7a, 0x1b, 0x41, 0xf7, 0x18, 0x41, 0xfc, 0x7b,
|
||||
0xa5, 0xb4, 0xc3, 0xe1, 0x71, 0xb4, 0x66, 0x54, 0x02, 0x0a, 0xd3, 0xd9, 0xd2, 0x9d, 0xe6, 0x18,
|
||||
0x6d, 0x2a, 0xb7, 0xdb, 0x45, 0xbe, 0xc1, 0x83, 0x7f, 0x94, 0x5b, 0xd7, 0xd8, 0x98, 0xd2, 0xcf,
|
||||
0x54, 0x38, 0x39, 0xda, 0x90, 0x86, 0xcc, 0xab, 0x0f, 0x15, 0xf8, 0xb8, 0xbf, 0xde, 0x50, 0x07,
|
||||
0x74, 0x45, 0x84, 0x4c, 0x2f, 0x08, 0xb1, 0x2f, 0x40, 0x49, 0x9c, 0xaf, 0xb6, 0xd1, 0x6c, 0xe3,
|
||||
0x45, 0xbf, 0xf1, 0x63, 0xcc, 0x77, 0x66, 0x5d, 0x45, 0x35, 0xb9, 0x0a, 0xac, 0x74, 0x14, 0x91,
|
||||
0x64, 0x1b, 0x34, 0x50, 0xb4, 0xa0, 0x1e, 0xd9, 0xa9, 0x62, 0x56, 0x57, 0xcb, 0x73, 0x3c, 0x96,
|
||||
0x5f, 0x86, 0x7f, 0xc3, 0x66, 0xbf, 0xac, 0x79, 0x21, 0x51, 0x14, 0x3f, 0x37, 0x29, 0xbe, 0x96,
|
||||
0xc8, 0xee, 0xf1, 0xaf, 0x4e, 0xc7, 0x9f, 0x83, 0x20, 0xe7, 0xb5, 0xb2, 0x52, 0x57, 0xcc, 0xa8,
|
||||
0xb0, 0xf2, 0x4d, 0x88, 0x3e, 0x71, 0xfb, 0xd7, 0x45, 0x4d, 0x96, 0x0b, 0xcb, 0x24, 0x0a, 0x88,
|
||||
0x4f, 0xaf, 0xe8, 0x96, 0x79, 0x87, 0x14, 0xf8, 0x1e, 0x3d, 0xf7, 0x2c, 0x48, 0xf7, 0x0e, 0x52,
|
||||
0x4e, 0x3d, 0xcb, 0xeb, 0x57, 0x54, 0xb9, 0x90, 0xe1, 0x14, 0x5c, 0x36, 0x7d, 0xc0, 0xa3, 0x5f,
|
||||
0xf4, 0xfd, 0xf6, 0x33, 0x23, 0x7e, 0xf2, 0xd0, 0xff, 0x0d, 0xe0, 0xe2, 0xa3, 0xcc, 0x81, 0x86,
|
||||
0xbc, 0xde, 0x67, 0x83, 0x03, 0xd6, 0xfa, 0x5b, 0x42, 0xd3, 0x1f, 0xfe, 0xd2, 0x0f, 0x2b, 0x1b
|
||||
};
|
||||
static uint8_t g_prime2048[] = {
|
||||
0xce, 0xd3, 0x02, 0x09, 0x7d, 0xe5, 0x34, 0xf5, 0x3f, 0x14, 0x2e, 0x7b, 0x3e, 0x15, 0x4c, 0x66,
|
||||
0x2c, 0xe1, 0xf0, 0xb7, 0x40, 0x72, 0x68, 0xfa, 0xad, 0xa6, 0xd5, 0xd9, 0x55, 0x1e, 0x7e, 0xfd,
|
||||
0x06, 0xbc, 0x4f, 0xb8, 0x27, 0xe9, 0x22, 0x3d, 0x17, 0xfa, 0x4d, 0x8c, 0x8b, 0x8e, 0xce, 0xf6,
|
||||
0xc9, 0x49, 0x38, 0x74, 0xa2, 0x77, 0x3b, 0x9a, 0xe1, 0xc0, 0xa7, 0xc8, 0x83, 0xf9, 0xdc, 0xa7,
|
||||
0x9a, 0x12, 0xc5, 0x19, 0x5c, 0xfb, 0x40, 0x0c, 0x08, 0x57, 0xa1, 0xf7, 0x8d, 0xf2, 0x10, 0x83,
|
||||
0xe8, 0xe7, 0x8a, 0xc1, 0x0c, 0x59, 0xa1, 0xa3, 0x77, 0xb1, 0x9f, 0x0d, 0x0f, 0xf8, 0x27, 0xdd,
|
||||
0xdc, 0xed, 0xbf, 0x04, 0x91, 0xa3, 0x00, 0x19, 0x08, 0x2d, 0x7c, 0xc9, 0xda, 0xfb, 0x05, 0x31,
|
||||
0xf5, 0x34, 0x0d, 0xaa, 0xd3, 0xbb, 0xc0, 0x5b, 0xfb, 0xad, 0x32, 0x6b, 0x98, 0x00, 0x17, 0x01,
|
||||
0x39, 0x61, 0x0e, 0x03, 0x2e, 0xf6, 0x60, 0x30, 0x7b, 0xb9, 0xeb, 0x39, 0x60, 0x1b, 0xc4, 0x7f,
|
||||
0xe5, 0xcb, 0x5f, 0xc3, 0xb0, 0x79, 0xdb, 0x04, 0xd2, 0x9a, 0x11, 0x95, 0x3e, 0xa4, 0x33, 0x61,
|
||||
0x8e, 0x94, 0x22, 0x9b, 0x0a, 0xd0, 0xfb, 0xda, 0x07, 0xc7, 0x34, 0xfb, 0xa9, 0x94, 0xc8, 0x31,
|
||||
0x03, 0xe1, 0x92, 0xac, 0x86, 0xfc, 0x45, 0xe3, 0x79, 0x0b, 0x9e, 0x29, 0x63, 0xe8, 0xcf, 0x26,
|
||||
0x05, 0xb3, 0x6e, 0xa9, 0xae, 0x9d, 0xe3, 0xdc, 0x03, 0x43, 0x26, 0xdf, 0x7e, 0x8b, 0xae, 0xcb,
|
||||
0xe8, 0x09, 0x04, 0x25, 0xdd, 0x42, 0xb8, 0x59, 0x44, 0xec, 0xc1, 0xc7, 0xbf, 0x78, 0x50, 0x31,
|
||||
0xec, 0x6e, 0xa5, 0x5f, 0xe4, 0x4f, 0x79, 0x7b, 0xf3, 0xbf, 0x03, 0xd3, 0xa9, 0x7b, 0x7c, 0x70,
|
||||
0xa2, 0x5f, 0xdb, 0x86, 0x96, 0xfa, 0xd1, 0x3f, 0x43, 0xc5, 0xd2, 0x2a, 0xf8, 0xf3, 0x3c, 0x7b
|
||||
};
|
||||
|
||||
// ecc curve value
|
||||
static TEE_Attribute g_eccCurveAttrNistP192 = {
|
||||
.attributeID = TEE_ATTR_ECC_CURVE,
|
||||
.content = {
|
||||
.value = {
|
||||
.a = TEE_ECC_CURVE_NIST_P192,
|
||||
.b = 0,
|
||||
},
|
||||
},
|
||||
};
|
||||
static TEE_Attribute g_eccCurveAttrNistP224 = {
|
||||
.attributeID = TEE_ATTR_ECC_CURVE,
|
||||
.content = {
|
||||
.value = {
|
||||
.a = TEE_ECC_CURVE_NIST_P224,
|
||||
.b = 0,
|
||||
},
|
||||
},
|
||||
};
|
||||
static TEE_Attribute g_eccCurveAttrNistP256 = {
|
||||
.attributeID = TEE_ATTR_ECC_CURVE,
|
||||
.content = {
|
||||
.value = {
|
||||
.a = TEE_ECC_CURVE_NIST_P256,
|
||||
.b = 0,
|
||||
},
|
||||
},
|
||||
};
|
||||
static TEE_Attribute g_eccCurveAttrNistP384 = {
|
||||
.attributeID = TEE_ATTR_ECC_CURVE,
|
||||
.content = {
|
||||
.value = {
|
||||
.a = TEE_ECC_CURVE_NIST_P384,
|
||||
.b = 0,
|
||||
},
|
||||
},
|
||||
};
|
||||
static TEE_Attribute g_eccCurveAttrNistP521 = {
|
||||
.attributeID = TEE_ATTR_ECC_CURVE,
|
||||
.content = {
|
||||
.value = {
|
||||
.a = TEE_ECC_CURVE_NIST_P521,
|
||||
.b = 0,
|
||||
},
|
||||
},
|
||||
};
|
||||
static TEE_Attribute g_eccCurveAttrSM2 = {
|
||||
.attributeID = TEE_ATTR_ECC_CURVE,
|
||||
.content = {
|
||||
.value = {
|
||||
.a = TEE_ECC_CURVE_SM2,
|
||||
.b = 0,
|
||||
},
|
||||
},
|
||||
};
|
||||
static TEE_Attribute g_eccCurveAttr25519 = {
|
||||
.attributeID = TEE_ATTR_ECC_CURVE,
|
||||
.content = {
|
||||
.value = {
|
||||
.a = TEE_ECC_CURVE_25519,
|
||||
.b = 0,
|
||||
},
|
||||
},
|
||||
};
|
||||
// dh gen params
|
||||
#define DH_GEN_PARAMS_CNT 3
|
||||
static TEE_Attribute g_dhGenParams512[DH_GEN_PARAMS_CNT] = {
|
||||
{
|
||||
.attributeID = TEE_ATTR_DH_BASE,
|
||||
.content = {
|
||||
.ref = {
|
||||
.buffer = g_base512,
|
||||
.length = sizeof(g_base512)
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
.attributeID = TEE_ATTR_DH_PRIME,
|
||||
.content = {
|
||||
.ref = {
|
||||
.buffer = g_prime512,
|
||||
.length = sizeof(g_prime512)
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
.attributeID = TEE_ATTR_DH_X_BITS,
|
||||
.content = {
|
||||
.value = {
|
||||
.a = 512,
|
||||
.b = 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
static TEE_Attribute g_dhGenParams1024[DH_GEN_PARAMS_CNT] = {
|
||||
{
|
||||
.attributeID = TEE_ATTR_DH_BASE,
|
||||
.content = {
|
||||
.ref = {
|
||||
.buffer = g_base1024,
|
||||
.length = sizeof(g_base1024)
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
.attributeID = TEE_ATTR_DH_PRIME,
|
||||
.content = {
|
||||
.ref = {
|
||||
.buffer = g_prime1024,
|
||||
.length = sizeof(g_prime1024)
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
.attributeID = TEE_ATTR_DH_X_BITS,
|
||||
.content = {
|
||||
.value = {
|
||||
.a = 1024,
|
||||
.b = 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
static TEE_Attribute g_dhGenParams2048[DH_GEN_PARAMS_CNT] = {
|
||||
{
|
||||
.attributeID = TEE_ATTR_DH_BASE,
|
||||
.content = {
|
||||
.ref = {
|
||||
.buffer = g_base2048,
|
||||
.length = sizeof(g_base2048)
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
.attributeID = TEE_ATTR_DH_PRIME,
|
||||
.content = {
|
||||
.ref = {
|
||||
.buffer = g_prime2048,
|
||||
.length = sizeof(g_prime2048)
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
.attributeID = TEE_ATTR_DH_X_BITS,
|
||||
.content = {
|
||||
.value = {
|
||||
.a = 2048,
|
||||
.b = 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
// rsa gen pulibc_exponent params
|
||||
static uint8_t g_e0[] = {0x01, 0x00, 0x01};
|
||||
static uint8_t g_e1[] = {0x0D, 0xBA, 0xA9};
|
||||
static uint8_t g_e2[] = {0x01, 0x1A, 0x73};
|
||||
static uint8_t g_e3[] = {0x01, 0x25, 0xA1};
|
||||
static uint8_t g_e4[] = {0x89, 0x95, 0x19};
|
||||
static TEE_Attribute g_rsaPubExpAttr0 = {
|
||||
.attributeID = TEE_ATTR_RSA_PUBLIC_EXPONENT,
|
||||
.content = {
|
||||
.ref = {
|
||||
.buffer = g_e0,
|
||||
.length = sizeof(g_e0)
|
||||
},
|
||||
},
|
||||
};
|
||||
static TEE_Attribute g_rsaPubExpAttr1 = {
|
||||
.attributeID = TEE_ATTR_RSA_PUBLIC_EXPONENT,
|
||||
.content = {
|
||||
.ref = {
|
||||
.buffer = g_e1,
|
||||
.length = sizeof(g_e1)
|
||||
},
|
||||
},
|
||||
};
|
||||
static TEE_Attribute g_rsaPubExpAttr2 = {
|
||||
.attributeID = TEE_ATTR_RSA_PUBLIC_EXPONENT,
|
||||
.content = {
|
||||
.ref = {
|
||||
.buffer = g_e2,
|
||||
.length = sizeof(g_e2)
|
||||
},
|
||||
},
|
||||
};
|
||||
static TEE_Attribute g_rsaPubExpAttr3 = {
|
||||
.attributeID = TEE_ATTR_RSA_PUBLIC_EXPONENT,
|
||||
.content = {
|
||||
.ref = {
|
||||
.buffer = g_e3,
|
||||
.length = sizeof(g_e3)
|
||||
},
|
||||
},
|
||||
};
|
||||
static TEE_Attribute g_rsaPubExpAttr4 = {
|
||||
.attributeID = TEE_ATTR_RSA_PUBLIC_EXPONENT,
|
||||
.content = {
|
||||
.ref = {
|
||||
.buffer = g_e4,
|
||||
.length = sizeof(g_e4)
|
||||
},
|
||||
},
|
||||
};
|
||||
typedef struct {
|
||||
char name[MAX_STRING_NAME_LEN];
|
||||
uint32_t needParamsType;
|
||||
TEE_Attribute *params;
|
||||
uint32_t paramCount;
|
||||
uint32_t dhKeySize;
|
||||
uint32_t ecCurve;
|
||||
uint32_t rsaPubExpId;
|
||||
} KeyGenParamsMap;
|
||||
static KeyGenParamsMap g_keyGenParamsMap[] = {
|
||||
// NEED_RSA_EXP_MAYBE
|
||||
{
|
||||
.name = {"default null params"},
|
||||
.needParamsType = NEED_NO_GEN_PARAMS,
|
||||
.dhKeySize = 0,
|
||||
.ecCurve = 0,
|
||||
.rsaPubExpId = 0,
|
||||
|
||||
.params = NULL,
|
||||
.paramCount = 0,
|
||||
},
|
||||
// NEED_DH_BASE_PRIME_XBITS
|
||||
{
|
||||
.name = {"dh bash prime xbits 512"},
|
||||
.needParamsType = NEED_DH_BASE_PRIME_XBITS,
|
||||
.dhKeySize = 512,
|
||||
.ecCurve = 0,
|
||||
.rsaPubExpId = 0,
|
||||
|
||||
.params = &(g_dhGenParams512[0]),
|
||||
.paramCount = 3,
|
||||
},
|
||||
{
|
||||
.name = {"dh bash prime xbits 1024"},
|
||||
.needParamsType = NEED_DH_BASE_PRIME_XBITS,
|
||||
.dhKeySize = 1024,
|
||||
.ecCurve = 0,
|
||||
.rsaPubExpId = 0,
|
||||
|
||||
.params = &(g_dhGenParams1024[0]),
|
||||
.paramCount = 3,
|
||||
},
|
||||
{
|
||||
.name = {"dh bash prime xbits 2048"},
|
||||
.needParamsType = NEED_DH_BASE_PRIME_XBITS,
|
||||
.dhKeySize = 2048,
|
||||
.ecCurve = 0,
|
||||
.rsaPubExpId = 0,
|
||||
|
||||
.params = &(g_dhGenParams2048[0]),
|
||||
.paramCount = 3,
|
||||
},
|
||||
// NEED_GEN_ECC_CURVE
|
||||
{
|
||||
.name = {"ecc curve nist p192"},
|
||||
.needParamsType = NEED_GEN_ECC_CURVE,
|
||||
.dhKeySize = 0,
|
||||
.ecCurve = TEE_ECC_CURVE_NIST_P192,
|
||||
.rsaPubExpId = 0,
|
||||
|
||||
.params = &g_eccCurveAttrNistP192,
|
||||
.paramCount = 1,
|
||||
|
||||
},
|
||||
{
|
||||
.name = {"ecc curve nist p224"},
|
||||
.needParamsType = NEED_GEN_ECC_CURVE,
|
||||
.dhKeySize = 0,
|
||||
.ecCurve = TEE_ECC_CURVE_NIST_P224,
|
||||
.rsaPubExpId = 0,
|
||||
|
||||
.params = &g_eccCurveAttrNistP224,
|
||||
.paramCount = 1,
|
||||
|
||||
},
|
||||
{
|
||||
.name = {"ecc curve nist p256"},
|
||||
.needParamsType = NEED_GEN_ECC_CURVE,
|
||||
.dhKeySize = 0,
|
||||
.ecCurve = TEE_ECC_CURVE_NIST_P256,
|
||||
.rsaPubExpId = 0,
|
||||
|
||||
.params = &g_eccCurveAttrNistP256,
|
||||
.paramCount = 1,
|
||||
},
|
||||
{
|
||||
.name = {"ecc curve nist p384"},
|
||||
.needParamsType = NEED_GEN_ECC_CURVE,
|
||||
.dhKeySize = 0,
|
||||
.ecCurve = TEE_ECC_CURVE_NIST_P384,
|
||||
.rsaPubExpId = 0,
|
||||
|
||||
.params = &g_eccCurveAttrNistP384,
|
||||
.paramCount = 1,
|
||||
},
|
||||
{
|
||||
.name = {"ecc curve nist p521"},
|
||||
.needParamsType = NEED_GEN_ECC_CURVE,
|
||||
.dhKeySize = 0,
|
||||
.ecCurve = TEE_ECC_CURVE_NIST_P521,
|
||||
.rsaPubExpId = 0,
|
||||
|
||||
.params = &g_eccCurveAttrNistP521,
|
||||
.paramCount = 1,
|
||||
|
||||
},
|
||||
{
|
||||
.name = {"ecc curve sm2"},
|
||||
.needParamsType = NEED_GEN_ECC_CURVE,
|
||||
.dhKeySize = 0,
|
||||
.ecCurve = TEE_ECC_CURVE_SM2,
|
||||
.rsaPubExpId = 0,
|
||||
|
||||
.params = &g_eccCurveAttrSM2,
|
||||
.paramCount = 1,
|
||||
},
|
||||
{
|
||||
.name = {"ecc curve 25519"},
|
||||
.needParamsType = NEED_GEN_ECC_CURVE,
|
||||
.dhKeySize = 0,
|
||||
.ecCurve = TEE_ECC_CURVE_25519,
|
||||
.rsaPubExpId = 0,
|
||||
|
||||
.params = &g_eccCurveAttr25519,
|
||||
.paramCount = 1,
|
||||
},
|
||||
// NEED_RSA_EXP_MAYBE
|
||||
{
|
||||
.name = {"rsa key gen params null"},
|
||||
.needParamsType = NEED_RSA_EXP_MAYBE,
|
||||
.dhKeySize = 0,
|
||||
.ecCurve = 0,
|
||||
.rsaPubExpId = 0,
|
||||
|
||||
.params = NULL,
|
||||
.paramCount = 0,
|
||||
},
|
||||
{
|
||||
.name = {"rsa key gen params attr0"},
|
||||
.needParamsType = NEED_RSA_EXP_MAYBE,
|
||||
.dhKeySize = 0,
|
||||
.ecCurve = 0,
|
||||
.rsaPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_0,
|
||||
|
||||
.params = &g_rsaPubExpAttr0,
|
||||
.paramCount = 1,
|
||||
},
|
||||
{
|
||||
.name = {"rsa key gen params attr1"},
|
||||
.needParamsType = NEED_RSA_EXP_MAYBE,
|
||||
.dhKeySize = 0,
|
||||
.ecCurve = 0,
|
||||
.rsaPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_1,
|
||||
|
||||
.params = &g_rsaPubExpAttr1,
|
||||
.paramCount = 1,
|
||||
},
|
||||
{
|
||||
.name = {"rsa key gen params attr2"},
|
||||
.needParamsType = NEED_RSA_EXP_MAYBE,
|
||||
.dhKeySize = 0,
|
||||
.ecCurve = 0,
|
||||
.rsaPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_2,
|
||||
|
||||
.params = &g_rsaPubExpAttr2,
|
||||
.paramCount = 1,
|
||||
},
|
||||
{
|
||||
.name = {"rsa key gen params attr3"},
|
||||
.needParamsType = NEED_RSA_EXP_MAYBE,
|
||||
.dhKeySize = 0,
|
||||
.ecCurve = 0,
|
||||
.rsaPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_3,
|
||||
|
||||
.params = &g_rsaPubExpAttr3,
|
||||
.paramCount = 1,
|
||||
},
|
||||
{
|
||||
.name = {"rsa key gen params attr4"},
|
||||
.needParamsType = NEED_RSA_EXP_MAYBE,
|
||||
.dhKeySize = 0,
|
||||
.ecCurve = 0,
|
||||
.rsaPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4,
|
||||
|
||||
.params = &g_rsaPubExpAttr4,
|
||||
.paramCount = 1,
|
||||
},
|
||||
};
|
||||
size_t g_keyGenParamsMapSize = sizeof(g_keyGenParamsMap) / sizeof(g_keyGenParamsMap[0]);
|
||||
|
||||
static int SetGenKeyParams(IntermediateReprestation *ir, TEE_Attribute **params, uint32_t *paramCount)
|
||||
{
|
||||
uint32_t needParamsType = ir->fwdKeyMap->needGenParams;
|
||||
uint32_t dhKeySize = ir->dhGenKeySize;
|
||||
uint32_t ecCurve = ir->ecKeyCurve;
|
||||
uint32_t rsaPubExpId = ir->rsaGenPubExpId;
|
||||
|
||||
uint32_t i;
|
||||
for (i = 0; i < g_keyGenParamsMapSize; i++) {
|
||||
if (g_keyGenParamsMap[i].needParamsType == needParamsType &&
|
||||
g_keyGenParamsMap[i].dhKeySize == dhKeySize &&
|
||||
g_keyGenParamsMap[i].ecCurve == ecCurve &&
|
||||
g_keyGenParamsMap[i].rsaPubExpId == rsaPubExpId) {
|
||||
tlogi("[%s]:find key gen params map:%s\n", __func__, g_keyGenParamsMap[i].name);
|
||||
*params = g_keyGenParamsMap[i].params;
|
||||
*paramCount = g_keyGenParamsMap[i].paramCount;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
tloge("[%s]:cound not find key gen params\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
static int GenerateKeyItem(IntermediateReprestation *ir)
|
||||
{
|
||||
uint32_t keyType = ir->genKeyType;
|
||||
uint32_t keySize = ir->keySize;
|
||||
tlogi("[%s]:keyType[0x%x].keySize[0x%x]\n", __func__, keyType, keySize);
|
||||
int ret = TEE_AllocateTransientObject(keyType, keySize,
|
||||
&(g_testKeyItemList[g_testKeyItemListSize].keyObjList[0]));
|
||||
if (ret != TEE_SUCCESS) {
|
||||
tloge("[%s]:allocate key object0 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
ret = TEE_AllocateTransientObject(keyType, keySize,
|
||||
&(g_testKeyItemList[g_testKeyItemListSize].keyObjList[1]));
|
||||
if (ret != TEE_SUCCESS) {
|
||||
tloge("[%s]:allocate key object1 failed\n", __func__);
|
||||
TEE_FreeTransientObject(g_testKeyItemList[g_testKeyItemListSize].keyObjList[0]);
|
||||
return -1;
|
||||
}
|
||||
TEE_Attribute *params = NULL;
|
||||
uint32_t paramCount = 0;
|
||||
int ret0 = SetGenKeyParams(ir, ¶ms, ¶mCount);
|
||||
int ret1 = TEE_GenerateKey(g_testKeyItemList[g_testKeyItemListSize].keyObjList[0],
|
||||
keySize, params, paramCount);
|
||||
int ret2 = TEE_GenerateKey(g_testKeyItemList[g_testKeyItemListSize].keyObjList[1],
|
||||
keySize, params, paramCount);
|
||||
if (ret0 != 0 || ret1 != 0 || ret2 != 0) {
|
||||
tloge("[%s]:generte key failed, ret0 = 0x%x, ret2 = 0x%x, ret3 = 0x%x\n", __func__,
|
||||
ret0, ret1, ret2);
|
||||
ret = -1;
|
||||
goto error1;
|
||||
}
|
||||
tlogi("[%s]:generte key success\n", __func__);
|
||||
|
||||
ir->tki = &(g_testKeyItemList[g_testKeyItemListSize]);
|
||||
|
||||
g_testKeyItemListSize++;
|
||||
tlogi("[%s]:GenerateKeyItem success\n", __func__);
|
||||
return 0;
|
||||
|
||||
error1:
|
||||
ir->tki = NULL;
|
||||
TEE_FreeTransientObject(g_testKeyItemList[g_testKeyItemListSize].keyObjList[0]);
|
||||
TEE_FreeTransientObject(g_testKeyItemList[g_testKeyItemListSize].keyObjList[1]);
|
||||
tloge("[%s]:generate test key item failed\n", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int GetOrGenIRTestKeys(IntermediateReprestation *ir)
|
||||
{
|
||||
ir->tki = NULL;
|
||||
int ret = FindKeyItem(ir);
|
||||
if (ret == 0) {
|
||||
tlogi("[%s]:find exist test key item and return\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
tlogi("[%s]:could not find key, need to generate.\n", __func__);
|
||||
ret = GenerateKeyItem(ir);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:GenerateKeyItem failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef TEST_CRYPTO_DATA_H
|
||||
#define TEST_CRYPTO_DATA_H
|
||||
#include "stddef.h"
|
||||
#include "test_crypto_api_types.h"
|
||||
// alg_map_data.c
|
||||
AlgMapInfo *FindAlgMapInfo(char *algName);
|
||||
KeyTypeMapInfo *FindKeyTypeValue(char *keyTypeName);
|
||||
|
||||
// key_object_database.c
|
||||
int GetOrGenIRTestKeys(IntermediateReprestation *ir);
|
||||
#endif // end TEST_CRYPTO_DATA_H
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef MONAD_H
|
||||
#define MONAD_H
|
||||
#include "test_crypto_api_types.h"
|
||||
#include "test_crypto_data.h"
|
||||
#include "tee_crypto_api.h"
|
||||
// monad_run.c
|
||||
int MonadRun2(TestVector *tv);
|
||||
|
||||
// monad_actions.c
|
||||
// ir init
|
||||
int IRSetUp(IntermediateReprestation *ir);
|
||||
int IRTearDown(IntermediateReprestation *ir);
|
||||
// common operations
|
||||
int GlbFree(IntermediateReprestation *ir);
|
||||
int GlbAlloc(IntermediateReprestation *ir);
|
||||
int GlbGetInfo(IntermediateReprestation *ir);
|
||||
int GlbGetInfoMulti(IntermediateReprestation *ir);
|
||||
int GlbReset(IntermediateReprestation *ir);
|
||||
int GlbS1S2(IntermediateReprestation *ir);
|
||||
int GlbS1S2Null(IntermediateReprestation *ir);
|
||||
int GlbCopy(IntermediateReprestation *ir);
|
||||
int GlbCopyRpl(IntermediateReprestation *ir);
|
||||
int GlbIsAlgSprt(IntermediateReprestation *ir);
|
||||
// digest operations
|
||||
int DIUpdateFwd(IntermediateReprestation *ir);
|
||||
int DIDofinalFwd(IntermediateReprestation *ir);
|
||||
int DIUpdateBck(IntermediateReprestation *ir);
|
||||
int DIDofinalBck(IntermediateReprestation *ir);
|
||||
// symmetric cipher operations
|
||||
int SCInitFwd(IntermediateReprestation *ir);
|
||||
int SCUpdateFwd(IntermediateReprestation *ir);
|
||||
int SCDofinalFwd(IntermediateReprestation *ir);
|
||||
int SCInitBck(IntermediateReprestation *ir);
|
||||
int SCUpdateBck(IntermediateReprestation *ir);
|
||||
int SCDofinalBck(IntermediateReprestation *ir);
|
||||
// mac operations
|
||||
int MInitFwd(IntermediateReprestation *ir);
|
||||
int MUpdateFwd(IntermediateReprestation *ir);
|
||||
int MComputeFwd(IntermediateReprestation *ir);
|
||||
int MInitBck(IntermediateReprestation *ir);
|
||||
int MUpdateBck(IntermediateReprestation *ir);
|
||||
int MCapareBck(IntermediateReprestation *ir);
|
||||
// ae opeartions
|
||||
int AEInitFwd(IntermediateReprestation *ir);
|
||||
int AEUpdateAadFwd(IntermediateReprestation *ir);
|
||||
int AEUpdateAadMtlFwd(IntermediateReprestation *ir);
|
||||
int AEUpdateFwd(IntermediateReprestation *ir);
|
||||
int AEUpdate0Fwd(IntermediateReprestation *ir);
|
||||
int AEInitBck(IntermediateReprestation *ir);
|
||||
int AEUpdateAadBck(IntermediateReprestation *ir);
|
||||
int AEUpdateAadMtlBck(IntermediateReprestation *ir);
|
||||
int AEUpdateBck(IntermediateReprestation *ir);
|
||||
int AEUpdate0Bck(IntermediateReprestation *ir);
|
||||
int AEEncFinalFwd(IntermediateReprestation *ir);
|
||||
int AEEncFinalOmtFwd(IntermediateReprestation *ir);
|
||||
int AEDoFinalBck(IntermediateReprestation *ir);
|
||||
int AEDoFinalOmtBck(IntermediateReprestation *ir);
|
||||
// asymmetric crypto operations
|
||||
int ASEncryFwd(IntermediateReprestation *ir);
|
||||
int ASDecryBck(IntermediateReprestation *ir);
|
||||
// asymmetric sign operations
|
||||
int ASSignFwd(IntermediateReprestation *ir);
|
||||
int ASVerifyBck(IntermediateReprestation *ir);
|
||||
// derive operations
|
||||
int DRDeriveFwd(IntermediateReprestation *ir);
|
||||
int DRDeriveBck(IntermediateReprestation *ir);
|
||||
|
||||
// monad_inverse_map.c
|
||||
int CopyReversElementList(MonadReversibilityProperty *dest, uint32_t *destSize);
|
||||
int DisbalanceGroupElement(MonadReversibilityProperty *list, uint32_t listSize, ActionEntryType element);
|
||||
int BalanceGroupElement(MonadReversibilityProperty *list, uint32_t listSize, ActionEntryType inverseElement);
|
||||
int BalanceGroupElementList(IntermediateReprestation *ir);
|
||||
|
||||
#endif // end MONAD_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,130 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include "string.h"
|
||||
#include "tee_crypto_api.h"
|
||||
#include "test_crypto_data.h"
|
||||
#include "monad.h"
|
||||
#include "securec.h"
|
||||
#include "tee_log.h"
|
||||
|
||||
static MonadReversibilityProperty g_groupReverseList[] = {
|
||||
{
|
||||
.elementName = "IRSetUp",
|
||||
.element = IRSetUp,
|
||||
.inverseElementName = "IRTearDown",
|
||||
.inverseElement = IRTearDown,
|
||||
.isBalanced = 0,
|
||||
},
|
||||
{
|
||||
.elementName = "GlbAlloc",
|
||||
.element = GlbAlloc,
|
||||
.inverseElementName = "GlbFree",
|
||||
.inverseElement = GlbFree,
|
||||
.isBalanced = 0,
|
||||
},
|
||||
};
|
||||
|
||||
static uint32_t g_groupReverseListSize = (uint32_t)(sizeof(g_groupReverseList) / sizeof(g_groupReverseList[0]));
|
||||
|
||||
int CopyReversElementList(MonadReversibilityProperty *dest, uint32_t *destSize)
|
||||
{
|
||||
if (*destSize < g_groupReverseListSize) {
|
||||
tloge("[%s]:destSize = %u < g_groupReverseListSize = %u\n", __func__,
|
||||
*destSize, g_groupReverseListSize);
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t i;
|
||||
for (i = 0; i < g_groupReverseListSize; i++) {
|
||||
dest[i].element = g_groupReverseList[i].element;
|
||||
dest[i].elementName = g_groupReverseList[i].elementName;
|
||||
dest[i].inverseElement = g_groupReverseList[i].inverseElement;
|
||||
dest[i].inverseElementName = g_groupReverseList[i].inverseElementName;
|
||||
dest[i].isBalanced = g_groupReverseList[i].isBalanced;
|
||||
}
|
||||
*destSize = g_groupReverseListSize;
|
||||
|
||||
tlogi("[%s]:CopyReversElementList success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DisbalanceGroupElement(MonadReversibilityProperty *list, uint32_t listSize, ActionEntryType element)
|
||||
{
|
||||
uint32_t i;
|
||||
MonadReversibilityProperty *find = NULL;
|
||||
for (i = 0; i < listSize; i++) {
|
||||
if (list[i].element == element) {
|
||||
find = &(list[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (find == NULL) {
|
||||
tloge("[%s]:could not find inverse elment\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:find element dual %s -> %s\n", __func__, find->elementName, find->inverseElementName);
|
||||
|
||||
find->isBalanced = GRUPP_NOT_BALANCED;
|
||||
|
||||
tlogi("[%s]:DisbalanceGroupElement success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BalanceGroupElement(MonadReversibilityProperty *list, uint32_t listSize, ActionEntryType inverseElement)
|
||||
{
|
||||
uint32_t i;
|
||||
MonadReversibilityProperty *find = NULL;
|
||||
for (i = 0; i < listSize; i++) {
|
||||
if (list[i].inverseElement == inverseElement) {
|
||||
find = &(list[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (find == NULL) {
|
||||
tloge("[%s]:could not find inverse elment\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:find element dual %s -> %s\n", __func__, find->elementName, find->inverseElementName);
|
||||
|
||||
find->isBalanced = GROUP_BALANCED;
|
||||
|
||||
tlogi("[%s]:BalanceGroupElement success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BalanceGroupElementList(IntermediateReprestation *ir)
|
||||
{
|
||||
MonadReversibilityProperty *list = ir->mrpl;
|
||||
uint32_t listSize = ir->mrplSize;
|
||||
|
||||
uint32_t i;
|
||||
for (i = 0; i < listSize; i++) {
|
||||
if (list[i].isBalanced == GRUPP_NOT_BALANCED) {
|
||||
int ret = list[i].inverseElement(ir);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:inverse element %s (<- element %s) excute failed\n", __func__,
|
||||
list[i].inverseElementName, list[i].elementName);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:inverse element %s (<- element %s) excute success\n", __func__,
|
||||
list[i].inverseElementName, list[i].elementName);
|
||||
} else {
|
||||
tlogi("[%s]:inverse element %s (<- element %s) is balanced, just return.\n", __func__,
|
||||
list[i].inverseElementName, list[i].elementName);
|
||||
}
|
||||
}
|
||||
|
||||
tlogi("[%s]:BalanceGroupElementList success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include "securec.h"
|
||||
#include "tee_log.h"
|
||||
#include "tee_crypto_api.h"
|
||||
#include "test_crypto_data.h"
|
||||
#include "test_crypto_api_types.h"
|
||||
#include "monad.h"
|
||||
|
||||
int MonadSetup2(TestVector *tv, IntermediateReprestation *ir)
|
||||
{
|
||||
(void)ir;
|
||||
ir->tv = tv;
|
||||
ir->mrplSize = MONAD_REVERSE_PROP_LIST_SIZE;
|
||||
int ret = CopyReversElementList(ir->mrpl, &(ir->mrplSize));
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:CopyReversElementList failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tlogi("[%s]:MonadSetup2 success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int CheckExpResult2(int realRet, int tvExpRet, const char *info)
|
||||
{
|
||||
if ((tvExpRet != 0) && realRet == 0) {
|
||||
tloge("[%s]:expect fail, but pass. tvExpRet[0x%x], realRet[0x%x]\n",
|
||||
info, tvExpRet, realRet);
|
||||
return -1;
|
||||
} else if ((tvExpRet == 0) && realRet != 0) {
|
||||
tloge("[%s]:expect pass, but fail. tvExpRet[0x%x], realRet[0x%x]\n",
|
||||
info, tvExpRet, realRet);
|
||||
return -1;
|
||||
} else if ((tvExpRet != 0) && realRet != 0) {
|
||||
tlogi("[%s]:expect fail, and fail. tvExpRet[0x%x], realRet[0x%x]\n",
|
||||
info, tvExpRet, realRet);
|
||||
return 0;
|
||||
} else if ((tvExpRet == 0) && realRet == 0) {
|
||||
tlogi("[%s]:expect pass, and pass. tvExpRet[0x%x], realRet[0x%x]\n",
|
||||
info, tvExpRet, realRet);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MonadTearDown(IntermediateReprestation *ir)
|
||||
{
|
||||
int ret = BalanceGroupElementList(ir);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:BalanceGroupElementList failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tlogi("[%s]:MonadTearDown success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MonadRun2(TestVector *tv)
|
||||
{
|
||||
IntermediateReprestation ir;
|
||||
int ret = memset_s((void *)&ir, sizeof(IntermediateReprestation), 0, sizeof(IntermediateReprestation));
|
||||
if (ret != EOK) {
|
||||
tloge("[%s]:memset_s failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = MonadSetup2(tv, &ir);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadSetup2 failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadSetup2 success\n", __func__);
|
||||
|
||||
int checkResult;
|
||||
uint32_t i;
|
||||
for (i = 0; i < tv->actionsSize; i++) {
|
||||
ret = tv->actions[i](&ir);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:%uth action excute failed, break pipeline.\n", __func__, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
checkResult = CheckExpResult2(ret, tv->expRet, __func__);
|
||||
if (checkResult != 0) {
|
||||
tloge("[%s]:CheckExpResult failed at %dth act in of seq.\n", __func__, i);
|
||||
}
|
||||
|
||||
ret = MonadTearDown(&ir);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:MonadTearDown sucess\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:MonadTearDown sucess\n", __func__);
|
||||
|
||||
return checkResult;
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include "tee_ext_api.h"
|
||||
#include "cases_entry.h"
|
||||
|
||||
#define SYSTEM_OH_CRYPTO "/system/bin/tee_test_crypto_api"
|
||||
#define VENDOR_OH_CRYPTO "/vendor/bin/tee_test_crypto_api"
|
||||
#define CRYPTO_UID 0
|
||||
|
||||
// TA_INVOKE_CMD
|
||||
enum {
|
||||
CMD_RUN_BY_FUN_SEQ = 0,
|
||||
};
|
||||
|
||||
TEE_Result TA_CreateEntryPoint(void)
|
||||
{
|
||||
tlogi("%s:start add caller info success\n", __func__);
|
||||
TEE_Result ret;
|
||||
ret = AddCaller_CA_exec(VENDOR_OH_CRYPTO, CRYPTO_UID);
|
||||
if (ret != TEE_SUCCESS)
|
||||
return ret;
|
||||
ret = AddCaller_CA_exec(SYSTEM_OH_CRYPTO, CRYPTO_UID);
|
||||
if (ret != TEE_SUCCESS)
|
||||
return ret;
|
||||
tlogi("%s:end add caller info success\n", __func__);
|
||||
return TEE_SUCCESS;
|
||||
}
|
||||
|
||||
TEE_Result TA_OpenSessionEntryPoint(uint32_t paramTypes, TEE_Param params[4], void **sessionContext)
|
||||
{
|
||||
(void)paramTypes;
|
||||
(void)params;
|
||||
(void)sessionContext;
|
||||
tlogi("in %s\n", __func__);
|
||||
return TEE_SUCCESS;
|
||||
}
|
||||
|
||||
TEE_Result TA_InvokeCommandEntryPoint(void *session_context, uint32_t cmd_id, uint32_t paramTypes, TEE_Param params[4])
|
||||
{
|
||||
(void)session_context;
|
||||
// check params
|
||||
if (!check_param_type(paramTypes,
|
||||
TEE_PARAM_TYPE_MEMREF_INOUT,
|
||||
TEE_PARAM_TYPE_NONE,
|
||||
TEE_PARAM_TYPE_NONE,
|
||||
TEE_PARAM_TYPE_NONE)) {
|
||||
tloge("%s:error, invalid param_types\n", __func__);
|
||||
return TEE_ERROR_BAD_PARAMETERS;
|
||||
}
|
||||
tlogi("%s:cmd_id is %d\n", __func__, cmd_id);
|
||||
int ret;
|
||||
switch (cmd_id) {
|
||||
case CMD_RUN_BY_FUN_SEQ: {
|
||||
ret = RunCaseEntryByName((const char *)params[0].memref.buffer, 1, 0);
|
||||
if (ret != 0) {
|
||||
tloge("[%s]:RunCaseEntryByName fail\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
tlogi("[%s]:RunCaseEntryByName success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void TA_CloseSessionEntryPoint(void *session_context)
|
||||
{
|
||||
(void)session_context;
|
||||
tlogi("in %s.\n", __func__);
|
||||
}
|
||||
|
||||
void TA_DestroyEntryPoint(void)
|
||||
{
|
||||
tlogi("in %s.\n", __func__);
|
||||
}
|
||||
@@ -1,255 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef TEST_CRYPTO_API_TYPES_H
|
||||
#define TEST_CRYPTO_API_TYPES_H
|
||||
#include "tee_trusted_storage_api.h"
|
||||
#include "stddef.h"
|
||||
#include "tee_crypto_api.h"
|
||||
#include "tee_log.h"
|
||||
|
||||
enum {
|
||||
DATA_MODE_WHOLE = 0,
|
||||
DATA_MODE_SLICE = 1,
|
||||
};
|
||||
|
||||
#define DATA_EXPAND_SIZE 1024
|
||||
#define AE_TAG_MAX_SIZE 64
|
||||
#define MAX_STRING_NAME_LEN 100
|
||||
|
||||
typedef struct {
|
||||
uint32_t dataMode;
|
||||
void *data;
|
||||
size_t dataMallocSize;
|
||||
size_t dataSize;
|
||||
size_t dataUsed;
|
||||
size_t sliceSize;
|
||||
uint8_t aeTag[AE_TAG_MAX_SIZE];
|
||||
size_t aeTagSize;
|
||||
} ProcessInOutData;
|
||||
|
||||
struct _IntermediateReprestation;
|
||||
typedef int (*ActionEntryType)(struct _IntermediateReprestation *ir);
|
||||
#define MAX_ACTIONS_SIZE 100
|
||||
typedef struct {
|
||||
// common test vector
|
||||
char algName[MAX_STRING_NAME_LEN]; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
size_t operaMaxKeySize; // ae, asymEn, asymSg, derive, symEn, mac,
|
||||
size_t keySize; // ae, asymEn, asymSg, derive, symEn, mac,
|
||||
char fwdKeyTypeName[MAX_STRING_NAME_LEN]; // ae, asymEn, asymSg, derive, symEn, mac,
|
||||
char bckKeyTypeName[MAX_STRING_NAME_LEN]; // asymEn, asymSg, derive, mac,
|
||||
uint32_t fwdEngine; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
uint32_t bckEngine; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
size_t dataSize; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
size_t sliceSize; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
uint32_t expRet; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
size_t ivLen; // symEn, mac,
|
||||
|
||||
// ae test vector
|
||||
size_t aeTagLen; // ae,
|
||||
size_t aeTagOSize; // ae,
|
||||
size_t aeNonceLen; // ae,
|
||||
uint8_t nonceByte; // ae,
|
||||
size_t aeAadLenInit; // aes-ccm,
|
||||
size_t aeAadLen; // ae,
|
||||
uint8_t aadByte; // ae,
|
||||
|
||||
// asym encrypt test vector
|
||||
uint32_t rsaEnMgf1Hash; // asymEn,
|
||||
|
||||
// asym sign test vector
|
||||
uint32_t rsaSgPssLen; // asymSg,
|
||||
|
||||
// ecc key gen nist
|
||||
uint32_t ecKeyCurve; // asymEn, asymSg, derive,
|
||||
// rsa key gen pub exp id
|
||||
uint32_t rsaGenPubExpId; // asymEn, asymSg,
|
||||
// dh key gen base prime xbits
|
||||
uint32_t dhGenKeySize; // derive,
|
||||
// common action sequence
|
||||
ActionEntryType actions[MAX_ACTIONS_SIZE]; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
uint32_t actionsSize; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
} TestVector;
|
||||
|
||||
enum {
|
||||
ER_OK = 0,
|
||||
ER_JF = 1,
|
||||
};
|
||||
|
||||
#define MAX_ACT_SEQ_LIST_SIZE 100
|
||||
|
||||
typedef struct {
|
||||
char algName[MAX_STRING_NAME_LEN];
|
||||
uint32_t algValue;
|
||||
uint32_t fwdMode;
|
||||
uint32_t bckMode;
|
||||
uint32_t operaKeyCount;
|
||||
uint32_t needKeyCount;
|
||||
uint32_t isSwitchFwdBckOperaKey;
|
||||
char algOperaClassName[MAX_STRING_NAME_LEN];
|
||||
uint32_t algOperaClassValue;
|
||||
} AlgMapInfo;
|
||||
enum {
|
||||
NEED_NO_GEN_PARAMS = 0,
|
||||
NEED_GEN_ECC_CURVE = 1,
|
||||
NEED_DH_BASE_PRIME_XBITS = 2,
|
||||
NEED_RSA_EXP_MAYBE = 3,
|
||||
};
|
||||
typedef struct {
|
||||
uint8_t keyTypeName[MAX_STRING_NAME_LEN];
|
||||
uint32_t keyType;
|
||||
uint32_t keyGenType;
|
||||
uint32_t needGenParams;
|
||||
} KeyTypeMapInfo;
|
||||
|
||||
enum {
|
||||
XTS_KEY_COUNT_TWO = 2,
|
||||
};
|
||||
|
||||
enum {
|
||||
GROUP_BALANCED = 0,
|
||||
GRUPP_NOT_BALANCED = 1,
|
||||
};
|
||||
typedef struct {
|
||||
char *elementName;
|
||||
ActionEntryType element;
|
||||
char *inverseElementName;
|
||||
ActionEntryType inverseElement;
|
||||
uint32_t isBalanced;
|
||||
} MonadReversibilityProperty;
|
||||
#define MONAD_REVERSE_PROP_LIST_SIZE 100
|
||||
#define AE_NONCE_BUFFER_SIZE 32
|
||||
#define AE_TAG_BUFFER_SIZE 32
|
||||
#define MAX_KEY_OBJECT_HANDLE_LIST_SIZE 2
|
||||
#define MAX_TEST_KEY_ITEM_LIST_SIZE 100
|
||||
typedef struct {
|
||||
uint32_t keyType;
|
||||
uint32_t keySize;
|
||||
TEE_ObjectHandle keyObjList[MAX_KEY_OBJECT_HANDLE_LIST_SIZE];
|
||||
size_t keyObjListSize;
|
||||
} TestKeyItem;
|
||||
|
||||
typedef struct _IntermediateReprestation {
|
||||
// input factor space
|
||||
TestVector *tv; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
|
||||
// inner state factor space
|
||||
AlgMapInfo *algMap; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
KeyTypeMapInfo *fwdKeyMap; // ae, asymEn, asymSg, derive, symEn, mac,
|
||||
KeyTypeMapInfo *bckKeyMap; // ae, asymEn, asymSg, derive, symEn, mac,
|
||||
|
||||
// common factor
|
||||
uint32_t algValue; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
|
||||
uint32_t algOperaClassValue; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
|
||||
uint32_t fwdMode; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
uint32_t bckMode; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
|
||||
uint32_t operaKeyCount; // ae, asymEn, asymSg, derive, symEn, mac,
|
||||
uint32_t needKeyCount; // ae, asymEn, asymSg, derive, symEn, mac,
|
||||
uint32_t isSwitchFwdBckOperaKey; // ae, asymEn, asymSg, derive, symEn, mac,
|
||||
|
||||
size_t operaMaxKeySize; // ae, asymEn, asymSg, derive, symEn, mac,
|
||||
size_t keySize; // ae, asymEn, asymSg, derive, symEn, mac,
|
||||
|
||||
uint32_t fwdKeyType; // ae, asymEn, asymSg, derive, symEn, mac,
|
||||
uint32_t bckKeyType; // ae, asymEn, asymSg, derive, symEn, mac,
|
||||
uint32_t genKeyType; // ae, asymEn, asymSg, derive, symEn, mac,
|
||||
|
||||
uint32_t dataSize; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
uint32_t sliceSize; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
|
||||
size_t ivLen; // digest, symEn, mac,
|
||||
|
||||
size_t aeNonceLen; // ae,
|
||||
uint8_t nonceByte; // ae,
|
||||
uint8_t nonce[AE_NONCE_BUFFER_SIZE]; // ae,
|
||||
size_t aeTagLen; // ae,
|
||||
size_t aeTagOSize; // ae,
|
||||
uint8_t aeTag[AE_TAG_BUFFER_SIZE]; // ae,
|
||||
size_t aeAadLenInit; // aes-ccm,
|
||||
size_t aeAadLen; // ae,
|
||||
uint8_t aadByte; // ae,
|
||||
uint8_t *pAad; // ae,
|
||||
|
||||
size_t rsaEnMgf1Hash; // asymEn,
|
||||
size_t rsaSgPssLen; // asymSg,
|
||||
|
||||
uint32_t fwdEngine; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
uint32_t bckEngine; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
|
||||
uint32_t tvExpRet; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
|
||||
ProcessInOutData plainData; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
ProcessInOutData cipherData; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
ProcessInOutData decryptedData; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
|
||||
TEE_OperationHandle fwdOperaHandle; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
TEE_OperationHandle bckOperaHandle; // ae, asymEn, asymSg, derive, digest, symEn, mac,
|
||||
|
||||
TestKeyItem *tki; // derive,
|
||||
// ecc key gen nist
|
||||
uint32_t ecKeyCurve; // asymEn, asymSg, derive,
|
||||
// rsa key gen pub exp id
|
||||
uint32_t rsaGenPubExpId; // asymEn, asymSg,
|
||||
// dh key gen base prime xbits
|
||||
uint32_t dhGenKeySize; // derive,
|
||||
|
||||
MonadReversibilityProperty mrpl[MONAD_REVERSE_PROP_LIST_SIZE];
|
||||
uint32_t mrplSize;
|
||||
} IntermediateReprestation;
|
||||
|
||||
enum {
|
||||
ERROR_OK = 0,
|
||||
};
|
||||
|
||||
enum {
|
||||
USE_DX = 0, // 使用DX引擎
|
||||
USE_SW = 1, // 使用SW软引擎
|
||||
USE_EP = 2, // 使用EPS引擎
|
||||
USE_SE = 3, // 使用SEC引擎
|
||||
USE_DF = 4, // 使用默认引擎
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
RSA_ENCRYPT_MGF_DEF = 0,
|
||||
RSA_ENCYPT_MGF_SHA1 = 1, // TEE_DH_HASH_SHA1_mode = 0
|
||||
RSA_ENCYPT_MGF_SHA224 = 2, // TEE_DH_HASH_SHA224_mode = 1,
|
||||
RSA_ENCYPT_MGF_SHA256 = 3, // TEE_DH_HASH_SHA256_mode = 2,
|
||||
RSA_ENCYPT_MGF_SHA384 = 4, // TEE_DH_HASH_SHA384_mode = 3,
|
||||
RSA_ENCYPT_MGF_SHA512 = 5, // TEE_DH_HASH_SHA512_mode = 4,
|
||||
RSA_ENCYPT_MGF_COUNT,
|
||||
} RsaEncryptMgfType;
|
||||
|
||||
typedef enum {
|
||||
TST_ECC_CURVE_NIST_NONE = 0,
|
||||
TST_ECC_CURVE_NIST_P192 = 1,
|
||||
TST_ECC_CURVE_NIST_P224 = 2,
|
||||
TST_ECC_CURVE_NIST_P256 = 3,
|
||||
TST_ECC_CURVE_NIST_P384 = 4,
|
||||
TST_ECC_CURVE_NIST_P521 = 5,
|
||||
TST_ECC_CURVE_SM2 = 6,
|
||||
TST_ECC_CURVE_25519 = 7,
|
||||
TST_ECC_CURVE_COUNT = 8,
|
||||
} EccKeyGenCurve;
|
||||
|
||||
enum {
|
||||
TST_RSA_KEYGEN_PUB_EXP_ID_NULL = 0,
|
||||
TST_RSA_KEYGEN_PUB_EXP_ID_0 = 1,
|
||||
TST_RSA_KEYGEN_PUB_EXP_ID_1 = 2,
|
||||
TST_RSA_KEYGEN_PUB_EXP_ID_2 = 3,
|
||||
TST_RSA_KEYGEN_PUB_EXP_ID_3 = 4,
|
||||
TST_RSA_KEYGEN_PUB_EXP_ID_4 = 5,
|
||||
};
|
||||
|
||||
#endif // end TEST_CRYPTO_API_TYPES_H
|
||||
@@ -1,35 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
|
||||
set(ta_sources)
|
||||
|
||||
list(APPEND ta_sources
|
||||
src/drvcaller_test.c
|
||||
)
|
||||
|
||||
list(APPEND header_dir
|
||||
include
|
||||
)
|
||||
|
||||
ta_compile_pub(
|
||||
ELF_NAME
|
||||
drvcaller_test.elf
|
||||
|
||||
SRC_LIST
|
||||
${ta_sources}
|
||||
|
||||
INCLUDE_DIRS
|
||||
${header_dir}
|
||||
|
||||
COMPILE_OPTS
|
||||
COMPILE_DEFS
|
||||
)
|
||||
@@ -1,22 +0,0 @@
|
||||
perm1,1
|
||||
perm2,2
|
||||
perm3,3
|
||||
perm4,4
|
||||
perm5,5
|
||||
perm6,6
|
||||
perm7,7
|
||||
perm8,8
|
||||
perm9,9
|
||||
perm10,10
|
||||
iomap_perm,11
|
||||
SHARE_BUFFER_TEST_ID,0x10
|
||||
ARGS_TEST_ID,0x11
|
||||
BUFFER_TEST_ID,0x12
|
||||
RETURN_EXCEPTION_ID,0x13
|
||||
SLEEP_TEST_ID,0x14
|
||||
MAX_BUFFER_TEST_ID,0x15
|
||||
CRASH_TEST_ID,0x16
|
||||
NO_PARAM_TEST_ID,0x17
|
||||
CALL_OTHER_DRV_TEST_ID,0x18
|
||||
STRING_TEST_ID,0x19
|
||||
IOMAP_TEST_ID,0x1a
|
||||
|
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
Licensed under the Mulan PSL v2.
|
||||
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
You may obtain a copy of Mulan PSL v2 at:
|
||||
http://license.coscl.org.cn/MulanPSL2
|
||||
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
PURPOSE.
|
||||
See the Mulan PSL v2 for more details.
|
||||
-->
|
||||
|
||||
<drv_perm>
|
||||
<drvcall_perm_apply>
|
||||
<item name="drv_test_module "/>
|
||||
</drvcall_perm_apply>
|
||||
</drv_perm>
|
||||
@@ -1,5 +0,0 @@
|
||||
gpd.ta.appID: 534D4152-542D-4353-b919-d3016a171fc9
|
||||
gpd.ta.service_name: drvcaller_test
|
||||
gpd.ta.instanceKeepAlive: false
|
||||
gpd.ta.dataSize: 1048576
|
||||
gpd.ta.stackSize: 8192
|
||||
@@ -1,171 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <securec.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <tee_drv_client.h>
|
||||
#include <tee_ext_api.h>
|
||||
#include <tee_log.h>
|
||||
#include <test_drv_cmdid.h>
|
||||
#include <mem_ops.h>
|
||||
|
||||
#define CA_PKGN_VENDOR "/vendor/bin/tee_test_drv"
|
||||
#define CA_PKGN_SYSTEM "/system/bin/tee_test_drv"
|
||||
#define CA_UID 0
|
||||
|
||||
#define DRV_UUID1 \
|
||||
{ \
|
||||
0x11112222, 0x0000, 0x0000, \
|
||||
{ \
|
||||
0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11 \
|
||||
} \
|
||||
}
|
||||
|
||||
#define BUFFER_SIZE 1024
|
||||
struct share_buffer_arg {
|
||||
uint64_t addr;
|
||||
uint32_t len;
|
||||
uint32_t share_token;
|
||||
};
|
||||
|
||||
static TEE_Result TeeTestDrive(uint32_t cmd)
|
||||
{
|
||||
int ret;
|
||||
const char *drvName = "drv_test_module";
|
||||
uint32_t args = (uint32_t)(&drvName);
|
||||
const char drvcallerInput[] = "the param is drvcaller_input";
|
||||
char drvOutput[] = "DRVMEM_OUTPUT";
|
||||
|
||||
uint32_t drvcallerInputLen = (uint32_t)strlen(drvcallerInput) + 1;
|
||||
uint32_t drvOutputLen = (uint32_t)strlen(drvOutput) + 1;
|
||||
TEE_UUID uuid = DRV_UUID1;
|
||||
|
||||
int64_t fd = tee_drv_open(drvName, &args, sizeof(args));
|
||||
if (fd <= 0) {
|
||||
tloge("open %s for get fd failed\n", drvName);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
char *tempBuffer = alloc_sharemem_aux(&uuid, BUFFER_SIZE);
|
||||
if (tempBuffer == NULL) {
|
||||
tloge("alloc share mem failed\n");
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
(void)memset_s(tempBuffer, BUFFER_SIZE, 0x0, BUFFER_SIZE);
|
||||
ret = strcpy_s(tempBuffer, drvcallerInputLen, drvcallerInput);
|
||||
if (ret != 0) {
|
||||
tloge("strcpy_s failed,ret = 0x%x\n", ret);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
struct share_buffer_arg inputArg = { 0 };
|
||||
#ifndef __aarch64__
|
||||
inputArg.addr = (uint64_t)(uint32_t)tempBuffer;
|
||||
#else
|
||||
inputArg.addr = (uint64_t)tempBuffer;
|
||||
#endif
|
||||
|
||||
inputArg.len = BUFFER_SIZE;
|
||||
|
||||
tlogi("%s drv test ioctl begin args:0x%x fd:%d\n", drvName, inputArg, (int32_t)fd);
|
||||
|
||||
ret = (int)tee_drv_ioctl(fd, cmd, (const void *)(&inputArg), sizeof(inputArg));
|
||||
if (ret != 0) {
|
||||
tloge("%s drv test ioctl failed, fd:%d \n", drvName, (int32_t)fd);
|
||||
}
|
||||
if (cmd == DRVTEST_COMMAND_COPYTOCLIENT) {
|
||||
if (strncmp(drvOutput, (char *)tempBuffer, drvOutputLen) != 0) {
|
||||
tloge("%s drv copy_to_client test failed, fd:%d, heap_buffer is:%s \n", drvName, (int32_t)fd, tempBuffer);
|
||||
free_sharemem(tempBuffer, BUFFER_SIZE);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
}
|
||||
|
||||
ret |= (int)tee_drv_close(fd);
|
||||
if (ret != 0) {
|
||||
tloge("drv test fail!\n");
|
||||
}
|
||||
|
||||
if (free_sharemem(tempBuffer, BUFFER_SIZE) != 0) {
|
||||
tloge("free sharemem failed\n");
|
||||
ret = -1;
|
||||
}
|
||||
return (TEE_Result)ret;
|
||||
}
|
||||
|
||||
TEE_Result TA_CreateEntryPoint(void)
|
||||
{
|
||||
tlogi("---- TA_CreateEntryPoint ----------- \n");
|
||||
TEE_Result ret;
|
||||
|
||||
ret = AddCaller_CA_exec(CA_PKGN_VENDOR, CA_UID);
|
||||
if (ret != TEE_SUCCESS) {
|
||||
tloge("add caller failed, ret: 0x%x", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = AddCaller_CA_exec(CA_PKGN_SYSTEM, CA_UID);
|
||||
if (ret != TEE_SUCCESS) {
|
||||
tloge("add caller failed, ret: 0x%x", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return TEE_SUCCESS;
|
||||
}
|
||||
|
||||
TEE_Result TA_OpenSessionEntryPoint(uint32_t parmType, TEE_Param params[4], void **sessionContext)
|
||||
{
|
||||
(void)parmType;
|
||||
(void)sessionContext;
|
||||
tlogi("---- TA_OpenSessionEntryPoint -------- \n");
|
||||
if (params[0].value.b == 0xFFFFFFFE)
|
||||
return TEE_ERROR_GENERIC;
|
||||
else
|
||||
return TEE_SUCCESS;
|
||||
}
|
||||
|
||||
TEE_Result TA_InvokeCommandEntryPoint(void *sessionContext, uint32_t cmd, uint32_t parmType, TEE_Param params[4])
|
||||
{
|
||||
TEE_Result ret = TEE_SUCCESS;
|
||||
(void)sessionContext;
|
||||
(void)parmType;
|
||||
(void)params;
|
||||
tlogi("---- TA invoke command ----------- command id: %u\n", cmd);
|
||||
|
||||
switch (cmd) {
|
||||
case DRVTEST_COMMAND_DRVVIRTTOPHYS:
|
||||
case DRVTEST_COMMAND_COPYFROMCLIENT:
|
||||
case DRVTEST_COMMAND_COPYTOCLIENT:
|
||||
ret = TeeTestDrive(cmd);
|
||||
if (ret != TEE_SUCCESS)
|
||||
tloge("invoke command for driver test failed! cmdId: %u, ret: 0x%x\n", cmd, ret);
|
||||
break;
|
||||
default:
|
||||
tloge("not support this invoke command! cmdId: %u\n", cmd);
|
||||
ret = TEE_ERROR_GENERIC;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void TA_CloseSessionEntryPoint(void *sessionContext)
|
||||
{
|
||||
(void)sessionContext;
|
||||
tlogi("---- TA_CloseSessionEntryPoint ----- \n");
|
||||
}
|
||||
|
||||
void TA_DestroyEntryPoint(void)
|
||||
{
|
||||
tlogi("---- TA_DestroyEntryPoint ---- \n");
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2023 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
|
||||
set(TARGET_NAME test_libc_api.elf)
|
||||
|
||||
list(APPEND ta_src
|
||||
src/test_time_api_func.c
|
||||
src/test_time_api_main.c
|
||||
src/test_libc_string.c
|
||||
src/test_libc_pthread.c
|
||||
src/test_libc_mem.c
|
||||
src/test_libc_main.c
|
||||
src/test_libc_common_lib.c
|
||||
src/ta_case_work.c
|
||||
src/libc_func/pthread_attr_destroy_1_1.c
|
||||
src/libc_func/pthread_attr_destroy_2_1.c
|
||||
src/libc_func/pthread_attr_destroy_3_1.c
|
||||
src/libc_func/pthread_attr_getstack_1_1.c
|
||||
src/libc_func/pthread_attr_getstacksize_1_1.c
|
||||
src/libc_func/pthread_attr_init_1_1.c
|
||||
src/libc_func/pthread_attr_init_3_1.c
|
||||
src/libc_func/pthread_attr_init_4_1.c
|
||||
src/libc_func/pthread_attr_setstack_1_1.c
|
||||
src/libc_func/pthread_attr_setstack_2_1.c
|
||||
src/libc_func/pthread_attr_setstack_4_1.c
|
||||
src/libc_func/pthread_attr_setstack_6_1.c
|
||||
src/libc_func/pthread_attr_setstack_7_1.c
|
||||
src/libc_func/pthread_attr_setstacksize_1_1.c
|
||||
src/libc_func/pthread_attr_setstacksize_2_1.c
|
||||
src/libc_func/pthread_attr_setstacksize_4_1.c
|
||||
src/libc_func/pthread_cond_broadcast_1_1.c
|
||||
src/libc_func/pthread_cond_init_1_1.c
|
||||
src/libc_func/pthread_cond_wait_0_1.c
|
||||
src/libc_func/pthread_cond_wait_0_2.c
|
||||
src/libc_func/pthread_cond_wait_0_3.c
|
||||
src/libc_func/pthread_create_12_1.c
|
||||
src/libc_func/pthread_create_1_1.c
|
||||
src/libc_func/pthread_create_2_1.c
|
||||
src/libc_func/pthread_create_4_1.c
|
||||
src/libc_func/pthread_create_5_1.c
|
||||
src/libc_func/pthread_create_5_2.c
|
||||
src/libc_func/pthread_equal.c
|
||||
src/libc_func/pthread_exit_2_1.c
|
||||
src/libc_func/pthread_exit_3_1.c
|
||||
src/libc_func/pthread_getspecific_1_1.c
|
||||
src/libc_func/pthread_getspecific_1_1.c
|
||||
src/libc_func/pthread_getspecific_1_1.c
|
||||
src/libc_func/pthread_mutex_destroy_1_1.c
|
||||
src/libc_func/pthread_mutex_destroy_1_1_0.c
|
||||
src/libc_func/pthread_mutex_destroy_2_1.c
|
||||
src/libc_func/pthread_mutex_destroy_4_2.c
|
||||
src/libc_func/pthread_mutex_init_0_1.c
|
||||
src/libc_func/pthread_mutex_init_1_1.c
|
||||
src/libc_func/pthread_mutex_init_2_1_0.c
|
||||
src/libc_func/pthread_mutex_init_3_1.c
|
||||
src/libc_func/pthread_mutex_lock_0_2.c
|
||||
src/libc_func/pthread_mutex_lock_0_3.c
|
||||
src/libc_func/pthread_mutex_lock_1_1_0.c
|
||||
src/libc_func/pthread_mutex_trylock_0_1.c
|
||||
src/libc_func/pthread_mutex_trylock_1_1.c
|
||||
src/libc_func/pthread_mutex_trylock_4_1.c
|
||||
src/libc_func/pthread_mutex_unlock_1_1.c
|
||||
src/libc_func/pthread_mutexattr_getprotocol_1_1.c
|
||||
src/libc_func/pthread_mutexattr_gettype_1_1.c
|
||||
src/libc_func/pthread_mutexattr_gettype_1_1.c
|
||||
src/libc_func/pthread_once_1_3.c
|
||||
src/libc_func/pthread_setspecific_1_2.c
|
||||
src/libc_func/pthread_spin_destroy_0_1.c
|
||||
src/libc_func/pthread_spin_destroy_1_1.c
|
||||
src/libc_func/pthread_spin_destroy_3_1.c
|
||||
src/libc_func/pthread_spin_init_1_1.c
|
||||
src/libc_func/pthread_spin_init_4_1.c
|
||||
src/libc_func/pthread_spin_lock_0_1.c
|
||||
src/libc_func/pthread_spin_lock_0_2.c
|
||||
src/libc_func/pthread_spin_lock_0_3.c
|
||||
src/libc_func/pthread_spin_lock_3_1.c
|
||||
src/libc_func/pthread_spin_trylock_0_1.c
|
||||
src/libc_func/pthread_spin_trylock_1_1.c
|
||||
src/libc_func/pthread_spin_trylock_4_1.c
|
||||
src/libc_func/pthread_spin_trylock_4_1_0.c
|
||||
src/libc_func/pthread_spin_unlock_1_1.c
|
||||
src/libc_func/test-string.c
|
||||
src/libc_func/test_ctype.c
|
||||
src/libc_func/test_error.c
|
||||
src/libc_func/test_getpid.c
|
||||
src/libc_func/test_locale.c
|
||||
src/libc_func/test_math.c
|
||||
src/libc_func/test_mmap.c
|
||||
src/libc_func/test_multibyte.c
|
||||
src/libc_func/test_prng.c
|
||||
src/libc_func/test_pthread_key_create.c
|
||||
src/libc_func/test_sem.c
|
||||
src/libc_func/test_stdio.c
|
||||
src/libc_func/test_stdlib.c
|
||||
src/libc_func/test_time.c
|
||||
src/libc_func/tst-calloc.c
|
||||
src/libc_func/tst-malloc.c
|
||||
src/libc_func/tst_free.c
|
||||
)
|
||||
|
||||
list(APPEND cflags
|
||||
-mfloat-abi=softfp
|
||||
-Wno-bitwise-op-parentheses
|
||||
-Wno-shift-op-parentheses
|
||||
-Wno-implicit-function-declaration
|
||||
-Wno-int-conversion
|
||||
-Wno-unused-parameter
|
||||
)
|
||||
|
||||
ta_compile_pub(
|
||||
ELF_NAME
|
||||
${TARGET_NAME}
|
||||
|
||||
SRC_LIST
|
||||
${ta_src}
|
||||
|
||||
INCLUDE_DIRS
|
||||
|
||||
COMPILE_OPTS
|
||||
${cflags}
|
||||
|
||||
COMPILE_DEFS
|
||||
API_LEVEL=3
|
||||
)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user