未验证 提交 f069b75c 编写于 作者: O openharmony_ci 提交者: Gitee

!5998 【OpenHarmony 3.2.8.1】【安全子系统】【master】huks代码维护

Merge pull request !5998 from qiaozzzh/1021_1
......@@ -593,7 +593,7 @@ int32_t BaseTestCipher(uint32_t times, uint32_t index, uint32_t performTimes)
g_testCipherParams[index].genKeyParamSetParams.keyStorageFlag == HKS_STORAGE_TEMP) {
ret = GenerateLocalRandomKey(&keyAlias, &g_testCipherParams[index].localKeyParams);
} else {
ret = GenerateKey(&keyAlias, &g_testCipherParams[index].keyAliasParams,
ret = HuksGenerateKey(&keyAlias, &g_testCipherParams[index].keyAliasParams,
&g_testCipherParams[index].genKeyParamSetParams, &g_testCipherParams[index].genKeyParamSetParamsOut);
}
HKS_TEST_ASSERT(ret == 0);
......@@ -648,7 +648,7 @@ int32_t BaseTestEncrypt(uint32_t times, uint32_t index, uint32_t performTimes)
ret = GenerateLocalRandomKey(&keyAlias, &g_testEncryptParams[index].localKeyParams);
} else {
if (g_testEncryptParams[index].keyAliasParams.blobExist) {
ret = GenerateKey(&keyAlias, &g_testEncryptParams[index].keyAliasParams,
ret = HuksGenerateKey(&keyAlias, &g_testEncryptParams[index].keyAliasParams,
&g_testEncryptParams[index].genKeyParamSetParams, NULL);
} else {
ret = TestConstuctBlob(&keyAlias,
......@@ -700,7 +700,7 @@ int32_t BaseTestDecrypt(uint32_t times, uint32_t index, uint32_t performTimes)
ret = GenerateLocalRandomKey(&keyAlias, &g_testDecryptParams[index].localKeyParams);
} else {
if (g_testDecryptParams[index].keyAliasParams.blobExist) {
ret = GenerateKey(&keyAlias, &g_testDecryptParams[index].keyAliasParams,
ret = HuksGenerateKey(&keyAlias, &g_testDecryptParams[index].keyAliasParams,
&g_testDecryptParams[index].genKeyParamSetParams, NULL);
} else {
ret = TestConstuctBlob(&keyAlias,
......
......@@ -551,7 +551,7 @@ int32_t TestConstructHashParamSet(
return ret;
}
int32_t GenerateKey(struct HksBlob **keyAlias, const struct HksTestBlobParams *keyAliasParams,
int32_t HuksGenerateKey(struct HksBlob **keyAlias, const struct HksTestBlobParams *keyAliasParams,
const struct HksTestGenKeyParamsParamSet *genKeyParamSetParams,
const struct HksTestGenKeyParamsParamSetOut *genKeyParamSetParamsOut)
{
......
......@@ -185,7 +185,7 @@ static uint32_t FileRead(const char *fileName, uint32_t offset, uint8_t *buf, ui
{
/* now offset is 0, but we maybe extend hi1131 file interfaces in the future */
if (offset != 0) {
return HKS_ERROR_INVALID_ARGUMENT;
return (uint32_t)(HKS_ERROR_INVALID_ARGUMENT);
}
unsigned int fileSize;
......@@ -206,7 +206,7 @@ static uint32_t FileRead(const char *fileName, uint32_t offset, uint8_t *buf, ui
return 0;
}
ret = UtilsFileRead(fd, buf, len);
ret = UtilsFileRead(fd, (char *)(buf), len);
UtilsFileClose(fd);
if (ret < 0) {
HKS_TEST_LOG_E("failed to read file, errno = 0x%x", ret);
......@@ -229,7 +229,7 @@ static int32_t FileWrite(const char *fileName, uint32_t offset, const uint8_t *b
return HKS_ERROR_OPEN_FILE_FAIL;
}
int32_t ret = UtilsFileWrite(fd, buf, len);
int32_t ret = UtilsFileWrite(fd, (const char *)buf, len);
if (ret < 0) {
HKS_TEST_LOG_E("failed to write key file, errno = 0x%x\n", ret);
ret = HKS_ERROR_WRITE_FILE_FAIL;
......
......@@ -412,7 +412,7 @@ int32_t TestConstructHashParamSet(
bool paramSetExist,
bool setDigest, uint32_t digest);
int32_t GenerateKey(struct HksBlob **keyAlias, const struct HksTestBlobParams *keyAliasParams,
int32_t HuksGenerateKey(struct HksBlob **keyAlias, const struct HksTestBlobParams *keyAliasParams,
const struct HksTestGenKeyParamsParamSet *genKeyParamSetParams,
const struct HksTestGenKeyParamsParamSetOut *genKeyParamSetParamsOut);
......
......@@ -154,7 +154,7 @@ static int32_t BaseTestDerive(uint32_t index)
ret = GenerateLocalRandomKey(&keyAlias, &g_testDeriveParams[index].localKeyParams);
} else {
if (g_testDeriveParams[index].keyAliasParams.blobExist) {
ret = GenerateKey(&keyAlias, &g_testDeriveParams[index].keyAliasParams,
ret = HuksGenerateKey(&keyAlias, &g_testDeriveParams[index].keyAliasParams,
&g_testDeriveParams[index].genKeyParamSetParams, NULL);
} else {
ret = TestConstuctBlob(&keyAlias,
......
......@@ -142,7 +142,7 @@ static int32_t BaseTestMac(uint32_t index)
g_testMacParams[index].keyParams.blobDataSize);
} else {
if (g_testMacParams[index].keyAliasParams.blobExist) {
ret = GenerateKey(&key, &(g_testMacParams[index].keyAliasParams),
ret = HuksGenerateKey(&key, &(g_testMacParams[index].keyAliasParams),
&g_testMacParams[index].genKeyParamSetParams, NULL);
} else {
ret = TestConstuctBlob(&key,
......
......@@ -39,6 +39,7 @@ hctest_suite("ActsHuksHalFunctionTest") {
include_dirs = [
"//base/security/huks/interfaces/innerkits/huks_standard/main/include",
"//base/iothardware/peripheral/interfaces/inner_api",
"//base/security/huks/frameworks/huks_standard/main/common/include",
"../common/include",
]
......
......@@ -17,10 +17,13 @@
#include "hks_api.h"
#include "hks_param.h"
#include "hks_test_aes.h"
#include "securec.h"
#include "cmsis_os2.h"
#include "ohos_types.h"
#include <unistd.h>
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
......
......@@ -26,6 +26,8 @@
#include "cmsis_os2.h"
#include "ohos_types.h"
#include <unistd.h>
#define TMP_SIZE 512
#define X25519_KEY_SIZE 32
#define TEST_TASK_STACK_SIZE 0x2000
......
......@@ -25,6 +25,8 @@
#include "cmsis_os2.h"
#include "ohos_types.h"
#include <unistd.h>
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
......
......@@ -24,6 +24,8 @@
#include "cmsis_os2.h"
#include "ohos_types.h"
#include <unistd.h>
#define TEST_INDEX_0 0
#define TEST_INDEX_1 1
#define TEST_INDEX_2 2
......
......@@ -27,6 +27,8 @@
#include "cmsis_os2.h"
#include "ohos_types.h"
#include <unistd.h>
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
......
......@@ -15,6 +15,7 @@
#include <hctest.h>
#include <unistd.h>
#include "hks_derive_test.h"
......@@ -180,7 +181,7 @@ static int32_t BaseTestDerive(uint32_t index)
ret = GenerateLocalRandomKey(&keyAlias, &g_testDeriveParams[index].localKeyParams);
} else {
if (g_testDeriveParams[index].keyAliasParams.blobExist) {
ret = GenerateKey(&keyAlias, &g_testDeriveParams[index].keyAliasParams,
ret = HuksGenerateKey(&keyAlias, &g_testDeriveParams[index].keyAliasParams,
&g_testDeriveParams[index].genKeyParamSetParams, NULL);
} else {
ret = TestConstuctBlob(&keyAlias,
......
......@@ -27,6 +27,8 @@
#include "cmsis_os2.h"
#include "ohos_types.h"
#include <unistd.h>
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
......
......@@ -18,6 +18,7 @@
#include "hks_generate_key_test.h"
#include <hctest.h>
#include <unistd.h>
#include "hks_api.h"
#include "hks_param.h"
......
......@@ -26,6 +26,8 @@
#include "cmsis_os2.h"
#include "ohos_types.h"
#include <unistd.h>
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
......
......@@ -16,6 +16,7 @@
#ifndef _CUT_AUTHENTICATE_
#include <hctest.h>
#include <unistd.h>
#include "hks_api.h"
#include "hks_param.h"
......
......@@ -16,6 +16,7 @@
#include "hks_mac_test.h"
#include <hctest.h>
#include <unistd.h>
#include "hks_api.h"
#include "hks_param.h"
......@@ -167,7 +168,7 @@ static int32_t BaseTestMac(uint32_t index)
g_testMacParams[index].keyParams.blobDataSize);
} else {
if (g_testMacParams[index].keyAliasParams.blobExist) {
ret = GenerateKey(&key, &(g_testMacParams[index].keyAliasParams),
ret = HuksGenerateKey(&key, &(g_testMacParams[index].keyAliasParams),
&g_testMacParams[index].genKeyParamSetParams, NULL);
} else {
ret = TestConstuctBlob(&key,
......
......@@ -18,6 +18,7 @@
#include "hks_modify_key_test.h"
#include <hctest.h>
#include <unistd.h>
#include "hks_api.h"
#include "hks_param.h"
......@@ -291,7 +292,7 @@ int32_t BaseTestCipherProcess(const struct HksBlob *keyAlias, uint32_t index)
}
/* 3. decrypt */
struct CipherDecryptStructure testDecryptStruct = {
keyAlias, &g_testCipherParams[index], cipherData,
(struct HksBlob *)(keyAlias), &g_testCipherParams[index], cipherData,
&decryptedData, ivData, nonceData, aadData, 1
};
ret = DecryptCipher(&testDecryptStruct);
......@@ -330,6 +331,7 @@ int32_t __attribute__((weak)) HksStoreKeyBlob(const struct HksBlob *processName,
(void)keyAlias;
(void)storageType;
(void)keyBlob;
return HKS_SUCCESS;
}
static void ExecHksModifyKeyTest001(void const *argument)
......
......@@ -18,6 +18,7 @@
#include "hks_others_test.h"
#include <hctest.h>
#include <unistd.h>
#include "hks_api.h"
#include "hks_param.h"
......
......@@ -18,8 +18,10 @@
#include "hks_safe_compare_key_test.h"
#include <hctest.h>
#include <unistd.h>
#include "hks_api.h"
#include "hks_mem.h"
#include "hks_param.h"
#include "hks_test_api_performance.h"
#include "hks_test_common.h"
......@@ -197,13 +199,13 @@ static int32_t CompareKeyData(struct HksBlob *keyAliasOne, struct HksBlob *keyAl
g_storageImageBuffer.size = sizeOne;
int32_t offset1;
int ret = GetKeyOffsetByKeyAlias(keyAliasOne, &offset1);
int ret = GetKeyOffsetByKeyAlias(keyAliasOne, (uint32_t *)(&offset1));
TEST_ASSERT_TRUE(ret == 0);
struct HksStoreKeyInfo *keyInfo1 = (struct HksStoreKeyInfo *)(g_storageImageBuffer.data + offset1);
int32_t offset2;
ret = GetKeyOffsetByKeyAlias(keyAliasTwo, &offset2);
ret = GetKeyOffsetByKeyAlias(keyAliasTwo, (uint32_t *)(&offset2));
TEST_ASSERT_TRUE(ret == 0);
struct HksStoreKeyInfo *keyInfo2 = (struct HksStoreKeyInfo *)(g_storageImageBuffer.data + offset2);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册