提交 77423fee 编写于 作者: 伞木希美

aaa

Signed-off-by: N伞木希美 <zhanghanlin9@huawei.com>
上级 3de19324
......@@ -30,6 +30,8 @@ import SecurityHuksSM2BasicAbort63KBPromiseJsunit from './SignVerify/SecurityHuk
import SecurityHuksSM2BasicAbort65KBPromiseJsunit from './SignVerify/SecurityHuksSM2BasicAbort65KBPromiseJsunit.test.js'
import SecurityHuksSM2BasicFinish63KBPromiseJsunit from './SignVerify/SecurityHuksSM2BasicFinish63KBPromiseJsunit.test.js'
import SecurityHuksSM2BasicFinish65KBPromiseJsunit from './SignVerify/SecurityHuksSM2BasicFinish65KBPromiseJsunit.test.js'
import SecurityHuksRSASignExtendJsunit from './SignVerify/SecurityHuksRSASignExtendJsunit.test.js'
export default function testsuite() {
SecurityHuksDSABasicAbort63KBPromiseJsunit()
SecurityHuksDSABasicAbort65KBPromiseJsunit()
......@@ -48,4 +50,5 @@ SecurityHuksSM2BasicAbort63KBPromiseJsunit()
SecurityHuksSM2BasicAbort65KBPromiseJsunit()
SecurityHuksSM2BasicFinish63KBPromiseJsunit()
SecurityHuksSM2BasicFinish65KBPromiseJsunit()
SecurityHuksRSASignExtendJsunit()
}
......@@ -138,6 +138,32 @@ static const struct HksTestDeriveParams g_testDeriveParams[] = {
{
true, DEFAULT_LOCAL_KEY_SIZE, true, DEFAULT_LOCAL_KEY_SIZE }
},
/* pbkdf-sha256-salt-info */
{ 2, HKS_SUCCESS, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE },
{
true, /* genKey params */
true, HKS_ALG_AES,
true, HKS_AES_KEY_SIZE_256,
true, HKS_KEY_PURPOSE_DERIVE,
true, HKS_DIGEST_SHA256,
false, 0,
false, 0,
false, 0 },
{ 0 },
{
true, /* derive params */
true, HKS_ALG_PBKDF2,
true, HKS_KEY_PURPOSE_DERIVE,
true, HKS_DIGEST_SHA256,
true, 1000,
true, DEFAULT_SALT_SIZE,
true, DEFAULT_INFO_SIZE,
false, true },
{
true, DEFAULT_DERIVE_SIZE, true, DEFAULT_DERIVE_SIZE },
{
false, 0, false, 0 }
},
};
static int32_t DeriveKey(const struct HksTestDeriveParamSet *deriveParamSetParams, const struct HksBlob *masterKey,
......@@ -242,6 +268,15 @@ static void ExecHksDeriveTest002(void const *argument)
osThreadExit();
}
static void ExecHksDeriveTest003(void const *argument)
{
LiteTestPrint("HksDeriveTest003 Begin!\n");
int32_t ret = BaseTestDerive(2);
TEST_ASSERT_TRUE(ret == 0);
LiteTestPrint("HksDeriveTest003 End!\n");
osThreadExit();
}
#ifndef _CUT_AUTHENTICATE_
/**
* @tc.name: HksDeriveTest.HksDeriveTest001
......@@ -264,6 +299,27 @@ LITE_TEST_CASE(HksDeriveTest, HksDeriveTest001, Level1)
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksDeriveTest001 End2!\n");
}
/**
* @tc.name: HksDeriveTest.HksDeriveTest003
* @tc.desc: The static function will return true;
* @tc.type: FUNC
*/
LITE_TEST_CASE(HksDeriveTest, HksDeriveTest003, 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)ExecHksDeriveTest003, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksDeriveTest001 End2!\n");
}
#endif /* _CUT_AUTHENTICATE_ */
/**
......@@ -287,4 +343,5 @@ LITE_TEST_CASE(HksDeriveTest, HksDeriveTest002, Level1)
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksDeriveTest002 End2!\n");
}
RUN_TEST_SUITE(HksDeriveTest);
......@@ -30,7 +30,11 @@
#include "ohos_types.h"
#define DEFAULT_SRC_DATA_SIZE 200
#define DIGEST_SHA1_HASH_SIZE 20
#define DIGEST_SHA224_HASH_SIZE 28
#define DIGEST_SHA256_HASH_SIZE 32
#define DIGEST_SHA384_HASH_SIZE 48
#define DIGEST_SHA512_HASH_SIZE 64
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
......@@ -92,50 +96,80 @@ static const struct HksTestHashParams g_testHashParams[] = {
{ true, DEFAULT_SRC_DATA_SIZE, true, DEFAULT_SRC_DATA_SIZE },
{ true, DIGEST_SHA256_HASH_SIZE, true, DIGEST_SHA256_HASH_SIZE }
},
{ 1, HKS_SUCCESS,
{ true, true, HKS_DIGEST_SHA384 },
{ true, DEFAULT_SRC_DATA_SIZE, true, DEFAULT_SRC_DATA_SIZE },
{ true, DIGEST_SHA384_HASH_SIZE, true, DIGEST_SHA384_HASH_SIZE }
},
{ 2, HKS_SUCCESS,
{ true, true, HKS_DIGEST_SHA512 },
{ true, DEFAULT_SRC_DATA_SIZE, true, DEFAULT_SRC_DATA_SIZE },
{ true, DIGEST_SHA512_HASH_SIZE, true, DIGEST_SHA512_HASH_SIZE }
},
};
static void ExecHksHashTest001(void const *argument)
static void ExecHksHashTestCommon(int index)
{
LiteTestPrint("HksMacTest001 Begin!\n");
struct HksParamSet *paramSet = NULL;
struct HksBlob *srcData = NULL;
struct HksBlob *hash = NULL;
int32_t ret = TestConstructHashParamSet(&paramSet,
g_testHashParams[0].paramSetParams.paramSetExist,
g_testHashParams[0].paramSetParams.setDigest, g_testHashParams[0].paramSetParams.digest);
g_testHashParams[index].paramSetParams.paramSetExist,
g_testHashParams[index].paramSetParams.setDigest, g_testHashParams[index].paramSetParams.digest);
TEST_ASSERT_TRUE(ret == 0);
ret = TestConstuctBlob(&srcData,
g_testHashParams[0].srcDataParams.blobExist,
g_testHashParams[0].srcDataParams.blobSize,
g_testHashParams[0].srcDataParams.blobDataExist,
g_testHashParams[0].srcDataParams.blobDataSize);
g_testHashParams[index].srcDataParams.blobExist,
g_testHashParams[index].srcDataParams.blobSize,
g_testHashParams[index].srcDataParams.blobDataExist,
g_testHashParams[index].srcDataParams.blobDataSize);
TEST_ASSERT_TRUE(ret == 0);
ret = TestConstructBlobOut(&hash,
g_testHashParams[0].hashParams.blobExist,
g_testHashParams[0].hashParams.blobSize,
g_testHashParams[0].hashParams.blobDataExist,
g_testHashParams[0].hashParams.blobDataSize);
g_testHashParams[index].hashParams.blobExist,
g_testHashParams[index].hashParams.blobSize,
g_testHashParams[index].hashParams.blobDataExist,
g_testHashParams[index].hashParams.blobDataSize);
TEST_ASSERT_TRUE(ret == 0);
ret = HksHashRun(paramSet, srcData, hash, 1);
if (ret != g_testHashParams[0].expectResult) {
HKS_TEST_LOG_I("HksHashRun failed, ret[%u] = %d", g_testHashParams[0].testId, ret);
if (ret != g_testHashParams[index].expectResult) {
HKS_TEST_LOG_I("HksHashRun failed, ret[%u] = %d", g_testHashParams[index].testId, ret);
}
TEST_ASSERT_TRUE(ret == g_testHashParams[0].expectResult);
TEST_ASSERT_TRUE(ret == g_testHashParams[index].expectResult);
HksFreeParamSet(&paramSet);
TestFreeBlob(&srcData);
TestFreeBlob(&hash);
HKS_TEST_LOG_I("[%u]TestHash, Testcase_Hash_[%03u] pass!", 1, g_testHashParams[0].testId);
HKS_TEST_LOG_I("[%u]TestHash, Testcase_Hash_[%03u] pass!", 1, g_testHashParams[index].testId);
TEST_ASSERT_TRUE(ret == 0);
}
static void ExecHksHashTest001(void const *argument)
{
LiteTestPrint("HksMacTest001 Begin!\n");
ExecHksHashTestCommon(0);
LiteTestPrint("HksMacTest001 End!\n");
osThreadExit();
}
static void ExecHksHashTest002(void const *argument)
{
LiteTestPrint("HksMacTest002 Begin!\n");
ExecHksHashTestCommon(1);
LiteTestPrint("HksMacTest002 End!\n");
osThreadExit();
}
static void ExecHksHashTest003(void const *argument)
{
LiteTestPrint("HksMacTest003 Begin!\n");
ExecHksHashTestCommon(2);
LiteTestPrint("HksMacTest003 End!\n");
osThreadExit();
}
/**
* @tc.name: HksHashTest.HksHashTest001
* @tc.desc: The static function will return true;
......@@ -157,6 +191,48 @@ LITE_TEST_CASE(HksHashTest, HksHashTest001, Level1)
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksMacTest001 End2!\n");
}
/**
* @tc.name: HksHashTest.HksHashTest002
* @tc.desc: The static function will return true;
* @tc.type: FUNC
*/
LITE_TEST_CASE(HksHashTest, HksHashTest002, 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)ExecHksHashTest002, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksMacTest001 End2!\n");
}
/**
* @tc.name: HksHashTest.HksHashTest003
* @tc.desc: The static function will return true;
* @tc.type: FUNC
*/
LITE_TEST_CASE(HksHashTest, HksHashTest003, 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)ExecHksHashTest003, NULL, &attr);
sleep(WAIT_TO_TEST_DONE);
LiteTestPrint("HksMacTest001 End2!\n");
}
RUN_TEST_SUITE(HksHashTest);
#endif /* _CUT_AUTHENTICATE_ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册