diff --git a/security_lite/huks/common/hks_test_cipher.c b/security_lite/huks/common/hks_test_cipher.c index 7d6d57ff22e50ff5eed6528ca9de0c2ab1036975..4a3e23c409c7925c6407ccf2448825eeffcd7d5c 100644 --- a/security_lite/huks/common/hks_test_cipher.c +++ b/security_lite/huks/common/hks_test_cipher.c @@ -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, diff --git a/security_lite/huks/common/hks_test_common.c b/security_lite/huks/common/hks_test_common.c index 208c962254e22fc3ceb0242e9863251ae12edc77..0201c60c81b469999c7686769a1564d2b918728b 100644 --- a/security_lite/huks/common/hks_test_common.c +++ b/security_lite/huks/common/hks_test_common.c @@ -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) { diff --git a/security_lite/huks/common/hks_test_file_operator.c b/security_lite/huks/common/hks_test_file_operator.c index 178ebc6a25893877a6bbf80522297ae0ce0ce4d5..735f361a8ee7e0678565be230a08e47d228288be 100644 --- a/security_lite/huks/common/hks_test_file_operator.c +++ b/security_lite/huks/common/hks_test_file_operator.c @@ -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; diff --git a/security_lite/huks/common/include/hks_test_common.h b/security_lite/huks/common/include/hks_test_common.h index 1b4b06fd8b08c699f1d6eaf780f1770bd53c1492..c25397c6ad5cd0a1a82dda06b6edb36917e9e804 100644 --- a/security_lite/huks/common/include/hks_test_common.h +++ b/security_lite/huks/common/include/hks_test_common.h @@ -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); diff --git a/security_lite/huks/liteos_a_adapter/hks_derive_test.cpp b/security_lite/huks/liteos_a_adapter/hks_derive_test.cpp index 2f0f33a8fabec402ea5825e4b2457ddade5395ce..feb8f21a674bf57b2416619118d3a73050083436 100644 --- a/security_lite/huks/liteos_a_adapter/hks_derive_test.cpp +++ b/security_lite/huks/liteos_a_adapter/hks_derive_test.cpp @@ -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, diff --git a/security_lite/huks/liteos_a_adapter/hks_mac_test.cpp b/security_lite/huks/liteos_a_adapter/hks_mac_test.cpp index 30f5fa6b7acbd743e1969b887464594c0aacdc6b..7b60bf077a057e43c5a504bebc4138bd16e12b95 100644 --- a/security_lite/huks/liteos_a_adapter/hks_mac_test.cpp +++ b/security_lite/huks/liteos_a_adapter/hks_mac_test.cpp @@ -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, diff --git a/security_lite/huks/liteos_m_adapter/BUILD.gn b/security_lite/huks/liteos_m_adapter/BUILD.gn index f73d2a65f328caa06333f0992f896ca11b3b0e2d..698f9ff9bde0adf022872e8029446a777c8e607d 100644 --- a/security_lite/huks/liteos_m_adapter/BUILD.gn +++ b/security_lite/huks/liteos_m_adapter/BUILD.gn @@ -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", ] diff --git a/security_lite/huks/liteos_m_adapter/hks_aes_test.c b/security_lite/huks/liteos_m_adapter/hks_aes_test.c index dc110242f1598cc401df605425bd999d55b76d7f..a56271783e6a763665a4edc1dcd636ffb26e95d0 100644 --- a/security_lite/huks/liteos_m_adapter/hks_aes_test.c +++ b/security_lite/huks/liteos_m_adapter/hks_aes_test.c @@ -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 + #define TEST_TASK_STACK_SIZE 0x2000 #define WAIT_TO_TEST_DONE 4 diff --git a/security_lite/huks/liteos_m_adapter/hks_agreement_test.c b/security_lite/huks/liteos_m_adapter/hks_agreement_test.c index 9b9f8d9b96dfa8cee7447640c9862b0fcff2d638..55cb1a5f894175c95ad0136874f38744e4d33f29 100644 --- a/security_lite/huks/liteos_m_adapter/hks_agreement_test.c +++ b/security_lite/huks/liteos_m_adapter/hks_agreement_test.c @@ -26,6 +26,8 @@ #include "cmsis_os2.h" #include "ohos_types.h" +#include + #define TMP_SIZE 512 #define X25519_KEY_SIZE 32 #define TEST_TASK_STACK_SIZE 0x2000 diff --git a/security_lite/huks/liteos_m_adapter/hks_bn_exp_mod_test.c b/security_lite/huks/liteos_m_adapter/hks_bn_exp_mod_test.c index 98bcd7a1460565fbcdde1010780a03ecbdfcd8dd..69841c53e79614355e0c3efe0a6e11502227cb19 100644 --- a/security_lite/huks/liteos_m_adapter/hks_bn_exp_mod_test.c +++ b/security_lite/huks/liteos_m_adapter/hks_bn_exp_mod_test.c @@ -25,6 +25,8 @@ #include "cmsis_os2.h" #include "ohos_types.h" +#include + #define TEST_TASK_STACK_SIZE 0x2000 #define WAIT_TO_TEST_DONE 4 diff --git a/security_lite/huks/liteos_m_adapter/hks_cipher_test.c b/security_lite/huks/liteos_m_adapter/hks_cipher_test.c index 8d73f9522f66d2f7408243cf3d40e51ffecb74a5..3d06929df3ccb4adc808787b483137dfa4ef6fa4 100644 --- a/security_lite/huks/liteos_m_adapter/hks_cipher_test.c +++ b/security_lite/huks/liteos_m_adapter/hks_cipher_test.c @@ -24,6 +24,8 @@ #include "cmsis_os2.h" #include "ohos_types.h" +#include + #define TEST_INDEX_0 0 #define TEST_INDEX_1 1 #define TEST_INDEX_2 2 diff --git a/security_lite/huks/liteos_m_adapter/hks_delete_test.c b/security_lite/huks/liteos_m_adapter/hks_delete_test.c index 3aaadc411a5ac79ca20a2fbd96415492269cb4bc..5a32370b31bd9e9aafff6d31b14bb6037f4ce49a 100644 --- a/security_lite/huks/liteos_m_adapter/hks_delete_test.c +++ b/security_lite/huks/liteos_m_adapter/hks_delete_test.c @@ -27,6 +27,8 @@ #include "cmsis_os2.h" #include "ohos_types.h" +#include + #define TEST_TASK_STACK_SIZE 0x2000 #define WAIT_TO_TEST_DONE 4 diff --git a/security_lite/huks/liteos_m_adapter/hks_derive_test.c b/security_lite/huks/liteos_m_adapter/hks_derive_test.c index af2fca799cd25fb792cbb3e0112c6251d07f2ca4..a936ae6a65cc7f2730201ec0ea01ce3ba1b82714 100644 --- a/security_lite/huks/liteos_m_adapter/hks_derive_test.c +++ b/security_lite/huks/liteos_m_adapter/hks_derive_test.c @@ -15,6 +15,7 @@ #include +#include #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, diff --git a/security_lite/huks/liteos_m_adapter/hks_exist_test.c b/security_lite/huks/liteos_m_adapter/hks_exist_test.c index ac981aa9af2b25d284d85dc9f861e10a6b9cfbd3..a1e524b48d8e2bbf1cb6ca64aec0b560da99313d 100644 --- a/security_lite/huks/liteos_m_adapter/hks_exist_test.c +++ b/security_lite/huks/liteos_m_adapter/hks_exist_test.c @@ -27,6 +27,8 @@ #include "cmsis_os2.h" #include "ohos_types.h" +#include + #define TEST_TASK_STACK_SIZE 0x2000 #define WAIT_TO_TEST_DONE 4 diff --git a/security_lite/huks/liteos_m_adapter/hks_generate_key_test.c b/security_lite/huks/liteos_m_adapter/hks_generate_key_test.c index 7675d495f9648764c7e0e226b28f51fa5ce80ec2..4ac3f982ce1c0c555da8fb0c3aea58310ede2c01 100644 --- a/security_lite/huks/liteos_m_adapter/hks_generate_key_test.c +++ b/security_lite/huks/liteos_m_adapter/hks_generate_key_test.c @@ -18,6 +18,7 @@ #include "hks_generate_key_test.h" #include +#include #include "hks_api.h" #include "hks_param.h" diff --git a/security_lite/huks/liteos_m_adapter/hks_generate_random_test.c b/security_lite/huks/liteos_m_adapter/hks_generate_random_test.c index d79bea696dd5fefeedf050325aff17ac9610291e..68777fd95112ea3ca33b7e097910588a077852de 100644 --- a/security_lite/huks/liteos_m_adapter/hks_generate_random_test.c +++ b/security_lite/huks/liteos_m_adapter/hks_generate_random_test.c @@ -26,6 +26,8 @@ #include "cmsis_os2.h" #include "ohos_types.h" +#include + #define TEST_TASK_STACK_SIZE 0x2000 #define WAIT_TO_TEST_DONE 4 diff --git a/security_lite/huks/liteos_m_adapter/hks_hash_test.c b/security_lite/huks/liteos_m_adapter/hks_hash_test.c index 2e4fc76381772c48e65116675357d825f8c9e1c4..11193777f0c7610dc7b18c99edbefb81085a023a 100644 --- a/security_lite/huks/liteos_m_adapter/hks_hash_test.c +++ b/security_lite/huks/liteos_m_adapter/hks_hash_test.c @@ -16,6 +16,7 @@ #ifndef _CUT_AUTHENTICATE_ #include +#include #include "hks_api.h" #include "hks_param.h" diff --git a/security_lite/huks/liteos_m_adapter/hks_mac_test.c b/security_lite/huks/liteos_m_adapter/hks_mac_test.c index 199c7273e1cbc11e8ac78e13036988efab008f1d..9dd1e7ee54f30600621444fe7e8a679e84583bf7 100644 --- a/security_lite/huks/liteos_m_adapter/hks_mac_test.c +++ b/security_lite/huks/liteos_m_adapter/hks_mac_test.c @@ -16,6 +16,7 @@ #include "hks_mac_test.h" #include +#include #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, diff --git a/security_lite/huks/liteos_m_adapter/hks_modify_key_test.c b/security_lite/huks/liteos_m_adapter/hks_modify_key_test.c index f91657283483d8f8e4f062aa7660931484abe124..e0ab398245dc265f7644e1c062b3027a7589fe1f 100644 --- a/security_lite/huks/liteos_m_adapter/hks_modify_key_test.c +++ b/security_lite/huks/liteos_m_adapter/hks_modify_key_test.c @@ -18,6 +18,7 @@ #include "hks_modify_key_test.h" #include +#include #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) diff --git a/security_lite/huks/liteos_m_adapter/hks_others_test.c b/security_lite/huks/liteos_m_adapter/hks_others_test.c index 65921277f3f325b8c31cc860778b5b507b0b9170..e313b30fa7b92f982d7e45ffd27059ea7d4c9707 100644 --- a/security_lite/huks/liteos_m_adapter/hks_others_test.c +++ b/security_lite/huks/liteos_m_adapter/hks_others_test.c @@ -18,6 +18,7 @@ #include "hks_others_test.h" #include +#include #include "hks_api.h" #include "hks_param.h" diff --git a/security_lite/huks/liteos_m_adapter/hks_safe_compare_key_test.c b/security_lite/huks/liteos_m_adapter/hks_safe_compare_key_test.c index a7b5a5c975be1737d6074c6d4af1c85a86c9fd29..24e97ea9a89c6a3386ce1854b8c9de8623983e15 100644 --- a/security_lite/huks/liteos_m_adapter/hks_safe_compare_key_test.c +++ b/security_lite/huks/liteos_m_adapter/hks_safe_compare_key_test.c @@ -18,8 +18,10 @@ #include "hks_safe_compare_key_test.h" #include +#include #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);