提交 b4e7ef2f 编写于 作者: Q qiaozzzh

huks代码维护

Signed-off-by: Nqiaozzzh <qiaozhang@huawei.com>
上级 2c331523
......@@ -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, (char const *)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;
......
......@@ -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
......
......@@ -28,6 +28,8 @@
#define TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
#include <unistd.h>
static osPriority_t g_setPriority;
/*
......
......@@ -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
......
......@@ -26,6 +26,8 @@
#include "cmsis_os2.h"
#include "ohos_types.h"
#include <unistd.h>
#define DEFAULT_DERIVE_SIZE 32
#define DEFAULT_INFO_SIZE 55
#define DEFAULT_SALT_SIZE 16
......
......@@ -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
......
......@@ -27,6 +27,8 @@
#include "cmsis_os2.h"
#include "ohos_types.h"
#include <unistd.h>
#define DEFAULT_X25519_PARAM_SET_OUT 104
#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 TEST_TASK_STACK_SIZE 0x2000
#define WAIT_TO_TEST_DONE 4
......
......@@ -28,6 +28,8 @@
#include "cmsis_os2.h"
#include "ohos_types.h"
#include <unistd.h>
#define DEFAULT_SRC_DATA_SIZE 200
#define DIGEST_SHA256_HASH_SIZE 32
#define TEST_TASK_STACK_SIZE 0x2000
......
......@@ -26,6 +26,8 @@
#include "cmsis_os2.h"
#include "ohos_types.h"
#include <unistd.h>
#define HKS_TEST_MAC_REE_KEY_SIZE_32 32
#define HKS_DEFAULT_MAC_SRCDATA_SIZE 253
#define HKS_DEFAULT_MAC_SHA256_SIZE 32
......
......@@ -30,6 +30,8 @@
#include "cmsis_os2.h"
#include "ohos_types.h"
#include <unistd.h>
#define DEFAULT_AES_CIPHER_PLAIN_SIZE 1000
#define AES_DEFAULT_GCM_NONCE_LENGTH 12
#define AES_DEFAULT_AAD_LEN 4
......
......@@ -18,6 +18,7 @@
#include "hks_others_test.h"
#include <hctest.h>
#include <unistd.h>
#include "hks_api.h"
#include "hks_param.h"
......
......@@ -16,9 +16,9 @@
#ifndef _CUT_AUTHENTICATE_
#include "hks_safe_compare_key_test.h"
#include "hks_mem.h"
#include <hctest.h>
#include <unistd.h>
#include "hks_api.h"
#include "hks_param.h"
#include "hks_test_api_performance.h"
......@@ -197,13 +197,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.
先完成此消息的编辑!
想要评论请 注册