!245 【加解密算法库】修改参数类型

Merge pull request !245 from 我辰辰呢/master
This commit is contained in:
openharmony_ci 2024-01-05 10:21:19 +00:00 committed by Gitee
commit 7c56b520f8
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 10 additions and 11 deletions

View File

@ -24,9 +24,9 @@
#include "memory.h"
#include "utils.h"
HcfResult HcfDhKeyUtilCreate(uint32_t pLen, int32_t skLen, HcfDhCommParamsSpec **returnCommonParamSpec)
HcfResult HcfDhKeyUtilCreate(int32_t pLen, int32_t skLen, HcfDhCommParamsSpec **returnCommonParamSpec)
{
if ((skLen < 0) || (returnCommonParamSpec == NULL)) {
if ((pLen < 0) || (skLen < 0) || (returnCommonParamSpec == NULL)) {
LOGE("Failed to parse params!");
return HCF_INVALID_PARAMS;
}

View File

@ -24,7 +24,7 @@
extern "C" {
#endif
HcfResult HcfDhKeyUtilCreate(uint32_t pLen, int32_t skLen, HcfDhCommParamsSpec **returnCommonParamSpec);
HcfResult HcfDhKeyUtilCreate(int32_t pLen, int32_t skLen, HcfDhCommParamsSpec **returnCommonParamSpec);
#ifdef __cplusplus
}

View File

@ -24,7 +24,7 @@
extern "C" {
#endif
HcfResult HcfDhCommonParamSpecCreate(uint32_t pLen, int32_t skLen, HcfDhCommParamsSpecSpi **returnCommonParamSpec);
HcfResult HcfDhCommonParamSpecCreate(int32_t pLen, int32_t skLen, HcfDhCommParamsSpecSpi **returnCommonParamSpec);
#ifdef __cplusplus
}

View File

@ -148,7 +148,7 @@ HcfResult SetAlgName(const char *algName, char **returnAlgName)
return HCF_SUCCESS;
}
HcfResult HcfDhCommonParamSpecCreate(uint32_t pLen, int32_t skLen, HcfDhCommParamsSpecSpi **returnCommonParamSpec)
HcfResult HcfDhCommonParamSpecCreate(int32_t pLen, int32_t skLen, HcfDhCommParamsSpecSpi **returnCommonParamSpec)
{
if (returnCommonParamSpec == NULL) {
LOGE("Invalid input parameter.");

View File

@ -45,7 +45,7 @@ static string g_x25519AlgoName = "X25519";
}
namespace OHOS {
constexpr uint32_t PLEN_BITS = 3072;
constexpr int32_t PLEN_BITS = 3072;
constexpr int32_t SKLEN_BITS = 256;
HcfEccPubKeyParamsSpec g_ecc256PubKeySpec;
HcfEccPriKeyParamsSpec g_ecc256PriKeySpec;
@ -992,7 +992,7 @@ namespace OHOS {
return HCF_SUCCESS;
}
static HcfResult ConstructDhCommParamsSpec(uint32_t pLen, int32_t skLen, HcfDhCommParamsSpec **spec)
static HcfResult ConstructDhCommParamsSpec(int32_t pLen, int32_t skLen, HcfDhCommParamsSpec **spec)
{
HcfDhCommParamsSpec *dhCommSpec = nullptr;

View File

@ -38,7 +38,7 @@ namespace OHOS {
FreeDhCommParamsSpec(returnCommonParamSpec);
}
bool DhKeyUtilFuzzTest(const uint32_t* pLen, size_t size)
bool DhKeyUtilFuzzTest(const int32_t* pLen, size_t size)
{
if (g_testFlag) {
TestDhKey();
@ -55,7 +55,7 @@ namespace OHOS {
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint32_t* pLen, size_t size)
extern "C" int LLVMFuzzerTestOneInput(const int32_t* pLen, size_t size)
{
/* Run your code on data */
OHOS::DhKeyUtilFuzzTest(pLen, size);

View File

@ -54,7 +54,6 @@ constexpr int PLEN_DH4096 = 4096;
constexpr int PLEN_DH6144 = 6144;
constexpr int PLEN_DH8192 = 8192;
constexpr int PLEN_DH10001 = 10001;
constexpr int PLEN_LTZERO = -1;
constexpr int PLEN_LTSK = 20;
class CryptoDHAsyKeyGeneratorBySpecTest : public testing::Test {
@ -1383,7 +1382,7 @@ HWTEST_F(CryptoDHAsyKeyGeneratorBySpecTest, CryptoDHAsyKeyGeneratorBySpecTest031
HWTEST_F(CryptoDHAsyKeyGeneratorBySpecTest, CryptoDHAsyKeyGeneratorBySpecTest032, TestSize.Level0)
{
HcfDhCommParamsSpec *returnCommonParamSpec = nullptr;
HcfResult res = HcfDhKeyUtilCreate(PLEN_LTZERO, SKLEN_DH1024, &returnCommonParamSpec);
HcfResult res = HcfDhKeyUtilCreate(INT_MAX, SKLEN_DH1024, &returnCommonParamSpec);
ASSERT_EQ(res, HCF_ERR_MALLOC);
res = HcfDhKeyUtilCreate(PLEN_LTSK, SKLEN_DH1024, &returnCommonParamSpec);