提交 ddfa70ad 编写于 作者: A aaronwangjun

aaron.wangjun@huawei.com

Signed-off-by: Naaronwangjun <aaron.wangjun@huawei.com>
Change-Id: I277cdff387f349c9fae516173be688cf1fd6fe3f
上级 e6305f40
......@@ -41,7 +41,6 @@ lite_component("acts_component") {
"//test/xts/acts/kernel_lite/kernelcmsis_hal:ActsCMSISTest",
"//test/xts/acts/utils_lite/kv_store_hal:ActsKvStoreTest",
#"//test/xts/acts/security_lite/huks_hal:ActsSecurityDataTest",
"//test/xts/acts/security_lite/huks/liteos_m_adapter:ActsHuksHalFunctionTest",
"//test/xts/acts/hiviewdfx_lite/hilog_hal:ActsDfxFuncTest",
"//test/xts/acts/hiviewdfx_lite/hievent_hal:ActsHieventLiteTest",
......@@ -89,7 +88,6 @@ lite_component("acts_component") {
"//test/xts/acts/utils_lite/kv_store_posix:ActsKvStoreTest",
"//test/xts/acts/startup_lite/syspara_posix:ActsParameterTest",
#"//test/xts/acts/security_lite/huks_posix:ActsSecurityDataTest",
"//test/xts/acts/security_lite/permission_posix/pms:ActsPMSTest",
#"//test/xts/acts/multimedia_lite/camera_lite_posix/camera_native:ActsMediaCameraTest",
......
......@@ -74,7 +74,7 @@ ohos_moduletest_suite("huks_std_function_test") {
deps = [
"//base/security/huks/frameworks/huks_standard/main:huks_standard_frameworks",
"//base/security/huks/interfaces/innerkits/huks_standard/main:libhukssdk",
"//test/xts/acts/security_lite/huks/common:huks_new_test_common",
"//test/xts/acts/security_lite/huks/common:huks_test_common",
"//third_party/bounds_checking_function:libsec_static",
"//utils/native/base:utils",
]
......
......@@ -13,7 +13,6 @@
group("securitytest") {
deps = [
#"//test/xts/acts/security_lite/huks_posix:ActsSecurityDataTest",
"//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/dac:ActsDacTest",
......
......@@ -22,14 +22,14 @@ config("hilog_lite_dir") {
[ "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite/" ]
}
config("huks_test_common") {
config("huks_test_common_dir") {
include_dirs = [
"//base/security/huks/interfaces/innerkits/huks_standard/main/include",
"include",
]
}
static_library("huks_new_test_common") {
static_library("huks_test_common") {
sources = [
"hks_test_aes.c",
"hks_test_api_performance.c",
......@@ -52,7 +52,7 @@ static_library("huks_new_test_common") {
"include",
]
configs += [ ":huks_test_common" ]
configs += [ ":huks_test_common_dir" ]
if (defined(ohos_lite)) {
if (ohos_kernel_type == "liteos_m") {
......
......@@ -48,7 +48,7 @@ hcpptest_suite("ActsHuksLiteFunctionTest") {
deps = [
"//base/security/huks/interfaces/innerkits/huks_lite:huks_3.0_sdk",
"//test/xts/acts/security_lite/huks/common:huks_new_test_common",
"//test/xts/acts/security_lite/huks/common:huks_test_common",
]
cflags = [ "-Wno-error" ]
......
......@@ -43,7 +43,7 @@ hctest_suite("ActsHuksHalFunctionTest") {
deps = [
#"//base/security/huks/huawei_property/source:huks_new",
"//test/xts/acts/security_lite/huks/common:huks_new_test_common",
"//test/xts/acts/security_lite/huks/common:huks_test_common",
]
cflags = [
......
......@@ -18,6 +18,8 @@
#include "hks_api.h"
#include "hks_param.h"
#include "securec.h"
#include "cmsis_os2.h"
#include "ohos_types.h"
/*
* @tc.register: register a test suit named "CalcMultiTest"
......@@ -50,6 +52,43 @@ static BOOL HksAesTestTearDown()
return TRUE;
}
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
static void ExecHksAesTest001(void const *argument)
{
LiteTestPrint("HksAesTest001 Begin!\n");
TEST_ASSERT_TRUE(TestAes256ByAgree() == 0);
LiteTestPrint("HksAesTest001 End!\n");
osThreadExit();
}
static void ExecHksAesTest002(void const *argument)
{
LiteTestPrint("HksAesTest002 Begin!\n");
TEST_ASSERT_TRUE(TestAes256ByAgree1() == 0);
LiteTestPrint("HksAesTest002 End!\n");
osThreadExit();
}
static void ExecHksAesTest003(void const *argument)
{
LiteTestPrint("HksAesTest003 Begin!\n");
TEST_ASSERT_TRUE(TestAes256ByAgree2() == 0);
LiteTestPrint("HksAesTest003 End!\n");
osThreadExit();
}
static void ExecHksAesTest004(void const *argument)
{
LiteTestPrint("HksAesTest004 Begin!\n");
TEST_ASSERT_EQUAL(TestAes256ByLocal(), 0);
LiteTestPrint("HksAesTest004 End!\n");
osThreadExit();
}
#ifndef _CUT_AUTHENTICATE_
#ifndef _CUT_ED25519_
/**
......@@ -59,7 +98,19 @@ static BOOL HksAesTestTearDown()
*/
LITE_TEST_CASE(HksAesTest, HksAesTest001, Level1)
{
TEST_ASSERT_TRUE(TestAes256ByAgree() == 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)ExecHksAesTest001, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksAesTest001 End2!\n");
}
/**
......@@ -69,7 +120,19 @@ LITE_TEST_CASE(HksAesTest, HksAesTest001, Level1)
*/
LITE_TEST_CASE(HksAesTest, HksAesTest002, Level1)
{
TEST_ASSERT_TRUE(TestAes256ByAgree1() == 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)ExecHksAesTest002, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksAesTest002 End2!\n");
}
/**
......@@ -79,7 +142,20 @@ LITE_TEST_CASE(HksAesTest, HksAesTest002, Level1)
*/
LITE_TEST_CASE(HksAesTest, HksAesTest003, Level1)
{
TEST_ASSERT_TRUE(TestAes256ByAgree2() == 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)ExecHksAesTest003, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksAesTest003 End2!\n");
}
#endif
#endif /* _CUT_AUTHENTICATE_ */
......@@ -91,7 +167,19 @@ LITE_TEST_CASE(HksAesTest, HksAesTest003, Level1)
*/
LITE_TEST_CASE(HksAesTest, HksAesTest004, Level1)
{
TEST_ASSERT_EQUAL(TestAes256ByLocal(), 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)ExecHksAesTest004, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksAesTest004 End2!\n");
}
RUN_TEST_SUITE(HksAesTest);
......@@ -24,6 +24,10 @@
#include "hks_test_log.h"
#include "hks_type.h"
#include "cmsis_os2.h"
#include "ohos_types.h"
#ifndef _CUT_AUTHENTICATE_
/*
......@@ -96,13 +100,15 @@ static int32_t AgreeKey(const struct HksTestAgreeParamSet *agreeParamSetParams,
return ret;
}
/**
* @tc.name: HksDeleteTest.HksDeleteTest001
* @tc.desc: The static function will return true;
* @tc.type: FUNC
*/
LITE_TEST_CASE(HksAgreementTest, HksAgreementTest001, Level1)
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
static void ExecHksAgreementTest001(void const *argument)
{
LiteTestPrint("HksAgreementTest001 Begin!\n");
/* 1. generate key */
struct HksBlob *privateKey = NULL;
struct HksBlob *peerPubKeyAlias = NULL;
......@@ -143,72 +149,103 @@ LITE_TEST_CASE(HksAgreementTest, HksAgreementTest001, Level1)
TestFreeBlob(&peerPublicKey);
TestFreeBlob(&agreeKey);
TEST_ASSERT_TRUE(ret == 0);
}
LiteTestPrint("HksAgreementTest001 End!\n");
osThreadExit();
}
/**
* @tc.name: HksDeleteTest.HksDeleteTest002
* @tc.desc: The static function will return true;
* @tc.type: FUNC
*/
LITE_TEST_CASE(HksAgreementTest, HksAgreementTest002, Level1)
static void ExecHksAgreementTest002(void const *argument)
{
LiteTestPrint("HksAgreementTest002 Begin!\n");
/* 1. generate key */
struct HksBlob *privateKey = NULL;
struct HksBlob *peerPubKeyAlias = NULL;
struct HksBlob *peerPublicKey = NULL;
struct HksBlob *privateKey1 = NULL;
struct HksBlob *peerPubKeyAlias1 = NULL;
struct HksBlob *peerPublicKey1 = NULL;
int32_t ret;
if (g_testAgreeParams[0].genKeyParamSetParams.setKeyStorageFlag &&
(g_testAgreeParams[0].genKeyParamSetParams.keyStorageFlag == HKS_STORAGE_TEMP)) {
ret = GenerateLocalX25519Key(&privateKey, &peerPublicKey, &g_testAgreeParams[0].localPrivateKeyParams, \
&g_testAgreeParams[0].localPublicKeyParams);
TEST_ASSERT_TRUE(ret == 0);
ret = GenerateLocalX25519Key(&privateKey1, &peerPublicKey1, &g_testAgreeParams[0].localPrivateKeyParams, \
&g_testAgreeParams[0].localPublicKeyParams);
TEST_ASSERT_TRUE(ret == 0);
ret = GenerateLocalX25519Key(&privateKey, NULL, &g_testAgreeParams[0].localPrivateKeyParams, NULL);
HKS_TEST_ASSERT(ret == 0);
ret = GenerateLocalX25519Key(NULL, &peerPublicKey, NULL, &g_testAgreeParams[0].localPublicKeyParams);
HKS_TEST_ASSERT(ret == 0);
}
/* 2. agreeKey */
struct HksBlob *agreeKey = NULL;
ret = TestConstuctBlob(&agreeKey, g_testAgreeParams[0].agreedKeyParams.blobExist, \
g_testAgreeParams[0].agreedKeyParams.blobSize, g_testAgreeParams[0].agreedKeyParams.blobDataExist, \
g_testAgreeParams[0].agreedKeyParams.blobDataSize);
TEST_ASSERT_TRUE(ret == 0);
ret = AgreeKey(&g_testAgreeParams[0].agreeParamSetParams, privateKey, peerPublicKey1, agreeKey);
TEST_ASSERT_TRUE(ret == g_testAgreeParams[0].expectResult);
struct HksBlob *agreeKey1 = NULL;
ret = TestConstuctBlob(&agreeKey1, g_testAgreeParams[0].agreedKeyParams.blobExist, \
g_testAgreeParams[0].agreedKeyParams.blobSize, g_testAgreeParams[0].agreedKeyParams.blobDataExist, \
ret = TestConstuctBlob(&agreeKey,
g_testAgreeParams[0].agreedKeyParams.blobExist,
g_testAgreeParams[0].agreedKeyParams.blobSize,
g_testAgreeParams[0].agreedKeyParams.blobDataExist,
g_testAgreeParams[0].agreedKeyParams.blobDataSize);
TEST_ASSERT_TRUE(ret == 0);
HKS_TEST_ASSERT(ret == 0);
ret = AgreeKey(&g_testAgreeParams[0].agreeParamSetParams, privateKey1, peerPublicKey, agreeKey1);
TEST_ASSERT_TRUE(ret == g_testAgreeParams[0].expectResult);
TEST_ASSERT_EQUAL(agreeKey->size, agreeKey1->size);
TEST_ASSERT_TRUE(memcmp(agreeKey->data, agreeKey1->data, agreeKey->size) == 0);
ret = AgreeKey(&g_testAgreeParams[0].agreeParamSetParams, privateKey, peerPublicKey, agreeKey);
HKS_TEST_ASSERT(ret == g_testAgreeParams[0].expectResult);
/* 3. delete key */
if (!(g_testAgreeParams[0].genKeyParamSetParams.setKeyStorageFlag &&
(g_testAgreeParams[0].genKeyParamSetParams.keyStorageFlag == HKS_STORAGE_TEMP)) &&
((g_testAgreeParams[0].keyAlias1Params.blobExist) && (g_testAgreeParams[0].keyAlias2Params.blobExist))) {
TEST_ASSERT_TRUE(HksDeleteKey(privateKey, NULL) == 0);
TEST_ASSERT_TRUE(HksDeleteKey(peerPubKeyAlias, NULL) == 0);
TEST_ASSERT_TRUE(HksDeleteKey(privateKey1, NULL) == 0);
TEST_ASSERT_TRUE(HksDeleteKey(peerPubKeyAlias1, NULL) == 0);
((g_testAgreeParams[0].keyAlias1Params.blobExist) &&
(g_testAgreeParams[0].keyAlias2Params.blobExist))) {
ret = HksDeleteKey(privateKey, NULL);
HKS_TEST_ASSERT(ret == 0);
ret = HksDeleteKey(peerPubKeyAlias, NULL);
HKS_TEST_ASSERT(ret == 0);
}
TestFreeBlob(&privateKey);
TestFreeBlob(&peerPubKeyAlias);
TestFreeBlob(&peerPublicKey);
TestFreeBlob(&agreeKey);
TestFreeBlob(&privateKey1);
TestFreeBlob(&peerPubKeyAlias1);
TestFreeBlob(&peerPublicKey1);
TestFreeBlob(&agreeKey1);
TEST_ASSERT_TRUE(ret == 0);
LiteTestPrint("HksAgreementTest002 End!\n");
osThreadExit();
}
/**
* @tc.name: HksDeleteTest.HksDeleteTest001
* @tc.desc: The static function will return true;
* @tc.type: FUNC
*/
LITE_TEST_CASE(HksAgreementTest, HksAgreementTest001, 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)ExecHksAgreementTest001, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksAgreementTest001 End2!\n");
}
/**
* @tc.name: HksDeleteTest.HksDeleteTest002
* @tc.desc: The static function will return true;
* @tc.type: FUNC
*/
LITE_TEST_CASE(HksAgreementTest, HksAgreementTest002, 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)ExecHksAgreementTest002, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksAgreementTest002 End2!\n");
}
RUN_TEST_SUITE(HksAgreementTest);
......
......@@ -21,6 +21,8 @@
#include "hks_param.h"
#include "hks_test_cipher.h"
#include "securec.h"
#include "cmsis_os2.h"
#include "ohos_types.h"
#define TEST_INDEX_0 0
#define TEST_INDEX_1 1
......@@ -59,6 +61,107 @@ static BOOL HksCipherTestTearDown()
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)
{
LiteTestPrint("HksCipherTest001 Begin!\n");
TEST_ASSERT_TRUE(BaseTestCipher(1, TEST_INDEX_0, 1) == 0);
LiteTestPrint("HksCipherTest001 End!\n");
osThreadExit();
}
static void ExecHksCipherTest002(void const *argument)
{
LiteTestPrint("HksCipherTest002 Begin!\n");
TEST_ASSERT_TRUE(BaseTestCipher(1, TEST_INDEX_0, 1) == 0);
LiteTestPrint("HksCipherTest002 End!\n");
osThreadExit();
}
static void ExecHksCipherTest003(void const *argument)
{
LiteTestPrint("HksCipherTest003 Begin!\n");
TEST_ASSERT_TRUE(BaseTestEncrypt(1, TEST_INDEX_0, 1) == 0);
LiteTestPrint("HksCipherTest003 End!\n");
osThreadExit();
}
static void ExecHksCipherTest004(void const *argument)
{
LiteTestPrint("HksCipherTest004 Begin!\n");
TEST_ASSERT_TRUE(BaseTestEncrypt(1, TEST_INDEX_1, 1) == 0);
LiteTestPrint("HksCipherTest004 End!\n");
osThreadExit();
}
static void ExecHksCipherTest005(void const *argument)
{
LiteTestPrint("HksCipherTest005 Begin!\n");
TEST_ASSERT_TRUE(BaseTestEncrypt(1, TEST_INDEX_2, 1) == 0);
LiteTestPrint("HksCipherTest005 End!\n");
osThreadExit();
}
static void ExecHksCipherTest006(void const *argument)
{
LiteTestPrint("HksCipherTest006 Begin!\n");
TEST_ASSERT_TRUE(BaseTestEncrypt(1, TEST_INDEX_3, 1) == 0);
LiteTestPrint("HksCipherTest006 End!\n");
osThreadExit();
}
static void ExecHksCipherTest007(void const *argument)
{
LiteTestPrint("HksCipherTest007 Begin!\n");
TEST_ASSERT_TRUE(BaseTestEncrypt(1, TEST_INDEX_4, 1) == 0);
LiteTestPrint("HksCipherTest007 End!\n");
osThreadExit();
}
static void ExecHksCipherTest008(void const *argument)
{
LiteTestPrint("HksCipherTest008 Begin!\n");
TEST_ASSERT_TRUE(BaseTestDecrypt(1, TEST_INDEX_0, 1) == 0);
LiteTestPrint("HksCipherTest008 End!\n");
osThreadExit();
}
static void ExecHksCipherTest009(void const *argument)
{
LiteTestPrint("HksCipherTest009 Begin!\n");
TEST_ASSERT_TRUE(BaseTestDecrypt(1, TEST_INDEX_1, 1) == 0);
LiteTestPrint("HksCipherTest009 End!\n");
osThreadExit();
}
static void ExecHksCipherTest010(void const *argument)
{
LiteTestPrint("HksCipherTest010 Begin!\n");
TEST_ASSERT_TRUE(BaseTestDecrypt(1, TEST_INDEX_2, 1) == 0);
LiteTestPrint("HksCipherTest010 End!\n");
osThreadExit();
}
static void ExecHksCipherTest011(void const *argument)
{
LiteTestPrint("HksCipherTest011 Begin!\n");
TEST_ASSERT_TRUE(BaseTestDecrypt(1, TEST_INDEX_3, 1) == 0);
LiteTestPrint("HksCipherTest011 End!\n");
osThreadExit();
}
static void ExecHksCipherTest012(void const *argument)
{
LiteTestPrint("HksCipherTest012 Begin!\n");
TEST_ASSERT_TRUE(BaseTestDecrypt(1, TEST_INDEX_4, 1) == 0);
LiteTestPrint("HksCipherTest012 End!\n");
osThreadExit();
}
/**
* @tc.name: HksCipherTest.HksCipherTest001
......@@ -67,64 +170,209 @@ static BOOL HksCipherTestTearDown()
*/
LITE_TEST_CASE(HksCipherTest, HksCipherTest001, Level1)
{
TEST_ASSERT_TRUE(BaseTestCipher(1, TEST_INDEX_0, 1) == 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)ExecHksCipherTest001, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksCipherTest001 End2!\n");
}
#ifndef _CUT_AUTHENTICATE_
LITE_TEST_CASE(HksCipherTest, HksCipherTest002, Level1)
{
TEST_ASSERT_TRUE(BaseTestCipher(1, TEST_INDEX_1, 1) == 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)ExecHksCipherTest002, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksCipherTest002 End2!\n");
}
LITE_TEST_CASE(HksCipherTest, HksCipherTest003, Level1)
{
TEST_ASSERT_TRUE(BaseTestEncrypt(1, TEST_INDEX_0, 1) == 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)ExecHksCipherTest003, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksCipherTest003 End2!\n");
}
LITE_TEST_CASE(HksCipherTest, HksCipherTest004, Level1)
{
TEST_ASSERT_TRUE(BaseTestEncrypt(1, TEST_INDEX_1, 1) == 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)ExecHksCipherTest004, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksCipherTest004 End2!\n");
}
LITE_TEST_CASE(HksCipherTest, HksCipherTest005, Level1)
{
TEST_ASSERT_TRUE(BaseTestEncrypt(1, TEST_INDEX_2, 1) == 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)ExecHksCipherTest005, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksCipherTest005 End2!\n");
}
LITE_TEST_CASE(HksCipherTest, HksCipherTest006, Level1)
{
TEST_ASSERT_TRUE(BaseTestEncrypt(1, TEST_INDEX_3, 1) == 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)ExecHksCipherTest006, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksCipherTest006 End2!\n");
}
LITE_TEST_CASE(HksCipherTest, HksCipherTest007, Level1)
{
TEST_ASSERT_TRUE(BaseTestEncrypt(1, TEST_INDEX_4, 1) == 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)ExecHksCipherTest007, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksCipherTest007 End2!\n");
}
LITE_TEST_CASE(HksCipherTest, HksCipherTest008, Level1)
{
TEST_ASSERT_TRUE(BaseTestDecrypt(1, TEST_INDEX_0, 1) == 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)ExecHksCipherTest008, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksCipherTest008 End2!\n");
}
LITE_TEST_CASE(HksCipherTest, HksCipherTest009, Level1)
{
TEST_ASSERT_TRUE(BaseTestDecrypt(1, TEST_INDEX_1, 1) == 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)ExecHksCipherTest009, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksCipherTest009 End2!\n");
}
LITE_TEST_CASE(HksCipherTest, HksCipherTest010, Level1)
{
TEST_ASSERT_TRUE(BaseTestDecrypt(1, TEST_INDEX_2, 1) == 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)ExecHksCipherTest010, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksCipherTest010 End2!\n");
}
LITE_TEST_CASE(HksCipherTest, HksCipherTest011, Level1)
{
TEST_ASSERT_TRUE(BaseTestDecrypt(1, TEST_INDEX_3, 1) == 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)ExecHksCipherTest011, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksCipherTest011 End2!\n");
}
LITE_TEST_CASE(HksCipherTest, HksCipherTest012, Level1)
{
TEST_ASSERT_TRUE(BaseTestDecrypt(1, TEST_INDEX_4, 1) == 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)ExecHksCipherTest012, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksCipherTest012 End2!\n");
}
#endif /* _CUT_AUTHENTICATE_ */
......
......@@ -59,32 +59,65 @@ static BOOL HksCurve25519TestTearDown()
}
/**
* @tc.name: HksCurve25519Test.HksCurve25519Test001
* @tc.desc: The static function will return true;
* @tc.type: FUNC
*/
LITE_TEST_CASE(HksCurve25519Test, HksCurve25519Test001, Level1)
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
static void LocalHksCurve25519Test001(void const *argument)
{
LiteTestPrint("HksCurve25519Test001 Begin!\n");
TEST_ASSERT_TRUE(TestCurve25519All() == 0);
LiteTestPrint("HksCurve25519Test001 End!\n");
osThreadExit();
}
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
static void LocalHksCurve25519Test002(void const *argument)
{
LiteTestPrint("HksCurve25519Test002 Begin!\n");
TEST_ASSERT_TRUE(TestEd25519SignTeeVerifyLocal() == 0);
LiteTestPrint("HksCurve25519Test002 End!\n");
osThreadExit();
}
static void LocalHksCurve25519Test003(void const *argument)
{
LiteTestPrint("HksCurve25519Test003 Begin!\n");
TEST_ASSERT_TRUE(TestCurve25519SignWrong() == 0);
LiteTestPrint("HksCurve25519Test003 End!\n");
osThreadExit();
}
static void LocalHksCurve25519Test004(void const *argument)
{
LiteTestPrint("HksCurve25519Test004 Begin!\n");
TEST_ASSERT_TRUE(TestCurve25519verifyWrong() == 0);
LiteTestPrint("HksCurve25519Test004 End!\n");
osThreadExit();
}
/**
* @tc.name: HksCurve25519Test.HksCurve25519Test001
* @tc.desc: The static function will return true;
* @tc.type: FUNC
*/
LITE_TEST_CASE(HksCurve25519Test, HksCurve25519Test001, 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)LocalHksCurve25519Test001, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksCurve25519Test001 End2!\n");
}
/**
* @tc.name: HksCurve25519Test.HksCurve25519Test002
* @tc.desc: The static function will return true;
......@@ -103,9 +136,7 @@ LITE_TEST_CASE(HksCurve25519Test, HksCurve25519Test002, Level1)
attr.stack_size = TEST_TASK_STACK_SIZE;
attr.priority = g_setPriority;
id = osThreadNew((osThreadFunc_t)LocalHksCurve25519Test002, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksCurve25519Test002 End2!\n");
}
......@@ -116,7 +147,19 @@ LITE_TEST_CASE(HksCurve25519Test, HksCurve25519Test002, Level1)
*/
LITE_TEST_CASE(HksCurve25519Test, HksCurve25519Test003, Level1)
{
TEST_ASSERT_TRUE(TestCurve25519SignWrong() == 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)LocalHksCurve25519Test003, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksCurve25519Test003 End2!\n");
}
/**
......@@ -126,7 +169,19 @@ LITE_TEST_CASE(HksCurve25519Test, HksCurve25519Test003, Level1)
*/
LITE_TEST_CASE(HksCurve25519Test, HksCurve25519Test004, Level1)
{
TEST_ASSERT_TRUE(TestCurve25519verifyWrong() == 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)LocalHksCurve25519Test004, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksCurve25519Test004 End2!\n");
}
RUN_TEST_SUITE(HksCurve25519Test);
......
......@@ -57,7 +57,6 @@ static BOOL HksDeleteTestTearDown()
return TRUE;
}
static const struct HksTestKeyExistParams g_testKeyExistParams[] = {
/* normal case */
{ 0, HKS_SUCCESS, true, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE } },
......
......@@ -24,9 +24,16 @@
#include "hks_test_api_performance.h"
#include "hks_test_common.h"
#include "hks_test_log.h"
#include "cmsis_os2.h"
#include "ohos_types.h"
#define DEFAULT_X25519_PARAM_SET_OUT 104
#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"
* @param: test subsystem name
......@@ -74,13 +81,10 @@ static const struct HksTestGenKeyParams g_testGenKeyParams[] = {
},
};
/**
* @tc.name: HksGenerateKeyTest.HksGenerateKeyTest001
* @tc.desc: The static function will return true;
* @tc.type: FUNC
*/
LITE_TEST_CASE(HksGenerateKeyTest, HksGenerateKeyTest001, Level1)
static void ExecHksGenerateKeyTest001(void const *argument)
{
LiteTestPrint("HksGenerateKeyTest001 Begin!\n");
uint32_t times = 1;
uint32_t index = 0;
uint32_t performTimes = 1;
......@@ -128,6 +132,31 @@ LITE_TEST_CASE(HksGenerateKeyTest, HksGenerateKeyTest001, Level1)
HksFreeParamSet(&paramSetOut);
HKS_TEST_LOG_I("[%u]TestGenerateKey, Testcase_GenerateKey_[%03u] pass!", times, g_testGenKeyParams[index].testId);
TEST_ASSERT_TRUE(ret == 0);
LiteTestPrint("HksGenerateKeyTest001 End!\n");
osThreadExit();
}
/**
* @tc.name: HksGenerateKeyTest.HksGenerateKeyTest001
* @tc.desc: The static function will return true;
* @tc.type: FUNC
*/
LITE_TEST_CASE(HksGenerateKeyTest, HksGenerateKeyTest001, 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)ExecHksGenerateKeyTest001, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksGenerateKeyTest001 End2!\n");
}
RUN_TEST_SUITE(HksGenerateKeyTest);
......
......@@ -24,6 +24,9 @@
#include "hks_test_log.h"
#include "hks_type.h"
#include "cmsis_os2.h"
#include "ohos_types.h"
/*
* @tc.register: register a test suit named "CalcMultiTest"
* @param: test subsystem name
......@@ -59,15 +62,17 @@ static const struct HksTestGenRandomParams g_testGenRandomParams[] = {
/* normal case */
{ 0, HKS_SUCCESS, { true, HKS_MAX_RANDOM_LEN, true, HKS_MAX_RANDOM_LEN } },
};
/**
* @tc.name: HksGenerateRandomTest.HksGenerateRandomTest001
* @tc.desc: The static function will return true;
* @tc.type: FUNC
*/
LITE_TEST_CASE(HksGenerateRandomTest, HksGenerateRandomTest001, Level1)
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
static osPriority_t g_setPriority;
static void ExecHksGenerateRandomTest001(void const *argument)
{
int32_t ret;
struct HksBlob *random = NULL;
LiteTestPrint("HksGenerateRandomTest001 Begin!\n");
ret = TestConstructBlobOut(&random,
g_testGenRandomParams[0].randomParams.blobExist,
......@@ -84,6 +89,31 @@ LITE_TEST_CASE(HksGenerateRandomTest, HksGenerateRandomTest001, Level1)
TestFreeBlob(&random);
TEST_ASSERT_TRUE(ret == 0);
LiteTestPrint("HksGenerateRandomTest001 End!\n");
osThreadExit();
}
/**
* @tc.name: HksGenerateRandomTest.HksGenerateRandomTest001
* @tc.desc: The static function will return true;
* @tc.type: FUNC
*/
LITE_TEST_CASE(HksGenerateRandomTest, HksGenerateRandomTest001, 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)ExecHksGenerateRandomTest001, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksGenerateRandomTest001 End2!\n");
}
RUN_TEST_SUITE(HksGenerateRandomTest);
......@@ -26,6 +26,9 @@
#include "hks_test_log.h"
#include "hks_type.h"
#include "cmsis_os2.h"
#include "ohos_types.h"
#define DEFAULT_SRC_DATA_SIZE 200
......@@ -62,6 +65,10 @@ static BOOL HksHashTestTearDown()
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[] = {
/* normal case */
......@@ -72,13 +79,9 @@ static const struct HksTestHashParams g_testHashParams[] = {
},
};
/**
* @tc.name: HksHashTest.HksHashTest001
* @tc.desc: The static function will return true;
* @tc.type: FUNC
*/
LITE_TEST_CASE(HksHashTest, HksHashTest001, Level1)
static void ExecHksHashTest001(void const *argument)
{
LiteTestPrint("HksMacTest001 Begin!\n");
struct HksParamSet *paramSet = NULL;
struct HksBlob *srcData = NULL;
struct HksBlob *hash = NULL;
......@@ -113,6 +116,31 @@ LITE_TEST_CASE(HksHashTest, HksHashTest001, Level1)
TestFreeBlob(&hash);
HKS_TEST_LOG_I("[%u]TestHash, Testcase_Hash_[%03u] pass!", 1, g_testHashParams[0].testId);
TEST_ASSERT_TRUE(ret == 0);
LiteTestPrint("HksMacTest001 End!\n");
osThreadExit();
}
/**
* @tc.name: HksHashTest.HksHashTest001
* @tc.desc: The static function will return true;
* @tc.type: FUNC
*/
LITE_TEST_CASE(HksHashTest, HksHashTest001, 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)ExecHksHashTest001, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksMacTest001 End2!\n");
}
RUN_TEST_SUITE(HksHashTest);
......
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file Execept in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
......@@ -23,6 +23,9 @@
#include "hks_test_common.h"
#include "hks_test_log.h"
#include "cmsis_os2.h"
#include "ohos_types.h"
#define HKS_TEST_MAC_REE_KEY_SIZE_32 32
#define HKS_DEFAULT_MAC_SRCDATA_SIZE 253
#define HKS_DEFAULT_MAC_SHA256_SIZE 32
......@@ -79,6 +82,11 @@ static BOOL HksMacTestTearDown()
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,
const struct HksTestBlobParams *srcDataParams, const struct HksTestBlobParams *macDataParams)
......@@ -179,6 +187,24 @@ static int32_t BaseTestMac(uint32_t index)
return ret;
}
static void ExecHksMacTest001(void const *argument)
{
LiteTestPrint("HksMacTest001 Begin!\n");
int32_t ret = BaseTestMac(0);
TEST_ASSERT_TRUE(ret == 0);
LiteTestPrint("HksMacTest001 End!\n");
osThreadExit();
}
static void ExecHksMacTest002(void const *argument)
{
LiteTestPrint("HksMacTest002 Begin!\n");
int32_t ret = BaseTestMac(1);
TEST_ASSERT_TRUE(ret == 0);
LiteTestPrint("HksMacTest002 End!\n");
osThreadExit();
}
/**
* @tc.name: HksMacTest.HksMacTest001
* @tc.desc: The static function will return true;
......@@ -186,8 +212,19 @@ static int32_t BaseTestMac(uint32_t index)
*/
LITE_TEST_CASE(HksMacTest, HksMacTest001, Level1)
{
int32_t ret = BaseTestMac(0);
TEST_ASSERT_TRUE(ret == 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)ExecHksMacTest001, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksMacTest001 End2!\n");
}
#ifndef _CUT_AUTHENTICATE_
......@@ -198,8 +235,19 @@ LITE_TEST_CASE(HksMacTest, HksMacTest001, Level1)
*/
LITE_TEST_CASE(HksMacTest, HksMacTest002, Level1)
{
int32_t ret = BaseTestMac(1);
TEST_ASSERT_TRUE(ret == 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)ExecHksMacTest002, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksMacTest002 End2!\n");
}
#endif /* _CUT_AUTHENTICATE_ */
......
......@@ -28,6 +28,9 @@
#include "hks_test_log.h"
#include "stdlib.h"
#include "cmsis_os2.h"
#include "ohos_types.h"
#define DEFAULT_AES_CIPHER_PLAIN_SIZE 1000
#define AES_DEFAULT_GCM_NONCE_LENGTH 12
#define AES_DEFAULT_AAD_LEN 4
......
......@@ -23,6 +23,9 @@
#include "hks_param.h"
#include "hks_type.h"
#include "cmsis_os2.h"
#include "ohos_types.h"
/*
* @tc.register: register a test suit named "CalcMultiTest"
* @param: test subsystem name
......@@ -54,6 +57,83 @@ static BOOL HksOthersTestTearDown()
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)
{
LiteTestPrint("HksOthersTest001 Begin!\n");
int32_t ret = HksGetKeyParamSet(NULL, NULL, NULL);
TEST_ASSERT_TRUE(ret == HKS_ERROR_NULL_POINTER);
LiteTestPrint("HksOthersTest001 End!\n");
osThreadExit();
}
static void ExcHksOthersTest002(void const *argument)
{
LiteTestPrint("HksOthersTest002 Begin!\n");
int32_t ret = HksGetKeyInfoList(NULL, NULL, NULL);
TEST_ASSERT_TRUE(ret == HKS_ERROR_NULL_POINTER);
LiteTestPrint("HksOthersTest002 End!\n");
osThreadExit();
}
static void ExcHksOthersTest003(void const *argument)
{
LiteTestPrint("HksOthersTest003 Begin!\n");
int32_t ret = HksAttestKey(NULL, NULL, NULL);
TEST_ASSERT_TRUE(ret == HKS_ERROR_NOT_SUPPORTED);
LiteTestPrint("HksOthersTest003 End!\n");
osThreadExit();
}
static void ExcHksOthersTest004(void const *argument)
{
LiteTestPrint("HksOthersTest004 Begin!\n");
int32_t ret = HksGetCertificateChain(NULL, NULL, NULL);
TEST_ASSERT_TRUE(ret == HKS_ERROR_NOT_SUPPORTED);
LiteTestPrint("HksOthersTest004 End!\n");
osThreadExit();
}
static void ExcHksOthersTest005(void const *argument)
{
LiteTestPrint("HksOthersTest005 Begin!\n");
int32_t ret = HksGetCertificateChain(NULL, NULL, NULL);
TEST_ASSERT_TRUE(ret == HKS_ERROR_NOT_SUPPORTED);
LiteTestPrint("HksOthersTest005 End!\n");
osThreadExit();
}
static void ExcHksOthersTest006(void const *argument)
{
LiteTestPrint("HksOthersTest006 Begin!\n");
int32_t ret = HksUnwrapKey(NULL, NULL, NULL, NULL);
TEST_ASSERT_TRUE(ret == HKS_ERROR_NOT_SUPPORTED);
LiteTestPrint("HksOthersTest006 End!\n");
osThreadExit();
}
static void ExcHksOthersTest007(void const *argument)
{
LiteTestPrint("HksOthersTest007 Begin!\n");
int32_t ret = HksGetSdkVersion(NULL);
TEST_ASSERT_TRUE(ret == HKS_ERROR_NULL_POINTER);
LiteTestPrint("HksOthersTest007 End!\n");
osThreadExit();
}
static void ExcHksOthersTest008(void const *argument)
{
LiteTestPrint("HksOthersTest008 Begin!\n");
int32_t ret = HksInitialize();
TEST_ASSERT_TRUE(ret == HKS_SUCCESS);
LiteTestPrint("HksOthersTest008 End!\n");
osThreadExit();
}
/**
* @tc.name: HksOthersTest.HksOthersTest001
* @tc.desc: The static function will return true;
......@@ -61,8 +141,19 @@ static BOOL HksOthersTestTearDown()
*/
LITE_TEST_CASE(HksOthersTest, HksOthersTest001, Level1)
{
int32_t ret = HksGetKeyParamSet(NULL, NULL, NULL);
TEST_ASSERT_TRUE(ret == HKS_ERROR_NULL_POINTER);
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)ExcHksOthersTest001, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksOthersTest001 End2!\n");
}
/**
......@@ -72,8 +163,19 @@ LITE_TEST_CASE(HksOthersTest, HksOthersTest001, Level1)
*/
LITE_TEST_CASE(HksOthersTest, HksOthersTest002, Level1)
{
int32_t ret = HksGetKeyInfoList(NULL, NULL, NULL);
TEST_ASSERT_TRUE(ret == HKS_ERROR_NULL_POINTER);
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)ExcHksOthersTest002, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksOthersTest002 End2!\n");
}
/**
......@@ -83,8 +185,19 @@ LITE_TEST_CASE(HksOthersTest, HksOthersTest002, Level1)
*/
LITE_TEST_CASE(HksOthersTest, HksOthersTest003, Level1)
{
int32_t ret = HksAttestKey(NULL, NULL, NULL);
TEST_ASSERT_TRUE(ret == HKS_ERROR_NOT_SUPPORTED);
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)ExcHksOthersTest003, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksOthersTest003 End2!\n");
}
/**
......@@ -94,8 +207,19 @@ LITE_TEST_CASE(HksOthersTest, HksOthersTest003, Level1)
*/
LITE_TEST_CASE(HksOthersTest, HksOthersTest004, Level1)
{
int32_t ret = HksGetCertificateChain(NULL, NULL, NULL);
TEST_ASSERT_TRUE(ret == HKS_ERROR_NOT_SUPPORTED);
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)ExcHksOthersTest004, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksOthersTest004 End2!\n");
}
/**
......@@ -105,8 +229,19 @@ LITE_TEST_CASE(HksOthersTest, HksOthersTest004, Level1)
*/
LITE_TEST_CASE(HksOthersTest, HksOthersTest005, Level1)
{
int32_t ret = HksWrapKey(NULL, NULL, NULL, NULL);
TEST_ASSERT_TRUE(ret == HKS_ERROR_NOT_SUPPORTED);
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)ExcHksOthersTest005, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksOthersTest005 End2!\n");
}
/**
......@@ -116,8 +251,19 @@ LITE_TEST_CASE(HksOthersTest, HksOthersTest005, Level1)
*/
LITE_TEST_CASE(HksOthersTest, HksOthersTest006, Level1)
{
int32_t ret = HksUnwrapKey(NULL, NULL, NULL, NULL);
TEST_ASSERT_TRUE(ret == HKS_ERROR_NOT_SUPPORTED);
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)ExcHksOthersTest006, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksOthersTest006 End2!\n");
}
/**
......@@ -127,8 +273,19 @@ LITE_TEST_CASE(HksOthersTest, HksOthersTest006, Level1)
*/
LITE_TEST_CASE(HksOthersTest, HksOthersTest007, Level1)
{
int32_t ret = HksGetSdkVersion(NULL);
TEST_ASSERT_TRUE(ret == HKS_ERROR_NULL_POINTER);
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)ExcHksOthersTest007, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksOthersTest007 End2!\n");
}
/**
......@@ -138,8 +295,19 @@ LITE_TEST_CASE(HksOthersTest, HksOthersTest007, Level1)
*/
LITE_TEST_CASE(HksOthersTest, HksOthersTest008, Level1)
{
int32_t ret = HksInitialize();
TEST_ASSERT_TRUE(ret == HKS_SUCCESS);
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)ExcHksOthersTest008, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksOthersTest008 End2!\n");
}
RUN_TEST_SUITE(HksOthersTest);
......
......@@ -27,6 +27,9 @@
#include "hks_test_log.h"
#include "hks_test_mem.h"
#include "cmsis_os2.h"
#include "ohos_types.h"
static const char *g_storePath = "/storage/";
static const char *g_testOne = "TestOne";
static const char *g_testTwo = "TestTwo";
......@@ -62,6 +65,10 @@ static BOOL HksSafeCompareKeyTestTearDown()
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[] = {
/* x25519: tee sign/verify */
......@@ -188,13 +195,9 @@ static int32_t CompareKeyData(struct HksBlob *keyAliasOne, struct HksBlob *keyAl
return ret;
}
/**
* @tc.name: HksSafeCompareKeyTest.HksSafeCompareKeyTest001
* @tc.desc: The static function will return true;
* @tc.type: FUNC
*/
LITE_TEST_CASE(HksSafeCompareKeyTest, HksSafeCompareKeyTest001, Level1)
static void ExcHksSafeCompareKeyTest001(void const *argument)
{
LiteTestPrint("HksSafeCompareKeyTest001 Begin!\n");
struct HksBlob keyAliasOne = { strlen(g_testOne), (uint8_t *)g_testOne };
int32_t ret = SafeTestGenerateKey(&keyAliasOne);
HKS_TEST_ASSERT(ret == 0);
......@@ -205,6 +208,30 @@ LITE_TEST_CASE(HksSafeCompareKeyTest, HksSafeCompareKeyTest001, Level1)
ret = CompareKeyData(&keyAliasOne, &keyAliasTwo);
HKS_TEST_ASSERT(ret != 0);
TEST_ASSERT_TRUE(ret != 0);
LiteTestPrint("HksSafeCompareKeyTest001 End!\n");
osThreadExit();
}
/**
* @tc.name: HksSafeCompareKeyTest.HksSafeCompareKeyTest001
* @tc.desc: The static function will return true;
* @tc.type: FUNC
*/
LITE_TEST_CASE(HksSafeCompareKeyTest, HksSafeCompareKeyTest001, 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)ExcHksSafeCompareKeyTest001, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksSafeCompareKeyTest001 End2!\n");
}
RUN_TEST_SUITE(HksSafeCompareKeyTest);
......
......@@ -15,7 +15,7 @@ import("//test/xts/tools/build/suite.gni")
_all_test_packages = [
"${ACTS_ROOT}/global:global",
## "${ACTS_ROOT}/security:security",
"${ACTS_ROOT}/security:security",
"${ACTS_ROOT}/multimedia:multimedia",
"${ACTS_ROOT}/hiviewdfx:hiviewdfxtestacts",
"${ACTS_ROOT}/barrierfree:barrierfree",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册