提交 e65ee122 编写于 作者: A aaronwangjun

aaron.wangjun@huawei.com

Signed-off-by: Naaronwangjun <aaron.wangjun@huawei.com>
Change-Id: I8a71c54044998d288f26e8e6af2cbe2e19cb7a3c
上级 1e240c12
...@@ -41,7 +41,7 @@ lite_component("acts_component") { ...@@ -41,7 +41,7 @@ lite_component("acts_component") {
#"//test/xts/acts/kernel_lite/kernelcmsis_hal:ActsCMSISTest", #"//test/xts/acts/kernel_lite/kernelcmsis_hal:ActsCMSISTest",
"//test/xts/acts/utils_lite/kv_store_hal:ActsKvStoreTest", "//test/xts/acts/utils_lite/kv_store_hal:ActsKvStoreTest",
"//test/xts/acts/security_lite/huks/liteos_m_adapter:ActsHuksHalFunctionTest", "//test/xts/acts/security_lite:securitytest",
"//test/xts/acts/hiviewdfx_lite/hilog_hal:ActsDfxFuncTest", "//test/xts/acts/hiviewdfx_lite/hilog_hal:ActsDfxFuncTest",
"//test/xts/acts/hiviewdfx_lite/hievent_hal:ActsHieventLiteTest", "//test/xts/acts/hiviewdfx_lite/hievent_hal:ActsHieventLiteTest",
...@@ -66,7 +66,6 @@ lite_component("acts_component") { ...@@ -66,7 +66,6 @@ lite_component("acts_component") {
"//test/xts/acts/distributed_schedule_lite/system_ability_manager_posix:ActsSamgrTest", "//test/xts/acts/distributed_schedule_lite/system_ability_manager_posix:ActsSamgrTest",
#"//test/xts/acts/distributedschedule_lite/distributed_schedule_posix:ActsDMSTest", #"//test/xts/acts/distributedschedule_lite/distributed_schedule_posix:ActsDMSTest",
"//test/xts/acts/security_lite/permission_posix/pms:ActsPMSTest",
"//test/xts/acts/hiviewdfx_lite/hilog_posix:ActsHilogTest", "//test/xts/acts/hiviewdfx_lite/hilog_posix:ActsHilogTest",
"//test/xts/acts/multimedia_lite/media_lite_posix/recorder_native:ActsMediaRecorderTest", "//test/xts/acts/multimedia_lite/media_lite_posix/recorder_native:ActsMediaRecorderTest",
...@@ -86,8 +85,7 @@ lite_component("acts_component") { ...@@ -86,8 +85,7 @@ lite_component("acts_component") {
"//test/xts/acts/startup_lite/syspara_posix:ActsParameterTest", "//test/xts/acts/startup_lite/syspara_posix:ActsParameterTest",
"//test/xts/acts/startup_lite/bootstrap_posix:ActsBootstrapTest", "//test/xts/acts/startup_lite/bootstrap_posix:ActsBootstrapTest",
"//test/xts/acts/communication_lite/lwip_posix:ActsLwipTest", "//test/xts/acts/communication_lite/lwip_posix:ActsLwipTest",
"//test/xts/acts/security_lite:securitytest",
"//test/xts/acts/security_lite/permission_posix/pms:ActsPMSTest",
#"//test/xts/acts/multimedia_lite/camera_lite_posix/camera_native:ActsMediaCameraTest", #"//test/xts/acts/multimedia_lite/camera_lite_posix/camera_native:ActsMediaCameraTest",
#"//test/xts/acts/multimedia_lite/media_lite_posix/player_native:ActsMediaPlayerTest", #"//test/xts/acts/multimedia_lite/media_lite_posix/player_native:ActsMediaPlayerTest",
......
...@@ -12,9 +12,16 @@ ...@@ -12,9 +12,16 @@
# limitations under the License. # limitations under the License.
group("securitytest") { group("securitytest") {
if (ohos_kernel_type == "liteos_a") {
deps = [ deps = [
"//test/xts/acts/security_lite/huks/liteos_a_adapter:Hukslitetest", "//test/xts/acts/security_lite/huks/liteos_a_adapter:Hukslitetest",
"//test/xts/acts/security_lite/permission_posix/capability:ActsCapabilityTest", "//test/xts/acts/security_lite/permission_posix/capability:ActsCapabilityTest",
"//test/xts/acts/security_lite/permission_posix/dac:ActsDacTest", "//test/xts/acts/security_lite/permission_posix/dac:ActsDacTest",
"//test/xts/acts/security_lite/permission_posix/pms:ActsPMSTest",
] ]
} else if (ohos_kernel_type == "linux") {
deps = [ "//test/xts/acts/security_lite/permission_posix/pms:ActsPMSTest" ]
} else if (ohos_kernel_type == "liteos_m") {
deps = [ "//test/xts/acts/security_lite/huks/liteos_m_adapter:ActsHuksHalFunctionTest" ]
}
} }
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include "hks_param.h" #include "hks_param.h"
#include "hks_test_log.h" #include "hks_test_log.h"
#include "securec.h"
#define USEC_MINT 1000 #define USEC_MINT 1000
#define USEC_UINT 1000000 #define USEC_UINT 1000000
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "hks_param.h" #include "hks_param.h"
#include "hks_test_log.h" #include "hks_test_log.h"
#include "hks_type.h" #include "hks_type.h"
#include "securec.h"
#define TEST_ALIAS_ED25519 "test_ed25519" #define TEST_ALIAS_ED25519 "test_ed25519"
#define TEST_PLAIN_TEST_ED25519 "This is a plain text! Hello world and thanks for watching ED25519~" #define TEST_PLAIN_TEST_ED25519 "This is a plain text! Hello world and thanks for watching ED25519~"
......
...@@ -42,7 +42,6 @@ hcpptest_suite("ActsHuksLiteFunctionTest") { ...@@ -42,7 +42,6 @@ hcpptest_suite("ActsHuksLiteFunctionTest") {
include_dirs = [ include_dirs = [
"//utils/native/base/include", "//utils/native/base/include",
"//third_party/bounds_checking_function/include", "//third_party/bounds_checking_function/include",
"//base/security/huks/huawei_property/include",
"../common/include", "../common/include",
] ]
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include "hks_param.h" #include "hks_param.h"
#include "hks_test_cipher.h" #include "hks_test_cipher.h"
#include "securec.h"
using namespace testing::ext; using namespace testing::ext;
namespace { namespace {
class HksCipherTest : public testing::Test { class HksCipherTest : public testing::Test {
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include "hks_param.h" #include "hks_param.h"
#include "hks_test_curve25519.h" #include "hks_test_curve25519.h"
#include "securec.h"
using namespace testing::ext; using namespace testing::ext;
namespace { namespace {
#ifndef _CUT_AUTHENTICATE_ #ifndef _CUT_AUTHENTICATE_
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include "hks_test_common.h" #include "hks_test_common.h"
#include "hks_test_log.h" #include "hks_test_log.h"
#include "securec.h"
using namespace testing::ext; using namespace testing::ext;
namespace { namespace {
class HksMacTest : public testing::Test { class HksMacTest : public testing::Test {
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include "hks_param.h" #include "hks_param.h"
#include "hks_type.h" #include "hks_type.h"
#include "securec.h"
using namespace testing::ext; using namespace testing::ext;
namespace { namespace {
#ifndef _CUT_AUTHENTICATE_ #ifndef _CUT_AUTHENTICATE_
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include "hks_test_file_operator.h" #include "hks_test_file_operator.h"
#include "hks_test_mem.h" #include "hks_test_mem.h"
#include "securec.h"
using namespace testing::ext; using namespace testing::ext;
namespace { namespace {
#ifndef _CUT_AUTHENTICATE_ #ifndef _CUT_AUTHENTICATE_
......
...@@ -41,10 +41,7 @@ hctest_suite("ActsHuksHalFunctionTest") { ...@@ -41,10 +41,7 @@ hctest_suite("ActsHuksHalFunctionTest") {
"../common/include", "../common/include",
] ]
deps = [ deps = [ "//test/xts/acts/security_lite/huks/common:huks_test_common" ]
#"//base/security/huks/huawei_property/source:huks_new",
"//test/xts/acts/security_lite/huks/common:huks_test_common",
]
cflags = [ cflags = [
"-D_CUT_ED25519_", "-D_CUT_ED25519_",
......
...@@ -21,6 +21,11 @@ ...@@ -21,6 +21,11 @@
#include "cmsis_os2.h" #include "cmsis_os2.h"
#include "ohos_types.h" #include "ohos_types.h"
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
/* /*
* @tc.register: register a test suit named "CalcMultiTest" * @tc.register: register a test suit named "CalcMultiTest"
* @param: test subsystem name * @param: test subsystem name
...@@ -29,6 +34,13 @@ ...@@ -29,6 +34,13 @@
*/ */
LITE_TEST_SUIT(security, securityData, HksAesTest); LITE_TEST_SUIT(security, securityData, HksAesTest);
static void ExecHksInitialize(void const *argument)
{
LiteTestPrint("HksInitialize Begin!\n");
TEST_ASSERT_TRUE(HksInitialize() == 0);
LiteTestPrint("HksInitialize End!\n");
osThreadExit();
}
/** /**
* @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp" * @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp"
* @return: true——setup success * @return: true——setup success
...@@ -37,7 +49,19 @@ static BOOL HksAesTestSetUp() ...@@ -37,7 +49,19 @@ static BOOL HksAesTestSetUp()
{ {
LiteTestPrint("setup\n"); LiteTestPrint("setup\n");
hi_watchdog_disable(); hi_watchdog_disable();
TEST_ASSERT_TRUE(HksInitialize() == 0); osThreadId_t id;
osThreadAttr_t attr;
g_setPriority = osPriorityAboveNormal6;
attr.name = "test";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)ExecHksInitialize, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksAgreementTestSetUp End2!\n");
return TRUE; return TRUE;
} }
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "hctest.h" #include "hctest.h"
#include "hi_watchdog.h" #include "hi_watchdog.h"
#include "hks_agreement_test.h" #include "hks_agreement_test.h"
#include "hks_api.h" #include "hks_api.h"
#include "hks_param.h" #include "hks_param.h"
#include "hks_test_api_performance.h" #include "hks_test_api_performance.h"
...@@ -27,9 +26,14 @@ ...@@ -27,9 +26,14 @@
#include "cmsis_os2.h" #include "cmsis_os2.h"
#include "ohos_types.h" #include "ohos_types.h"
#define TMP_SIZE 512
#define X25519_KEY_SIZE 32
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
#ifndef _CUT_AUTHENTICATE_ static osPriority_t g_setPriority;
#ifndef _CUT_AUTHENTICATE_
/* /*
* @tc.register: register a test suit named "CalcMultiTest" * @tc.register: register a test suit named "CalcMultiTest"
* @param: test subsystem name * @param: test subsystem name
...@@ -38,6 +42,14 @@ ...@@ -38,6 +42,14 @@
*/ */
LITE_TEST_SUIT(security, securityData, HksAgreementTest); LITE_TEST_SUIT(security, securityData, HksAgreementTest);
static void ExecHksInitialize(void const *argument)
{
LiteTestPrint("HksInitialize Begin!\n");
TEST_ASSERT_TRUE(HksInitialize() == 0);
LiteTestPrint("HksInitialize End!\n");
osThreadExit();
}
/** /**
* @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp" * @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp"
* @return: true——setup success * @return: true——setup success
...@@ -45,9 +57,20 @@ LITE_TEST_SUIT(security, securityData, HksAgreementTest); ...@@ -45,9 +57,20 @@ LITE_TEST_SUIT(security, securityData, HksAgreementTest);
static BOOL HksAgreementTestSetUp() static BOOL HksAgreementTestSetUp()
{ {
LiteTestPrint("setup\n"); LiteTestPrint("setup\n");
hi_watchdog_disable(); hi_watchdog_disable();
TEST_ASSERT_TRUE(HksInitialize() == 0); osThreadId_t id;
osThreadAttr_t attr;
g_setPriority = osPriorityAboveNormal6;
attr.name = "test";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)ExecHksInitialize, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksAgreementTestSetUp End2!\n");
return TRUE; return TRUE;
} }
...@@ -63,8 +86,6 @@ static BOOL HksAgreementTestTearDown() ...@@ -63,8 +86,6 @@ static BOOL HksAgreementTestTearDown()
return TRUE; return TRUE;
} }
#define TMP_SIZE 512
#define X25519_KEY_SIZE 32
static const struct HksTestAgreeParams g_testAgreeParams[] = { static const struct HksTestAgreeParams g_testAgreeParams[] = {
/* ree x25519 success */ /* ree x25519 success */
{ 0, HKS_SUCCESS, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE }, { 0, HKS_SUCCESS, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE },
...@@ -100,11 +121,6 @@ static int32_t AgreeKey(const struct HksTestAgreeParamSet *agreeParamSetParams, ...@@ -100,11 +121,6 @@ static int32_t AgreeKey(const struct HksTestAgreeParamSet *agreeParamSetParams,
return ret; return ret;
} }
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
static void ExecHksAgreementTest001(void const *argument) static void ExecHksAgreementTest001(void const *argument)
{ {
LiteTestPrint("HksAgreementTest001 Begin!\n"); LiteTestPrint("HksAgreementTest001 Begin!\n");
......
...@@ -16,13 +16,19 @@ ...@@ -16,13 +16,19 @@
#include "hctest.h" #include "hctest.h"
#include "hi_watchdog.h" #include "hi_watchdog.h"
#include "hks_bn_exp_mod_test.h" #include "hks_bn_exp_mod_test.h"
#include "hks_api.h" #include "hks_api.h"
#include "hks_param.h" #include "hks_param.h"
#include "hks_test_api_performance.h" #include "hks_test_api_performance.h"
#include "hks_test_common.h" #include "hks_test_common.h"
#include "hks_test_log.h" #include "hks_test_log.h"
#include "hks_type.h" #include "hks_type.h"
#include "cmsis_os2.h"
#include "ohos_types.h"
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
/* /*
* @tc.register: register a test suit named "CalcMultiTest" * @tc.register: register a test suit named "CalcMultiTest"
...@@ -32,6 +38,13 @@ ...@@ -32,6 +38,13 @@
*/ */
LITE_TEST_SUIT(security, securityData, HksBnExpModTest); LITE_TEST_SUIT(security, securityData, HksBnExpModTest);
static void ExecHksInitialize(void const *argument)
{
LiteTestPrint("HksInitialize Begin!\n");
TEST_ASSERT_TRUE(HksInitialize() == 0);
LiteTestPrint("HksInitialize End!\n");
osThreadExit();
}
/** /**
* @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp" * @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp"
* @return: true——setup success * @return: true——setup success
...@@ -40,7 +53,19 @@ static BOOL HksBnExpModTestSetUp() ...@@ -40,7 +53,19 @@ static BOOL HksBnExpModTestSetUp()
{ {
LiteTestPrint("setup\n"); LiteTestPrint("setup\n");
hi_watchdog_disable(); hi_watchdog_disable();
TEST_ASSERT_TRUE(HksInitialize() == 0); osThreadId_t id;
osThreadAttr_t attr;
g_setPriority = osPriorityAboveNormal6;
attr.name = "test";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)ExecHksInitialize, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksBnExpModTestSetUp End2!\n");
return TRUE; return TRUE;
} }
......
...@@ -29,6 +29,10 @@ ...@@ -29,6 +29,10 @@
#define TEST_INDEX_2 2 #define TEST_INDEX_2 2
#define TEST_INDEX_3 3 #define TEST_INDEX_3 3
#define TEST_INDEX_4 4 #define TEST_INDEX_4 4
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
/* /*
* @tc.register: register a test suit named "CalcMultiTest" * @tc.register: register a test suit named "CalcMultiTest"
...@@ -38,6 +42,14 @@ ...@@ -38,6 +42,14 @@
*/ */
LITE_TEST_SUIT(security, securityData, HksCipherTest); LITE_TEST_SUIT(security, securityData, HksCipherTest);
static void ExecHksInitialize(void const *argument)
{
LiteTestPrint("HksInitialize Begin!\n");
TEST_ASSERT_TRUE(HksInitialize() == 0);
LiteTestPrint("HksInitialize End!\n");
osThreadExit();
}
/** /**
* @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp" * @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp"
* @return: true——setup success * @return: true——setup success
...@@ -46,7 +58,19 @@ static BOOL HksCipherTestSetUp() ...@@ -46,7 +58,19 @@ static BOOL HksCipherTestSetUp()
{ {
LiteTestPrint("setup\n"); LiteTestPrint("setup\n");
hi_watchdog_disable(); hi_watchdog_disable();
TEST_ASSERT_TRUE(HksInitialize() == 0); osThreadId_t id;
osThreadAttr_t attr;
g_setPriority = osPriorityAboveNormal6;
attr.name = "test";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)ExecHksInitialize, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksCipherTestSetUp End2!\n");
return TRUE; return TRUE;
} }
...@@ -61,11 +85,6 @@ static BOOL HksCipherTestTearDown() ...@@ -61,11 +85,6 @@ static BOOL HksCipherTestTearDown()
return TRUE; return TRUE;
} }
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
static void ExecHksCipherTest001(void const *argument) static void ExecHksCipherTest001(void const *argument)
{ {
LiteTestPrint("HksCipherTest001 Begin!\n"); LiteTestPrint("HksCipherTest001 Begin!\n");
......
...@@ -26,6 +26,13 @@ ...@@ -26,6 +26,13 @@
#include "los_config.h" #include "los_config.h"
#include "ohos_types.h" #include "ohos_types.h"
#include "securec.h" #include "securec.h"
#include "cmsis_os2.h"
#include "ohos_types.h"
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
/* /*
* @tc.register: register a test suit named "CalcMultiTest" * @tc.register: register a test suit named "CalcMultiTest"
...@@ -35,6 +42,13 @@ ...@@ -35,6 +42,13 @@
*/ */
LITE_TEST_SUIT(security, securityData, HksCurve25519Test); LITE_TEST_SUIT(security, securityData, HksCurve25519Test);
static void ExecHksInitialize(void const *argument)
{
LiteTestPrint("HksInitialize Begin!\n");
TEST_ASSERT_TRUE(HksInitialize() == 0);
LiteTestPrint("HksInitialize End!\n");
osThreadExit();
}
/** /**
* @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp" * @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp"
* @return: true——setup success * @return: true——setup success
...@@ -43,7 +57,19 @@ static BOOL HksCurve25519TestSetUp() ...@@ -43,7 +57,19 @@ static BOOL HksCurve25519TestSetUp()
{ {
LiteTestPrint("setup\n"); LiteTestPrint("setup\n");
hi_watchdog_disable(); hi_watchdog_disable();
TEST_ASSERT_TRUE(HksInitialize() == 0); osThreadId_t id;
osThreadAttr_t attr;
g_setPriority = osPriorityAboveNormal6;
attr.name = "test";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)ExecHksInitialize, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksCurve25519TestSetUp End2!\n");
return TRUE; return TRUE;
} }
...@@ -58,12 +84,6 @@ static BOOL HksCurve25519TestTearDown() ...@@ -58,12 +84,6 @@ static BOOL HksCurve25519TestTearDown()
return TRUE; return TRUE;
} }
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
static void LocalHksCurve25519Test001(void const *argument) static void LocalHksCurve25519Test001(void const *argument)
{ {
LiteTestPrint("HksCurve25519Test001 Begin!\n"); LiteTestPrint("HksCurve25519Test001 Begin!\n");
......
...@@ -18,14 +18,23 @@ ...@@ -18,14 +18,23 @@
#include "hctest.h" #include "hctest.h"
#include "hi_watchdog.h" #include "hi_watchdog.h"
#include "hks_delete_test.h" #include "hks_delete_test.h"
#include "hks_api.h" #include "hks_api.h"
#include "hks_param.h" #include "hks_param.h"
#include "hks_test_api_performance.h" #include "hks_test_api_performance.h"
#include "hks_test_common.h" #include "hks_test_common.h"
#include "hks_test_log.h" #include "hks_test_log.h"
#include "hks_type.h" #include "hks_type.h"
#include "cmsis_os2.h"
#include "ohos_types.h"
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
static const struct HksTestKeyExistParams g_testKeyExistParams[] = {
/* normal case */
{ 0, HKS_SUCCESS, true, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE } },
};
/* /*
* @tc.register: register a test suit named "CalcMultiTest" * @tc.register: register a test suit named "CalcMultiTest"
* @param: test subsystem name * @param: test subsystem name
...@@ -34,6 +43,38 @@ ...@@ -34,6 +43,38 @@
*/ */
LITE_TEST_SUIT(security, securityData, HksDeleteTest); LITE_TEST_SUIT(security, securityData, HksDeleteTest);
static void ExecHksInitialize(void const *argument)
{
LiteTestPrint("HksInitialize Begin!\n");
TEST_ASSERT_TRUE(HksInitialize() == 0);
LiteTestPrint("HksInitialize End!\n");
osThreadExit();
}
static void ExecHksDeleteTest001(void const *argument)
{
LiteTestPrint("HksDeleteTest001 Begin!\n");
int32_t ret;
struct HksBlob *keyAlias = NULL;
if (g_testKeyExistParams[0].isGenKey) {
HKS_TEST_ASSERT(TestGenDefaultKeyAndGetAlias(&keyAlias) == 0);
} else {
ret = TestConstuctBlob(&keyAlias,
g_testKeyExistParams[0].keyAliasParams.blobExist,
g_testKeyExistParams[0].keyAliasParams.blobSize,
g_testKeyExistParams[0].keyAliasParams.blobDataExist,
g_testKeyExistParams[0].keyAliasParams.blobDataSize);
HKS_TEST_ASSERT(ret == 0);
}
ret = HksDeleteKeyRun(keyAlias, 1);
HKS_TEST_ASSERT(ret == g_testKeyExistParams[0].expectResult);
TestFreeBlob(&keyAlias);
TEST_ASSERT_TRUE(ret == 0);
LiteTestPrint("HksDeleteTest001 End!\n");
osThreadExit();
}
/** /**
* @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp" * @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp"
* @return: true——setup success * @return: true——setup success
...@@ -42,7 +83,19 @@ static BOOL HksDeleteTestSetUp() ...@@ -42,7 +83,19 @@ static BOOL HksDeleteTestSetUp()
{ {
LiteTestPrint("setup\n"); LiteTestPrint("setup\n");
hi_watchdog_disable(); hi_watchdog_disable();
TEST_ASSERT_TRUE(HksInitialize() == 0); osThreadId_t id;
osThreadAttr_t attr;
g_setPriority = osPriorityAboveNormal6;
attr.name = "test";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)ExecHksInitialize, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksDeriveTestSetUp End2!\n");
return TRUE; return TRUE;
} }
...@@ -57,11 +110,6 @@ static BOOL HksDeleteTestTearDown() ...@@ -57,11 +110,6 @@ static BOOL HksDeleteTestTearDown()
return TRUE; return TRUE;
} }
static const struct HksTestKeyExistParams g_testKeyExistParams[] = {
/* normal case */
{ 0, HKS_SUCCESS, true, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE } },
};
/** /**
* @tc.name: HksDeleteTest.HksDeleteTest001 * @tc.name: HksDeleteTest.HksDeleteTest001
* @tc.desc: The static function will return true; * @tc.desc: The static function will return true;
...@@ -69,24 +117,19 @@ static const struct HksTestKeyExistParams g_testKeyExistParams[] = { ...@@ -69,24 +117,19 @@ static const struct HksTestKeyExistParams g_testKeyExistParams[] = {
*/ */
LITE_TEST_CASE(HksDeleteTest, HksDeleteTest001, Level1) LITE_TEST_CASE(HksDeleteTest, HksDeleteTest001, Level1)
{ {
int32_t ret; osThreadId_t id;
struct HksBlob *keyAlias = NULL; osThreadAttr_t attr;
if (g_testKeyExistParams[0].isGenKey) { g_setPriority = osPriorityAboveNormal6;
HKS_TEST_ASSERT(TestGenDefaultKeyAndGetAlias(&keyAlias) == 0); attr.name = "test";
} else { attr.attr_bits = 0U;
ret = TestConstuctBlob(&keyAlias, attr.cb_mem = NULL;
g_testKeyExistParams[0].keyAliasParams.blobExist, attr.cb_size = 0U;
g_testKeyExistParams[0].keyAliasParams.blobSize, attr.stack_mem = NULL;
g_testKeyExistParams[0].keyAliasParams.blobDataExist, attr.stack_size = TEST_TASK_STACK_SIZE;
g_testKeyExistParams[0].keyAliasParams.blobDataSize); attr.priority = g_setPriority;
HKS_TEST_ASSERT(ret == 0); id = osThreadNew((osThreadFunc_t)ExecHksDeleteTest001, NULL, &attr);
} sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksDeleteTest001 End2!\n");
ret = HksDeleteKeyRun(keyAlias, 1);
HKS_TEST_ASSERT(ret == g_testKeyExistParams[0].expectResult);
TestFreeBlob(&keyAlias);
TEST_ASSERT_TRUE(ret == 0);
} }
RUN_TEST_SUITE(HksDeleteTest); RUN_TEST_SUITE(HksDeleteTest);
......
...@@ -22,10 +22,16 @@ ...@@ -22,10 +22,16 @@
#include "hks_test_api_performance.h" #include "hks_test_api_performance.h"
#include "hks_test_common.h" #include "hks_test_common.h"
#include "hks_test_log.h" #include "hks_test_log.h"
#include "cmsis_os2.h"
#include "ohos_types.h"
#define DEFAULT_DERIVE_SIZE 32 #define DEFAULT_DERIVE_SIZE 32
#define DEFAULT_INFO_SIZE 55 #define DEFAULT_INFO_SIZE 55
#define DEFAULT_SALT_SIZE 16 #define DEFAULT_SALT_SIZE 16
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
/* /*
* @tc.register: register a test suit named "CalcMultiTest" * @tc.register: register a test suit named "CalcMultiTest"
...@@ -35,6 +41,13 @@ ...@@ -35,6 +41,13 @@
*/ */
LITE_TEST_SUIT(security, securityData, HksDeriveTest); LITE_TEST_SUIT(security, securityData, HksDeriveTest);
static void ExecHksInitialize(void const *argument)
{
LiteTestPrint("HksInitialize Begin!\n");
TEST_ASSERT_TRUE(HksInitialize() == 0);
LiteTestPrint("HksInitialize End!\n");
osThreadExit();
}
/** /**
* @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp" * @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp"
* @return: true——setup success * @return: true——setup success
...@@ -43,7 +56,19 @@ static BOOL HksDeriveTestSetUp() ...@@ -43,7 +56,19 @@ static BOOL HksDeriveTestSetUp()
{ {
LiteTestPrint("setup\n"); LiteTestPrint("setup\n");
hi_watchdog_disable(); hi_watchdog_disable();
TEST_ASSERT_TRUE(HksInitialize() == 0); osThreadId_t id;
osThreadAttr_t attr;
g_setPriority = osPriorityAboveNormal6;
attr.name = "test";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)ExecHksInitialize, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksDeriveTestSetUp End2!\n");
return TRUE; return TRUE;
} }
...@@ -199,6 +224,24 @@ static int32_t BaseTestDerive(uint32_t index) ...@@ -199,6 +224,24 @@ static int32_t BaseTestDerive(uint32_t index)
return ret; return ret;
} }
static void ExecHksDeriveTest001(void const *argument)
{
LiteTestPrint("HksDeriveTest001 Begin!\n");
int32_t ret = BaseTestDerive(0);
TEST_ASSERT_TRUE(ret == 0);
LiteTestPrint("HksDeriveTest001 End!\n");
osThreadExit();
}
static void ExecHksDeriveTest002(void const *argument)
{
LiteTestPrint("HksDeriveTest002 Begin!\n");
int32_t ret = BaseTestDerive(1);
TEST_ASSERT_TRUE(ret == 0);
LiteTestPrint("HksDeriveTest002 End!\n");
osThreadExit();
}
#ifndef _CUT_AUTHENTICATE_ #ifndef _CUT_AUTHENTICATE_
/** /**
* @tc.name: HksDeriveTest.HksDeriveTest001 * @tc.name: HksDeriveTest.HksDeriveTest001
...@@ -207,8 +250,19 @@ static int32_t BaseTestDerive(uint32_t index) ...@@ -207,8 +250,19 @@ static int32_t BaseTestDerive(uint32_t index)
*/ */
LITE_TEST_CASE(HksDeriveTest, HksDeriveTest001, Level1) LITE_TEST_CASE(HksDeriveTest, HksDeriveTest001, Level1)
{ {
int32_t ret = BaseTestDerive(0); osThreadId_t id;
TEST_ASSERT_TRUE(ret == 0); osThreadAttr_t attr;
g_setPriority = osPriorityAboveNormal6;
attr.name = "test";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)ExecHksDeriveTest001, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksDeriveTest001 End2!\n");
} }
#endif /* _CUT_AUTHENTICATE_ */ #endif /* _CUT_AUTHENTICATE_ */
...@@ -219,7 +273,18 @@ LITE_TEST_CASE(HksDeriveTest, HksDeriveTest001, Level1) ...@@ -219,7 +273,18 @@ LITE_TEST_CASE(HksDeriveTest, HksDeriveTest001, Level1)
*/ */
LITE_TEST_CASE(HksDeriveTest, HksDeriveTest002, Level1) LITE_TEST_CASE(HksDeriveTest, HksDeriveTest002, Level1)
{ {
int32_t ret = BaseTestDerive(1); osThreadId_t id;
TEST_ASSERT_TRUE(ret == 0); osThreadAttr_t attr;
g_setPriority = osPriorityAboveNormal6;
attr.name = "test";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)ExecHksDeriveTest002, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksDeriveTest002 End2!\n");
} }
RUN_TEST_SUITE(HksDeriveTest); RUN_TEST_SUITE(HksDeriveTest);
...@@ -24,6 +24,18 @@ ...@@ -24,6 +24,18 @@
#include "hks_test_common.h" #include "hks_test_common.h"
#include "hks_test_log.h" #include "hks_test_log.h"
#include "hks_type.h" #include "hks_type.h"
#include "cmsis_os2.h"
#include "ohos_types.h"
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
static const struct HksTestKeyExistParams g_testKeyExistParams[] = {
/* normal case */
{ 0, HKS_SUCCESS, true, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE } },
};
/* /*
* @tc.register: register a test suit named "CalcMultiTest" * @tc.register: register a test suit named "CalcMultiTest"
...@@ -33,6 +45,43 @@ ...@@ -33,6 +45,43 @@
*/ */
LITE_TEST_SUIT(security, securityData, HksExistTest); LITE_TEST_SUIT(security, securityData, HksExistTest);
static void ExecHksInitialize(void const *argument)
{
LiteTestPrint("HksInitialize Begin!\n");
TEST_ASSERT_TRUE(HksInitialize() == 0);
LiteTestPrint("HksInitialize End!\n");
osThreadExit();
}
static void ExecHksExistTest001(void const *argument)
{
int32_t ret;
LiteTestPrint("HksExistTest001 Begin!\n");
struct HksBlob *keyAlias = NULL;
if (g_testKeyExistParams[0].isGenKey) {
TEST_ASSERT_TRUE(TestGenDefaultKeyAndGetAlias(&keyAlias) == 0);
ret = HksKeyExistRun(keyAlias, 1);
TEST_ASSERT_TRUE(ret == g_testKeyExistParams[0].expectResult);
TEST_ASSERT_TRUE(HksDeleteKey(keyAlias, NULL) == HKS_SUCCESS);
} else {
ret = TestConstuctBlob(&keyAlias,
g_testKeyExistParams[0].keyAliasParams.blobExist,
g_testKeyExistParams[0].keyAliasParams.blobSize,
g_testKeyExistParams[0].keyAliasParams.blobDataExist,
g_testKeyExistParams[0].keyAliasParams.blobDataSize);
TEST_ASSERT_TRUE(ret == 0);
ret = HksKeyExistRun(keyAlias, 1);
if (ret != g_testKeyExistParams[0].expectResult) {
HKS_TEST_LOG_I("HksKeyExistRun 2 failed, ret[%u] = %d", g_testKeyExistParams[0].testId, ret);
}
TEST_ASSERT_TRUE(ret == g_testKeyExistParams[0].expectResult);
}
TestFreeBlob(&keyAlias);
TEST_ASSERT_TRUE(ret == 0);
LiteTestPrint("HksExistTest001 End!\n");
osThreadExit();
}
/** /**
* @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp" * @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp"
* @return: true——setup success * @return: true——setup success
...@@ -41,7 +90,19 @@ static BOOL HksExistTestSetUp() ...@@ -41,7 +90,19 @@ static BOOL HksExistTestSetUp()
{ {
LiteTestPrint("setup\n"); LiteTestPrint("setup\n");
hi_watchdog_disable(); hi_watchdog_disable();
TEST_ASSERT_TRUE(HksInitialize() == 0); osThreadId_t id;
osThreadAttr_t attr;
g_setPriority = osPriorityAboveNormal6;
attr.name = "test";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)ExecHksInitialize, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksGenerateKeyTestSetUp End2!\n");
return TRUE; return TRUE;
} }
...@@ -56,12 +117,6 @@ static BOOL HksExistTestTearDown() ...@@ -56,12 +117,6 @@ static BOOL HksExistTestTearDown()
return TRUE; return TRUE;
} }
static const struct HksTestKeyExistParams g_testKeyExistParams[] = {
/* normal case */
{ 0, HKS_SUCCESS, true, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE } },
};
/** /**
* @tc.name: HksExistTest.HksExistTest001 * @tc.name: HksExistTest.HksExistTest001
* @tc.desc: The static function will return true; * @tc.desc: The static function will return true;
...@@ -69,28 +124,19 @@ static const struct HksTestKeyExistParams g_testKeyExistParams[] = { ...@@ -69,28 +124,19 @@ static const struct HksTestKeyExistParams g_testKeyExistParams[] = {
*/ */
LITE_TEST_CASE(HksExistTest, HksExistTest001, Level1) LITE_TEST_CASE(HksExistTest, HksExistTest001, Level1)
{ {
int32_t ret; osThreadId_t id;
struct HksBlob *keyAlias = NULL; osThreadAttr_t attr;
if (g_testKeyExistParams[0].isGenKey) { g_setPriority = osPriorityAboveNormal6;
TEST_ASSERT_TRUE(TestGenDefaultKeyAndGetAlias(&keyAlias) == 0); attr.name = "test";
ret = HksKeyExistRun(keyAlias, 1); attr.attr_bits = 0U;
TEST_ASSERT_TRUE(ret == g_testKeyExistParams[0].expectResult); attr.cb_mem = NULL;
TEST_ASSERT_TRUE(HksDeleteKey(keyAlias, NULL) == HKS_SUCCESS); attr.cb_size = 0U;
} else { attr.stack_mem = NULL;
ret = TestConstuctBlob(&keyAlias, attr.stack_size = TEST_TASK_STACK_SIZE;
g_testKeyExistParams[0].keyAliasParams.blobExist, attr.priority = g_setPriority;
g_testKeyExistParams[0].keyAliasParams.blobSize, id = osThreadNew((osThreadFunc_t)ExecHksExistTest001, NULL, &attr);
g_testKeyExistParams[0].keyAliasParams.blobDataExist, sleep(WAIT_TO_TEST_DONE);
g_testKeyExistParams[0].keyAliasParams.blobDataSize); LiteTestPrint("HksExistTest001 End2!\n");
TEST_ASSERT_TRUE(ret == 0);
ret = HksKeyExistRun(keyAlias, 1);
if (ret != g_testKeyExistParams[0].expectResult) {
HKS_TEST_LOG_I("HksKeyExistRun 2 failed, ret[%u] = %d", g_testKeyExistParams[0].testId, ret);
}
TEST_ASSERT_TRUE(ret == g_testKeyExistParams[0].expectResult);
}
TestFreeBlob(&keyAlias);
TEST_ASSERT_TRUE(ret == 0);
} }
RUN_TEST_SUITE(HksExistTest); RUN_TEST_SUITE(HksExistTest);
#endif /* _CUT_AUTHENTICATE_ */ #endif /* _CUT_AUTHENTICATE_ */
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "ohos_types.h" #include "ohos_types.h"
#define DEFAULT_X25519_PARAM_SET_OUT 104 #define DEFAULT_X25519_PARAM_SET_OUT 104
#define TEST_TASK_STACK_SIZE 0x2000 #define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4 #define WAIT_TO_TEST_DONE 4
...@@ -42,6 +41,14 @@ static osPriority_t g_setPriority; ...@@ -42,6 +41,14 @@ static osPriority_t g_setPriority;
*/ */
LITE_TEST_SUIT(security, securityData, HksGenerateKeyTest); LITE_TEST_SUIT(security, securityData, HksGenerateKeyTest);
static void ExecHksInitialize(void const *argument)
{
LiteTestPrint("HksInitialize Begin!\n");
TEST_ASSERT_TRUE(HksInitialize() == 0);
LiteTestPrint("HksInitialize End!\n");
osThreadExit();
}
/** /**
* @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp" * @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp"
* @return: true——setup success * @return: true——setup success
...@@ -50,7 +57,19 @@ static BOOL HksGenerateKeyTestSetUp() ...@@ -50,7 +57,19 @@ static BOOL HksGenerateKeyTestSetUp()
{ {
LiteTestPrint("setup\n"); LiteTestPrint("setup\n");
hi_watchdog_disable(); hi_watchdog_disable();
TEST_ASSERT_TRUE(HksInitialize() == 0); osThreadId_t id;
osThreadAttr_t attr;
g_setPriority = osPriorityAboveNormal6;
attr.name = "test";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)ExecHksInitialize, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksGenerateKeyTestSetUp End2!\n");
return TRUE; return TRUE;
} }
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
*/ */
#include "hks_generate_random_test.h" #include "hks_generate_random_test.h"
#include "hctest.h" #include "hctest.h"
#include "hi_watchdog.h" #include "hi_watchdog.h"
#include "hks_api.h" #include "hks_api.h"
...@@ -27,6 +26,11 @@ ...@@ -27,6 +26,11 @@
#include "cmsis_os2.h" #include "cmsis_os2.h"
#include "ohos_types.h" #include "ohos_types.h"
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
/* /*
* @tc.register: register a test suit named "CalcMultiTest" * @tc.register: register a test suit named "CalcMultiTest"
* @param: test subsystem name * @param: test subsystem name
...@@ -35,6 +39,14 @@ ...@@ -35,6 +39,14 @@
*/ */
LITE_TEST_SUIT(security, securityData, HksGenerateRandomTest); LITE_TEST_SUIT(security, securityData, HksGenerateRandomTest);
static void ExecHksInitialize(void const *argument)
{
LiteTestPrint("HksInitialize Begin!\n");
TEST_ASSERT_TRUE(HksInitialize() == 0);
LiteTestPrint("HksInitialize End!\n");
osThreadExit();
}
/** /**
* @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp" * @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp"
* @return: true——setup success * @return: true——setup success
...@@ -43,7 +55,19 @@ static BOOL HksGenerateRandomTestSetUp() ...@@ -43,7 +55,19 @@ static BOOL HksGenerateRandomTestSetUp()
{ {
LiteTestPrint("setup\n"); LiteTestPrint("setup\n");
hi_watchdog_disable(); hi_watchdog_disable();
TEST_ASSERT_TRUE(HksInitialize() == 0); osThreadId_t id;
osThreadAttr_t attr;
g_setPriority = osPriorityAboveNormal6;
attr.name = "test";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)ExecHksInitialize, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksGenerateRandomTestSetUp End2!\n");
return TRUE; return TRUE;
} }
...@@ -63,11 +87,6 @@ static const struct HksTestGenRandomParams g_testGenRandomParams[] = { ...@@ -63,11 +87,6 @@ static const struct HksTestGenRandomParams g_testGenRandomParams[] = {
{ 0, HKS_SUCCESS, { true, HKS_MAX_RANDOM_LEN, true, HKS_MAX_RANDOM_LEN } }, { 0, HKS_SUCCESS, { true, HKS_MAX_RANDOM_LEN, true, HKS_MAX_RANDOM_LEN } },
}; };
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
static void ExecHksGenerateRandomTest001(void const *argument) static void ExecHksGenerateRandomTest001(void const *argument)
{ {
int32_t ret; int32_t ret;
......
...@@ -15,8 +15,6 @@ ...@@ -15,8 +15,6 @@
#ifndef _CUT_AUTHENTICATE_ #ifndef _CUT_AUTHENTICATE_
#include "hks_hash_test.h"
#include <hctest.h> #include <hctest.h>
#include "hi_watchdog.h" #include "hi_watchdog.h"
#include "hks_api.h" #include "hks_api.h"
...@@ -25,14 +23,17 @@ ...@@ -25,14 +23,17 @@
#include "hks_test_common.h" #include "hks_test_common.h"
#include "hks_test_log.h" #include "hks_test_log.h"
#include "hks_type.h" #include "hks_type.h"
#include "hks_hash_test.h"
#include "cmsis_os2.h" #include "cmsis_os2.h"
#include "ohos_types.h" #include "ohos_types.h"
#define DEFAULT_SRC_DATA_SIZE 200 #define DEFAULT_SRC_DATA_SIZE 200
#define DIGEST_SHA256_HASH_SIZE 32 #define DIGEST_SHA256_HASH_SIZE 32
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
/* /*
* @tc.register: register a test suit named "CalcMultiTest" * @tc.register: register a test suit named "CalcMultiTest"
...@@ -42,6 +43,14 @@ ...@@ -42,6 +43,14 @@
*/ */
LITE_TEST_SUIT(security, securityData, HksHashTest); LITE_TEST_SUIT(security, securityData, HksHashTest);
static void ExecHksInitialize(void const *argument)
{
LiteTestPrint("HksInitialize Begin!\n");
TEST_ASSERT_TRUE(HksInitialize() == 0);
LiteTestPrint("HksInitialize End!\n");
osThreadExit();
}
/** /**
* @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp" * @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp"
* @return: true——setup success * @return: true——setup success
...@@ -50,7 +59,19 @@ static BOOL HksHashTestSetUp() ...@@ -50,7 +59,19 @@ static BOOL HksHashTestSetUp()
{ {
LiteTestPrint("setup\n"); LiteTestPrint("setup\n");
hi_watchdog_disable(); hi_watchdog_disable();
TEST_ASSERT_TRUE(HksInitialize() == 0); osThreadId_t id;
osThreadAttr_t attr;
g_setPriority = osPriorityAboveNormal6;
attr.name = "test";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)ExecHksInitialize, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksMacTestSetUp End2!\n");
return TRUE; return TRUE;
} }
...@@ -65,11 +86,6 @@ static BOOL HksHashTestTearDown() ...@@ -65,11 +86,6 @@ static BOOL HksHashTestTearDown()
return TRUE; return TRUE;
} }
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
static const struct HksTestHashParams g_testHashParams[] = { static const struct HksTestHashParams g_testHashParams[] = {
/* normal case */ /* normal case */
{ 0, HKS_SUCCESS, { 0, HKS_SUCCESS,
......
...@@ -30,6 +30,11 @@ ...@@ -30,6 +30,11 @@
#define HKS_DEFAULT_MAC_SRCDATA_SIZE 253 #define HKS_DEFAULT_MAC_SRCDATA_SIZE 253
#define HKS_DEFAULT_MAC_SHA256_SIZE 32 #define HKS_DEFAULT_MAC_SHA256_SIZE 32
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
static const struct HksTestMacParams g_testMacParams[] = { static const struct HksTestMacParams g_testMacParams[] = {
/* success: ree-sha256 */ /* success: ree-sha256 */
...@@ -59,6 +64,14 @@ static const struct HksTestMacParams g_testMacParams[] = { ...@@ -59,6 +64,14 @@ static const struct HksTestMacParams g_testMacParams[] = {
*/ */
LITE_TEST_SUIT(security, securityData, HksMacTest); LITE_TEST_SUIT(security, securityData, HksMacTest);
static void ExecHksInitialize(void const *argument)
{
LiteTestPrint("HksInitialize Begin!\n");
TEST_ASSERT_TRUE(HksInitialize() == 0);
LiteTestPrint("HksInitialize End!\n");
osThreadExit();
}
/** /**
* @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp" * @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp"
* @return: true——setup success * @return: true——setup success
...@@ -67,7 +80,19 @@ static BOOL HksMacTestSetUp() ...@@ -67,7 +80,19 @@ static BOOL HksMacTestSetUp()
{ {
LiteTestPrint("setup\n"); LiteTestPrint("setup\n");
hi_watchdog_disable(); hi_watchdog_disable();
TEST_ASSERT_TRUE(HksInitialize() == 0); osThreadId_t id;
osThreadAttr_t attr;
g_setPriority = osPriorityAboveNormal6;
attr.name = "test";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)ExecHksInitialize, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksMacTestSetUp End2!\n");
return TRUE; return TRUE;
} }
...@@ -82,12 +107,6 @@ static BOOL HksMacTestTearDown() ...@@ -82,12 +107,6 @@ static BOOL HksMacTestTearDown()
return TRUE; return TRUE;
} }
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
static int32_t ConstructDataToBlob(struct HksBlob **srcData, struct HksBlob **macData, static int32_t ConstructDataToBlob(struct HksBlob **srcData, struct HksBlob **macData,
const struct HksTestBlobParams *srcDataParams, const struct HksTestBlobParams *macDataParams) const struct HksTestBlobParams *srcDataParams, const struct HksTestBlobParams *macDataParams)
{ {
......
...@@ -37,6 +37,11 @@ ...@@ -37,6 +37,11 @@
static const char *g_storePath = "./hks_store/"; static const char *g_storePath = "./hks_store/";
static const char *g_testName = "TestName"; static const char *g_testName = "TestName";
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
static const struct HksTestCipherParams g_testCipherParams[] = { static const struct HksTestCipherParams g_testCipherParams[] = {
/* success: aes256-gcm-none */ /* success: aes256-gcm-none */
{ 0, HKS_SUCCESS, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE }, { 0, HKS_SUCCESS, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE },
...@@ -88,6 +93,14 @@ static const struct HksTestCipherParams g_testCipherParams[] = { ...@@ -88,6 +93,14 @@ static const struct HksTestCipherParams g_testCipherParams[] = {
*/ */
LITE_TEST_SUIT(security, securityData, HksModifyKeyTest); LITE_TEST_SUIT(security, securityData, HksModifyKeyTest);
static void ExecHksInitialize(void const *argument)
{
LiteTestPrint("HksInitialize Begin!\n");
TEST_ASSERT_TRUE(HksInitialize() == 0);
LiteTestPrint("HksInitialize End!\n");
osThreadExit();
}
/** /**
* @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp" * @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp"
* @return: true——setup success * @return: true——setup success
...@@ -96,7 +109,19 @@ static BOOL HksModifyKeyTestSetUp() ...@@ -96,7 +109,19 @@ static BOOL HksModifyKeyTestSetUp()
{ {
LiteTestPrint("setup\n"); LiteTestPrint("setup\n");
hi_watchdog_disable(); hi_watchdog_disable();
TEST_ASSERT_TRUE(HksInitialize() == 0); osThreadId_t id;
osThreadAttr_t attr;
g_setPriority = osPriorityAboveNormal6;
attr.name = "test";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)ExecHksInitialize, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksModifyKeyTestSetUp End2!\n");
return TRUE; return TRUE;
} }
...@@ -310,13 +335,10 @@ int32_t __attribute__((weak)) HksStoreKeyBlob(const struct HksBlob *processName, ...@@ -310,13 +335,10 @@ int32_t __attribute__((weak)) HksStoreKeyBlob(const struct HksBlob *processName,
(void)keyBlob; (void)keyBlob;
} }
/** static void ExecHksModifyKeyTest001(void const *argument)
* @tc.name: HksModifyKeyTest.HksModifyKeyTest001
* @tc.desc: The static function will return true;
* @tc.type: FUNC
*/
LITE_TEST_CASE(HksModifyKeyTest, HksModifyKeyTest001, Level1)
{ {
LiteTestPrint("HksModifyKeyTest001 Begin!\n");
uint32_t index = 0; uint32_t index = 0;
struct HksBlob keyAlias = { strlen(g_testName), (uint8_t *)g_testName }; struct HksBlob keyAlias = { strlen(g_testName), (uint8_t *)g_testName };
int32_t ret = GenerateKeyTwo(&keyAlias, &g_testCipherParams[index].keyAliasParams, int32_t ret = GenerateKeyTwo(&keyAlias, &g_testCipherParams[index].keyAliasParams,
...@@ -365,6 +387,31 @@ LITE_TEST_CASE(HksModifyKeyTest, HksModifyKeyTest001, Level1) ...@@ -365,6 +387,31 @@ LITE_TEST_CASE(HksModifyKeyTest, HksModifyKeyTest001, Level1)
TestFreeBlob(&nonceData); TestFreeBlob(&nonceData);
TestFreeBlob(&aadData); TestFreeBlob(&aadData);
TEST_ASSERT_TRUE(ret != 0); TEST_ASSERT_TRUE(ret != 0);
LiteTestPrint("HksModifyKeyTest001 End!\n");
osThreadExit();
}
/**
* @tc.name: HksModifyKeyTest.HksModifyKeyTest001
* @tc.desc: The static function will return true;
* @tc.type: FUNC
*/
LITE_TEST_CASE(HksModifyKeyTest, HksModifyKeyTest001, Level1)
{
osThreadId_t id;
osThreadAttr_t attr;
g_setPriority = osPriorityAboveNormal6;
attr.name = "test";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)ExecHksModifyKeyTest001, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksModifyKeyTest001 End2!\n");
} }
RUN_TEST_SUITE(HksModifyKeyTest); RUN_TEST_SUITE(HksModifyKeyTest);
......
...@@ -26,6 +26,11 @@ ...@@ -26,6 +26,11 @@
#include "cmsis_os2.h" #include "cmsis_os2.h"
#include "ohos_types.h" #include "ohos_types.h"
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
/* /*
* @tc.register: register a test suit named "CalcMultiTest" * @tc.register: register a test suit named "CalcMultiTest"
* @param: test subsystem name * @param: test subsystem name
...@@ -34,6 +39,13 @@ ...@@ -34,6 +39,13 @@
*/ */
LITE_TEST_SUIT(security, securityData, HksOthersTest); LITE_TEST_SUIT(security, securityData, HksOthersTest);
static void ExecHksInitialize(void const *argument)
{
LiteTestPrint("HksInitialize Begin!\n");
TEST_ASSERT_TRUE(HksInitialize() == 0);
LiteTestPrint("HksInitialize End!\n");
osThreadExit();
}
/** /**
* @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp" * @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp"
* @return: true——setup success * @return: true——setup success
...@@ -42,7 +54,19 @@ static BOOL HksOthersTestSetUp() ...@@ -42,7 +54,19 @@ static BOOL HksOthersTestSetUp()
{ {
LiteTestPrint("setup\n"); LiteTestPrint("setup\n");
hi_watchdog_disable(); hi_watchdog_disable();
TEST_ASSERT_TRUE(HksInitialize() == 0); osThreadId_t id;
osThreadAttr_t attr;
g_setPriority = osPriorityAboveNormal6;
attr.name = "test";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)ExecHksInitialize, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksOthersTestSetUp End2!\n");
return TRUE; return TRUE;
} }
...@@ -57,11 +81,6 @@ static BOOL HksOthersTestTearDown() ...@@ -57,11 +81,6 @@ static BOOL HksOthersTestTearDown()
return TRUE; return TRUE;
} }
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
static void ExcHksOthersTest001(void const *argument) static void ExcHksOthersTest001(void const *argument)
{ {
LiteTestPrint("HksOthersTest001 Begin!\n"); LiteTestPrint("HksOthersTest001 Begin!\n");
......
...@@ -30,6 +30,11 @@ ...@@ -30,6 +30,11 @@
const char *g_storePath = "/storage/"; const char *g_storePath = "/storage/";
const char *g_testEd25519 = "test_ed25519"; const char *g_testEd25519 = "test_ed25519";
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
/* /*
* @tc.register: register a test suit named "CalcMultiTest" * @tc.register: register a test suit named "CalcMultiTest"
* @param: test subsystem name * @param: test subsystem name
...@@ -38,6 +43,14 @@ const char *g_testEd25519 = "test_ed25519"; ...@@ -38,6 +43,14 @@ const char *g_testEd25519 = "test_ed25519";
*/ */
LITE_TEST_SUIT(security, securityData, HksSafeCipherKeyTest); LITE_TEST_SUIT(security, securityData, HksSafeCipherKeyTest);
static void ExecHksInitialize(void const *argument)
{
LiteTestPrint("HksInitialize Begin!\n");
TEST_ASSERT_TRUE(HksInitialize() == 0);
LiteTestPrint("HksInitialize End!\n");
osThreadExit();
}
/** /**
* @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp" * @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp"
* @return: true——setup success * @return: true——setup success
...@@ -46,7 +59,20 @@ static BOOL HksSafeCipherKeyTestSetUp() ...@@ -46,7 +59,20 @@ static BOOL HksSafeCipherKeyTestSetUp()
{ {
LiteTestPrint("setup\n"); LiteTestPrint("setup\n");
hi_watchdog_disable(); hi_watchdog_disable();
TEST_ASSERT_TRUE(HksInitialize() == 0); osThreadId_t id;
osThreadAttr_t attr;
g_setPriority = osPriorityAboveNormal6;
attr.name = "test";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)ExecHksInitialize, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksSafeCipherKeyTestSetUp End2!\n");
return TRUE; return TRUE;
} }
......
...@@ -34,6 +34,11 @@ static const char *g_storePath = "/storage/"; ...@@ -34,6 +34,11 @@ static const char *g_storePath = "/storage/";
static const char *g_testOne = "TestOne"; static const char *g_testOne = "TestOne";
static const char *g_testTwo = "TestTwo"; static const char *g_testTwo = "TestTwo";
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
/* /*
* @tc.register: register a test suit named "CalcMultiTest" * @tc.register: register a test suit named "CalcMultiTest"
* @param: test subsystem name * @param: test subsystem name
...@@ -46,11 +51,31 @@ LITE_TEST_SUIT(security, securityData, HksSafeCompareKeyTest); ...@@ -46,11 +51,31 @@ LITE_TEST_SUIT(security, securityData, HksSafeCompareKeyTest);
* @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp" * @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp"
* @return: true——setup success * @return: true——setup success
*/ */
static void ExecHksInitialize(void const *argument)
{
LiteTestPrint("HksInitialize Begin!\n");
TEST_ASSERT_TRUE(HksInitialize() == 0);
LiteTestPrint("HksInitialize End!\n");
osThreadExit();
}
static BOOL HksSafeCompareKeyTestSetUp() static BOOL HksSafeCompareKeyTestSetUp()
{ {
LiteTestPrint("setup\n"); LiteTestPrint("setup\n");
hi_watchdog_disable(); hi_watchdog_disable();
TEST_ASSERT_TRUE(HksInitialize() == 0); osThreadId_t id;
osThreadAttr_t attr;
g_setPriority = osPriorityAboveNormal6;
attr.name = "test";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)ExecHksInitialize, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksSafeCompareKeyTestSetUp End2!\n");
return TRUE; return TRUE;
} }
...@@ -65,10 +90,7 @@ static BOOL HksSafeCompareKeyTestTearDown() ...@@ -65,10 +90,7 @@ static BOOL HksSafeCompareKeyTestTearDown()
return TRUE; return TRUE;
} }
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
static const struct HksTestGenKeyParams g_testGenKeyParams[] = { static const struct HksTestGenKeyParams g_testGenKeyParams[] = {
/* x25519: tee sign/verify */ /* x25519: tee sign/verify */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册