fix issue

Signed-off-by: zxz*3 <zhangxiaozan1@huawei.com>
This commit is contained in:
zxz*3 2024-08-25 11:01:35 +08:00 committed by lanming
parent 4c35372948
commit 9f7ae4866d
4 changed files with 41 additions and 17 deletions

View File

@ -144,7 +144,7 @@ static uint32_t GetParcelIncreaseSize(HcParcel *parcel, uint32_t newSize)
bool ParcelWrite(HcParcel *parcel, const void *src, uint32_t dataSize)
{
errno_t rc;
if (parcel == NULL || parcel->data == NULL || src == NULL || dataSize == 0) {
if (parcel == NULL || src == NULL || dataSize == 0) {
return false;
}
if (parcel->endPos > PARCEL_UINT_MAX - dataSize) {

View File

@ -1225,28 +1225,36 @@ static const char *GetAlgNameBySpec(const HcfAsyKeyGeneratorBySpec *self)
static HcfResult ConvertKey(HcfAsyKeyGenerator *self, HcfParamsSpec *params, HcfBlob *pubKeyBlob,
HcfBlob *priKeyBlob, HcfKeyPair **returnKeyPair)
{
HcfAsyKeyGeneratorImpl *impl = (HcfAsyKeyGeneratorImpl *)self;
if (self == NULL || impl->spiObj == NULL || impl->spiObj->engineConvertKey == NULL) {
if (self == NULL) {
LOGE("Invalid input parameter.");
return HCF_INVALID_PARAMS;
}
if (!HcfIsClassMatch((HcfObjectBase *)self, GetAsyKeyGeneratorClass())) {
return HCF_INVALID_PARAMS;
}
HcfAsyKeyGeneratorImpl *impl = (HcfAsyKeyGeneratorImpl *)self;
if (impl->spiObj == NULL || impl->spiObj->engineConvertKey == NULL) {
LOGE("Invalid input parameter.");
return HCF_INVALID_PARAMS;
}
return impl->spiObj->engineConvertKey(impl->spiObj, params, pubKeyBlob, priKeyBlob, returnKeyPair);
}
static HcfResult ConvertPemKey(HcfAsyKeyGenerator *self, HcfParamsSpec *params, const char *pubKeyStr,
const char *priKeyStr, HcfKeyPair **returnKeyPair)
{
HcfAsyKeyGeneratorImpl *impl = (HcfAsyKeyGeneratorImpl *)self;
if (self == NULL || impl->spiObj == NULL || impl->spiObj->engineConvertPemKey == NULL) {
if (self == NULL) {
LOGE("Invalid input parameter.");
return HCF_INVALID_PARAMS;
}
if (!HcfIsClassMatch((HcfObjectBase *)self, GetAsyKeyGeneratorClass())) {
return HCF_INVALID_PARAMS;
}
HcfAsyKeyGeneratorImpl *impl = (HcfAsyKeyGeneratorImpl *)self;
if (impl->spiObj == NULL || impl->spiObj->engineConvertPemKey == NULL) {
LOGE("Invalid input parameter.");
return HCF_INVALID_PARAMS;
}
return impl->spiObj->engineConvertPemKey(impl->spiObj, params, pubKeyStr, priKeyStr, returnKeyPair);
}
@ -1254,53 +1262,69 @@ static HcfResult GenerateKeyPair(HcfAsyKeyGenerator *self, HcfParamsSpec *params
HcfKeyPair **returnKeyPair)
{
(void)params;
HcfAsyKeyGeneratorImpl *impl = (HcfAsyKeyGeneratorImpl *)self;
if (self == NULL || impl->spiObj == NULL || impl->spiObj->engineGenerateKeyPair == NULL) {
if (self == NULL) {
LOGE("Invalid input parameter.");
return HCF_INVALID_PARAMS;
}
if (!HcfIsClassMatch((HcfObjectBase *)self, GetAsyKeyGeneratorClass())) {
return HCF_INVALID_PARAMS;
}
HcfAsyKeyGeneratorImpl *impl = (HcfAsyKeyGeneratorImpl *)self;
if (impl->spiObj == NULL || impl->spiObj->engineGenerateKeyPair == NULL) {
LOGE("Invalid input parameter.");
return HCF_INVALID_PARAMS;
}
return impl->spiObj->engineGenerateKeyPair(impl->spiObj, returnKeyPair);
}
static HcfResult GenerateKeyPairBySpec(const HcfAsyKeyGeneratorBySpec *self, HcfKeyPair **returnKeyPair)
{
HcfAsyKeyGeneratorBySpecImpl *impl = (HcfAsyKeyGeneratorBySpecImpl *)self;
if (self == NULL || impl->spiObj == NULL || impl->spiObj->engineGenerateKeyPairBySpec == NULL) {
if (self == NULL) {
LOGE("Invalid input parameter.");
return HCF_INVALID_PARAMS;
}
if (!HcfIsClassMatch((HcfObjectBase *)self, GetAsyKeyGeneratorBySpecClass())) {
return HCF_INVALID_PARAMS;
}
HcfAsyKeyGeneratorBySpecImpl *impl = (HcfAsyKeyGeneratorBySpecImpl *)self;
if (impl->spiObj == NULL || impl->spiObj->engineGenerateKeyPairBySpec == NULL) {
LOGE("Invalid input parameter.");
return HCF_INVALID_PARAMS;
}
return impl->spiObj->engineGenerateKeyPairBySpec(impl->spiObj, impl->paramsSpec, returnKeyPair);
}
static HcfResult GeneratePubKeyBySpec(const HcfAsyKeyGeneratorBySpec *self, HcfPubKey **returnPubKey)
{
HcfAsyKeyGeneratorBySpecImpl *impl = (HcfAsyKeyGeneratorBySpecImpl *)self;
if (self == NULL || impl->spiObj == NULL || impl->spiObj->engineGeneratePubKeyBySpec == NULL) {
if (self == NULL) {
LOGE("Invalid input parameter.");
return HCF_INVALID_PARAMS;
}
if (!HcfIsClassMatch((HcfObjectBase *)self, GetAsyKeyGeneratorBySpecClass())) {
return HCF_INVALID_PARAMS;
}
HcfAsyKeyGeneratorBySpecImpl *impl = (HcfAsyKeyGeneratorBySpecImpl *)self;
if (impl->spiObj == NULL || impl->spiObj->engineGeneratePubKeyBySpec == NULL) {
LOGE("Invalid input parameter.");
return HCF_INVALID_PARAMS;
}
return impl->spiObj->engineGeneratePubKeyBySpec(impl->spiObj, impl->paramsSpec, returnPubKey);
}
static HcfResult GeneratePriKeyBySpec(const HcfAsyKeyGeneratorBySpec *self, HcfPriKey **returnPriKey)
{
HcfAsyKeyGeneratorBySpecImpl *impl = (HcfAsyKeyGeneratorBySpecImpl *)self;
if (self == NULL || impl->spiObj == NULL || impl->spiObj->engineGeneratePriKeyBySpec == NULL) {
if (self == NULL) {
LOGE("Invalid input parameter.");
return HCF_INVALID_PARAMS;
}
if (!HcfIsClassMatch((HcfObjectBase *)self, GetAsyKeyGeneratorBySpecClass())) {
return HCF_INVALID_PARAMS;
}
HcfAsyKeyGeneratorBySpecImpl *impl = (HcfAsyKeyGeneratorBySpecImpl *)self;
if (impl->spiObj == NULL || impl->spiObj->engineGeneratePriKeyBySpec == NULL) {
LOGE("Invalid input parameter.");
return HCF_INVALID_PARAMS;
}
return impl->spiObj->engineGeneratePriKeyBySpec(impl->spiObj, impl->paramsSpec, returnPriKey);
}

View File

@ -448,7 +448,7 @@ bool IsBigEndian(void)
HcfResult BigIntegerToBigNum(const HcfBigInteger *src, BIGNUM **dest)
{
if (src == NULL || src->data == NULL || dest == NULL) {
if (src == NULL || dest == NULL) {
LOGE("Invalid input parameter.");
return HCF_INVALID_PARAMS;
}

View File

@ -1223,7 +1223,7 @@ static HcfResult EngineGenerateKeyPairBySpec(const HcfAsyKeyGeneratorSpi *self,
HcfKeyPair **returnKeyPair)
{
if ((self == NULL) || (returnKeyPair == NULL) || (params == NULL) ||
(((HcfEccCommParamsSpec *)params)->field != NULL)) {
(((HcfEccCommParamsSpec *)params)->field == NULL)) {
LOGE("Invalid input parameter.");
return HCF_INVALID_PARAMS;
}
@ -1259,7 +1259,7 @@ static HcfResult EngineGeneratePubKeyBySpec(const HcfAsyKeyGeneratorSpi *self, c
HcfPubKey **returnPubKey)
{
if ((self == NULL) || (returnPubKey == NULL) || (params == NULL) ||
(((HcfEccCommParamsSpec *)params)->field != NULL)) {
(((HcfEccCommParamsSpec *)params)->field == NULL)) {
LOGE("Invalid input parameter.");
return HCF_INVALID_PARAMS;
}
@ -1292,7 +1292,7 @@ static HcfResult EngineGeneratePriKeyBySpec(const HcfAsyKeyGeneratorSpi *self, c
HcfPriKey **returnPriKey)
{
if ((self == NULL) || (returnPriKey == NULL) || (params == NULL) ||
(((HcfEccCommParamsSpec *)params)->field != NULL)) {
(((HcfEccCommParamsSpec *)params)->field == NULL)) {
LOGE("Invalid input parameter.");
return HCF_INVALID_PARAMS;
}