mirror of
https://gitee.com/openharmony/security_crypto_framework
synced 2024-11-23 15:00:04 +00:00
fix issue
Signed-off-by: lanming <lanming@huawei.com>
This commit is contained in:
parent
a9955116cd
commit
fa55de0b43
@ -122,6 +122,7 @@ static HcfResult InitEvpPkeyCtx(HcfCipherRsaGeneratorSpiImpl *impl, HcfKey *key,
|
||||
HcfPrintOpensslError();
|
||||
OpensslEvpPkeyFree(pkey);
|
||||
OpensslEvpPkeyCtxFree(impl->ctx);
|
||||
impl->ctx = NULL;
|
||||
return HCF_ERR_CRYPTO_OPERATION;
|
||||
}
|
||||
OpensslEvpPkeyFree(pkey);
|
||||
|
@ -202,12 +202,6 @@ static HcfResult InitHkdfData(OpensslHkdfSpiImpl *self, HcfHkdfParamsSpec *param
|
||||
LOGE("malloc info failed!");
|
||||
break;
|
||||
}
|
||||
data->out = (unsigned char *)HcfMalloc(params->output.len, 0);
|
||||
if (data->out == NULL) {
|
||||
LOGE("malloc out failed!");
|
||||
break;
|
||||
}
|
||||
data->outLen = params->output.len;
|
||||
self->kdfData = data;
|
||||
return HCF_SUCCESS;
|
||||
} while (0);
|
||||
|
@ -136,7 +136,7 @@ static void OpensslDestroyMd(HcfObjectBase *self)
|
||||
|
||||
HcfResult OpensslMdSpiCreate(const char *opensslAlgoName, HcfMdSpi **spiObj)
|
||||
{
|
||||
if (spiObj == NULL) {
|
||||
if (spiObj == NULL || opensslAlgoName == NULL) {
|
||||
LOGE("Invalid input parameter.");
|
||||
return HCF_INVALID_PARAMS;
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ static const char *GetRandAlgoName(HcfRandSpi *self)
|
||||
|
||||
static void OpensslSetSeed(HcfRandSpi *self, HcfBlob *seed)
|
||||
{
|
||||
(void)self;
|
||||
OpensslRandSeed(seed->data, seed->len);
|
||||
}
|
||||
|
||||
|
@ -378,20 +378,15 @@ static HcfResult EngineDsaSignDoFinal(HcfSignSpi *self, HcfBlob *data, HcfBlob *
|
||||
LOGE("Failed to allocate signatureData memory!");
|
||||
return HCF_ERR_MALLOC;
|
||||
}
|
||||
size_t actualLen = maxLen;
|
||||
if (OpensslEvpDigestSignFinal(impl->mdCtx, signatureData, &actualLen) != HCF_OPENSSL_SUCCESS) {
|
||||
|
||||
if (OpensslEvpDigestSignFinal(impl->mdCtx, signatureData, &maxLen) != HCF_OPENSSL_SUCCESS) {
|
||||
HcfPrintOpensslError();
|
||||
HcfFree(signatureData);
|
||||
return HCF_ERR_CRYPTO_OPERATION;
|
||||
}
|
||||
if (actualLen > maxLen) {
|
||||
LOGD("[error] Signature data too long.");
|
||||
HcfFree(signatureData);
|
||||
return HCF_ERR_CRYPTO_OPERATION;
|
||||
}
|
||||
|
||||
returnSignatureData->data = signatureData;
|
||||
returnSignatureData->len = (uint32_t)actualLen;
|
||||
returnSignatureData->len = (uint32_t)maxLen;
|
||||
return HCF_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -225,21 +225,16 @@ static HcfResult EngineSignDoFinal(HcfSignSpi *self, HcfBlob *data, HcfBlob *ret
|
||||
LOGE("Failed to allocate outData memory!");
|
||||
return HCF_ERR_MALLOC;
|
||||
}
|
||||
size_t actualLen = maxLen;
|
||||
if (OpensslEvpDigestSignFinal(impl->ctx, outData, &actualLen) != HCF_OPENSSL_SUCCESS) {
|
||||
|
||||
if (OpensslEvpDigestSignFinal(impl->ctx, outData, &maxLen) != HCF_OPENSSL_SUCCESS) {
|
||||
HcfPrintOpensslError();
|
||||
LOGD("[error] EVP_DigestSignFinal failed.");
|
||||
HcfFree(outData);
|
||||
return HCF_ERR_CRYPTO_OPERATION;
|
||||
}
|
||||
if (actualLen > maxLen) {
|
||||
LOGD("[error] signature data too long.");
|
||||
HcfFree(outData);
|
||||
return HCF_ERR_CRYPTO_OPERATION;
|
||||
}
|
||||
|
||||
returnSignatureData->data = outData;
|
||||
returnSignatureData->len = (uint32_t)actualLen;
|
||||
returnSignatureData->len = (uint32_t)maxLen;
|
||||
return HCF_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -251,6 +251,7 @@ static HcfResult SetSignParams(HcfSignSpiRsaOpensslImpl *impl, HcfPriKey *privat
|
||||
EVP_MD *opensslAlg = NULL;
|
||||
(void)GetOpensslDigestAlg(impl->md, &opensslAlg);
|
||||
if (opensslAlg == NULL) {
|
||||
OpensslEvpPkeyFree(dupKey);
|
||||
LOGE("Get openssl digest alg fail");
|
||||
return HCF_INVALID_PARAMS;
|
||||
}
|
||||
@ -318,6 +319,7 @@ static HcfResult SetVerifyParams(HcfVerifySpiRsaOpensslImpl *impl, HcfPubKey *pu
|
||||
EVP_MD *opensslAlg = NULL;
|
||||
(void)GetOpensslDigestAlg(impl->md, &opensslAlg);
|
||||
if (opensslAlg == NULL) {
|
||||
OpensslEvpPkeyFree(dupKey);
|
||||
LOGE("Get openssl digest alg fail");
|
||||
return HCF_INVALID_PARAMS;
|
||||
}
|
||||
@ -529,20 +531,15 @@ static HcfResult EngineDigestSign(HcfSignSpiRsaOpensslImpl *impl, HcfBlob *data,
|
||||
LOGE("Failed to allocate outData memory!");
|
||||
return HCF_ERR_MALLOC;
|
||||
}
|
||||
size_t actualLen = maxLen;
|
||||
if (OpensslEvpDigestSignFinal(impl->mdctx, outData, &actualLen) != HCF_OPENSSL_SUCCESS) {
|
||||
|
||||
if (OpensslEvpDigestSignFinal(impl->mdctx, outData, &maxLen) != HCF_OPENSSL_SUCCESS) {
|
||||
LOGD("[error] OpensslEvpDigestSignFinal fail");
|
||||
HcfFree(outData);
|
||||
HcfPrintOpensslError();
|
||||
return HCF_ERR_CRYPTO_OPERATION;
|
||||
}
|
||||
if (actualLen > maxLen) {
|
||||
LOGD("[error] signature data too long.");
|
||||
HcfFree(outData);
|
||||
return HCF_ERR_CRYPTO_OPERATION;
|
||||
}
|
||||
returnSignatureData->data = outData;
|
||||
returnSignatureData->len = (uint32_t)actualLen;
|
||||
returnSignatureData->len = (uint32_t)maxLen;
|
||||
return HCF_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -67,10 +67,15 @@ static const char *GetAlg25519PriKeyClass(void)
|
||||
|
||||
static void DestroyAlg25519KeyGeneratorSpiImpl(HcfObjectBase *self)
|
||||
{
|
||||
if (self == NULL) {
|
||||
if ((self == NULL) || (self->getClass() == NULL)) {
|
||||
LOGE("Invalid input parameter.");
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(obj->getClass(), GetEd25519KeyGeneratorSpiClass()) != 0 && ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!HcfIsClassMatch(self, GetEd25519KeyGeneratorSpiClass()) &&
|
||||
!HcfIsClassMatch(self, GetX25519KeyGeneratorSpiClass())) {
|
||||
LOGE("Invalid class of self.");
|
||||
|
Loading…
Reference in New Issue
Block a user