mirror of
https://gitee.com/openharmony/security_crypto_framework
synced 2024-11-27 09:00:31 +00:00
commit
7c56b520f8
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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.");
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user