Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
8f2bea9c
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
大约 1 年 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8f2bea9c
编写于
9月 15, 2021
作者:
O
openharmony_ci
提交者:
Gitee
9月 15, 2021
浏览文件
操作
浏览文件
下载
差异文件
!614 修改了huks L0执行失败问题
Merge pull request !614 from aaronwangjun/dev4
上级
769018c0
ddfa70ad
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
904 addition
and
147 deletion
+904
-147
build_lite/BUILD.gn
build_lite/BUILD.gn
+0
-2
security/dataprotect/huks_standard_adapter/BUILD.gn
security/dataprotect/huks_standard_adapter/BUILD.gn
+1
-1
security_lite/BUILD.gn
security_lite/BUILD.gn
+0
-1
security_lite/huks/common/BUILD.gn
security_lite/huks/common/BUILD.gn
+3
-3
security_lite/huks/liteos_a_adapter/BUILD.gn
security_lite/huks/liteos_a_adapter/BUILD.gn
+1
-1
security_lite/huks/liteos_m_adapter/BUILD.gn
security_lite/huks/liteos_m_adapter/BUILD.gn
+1
-1
security_lite/huks/liteos_m_adapter/hks_aes_test.c
security_lite/huks/liteos_m_adapter/hks_aes_test.c
+93
-5
security_lite/huks/liteos_m_adapter/hks_agreement_test.c
security_lite/huks/liteos_m_adapter/hks_agreement_test.c
+86
-49
security_lite/huks/liteos_m_adapter/hks_cipher_test.c
security_lite/huks/liteos_m_adapter/hks_cipher_test.c
+265
-17
security_lite/huks/liteos_m_adapter/hks_curve25519_test.c
security_lite/huks/liteos_m_adapter/hks_curve25519_test.c
+70
-15
security_lite/huks/liteos_m_adapter/hks_delete_test.c
security_lite/huks/liteos_m_adapter/hks_delete_test.c
+0
-1
security_lite/huks/liteos_m_adapter/hks_generate_key_test.c
security_lite/huks/liteos_m_adapter/hks_generate_key_test.c
+35
-6
security_lite/huks/liteos_m_adapter/hks_generate_random_test.c
...ity_lite/huks/liteos_m_adapter/hks_generate_random_test.c
+36
-6
security_lite/huks/liteos_m_adapter/hks_hash_test.c
security_lite/huks/liteos_m_adapter/hks_hash_test.c
+34
-6
security_lite/huks/liteos_m_adapter/hks_mac_test.c
security_lite/huks/liteos_m_adapter/hks_mac_test.c
+55
-7
security_lite/huks/liteos_m_adapter/hks_modify_key_test.c
security_lite/huks/liteos_m_adapter/hks_modify_key_test.c
+3
-0
security_lite/huks/liteos_m_adapter/hks_others_test.c
security_lite/huks/liteos_m_adapter/hks_others_test.c
+188
-20
security_lite/huks/liteos_m_adapter/hks_safe_compare_key_test.c
...ty_lite/huks/liteos_m_adapter/hks_safe_compare_key_test.c
+33
-6
未找到文件。
build_lite/BUILD.gn
浏览文件 @
8f2bea9c
...
...
@@ -40,7 +40,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",
...
...
@@ -86,7 +85,6 @@ lite_component("acts_component") {
"//test/xts/acts/startup_lite/syspara_posix:ActsParameterTest",
"//test/xts/acts/startup_lite/bootstrap_posix:ActsBootstrapTest",
#"//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",
...
...
security/dataprotect/huks_standard_adapter/BUILD.gn
浏览文件 @
8f2bea9c
...
...
@@ -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",
]
...
...
security_lite/BUILD.gn
浏览文件 @
8f2bea9c
...
...
@@ -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",
...
...
security_lite/huks/common/BUILD.gn
浏览文件 @
8f2bea9c
...
...
@@ -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") {
...
...
security_lite/huks/liteos_a_adapter/BUILD.gn
浏览文件 @
8f2bea9c
...
...
@@ -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" ]
...
...
security_lite/huks/liteos_m_adapter/BUILD.gn
浏览文件 @
8f2bea9c
...
...
@@ -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 = [
...
...
security_lite/huks/liteos_m_adapter/hks_aes_test.c
浏览文件 @
8f2bea9c
...
...
@@ -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_ */
...
...
@@ -90,8 +166,20 @@ LITE_TEST_CASE(HksAesTest, HksAesTest003, Level1)
* @tc.type: FUNC
*/
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
);
security_lite/huks/liteos_m_adapter/hks_agreement_test.c
浏览文件 @
8f2bea9c
...
...
@@ -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,14 +100,16 @@ 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
)
{
/* 1. generate key */
LiteTestPrint
(
"HksAgreementTest001 Begin!
\n
"
);
/* 1. generate key */
struct
HksBlob
*
privateKey
=
NULL
;
struct
HksBlob
*
peerPubKeyAlias
=
NULL
;
struct
HksBlob
*
peerPublicKey
=
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
)
{
/* 1. generate key */
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
);
...
...
security_lite/huks/liteos_m_adapter/hks_cipher_test.c
浏览文件 @
8f2bea9c
...
...
@@ -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_ */
...
...
security_lite/huks/liteos_m_adapter/hks_curve25519_test.c
浏览文件 @
8f2bea9c
...
...
@@ -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
);
...
...
security_lite/huks/liteos_m_adapter/hks_delete_test.c
浏览文件 @
8f2bea9c
...
...
@@ -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
}
},
...
...
security_lite/huks/liteos_m_adapter/hks_generate_key_test.c
浏览文件 @
8f2bea9c
...
...
@@ -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
);
...
...
security_lite/huks/liteos_m_adapter/hks_generate_random_test.c
浏览文件 @
8f2bea9c
...
...
@@ -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
);
security_lite/huks/liteos_m_adapter/hks_hash_test.c
浏览文件 @
8f2bea9c
...
...
@@ -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
);
...
...
security_lite/huks/liteos_m_adapter/hks_mac_test.c
浏览文件 @
8f2bea9c
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file
ex
cept in compliance with the License.
* you may not use this file
Exe
cept 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,15 +187,44 @@ 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;
* @tc.type: FUNC
*/
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_
...
...
@@ -197,9 +234,20 @@ LITE_TEST_CASE(HksMacTest, HksMacTest001, Level1)
* @tc.type: FUNC
*/
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_ */
...
...
security_lite/huks/liteos_m_adapter/hks_modify_key_test.c
浏览文件 @
8f2bea9c
...
...
@@ -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
...
...
security_lite/huks/liteos_m_adapter/hks_others_test.c
浏览文件 @
8f2bea9c
...
...
@@ -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
"
);
}
/**
...
...
@@ -71,9 +162,20 @@ LITE_TEST_CASE(HksOthersTest, HksOthersTest001, Level1)
* @tc.type: FUNC
*/
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
"
);
}
/**
...
...
@@ -82,9 +184,20 @@ LITE_TEST_CASE(HksOthersTest, HksOthersTest002, Level1)
* @tc.type: FUNC
*/
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
"
);
}
/**
...
...
@@ -93,9 +206,20 @@ LITE_TEST_CASE(HksOthersTest, HksOthersTest003, Level1)
* @tc.type: FUNC
*/
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
"
);
}
/**
...
...
@@ -126,9 +272,20 @@ LITE_TEST_CASE(HksOthersTest, HksOthersTest006, Level1)
* @tc.type: FUNC
*/
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
);
...
...
security_lite/huks/liteos_m_adapter/hks_safe_compare_key_test.c
浏览文件 @
8f2bea9c
...
...
@@ -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
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录