修改AI扫描问题

Signed-off-by: hhhFun <fanghaojie@huawei.com>
This commit is contained in:
hhhFun 2024-08-23 22:58:31 +08:00 committed by lanming
parent 5aa6834152
commit 324dd420f0
6 changed files with 20 additions and 3 deletions

View File

@ -816,6 +816,11 @@ napi_value NapiVerify::JsUpdateSync(napi_env env, napi_callback_info info)
}
HcfVerify *verify = napiVerify->GetVerify();
if (verify == nullptr) {
LOGE("failed to get verify obj.");
napi_throw(env, GenerateBusinessError(env, HCF_INVALID_PARAMS, "fail to get verify obj."));
return nullptr;
}
ret = verify->update(verify, &blob);
HcfBlobDataFree(&blob);
if (ret != HCF_SUCCESS) {

View File

@ -44,7 +44,7 @@ HcfResult HcfDhKeyUtilCreate(int32_t pLen, int32_t skLen, HcfDhCommParamsSpec **
}
ret = CreateDhCommonSpecImpl(&(spiInstance->paramsSpec), returnCommonParamSpec);
if (ret != HCF_SUCCESS) {
LOGE("Failed to create spi object!");
LOGE("Failed to create spi impl object!");
}
FreeDhCommParamsSpec(&(spiInstance->paramsSpec));
HcfFree(spiInstance);

View File

@ -70,6 +70,9 @@ namespace OHOS {
uint8_t *cipherText, int cipherTextLen)
{
HcfBlob output = {};
if (cipherTextLen <= 0) {
return -1;
}
int32_t maxLen = cipherTextLen;
int32_t ret = cipher->init(cipher, DECRYPT_MODE, &(key->key), nullptr);
if (ret != 0) {
@ -149,6 +152,9 @@ namespace OHOS {
uint8_t *cipherText, int cipherTextLen)
{
HcfBlob output = {};
if (cipherTextLen <= 0) {
return -1;
}
int32_t maxLen = cipherTextLen;
int32_t ret = cipher->init(cipher, DECRYPT_MODE, reinterpret_cast<HcfKey *>(key), nullptr);
if (ret != 0) {

View File

@ -26,6 +26,9 @@
namespace OHOS {
bool HcfKeyAgreementCreateFuzzTest(const uint8_t* data, size_t size)
{
if (data == nullptr || size == 0) {
return false;
}
HcfKeyAgreement *keyAgreement = nullptr;
std::string algoName(reinterpret_cast<const char *>(data), size);
int32_t res = HcfKeyAgreementCreate(algoName.c_str(), &keyAgreement);

View File

@ -47,6 +47,9 @@ void EndianSwap(unsigned char *pData, int startIndex, int length)
// 512 defined the length of byte array
void GenerateRsa512CorrectCommonKeySpec(unsigned char *dataN, HcfRsaCommParamsSpec *returnSpec)
{
if (dataN == nullptr) {
return;
}
RemoveLastChar(CORRECT_512_N, dataN, RSA_512_N_BYTE_SIZE);
if (!IsBigEndian()) {
// the device is not big endian

View File

@ -37,7 +37,7 @@ HcfResult GenerateSm4SymKey(HcfSymKey **key)
HcfSymKeyGenerator *generator = nullptr;
HcfResult ret = HcfSymKeyGeneratorCreate("SM4_128", &generator);
if (ret != HCF_SUCCESS) {
if (ret != HCF_SUCCESS || generator == nullptr) {
LOGE("HcfSymKeyGeneratorCreate failed!");
return ret;
}
@ -55,7 +55,7 @@ int32_t GenerateSymKeyForSm4(const char *algoName, HcfSymKey **key)
HcfSymKeyGenerator *generator = nullptr;
int32_t ret = HcfSymKeyGeneratorCreate(algoName, &generator);
if (ret != 0) {
if (ret != 0 || generator == nullptr) {
LOGE("HcfSymKeyGeneratorCreate failed!");
return ret;
}