!182 证书算法库代码问题修改

Merge pull request !182 from 王静/master
This commit is contained in:
openharmony_ci 2024-06-27 09:25:03 +00:00 committed by Gitee
commit 75fa41549d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
20 changed files with 209 additions and 169 deletions

View File

@ -34,8 +34,8 @@ extern "C" {
#endif
const char *GetX509CertChainClass(void);
CfResult ToString(HcfX509CertChainSpi *self, CfBlob *out);
CfResult HashCode(HcfX509CertChainSpi *self, CfBlob *out);
CfResult CfToString(HcfX509CertChainSpi *self, CfBlob *out);
CfResult CfHashCode(HcfX509CertChainSpi *self, CfBlob *out);
#ifdef __cplusplus
}

View File

@ -332,6 +332,7 @@ CfResult DeepCopyDataToOut(const char *data, uint32_t len, CfBlob *out)
if (memcpy_s(out->data, len, data, len) != EOK) {
CF_LOG_E("Failed to memcpy_s");
CfFree(out->data);
out->data = NULL;
return CF_ERR_COPY;
}
out->size = len;

View File

@ -96,7 +96,7 @@ static CfResult ConvertOpensslErrorMsg(int32_t errCode)
static void DestroyX509CertChain(CfObjectBase *self)
{
if (self == NULL || !IsClassMatch(self, GetX509CertChainClass())) {
if (self == NULL || !CfIsClassMatch(self, GetX509CertChainClass())) {
LOGE("Invalid params!");
return;
}
@ -143,7 +143,7 @@ static CfResult GetCertlist(HcfX509CertChainSpi *self, HcfX509CertificateArray *
LOGE("[GetCertlist openssl] The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertChainClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertChainClass())) {
LOGE("[GetCertlist openssl] Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -188,12 +188,12 @@ static CfResult GetCertlist(HcfX509CertChainSpi *self, HcfX509CertificateArray *
static X509 *GetX509FromHcfX509Certificate(const HcfCertificate *cert)
{
if (!IsClassMatch((CfObjectBase *)cert, HCF_X509_CERTIFICATE_CLASS)) {
if (!CfIsClassMatch((CfObjectBase *)cert, HCF_X509_CERTIFICATE_CLASS)) {
LOGE("Input wrong openssl class type!");
return NULL;
}
HcfX509CertificateImpl *impl = (HcfX509CertificateImpl *)cert;
if (!IsClassMatch((CfObjectBase *)(impl->spiObj), X509_CERT_OPENSSL_CLASS)) {
if (!CfIsClassMatch((CfObjectBase *)(impl->spiObj), X509_CERT_OPENSSL_CLASS)) {
LOGE("Input wrong openssl class type!");
return NULL;
}
@ -770,7 +770,7 @@ static const char *GetDpUrl(DIST_POINT *dp)
}
if (gtype == GEN_URI && ASN1_STRING_length(url) > GEN_URI) {
const char *uptr = (const char *)ASN1_STRING_get0_data(url);
if (IsHttp(uptr)) {
if (CfIsHttp(uptr)) {
// can/should not use HTTPS here
return uptr;
}
@ -806,7 +806,7 @@ static X509_CRL *GetCrlFromCert(const HcfX509CertChainValidateParams *params, X5
if (params->revocationCheckParam->crlDownloadURI != NULL &&
params->revocationCheckParam->crlDownloadURI->data != NULL) {
char *url = (char *)params->revocationCheckParam->crlDownloadURI->data;
if (IsUrlValid(url)) {
if (CfIsUrlValid(url)) {
return X509_CRL_load_http(url, NULL, NULL, HTTP_TIMEOUT);
}
}
@ -1043,7 +1043,7 @@ static CfResult GetOcspUrl(GetOcspUrlParams *params)
}
}
char *urlValiable = (url == NULL) ? (char *)(params->revo->ocspResponderURI->data) : url;
if (!IsUrlValid(urlValiable)) {
if (!CfIsUrlValid(urlValiable)) {
LOGE("Invalid url.");
return CF_INVALID_PARAMS;
}
@ -1095,8 +1095,13 @@ static BIO *CreateConnectBio(char *host, char *port, int ssl)
return NULL;
}
bio = BIO_new_ssl_connect(sslCtx);
if (bio == NULL) {
LOGE("bio is null.");
return NULL;
}
if (BIO_set_conn_hostname(bio, host) != 1) {
LOGE("Set host name failed.");
BIO_free_all(bio);
return NULL;
}
} else {
@ -1111,16 +1116,19 @@ static BIO *CreateConnectBio(char *host, char *port, int ssl)
if (port != NULL) {
if (BIO_set_conn_port(bio, port) != 1) {
LOGE("Set port failed.");
BIO_free_all(bio);
return NULL;
}
} else if (ssl) {
if (BIO_set_conn_port(bio, HTTPS_PORT) != 1) {
LOGE("Set port failed.");
BIO_free_all(bio);
return NULL;
}
} else {
if (BIO_set_conn_port(bio, HTTP_PORT) != 1) {
LOGE("Set port failed.");
BIO_free_all(bio);
return NULL;
}
}
@ -1531,7 +1539,7 @@ static CfResult Validate(
LOGE("The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertChainClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertChainClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -1780,8 +1788,8 @@ CfResult HcfX509CertChainByEncSpiCreate(const CfEncodingBlob *inStream, HcfX509C
certChain->base.base.destroy = DestroyX509CertChain;
certChain->base.engineGetCertList = GetCertlist;
certChain->base.engineValidate = Validate;
certChain->base.engineToString = ToString;
certChain->base.engineHashCode = HashCode;
certChain->base.engineToString = CfToString;
certChain->base.engineHashCode = CfHashCode;
*spi = (HcfX509CertChainSpi *)certChain;
return CF_SUCCESS;
}
@ -1856,8 +1864,8 @@ CfResult HcfX509CertChainByArrSpiCreate(const HcfX509CertificateArray *inCerts,
certChain->base.base.destroy = DestroyX509CertChain;
certChain->base.engineGetCertList = GetCertlist;
certChain->base.engineValidate = Validate;
certChain->base.engineToString = ToString;
certChain->base.engineHashCode = HashCode;
certChain->base.engineToString = CfToString;
certChain->base.engineHashCode = CfHashCode;
*spi = (HcfX509CertChainSpi *)certChain;
return CF_SUCCESS;

View File

@ -31,13 +31,13 @@ const char *GetX509CertChainClass(void)
return X509_CERT_CHAIN_OPENSSL_CLASS;
}
CfResult ToString(HcfX509CertChainSpi *self, CfBlob *out)
CfResult CfToString(HcfX509CertChainSpi *self, CfBlob *out)
{
if ((self == NULL) || (out == NULL)) {
LOGE("The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertChainClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertChainClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -72,13 +72,13 @@ CfResult ToString(HcfX509CertChainSpi *self, CfBlob *out)
return CF_ERR_CRYPTO_OPERATION;
}
CfResult HashCode(HcfX509CertChainSpi *self, CfBlob *out)
CfResult CfHashCode(HcfX509CertChainSpi *self, CfBlob *out)
{
if ((self == NULL) || (out == NULL)) {
LOGE("The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertChainClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertChainClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}

View File

@ -77,7 +77,7 @@ static void DestroyX509CertChainValidator(CfObjectBase *self)
LOGE("Invalid params!");
return;
}
if (!IsClassMatch(self, GetX509CertChainValidatorClass())) {
if (!CfIsClassMatch(self, GetX509CertChainValidatorClass())) {
LOGE("Class is not match.");
return;
}
@ -206,7 +206,7 @@ static CfResult Validate(HcfCertChainValidatorSpi *self, const CfArray *certsLis
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertChainValidatorClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertChainValidatorClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}

View File

@ -63,7 +63,7 @@ static void DestroyX509Openssl(CfObjectBase *self)
if (self == NULL) {
return;
}
if (!IsClassMatch(self, GetX509CertClass())) {
if (!CfIsClassMatch(self, GetX509CertClass())) {
LOGE("Input wrong class type!");
return;
}
@ -83,7 +83,7 @@ static void DestroyX509PubKeyOpenssl(HcfObjectBase *self)
if (self == NULL) {
return;
}
if (!IsPubKeyClassMatch(self, GetX509CertPubKeyClass())) {
if (!CfIsPubKeyClassMatch(self, GetX509CertPubKeyClass())) {
LOGE("Input wrong class type!");
return;
}
@ -108,7 +108,7 @@ static HcfResult GetPubKeyEncoded(HcfKey *self, HcfBlob *returnBlob)
LOGE("Input params is invalid.");
return HCF_INVALID_PARAMS;
}
if (!IsPubKeyClassMatch((HcfObjectBase *)self, GetX509CertPubKeyClass())) {
if (!CfIsPubKeyClassMatch((HcfObjectBase *)self, GetX509CertPubKeyClass())) {
LOGE("Input wrong class type!");
return HCF_INVALID_PARAMS;
}
@ -148,8 +148,8 @@ static CfResult VerifyX509Openssl(HcfX509CertificateSpi *self, HcfPubKey *key)
LOGE("The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass()) ||
(!IsPubKeyClassMatch((HcfObjectBase *)key, GetX509CertPubKeyClass()))) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass()) ||
(!CfIsPubKeyClassMatch((HcfObjectBase *)key, GetX509CertPubKeyClass()))) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -171,7 +171,7 @@ static CfResult GetEncodedX509Openssl(HcfX509CertificateSpi *self, CfEncodingBlo
LOGE("The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -204,7 +204,7 @@ static CfResult GetPublicKeyX509Openssl(HcfX509CertificateSpi *self, HcfPubKey *
LOGE("The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -375,7 +375,7 @@ static CfResult CheckValidityWithDateX509Openssl(HcfX509CertificateSpi *self, co
LOGE("The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -571,7 +571,7 @@ static long GetVersionX509Openssl(HcfX509CertificateSpi *self)
LOGE("The input data is null!");
return INVALID_VERSION;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Input wrong class type!");
return INVALID_VERSION;
}
@ -586,7 +586,7 @@ static CfResult GetSerialNumberX509Openssl(HcfX509CertificateSpi *self, CfBlob *
LOGE("The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -619,7 +619,7 @@ static CfResult GetIssuerDNX509Openssl(HcfX509CertificateSpi *self, CfBlob *out)
LOGE("[Get issuerDN openssl] The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -659,7 +659,7 @@ static CfResult GetSubjectDNX509Openssl(HcfX509CertificateSpi *self, CfBlob *out
LOGE("[Get subjectDN openssl]The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -726,7 +726,7 @@ static CfResult GetSubjectDNX509OpensslEx(HcfX509CertificateSpi *self, CfEncodin
LOGE("[Get utf8 subjectDN openssl]The input data is null or encodingType is not utf8!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -769,7 +769,7 @@ static CfResult GetNotBeforeX509Openssl(HcfX509CertificateSpi *self, CfBlob *out
LOGE("Get not before, input is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Get not before, input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -801,7 +801,7 @@ static CfResult GetNotAfterX509Openssl(HcfX509CertificateSpi *self, CfBlob *outD
LOGE("Get not after, input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Get not after, input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -833,7 +833,7 @@ static CfResult GetSignatureX509Openssl(HcfX509CertificateSpi *self, CfBlob *sig
LOGE("The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -862,7 +862,7 @@ static CfResult GetSigAlgNameX509Openssl(HcfX509CertificateSpi *self, CfBlob *ou
LOGE("[GetSigAlgName openssl] The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("[GetSigAlgName openssl] Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -893,7 +893,7 @@ static CfResult GetSigAlgOidX509Openssl(HcfX509CertificateSpi *self, CfBlob *out
LOGE("[GetSigAlgOID openssl] The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("[GetSigAlgOID openssl] Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -920,7 +920,7 @@ static CfResult GetSigAlgParamsX509Openssl(HcfX509CertificateSpi *self, CfBlob *
LOGE("[GetSigAlgParams openssl] The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("[GetSigAlgParams openssl] Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -985,7 +985,7 @@ static CfResult GetKeyUsageX509Openssl(HcfX509CertificateSpi *self, CfBlob *bool
LOGE("[GetKeyUsage openssl] The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -1030,7 +1030,7 @@ static CfResult GetExtendedKeyUsageX509Openssl(HcfX509CertificateSpi *self, CfAr
LOGE("The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -1079,7 +1079,7 @@ static int32_t GetBasicConstraintsX509Openssl(HcfX509CertificateSpi *self)
LOGE("The input data is null!");
return INVALID_CONSTRAINTS_LEN;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Input wrong class type!");
return INVALID_CONSTRAINTS_LEN;
}
@ -1139,7 +1139,7 @@ static CfResult GetSubjectAltNamesX509Openssl(HcfX509CertificateSpi *self, CfArr
LOGE("[GetSubjectAltNames openssl] The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -1189,7 +1189,7 @@ static CfResult GetIssuerAltNamesX509Openssl(HcfX509CertificateSpi *self, CfArra
LOGE("[GetIssuerAltNames openssl] The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -1239,7 +1239,7 @@ static CfResult ToStringX509Openssl(HcfX509CertificateSpi *self, CfBlob *out)
LOGE("The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -1274,7 +1274,7 @@ static CfResult HashCodeX509Openssl(HcfX509CertificateSpi *self, CfBlob *out)
LOGE("The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -1305,7 +1305,7 @@ static CfResult GetExtensionsObjectX509Openssl(HcfX509CertificateSpi *self, CfBl
LOGE("The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -1853,7 +1853,7 @@ static CfResult MatchX509Openssl(HcfX509CertificateSpi *self, const HcfX509CertM
LOGE("[GetIssuerAltNames openssl] The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -2027,7 +2027,7 @@ static CfResult GetCRLDistributionPointsURIX509Openssl(HcfX509CertificateSpi *se
LOGE("[GetCRLDistributionPointsURI openssl] The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertClass())) {
LOGE("[GetCRLDistributionPointsURI openssl] Input wrong class type!");
return CF_INVALID_PARAMS;
}

View File

@ -45,7 +45,7 @@ static const char *GetClass(void)
static X509_REVOKED *GetSelfRev(const HcfX509CrlEntry *self)
{
if (!IsClassMatch((CfObjectBase *)self, GetClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetClass())) {
LOGE("Input wrong class type!");
return NULL;
}
@ -127,12 +127,12 @@ static CfResult GetCertIssuer(HcfX509CrlEntry *self, CfBlob *encodedOut)
LOGE("Invalid Paramas for calling GetCertIssuer!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
CfBlob *certIssuer = ((HcfX509CRLEntryOpensslImpl *)self)->certIssuer;
if (!IsBlobValid(certIssuer)) {
if (!CfIsBlobValid(certIssuer)) {
LOGE("Get certIssuer fail! No certIssuer in CRL entry.");
return CF_NOT_SUPPORT;
}
@ -339,7 +339,7 @@ static void Destroy(CfObjectBase *self)
LOGE("Invalid Paramas!");
return;
}
if (!IsClassMatch((CfObjectBase *)self, GetClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetClass())) {
LOGE("Input wrong class type!");
return;
}

View File

@ -62,7 +62,7 @@ static const char *GetType(HcfX509CrlSpi *self)
LOGE("Invalid Paramas!");
return NULL;
}
if (!IsClassMatch((CfObjectBase *)self, GetClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetClass())) {
LOGE("Input wrong class type!");
return NULL;
}
@ -71,7 +71,7 @@ static const char *GetType(HcfX509CrlSpi *self)
static X509_CRL *GetCrl(HcfX509CrlSpi *self)
{
if (!IsClassMatch((CfObjectBase *)self, GetClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetClass())) {
LOGE("Input wrong class type!");
return NULL;
}
@ -80,12 +80,12 @@ static X509_CRL *GetCrl(HcfX509CrlSpi *self)
static X509 *GetX509FromCertificate(const HcfCertificate *cert)
{
if (!IsClassMatch((CfObjectBase *)cert, HCF_X509_CERTIFICATE_CLASS)) {
if (!CfIsClassMatch((CfObjectBase *)cert, HCF_X509_CERTIFICATE_CLASS)) {
LOGE("Input wrong openssl class type!");
return NULL;
}
HcfX509CertificateImpl *impl = (HcfX509CertificateImpl *)cert;
if (!IsClassMatch((CfObjectBase *)(impl->spiObj), X509_CERT_OPENSSL_CLASS)) {
if (!CfIsClassMatch((CfObjectBase *)(impl->spiObj), X509_CERT_OPENSSL_CLASS)) {
LOGE("Input wrong openssl class type!");
return NULL;
}
@ -99,7 +99,7 @@ static bool IsRevoked(HcfX509CrlSpi *self, const HcfCertificate *cert)
LOGE("Invalid Paramas!");
return false;
}
if (!IsClassMatch((CfObjectBase *)self, GetClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetClass())) {
LOGE("Input wrong class type!");
return false;
}
@ -124,7 +124,7 @@ static CfResult GetEncoded(HcfX509CrlSpi *self, CfEncodingBlob *encodedOut)
LOGE("Invalid Paramas!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -159,8 +159,8 @@ static CfResult Verify(HcfX509CrlSpi *self, HcfPubKey *key)
LOGE("Invalid Paramas!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetClass()) ||
(!IsPubKeyClassMatch((HcfObjectBase *)key, OPENSSL_RSA_PUBKEY_CLASS))) {
if (!CfIsClassMatch((CfObjectBase *)self, GetClass()) ||
(!CfIsPubKeyClassMatch((HcfObjectBase *)key, OPENSSL_RSA_PUBKEY_CLASS))) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -211,7 +211,7 @@ static long GetVersion(HcfX509CrlSpi *self)
LOGE("Invalid Paramas!");
return OPENSSL_INVALID_VERSION;
}
if (!IsClassMatch((CfObjectBase *)self, GetClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetClass())) {
LOGE("Input wrong class type!");
return OPENSSL_INVALID_VERSION;
}
@ -390,7 +390,7 @@ static CfResult GetRevokedCertWithCert(HcfX509CrlSpi *self, HcfX509Certificate *
LOGE("Invalid Paramas!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -629,7 +629,7 @@ static CfResult GetSignatureAlgName(HcfX509CrlSpi *self, CfBlob *algNameOut)
LOGE("Invalid Paramas!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -743,7 +743,7 @@ static CfResult ToString(HcfX509CrlSpi *self, CfBlob *out)
LOGE("The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -781,7 +781,7 @@ static CfResult HashCode(HcfX509CrlSpi *self, CfBlob *out)
LOGE("The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -815,7 +815,7 @@ static CfResult GetExtensionsObject(HcfX509CrlSpi *self, CfBlob *out)
LOGE("The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -1027,7 +1027,7 @@ static CfResult MatchX509CRLOpenssl(HcfX509CrlSpi *self, const HcfX509CrlMatchPa
LOGE("The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -1061,7 +1061,7 @@ static void Destroy(CfObjectBase *self)
if (self == NULL) {
return;
}
if (!IsClassMatch(self, GetClass())) {
if (!CfIsClassMatch(self, GetClass())) {
LOGE("Input wrong class type!");
return;
}

View File

@ -48,7 +48,7 @@ static void DestroyX509DistinguishedNameOpenssl(CfObjectBase *self)
if (self == NULL) {
return;
}
if (!IsClassMatch(self, GetX509DistinguishedNameClass())) {
if (!CfIsClassMatch(self, GetX509DistinguishedNameClass())) {
LOGE("Input wrong class type!");
return;
}
@ -64,7 +64,7 @@ static CfResult GetEncodeOpenssl(HcfX509DistinguishedNameSpi *self, CfEncodingBl
LOGE("The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509DistinguishedNameClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509DistinguishedNameClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}
@ -175,7 +175,7 @@ static CfResult GetNameOpenssl(HcfX509DistinguishedNameSpi *self, CfBlob *type,
LOGE("The input data is null!");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509DistinguishedNameClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509DistinguishedNameClass())) {
LOGE("Input wrong class type!");
return CF_INVALID_PARAMS;
}

View File

@ -27,12 +27,12 @@
extern "C" {
#endif
bool IsStrValid(const char *str, uint32_t maxLen);
bool IsBlobValid(const CfBlob *blob);
bool IsClassMatch(const CfObjectBase *obj, const char *className);
bool IsPubKeyClassMatch(const HcfObjectBase *obj, const char *className);
bool IsUrlValid(const char *url);
bool IsHttp(const char *url);
bool CfIsStrValid(const char *str, uint32_t maxLen);
bool CfIsBlobValid(const CfBlob *blob);
bool CfIsClassMatch(const CfObjectBase *obj, const char *className);
bool CfIsPubKeyClassMatch(const HcfObjectBase *obj, const char *className);
bool CfIsUrlValid(const char *url);
bool CfIsHttp(const char *url);
#ifdef __cplusplus
}

View File

@ -24,7 +24,7 @@
#define HTTP_URL_LEN 7
#define HTTPS_URL_LEN 8
bool IsStrValid(const char *str, uint32_t maxLen)
bool CfIsStrValid(const char *str, uint32_t maxLen)
{
if (str == NULL) {
LOGE("input string is NULL ptr");
@ -38,12 +38,12 @@ bool IsStrValid(const char *str, uint32_t maxLen)
return true;
}
bool IsBlobValid(const CfBlob *blob)
bool CfIsBlobValid(const CfBlob *blob)
{
return ((blob != NULL) && (blob->data != NULL) && (blob->size > 0));
}
bool IsClassMatch(const CfObjectBase *obj, const char *className)
bool CfIsClassMatch(const CfObjectBase *obj, const char *className)
{
if ((obj == NULL) || (obj->getClass() == NULL) || (className == NULL)) {
return false;
@ -56,7 +56,7 @@ bool IsClassMatch(const CfObjectBase *obj, const char *className)
}
}
bool IsPubKeyClassMatch(const HcfObjectBase *obj, const char *className)
bool CfIsPubKeyClassMatch(const HcfObjectBase *obj, const char *className)
{
if ((obj == NULL) || (obj->getClass() == NULL) || (className == NULL)) {
return false;
@ -69,7 +69,7 @@ bool IsPubKeyClassMatch(const HcfObjectBase *obj, const char *className)
}
}
bool IsUrlValid(const char *url)
bool CfIsUrlValid(const char *url)
{
if (url == NULL) {
return false;
@ -107,7 +107,7 @@ bool IsUrlValid(const char *url)
return false;
}
bool IsHttp(const char *url)
bool CfIsHttp(const char *url)
{
if (url != NULL && strncmp(url, "http://", strlen("http://")) == 0) {
return true;

View File

@ -73,7 +73,7 @@ static void DestroyCertChainValidator(CfObjectBase *self)
LOGE("Invalid input parameter.");
return;
}
if (!IsClassMatch(self, GetCertChainValidatorClass())) {
if (!CfIsClassMatch(self, GetCertChainValidatorClass())) {
LOGE("Class is not match.");
return;
}
@ -130,7 +130,7 @@ static CfResult Validate(HcfCertChainValidator *self, const HcfCertChainData *ce
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetCertChainValidatorClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetCertChainValidatorClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -161,7 +161,7 @@ static const char *GetAlgorithm(HcfCertChainValidator *self)
LOGE("Invalid input parameter.");
return NULL;
}
if (!IsClassMatch((CfObjectBase *)self, GetCertChainValidatorClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetCertChainValidatorClass())) {
LOGE("Class is not match.");
return NULL;
}
@ -173,7 +173,7 @@ static const char *GetAlgorithm(HcfCertChainValidator *self)
CfResult HcfCertChainValidatorCreate(const char *algorithm, HcfCertChainValidator **pathValidator)
{
CF_LOG_I("enter");
if (!IsStrValid(algorithm, HCF_MAX_STR_LEN) || (pathValidator == NULL)) {
if (!CfIsStrValid(algorithm, HCF_MAX_STR_LEN) || (pathValidator == NULL)) {
return CF_INVALID_PARAMS;
}
const HcfCertChainValidatorFuncSet *func = FindAbility(algorithm);
@ -204,6 +204,7 @@ CfResult HcfCertChainValidatorCreate(const char *algorithm, HcfCertChainValidato
if (returnValidator->algorithm == NULL) {
LOGE("Failed to allocate algorithm memory!");
CfFree(returnValidator);
CfObjDestroy(spiObj);
return CF_ERR_MALLOC;
}
(void)memcpy_s(returnValidator->algorithm, algoNameLen, algorithm, algoNameLen);

View File

@ -45,7 +45,7 @@ static void DestroyCertCrlCollection(CfObjectBase *self)
LOGE("Invalid input parameter.");
return;
}
if (!IsClassMatch(self, GetCertCrlCollectionClass())) {
if (!CfIsClassMatch(self, GetCertCrlCollectionClass())) {
LOGE("Class is not match.");
return;
}
@ -165,7 +165,7 @@ static CfResult SelectCerts(
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetCertCrlCollectionClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetCertCrlCollectionClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -189,7 +189,7 @@ static CfResult SelectCRLs(
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetCertCrlCollectionClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetCertCrlCollectionClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -212,7 +212,7 @@ static CfResult GetCRLs(HcfCertCrlCollection *self, HcfX509CrlArray **retCrls)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetCertCrlCollectionClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetCertCrlCollectionClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}

View File

@ -86,7 +86,7 @@ static void DestroyCertChain(CfObjectBase *self)
LOGE("Invalid input parameter.");
return;
}
if (!IsClassMatch(self, GetCertChainClass())) {
if (!CfIsClassMatch(self, GetCertChainClass())) {
LOGE("Class is not match.");
return;
}
@ -101,7 +101,7 @@ static CfResult GetCertList(HcfCertChain *self, HcfX509CertificateArray *out)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetCertChainClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetCertChainClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -115,7 +115,7 @@ static CfResult ToString(HcfCertChain *self, CfBlob *out)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetCertChainClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetCertChainClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -129,7 +129,7 @@ static CfResult HashCode(HcfCertChain *self, CfBlob *out)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetCertChainClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetCertChainClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -144,7 +144,7 @@ static CfResult Validate(
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetCertChainClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetCertChainClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}

View File

@ -66,7 +66,7 @@ static void DestroyX509Certificate(CfObjectBase *self)
LOGE("Invalid input parameter.");
return;
}
if (!IsClassMatch(self, GetX509CertificateClass())) {
if (!CfIsClassMatch(self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return;
}
@ -81,7 +81,7 @@ static CfResult Verify(HcfCertificate *self, void *key)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -95,7 +95,7 @@ static CfResult GetEncoded(HcfCertificate *self, CfEncodingBlob *encodedByte)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -109,7 +109,7 @@ static CfResult GetPublicKey(HcfCertificate *self, void **keyOut)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -123,7 +123,7 @@ static CfResult CheckValidityWithDate(HcfX509Certificate *self, const char *date
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -137,7 +137,7 @@ static long GetVersion(HcfX509Certificate *self)
LOGE("Invalid input parameter.");
return INVALID_VERSION;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return INVALID_VERSION;
}
@ -151,7 +151,7 @@ static CfResult GetSerialNumber(HcfX509Certificate *self, CfBlob *out)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -165,7 +165,7 @@ static CfResult GetIssuerName(HcfX509Certificate *self, CfBlob *out)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -179,7 +179,7 @@ static CfResult GetSubjectName(HcfX509Certificate *self, CfBlob *out)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -193,7 +193,7 @@ static CfResult GetSubjectNameEx(HcfX509Certificate *self, CfEncodinigType encod
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -207,7 +207,7 @@ static CfResult GetNotBeforeTime(HcfX509Certificate *self, CfBlob *outDate)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -221,7 +221,7 @@ static CfResult GetNotAfterTime(HcfX509Certificate *self, CfBlob *outDate)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -235,7 +235,7 @@ static CfResult GetSignature(HcfX509Certificate *self, CfBlob *sigOut)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -249,7 +249,7 @@ static CfResult GetSignatureAlgName(HcfX509Certificate *self, CfBlob *outName)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -263,7 +263,7 @@ static CfResult GetSignatureAlgOid(HcfX509Certificate *self, CfBlob *out)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -277,7 +277,7 @@ static CfResult GetSignatureAlgParams(HcfX509Certificate *self, CfBlob *sigAlgPa
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -291,7 +291,7 @@ static CfResult GetKeyUsage(HcfX509Certificate *self, CfBlob *boolArr)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -305,7 +305,7 @@ static CfResult GetExtKeyUsage(HcfX509Certificate *self, CfArray *keyUsageOut)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -319,7 +319,7 @@ static int32_t GetBasicConstraints(HcfX509Certificate *self)
LOGE("Invalid input parameter.");
return INVALID_CONSTRAINTS_LEN;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return INVALID_CONSTRAINTS_LEN;
}
@ -333,7 +333,7 @@ static CfResult GetSubjectAltNames(HcfX509Certificate *self, CfArray *outName)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -347,7 +347,7 @@ static CfResult GetIssuerAltNames(HcfX509Certificate *self, CfArray *outName)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -361,7 +361,7 @@ static CfResult GetCRLDistributionPointsURI(HcfX509Certificate *self, CfArray *o
LOGE("crl dp invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("crl dp class is not match.");
return CF_INVALID_PARAMS;
}
@ -375,7 +375,7 @@ static CfResult Match(HcfX509Certificate *self, const HcfX509CertMatchParams *ma
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -389,7 +389,7 @@ static CfResult ToString(HcfX509Certificate *self, CfBlob *out)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -403,7 +403,7 @@ static CfResult HashCode(HcfX509Certificate *self, CfBlob *out)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -417,7 +417,7 @@ static CfResult GetExtensionsObject(HcfX509Certificate *self, CfBlob *out)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CertificateClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}

View File

@ -76,7 +76,7 @@ static void DestroyX509Crl(CfObjectBase *self)
LOGE("Invalid input parameter.");
return;
}
if (!IsClassMatch(self, GetX509CrlClass())) {
if (!CfIsClassMatch(self, GetX509CrlClass())) {
LOGE("Class is not match.");
return;
}
@ -91,7 +91,7 @@ static const char *GetType(HcfCrl *self)
LOGE("Invalid input parameter.");
return NULL;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return NULL;
}
@ -105,7 +105,7 @@ static bool IsRevoked(HcfCrl *self, const HcfCertificate *cert)
LOGE("Invalid input parameter.");
return false;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return false;
}
@ -119,7 +119,7 @@ static CfResult Verify(HcfX509Crl *self, void *key)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -133,7 +133,7 @@ static CfResult GetEncoded(HcfX509Crl *self, CfEncodingBlob *encodedByte)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -147,7 +147,7 @@ static long GetVersion(HcfX509Crl *self)
LOGE("Invalid input parameter.");
return OPENSSL_INVALID_VERSION;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return OPENSSL_INVALID_VERSION;
}
@ -161,7 +161,7 @@ static CfResult GetIssuerName(HcfX509Crl *self, CfBlob *out)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -175,7 +175,7 @@ static CfResult GetLastUpdate(HcfX509Crl *self, CfBlob *out)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -189,7 +189,7 @@ static CfResult GetNextUpdate(HcfX509Crl *self, CfBlob *out)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -203,7 +203,7 @@ static CfResult GetRevokedCert(HcfX509Crl *self, const CfBlob *serialNumber, Hcf
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -217,7 +217,7 @@ static CfResult GetRevokedCertWithCert(HcfX509Crl *self, HcfX509Certificate *cer
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -231,7 +231,7 @@ static CfResult GetRevokedCerts(HcfX509Crl *self, CfArray *entrysOut)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -245,7 +245,7 @@ static CfResult GetTbsInfo(HcfX509Crl *self, CfBlob *tbsCertListOut)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -259,7 +259,7 @@ static CfResult GetSignature(HcfX509Crl *self, CfBlob *signature)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -273,7 +273,7 @@ static CfResult GetSignatureAlgName(HcfX509Crl *self, CfBlob *out)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -287,7 +287,7 @@ static CfResult GetSignatureAlgOid(HcfX509Crl *self, CfBlob *out)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -301,7 +301,7 @@ static CfResult GetSignatureAlgParams(HcfX509Crl *self, CfBlob *sigAlgParamOut)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -315,7 +315,7 @@ static CfResult GetExtensions(HcfX509Crl *self, CfBlob *outBlob)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -329,7 +329,7 @@ static CfResult ToString(HcfX509Crl *self, CfBlob *out)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -343,7 +343,7 @@ static CfResult HashCode(HcfX509Crl *self, CfBlob *out)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -357,7 +357,7 @@ static CfResult GetExtensionsOjbect(HcfX509Crl *self, CfBlob *out)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -371,7 +371,7 @@ static CfResult Match(HcfX509Crl *self, const HcfX509CrlMatchParams *matchParams
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509CrlClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}

View File

@ -72,7 +72,7 @@ static void DestroyX509DistinguishedName(CfObjectBase *self)
LOGE("Invalid input parameter.");
return;
}
if (!IsClassMatch(self, GetX509DistinguishedNameClass())) {
if (!CfIsClassMatch(self, GetX509DistinguishedNameClass())) {
LOGE("Class is not match.");
return;
}
@ -87,7 +87,7 @@ static CfResult GetEncoded(HcfX509DistinguishedName *self, CfEncodingBlob *out)
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509DistinguishedNameClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509DistinguishedNameClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}
@ -101,7 +101,7 @@ static CfResult GetName(HcfX509DistinguishedName *self, CfBlob *type, CfBlob *ou
LOGE("Invalid input parameter.");
return CF_INVALID_PARAMS;
}
if (!IsClassMatch((CfObjectBase *)self, GetX509DistinguishedNameClass())) {
if (!CfIsClassMatch((CfObjectBase *)self, GetX509DistinguishedNameClass())) {
LOGE("Class is not match.");
return CF_INVALID_PARAMS;
}

View File

@ -674,17 +674,22 @@ static napi_value CreateTrustAnchorsWithKeyStore(napi_env env, size_t argc, napi
return nullptr;
}
if (!CreateCallbackAndPromise(env, context, argc, ARGS_SIZE_TWO, nullptr)) {
LOGE("CreateCallbackAndPromise failed!");
napi_throw(env, CertGenerateBusinessError(env, CF_INVALID_PARAMS, "CreateCallbackAndPromise failed!"));
context->async->asyncType = GetAsyncType(env, argc, ARGS_SIZE_TWO, nullptr);
if (context->async->asyncType == ASYNC_TYPE_CALLBACK) {
LOGE("ASYNC_TYPE_CALLBACK is not supported.");
napi_throw(env, CertGenerateBusinessError(env, CF_INVALID_PARAMS, "ASYNC_TYPE_CALLBACK is not supported."));
return nullptr;
}
napi_create_promise(env, &context->async->deferred, &context->async->promise);
context->keyStore = CertGetBlobFromUint8ArrJSParams(env, param1);
if (context->keyStore == nullptr) {
DeleteCertChainContext(env, context);
return nullptr;
}
context->pwd = CertGetBlobFromStringJSParams(env, param2);
if (context->pwd == nullptr) {
DeleteCertChainContext(env, context);
return nullptr;
}

View File

@ -299,6 +299,31 @@ static bool GetRevocationDetail(napi_env env, napi_value rckObj, HcfRevocationCh
return GetRevocationOptions(env, rckObj, out);
}
static void FreeHcfRevocationCheckParam(HcfRevocationCheckParam *param)
{
if (param == nullptr) {
return;
}
if (param->ocspRequestExtension != nullptr) {
FreeCfBlobArray(param->ocspRequestExtension->data, param->ocspRequestExtension->count);
CfFree(param->ocspRequestExtension);
}
CfBlobFree(&param->ocspResponderURI);
if (param->ocspResponderCert != nullptr) {
CfObjDestroy(param->ocspResponderCert);
}
CfBlobFree(&param->ocspResponses);
CfBlobFree(&param->crlDownloadURI);
if (param->options != nullptr) {
if (param->options->data != nullptr) {
CfFree(param->options->data);
}
CfFree(param->options);
}
CfBlobFree(&param->ocspDigest);
CfFree(param);
}
static bool GetRevocationCheckParam(napi_env env, napi_value arg, HcfRevocationCheckParam *&out)
{
napi_value rckObj = GetProp(env, arg, CERT_CHAIN_VALIDATE_TAG_REVOCATIONCHECKPARAM.c_str());
@ -320,7 +345,7 @@ static bool GetRevocationCheckParam(napi_env env, napi_value arg, HcfRevocationC
}
if (!GetRevocationDetail(env, rckObj, out)) {
LOGE("Failed to get revocation detail!");
CfFree(out);
FreeHcfRevocationCheckParam(out);
return false;
}

View File

@ -369,7 +369,7 @@ HWTEST_F(CfCommonTest, CfMemTest004, TestSize.Level0)
*/
HWTEST_F(CfCommonTest, IsStrValid001, TestSize.Level0)
{
bool checkRes = IsStrValid(nullptr, 0);
bool checkRes = CfIsStrValid(nullptr, 0);
EXPECT_EQ(checkRes, false);
}
@ -382,7 +382,7 @@ HWTEST_F(CfCommonTest, IsStrValid001, TestSize.Level0)
HWTEST_F(CfCommonTest, IsStrValid002, TestSize.Level0)
{
char str[] = "this is test for beyond max length.";
bool checkRes = IsStrValid(str, TEST_DEFAULT_SIZE);
bool checkRes = CfIsStrValid(str, TEST_DEFAULT_SIZE);
EXPECT_EQ(checkRes, false);
}
@ -395,7 +395,7 @@ HWTEST_F(CfCommonTest, IsStrValid002, TestSize.Level0)
HWTEST_F(CfCommonTest, IsStrValid003, TestSize.Level0)
{
char str[] = "123456789";
bool checkRes = IsStrValid(str, TEST_DEFAULT_SIZE);
bool checkRes = CfIsStrValid(str, TEST_DEFAULT_SIZE);
EXPECT_EQ(checkRes, true);
}
@ -409,7 +409,7 @@ HWTEST_F(CfCommonTest, IsBlobValid001, TestSize.Level0)
{
uint8_t blobData[] = "normal case";
CfBlob blob = { sizeof(blobData), blobData };
bool checkRes = IsBlobValid(&blob);
bool checkRes = CfIsBlobValid(&blob);
EXPECT_EQ(checkRes, true);
}
@ -421,7 +421,7 @@ HWTEST_F(CfCommonTest, IsBlobValid001, TestSize.Level0)
*/
HWTEST_F(CfCommonTest, IsBlobValid002, TestSize.Level0)
{
bool checkRes = IsBlobValid(nullptr);
bool checkRes = CfIsBlobValid(nullptr);
EXPECT_EQ(checkRes, false);
}
@ -434,7 +434,7 @@ HWTEST_F(CfCommonTest, IsBlobValid002, TestSize.Level0)
HWTEST_F(CfCommonTest, IsBlobValid003, TestSize.Level0)
{
CfBlob blob = { TEST_DEFAULT_SIZE, nullptr };
bool checkRes = IsBlobValid(&blob);
bool checkRes = CfIsBlobValid(&blob);
EXPECT_EQ(checkRes, false);
}
@ -448,7 +448,7 @@ HWTEST_F(CfCommonTest, IsBlobValid004, TestSize.Level0)
{
uint8_t blobData[] = "invalid blob size is 0";
CfBlob blob = { 0, blobData };
bool checkRes = IsBlobValid(&blob);
bool checkRes = CfIsBlobValid(&blob);
EXPECT_EQ(checkRes, false);
}
@ -470,7 +470,7 @@ static const char *GetClassNull(void)
*/
HWTEST_F(CfCommonTest, IsClassMatch001, TestSize.Level0)
{
bool checkRes = IsClassMatch(nullptr, "TEST_FOR_GET_CLASS");
bool checkRes = CfIsClassMatch(nullptr, "TEST_FOR_GET_CLASS");
EXPECT_EQ(checkRes, false);
}
@ -483,7 +483,7 @@ HWTEST_F(CfCommonTest, IsClassMatch001, TestSize.Level0)
HWTEST_F(CfCommonTest, IsClassMatch002, TestSize.Level0)
{
CfObjectBase obj = { GetClassNull, nullptr };
bool checkRes = IsClassMatch(&obj, "TEST_FOR_GET_CLASS");
bool checkRes = CfIsClassMatch(&obj, "TEST_FOR_GET_CLASS");
EXPECT_EQ(checkRes, false);
}
@ -496,7 +496,7 @@ HWTEST_F(CfCommonTest, IsClassMatch002, TestSize.Level0)
HWTEST_F(CfCommonTest, IsClassMatch003, TestSize.Level0)
{
CfObjectBase obj = { GetClass, nullptr };
bool checkRes = IsClassMatch(&obj, nullptr);
bool checkRes = CfIsClassMatch(&obj, nullptr);
EXPECT_EQ(checkRes, false);
}
@ -509,7 +509,7 @@ HWTEST_F(CfCommonTest, IsClassMatch003, TestSize.Level0)
HWTEST_F(CfCommonTest, IsClassMatch004, TestSize.Level0)
{
CfObjectBase obj = { GetClass, nullptr };
bool checkRes = IsClassMatch(&obj, "TEST_FOR_GET_CLASS");
bool checkRes = CfIsClassMatch(&obj, "TEST_FOR_GET_CLASS");
EXPECT_EQ(checkRes, true);
}
@ -522,7 +522,7 @@ HWTEST_F(CfCommonTest, IsClassMatch004, TestSize.Level0)
HWTEST_F(CfCommonTest, IsClassMatch005, TestSize.Level0)
{
CfObjectBase obj = { GetClass, nullptr };
bool checkRes = IsClassMatch(&obj, "TEST_FOR_GET_CLASS123");
bool checkRes = CfIsClassMatch(&obj, "TEST_FOR_GET_CLASS123");
EXPECT_EQ(checkRes, false);
}
@ -535,7 +535,7 @@ HWTEST_F(CfCommonTest, IsClassMatch005, TestSize.Level0)
HWTEST_F(CfCommonTest, IsPubKeyClassMatch001, TestSize.Level0)
{
HcfObjectBase obj = { GetClass, nullptr };
bool checkRes = IsPubKeyClassMatch(&obj, "TEST_FOR_GET_CLASS");
bool checkRes = CfIsPubKeyClassMatch(&obj, "TEST_FOR_GET_CLASS");
EXPECT_EQ(checkRes, true);
}
@ -548,7 +548,7 @@ HWTEST_F(CfCommonTest, IsPubKeyClassMatch001, TestSize.Level0)
HWTEST_F(CfCommonTest, IsPubKeyClassMatch002, TestSize.Level0)
{
HcfObjectBase obj = { GetClass, nullptr };
bool checkRes = IsPubKeyClassMatch(&obj, "TEST_FOR_GET_CLASS000");
bool checkRes = CfIsPubKeyClassMatch(&obj, "TEST_FOR_GET_CLASS000");
EXPECT_EQ(checkRes, false);
}
@ -560,7 +560,7 @@ HWTEST_F(CfCommonTest, IsPubKeyClassMatch002, TestSize.Level0)
*/
HWTEST_F(CfCommonTest, IsPubKeyClassMatch003, TestSize.Level0)
{
bool checkRes = IsPubKeyClassMatch(nullptr, "TEST_FOR_GET_CLASS");
bool checkRes = CfIsPubKeyClassMatch(nullptr, "TEST_FOR_GET_CLASS");
EXPECT_EQ(checkRes, false);
}
@ -573,7 +573,7 @@ HWTEST_F(CfCommonTest, IsPubKeyClassMatch003, TestSize.Level0)
HWTEST_F(CfCommonTest, IsPubKeyClassMatch004, TestSize.Level0)
{
HcfObjectBase obj = { GetClassNull, nullptr };
bool checkRes = IsPubKeyClassMatch(&obj, "TEST_FOR_GET_CLASS");
bool checkRes = CfIsPubKeyClassMatch(&obj, "TEST_FOR_GET_CLASS");
EXPECT_EQ(checkRes, false);
}
@ -586,7 +586,7 @@ HWTEST_F(CfCommonTest, IsPubKeyClassMatch004, TestSize.Level0)
HWTEST_F(CfCommonTest, IsPubKeyClassMatch005, TestSize.Level0)
{
HcfObjectBase obj = { GetClass, nullptr };
bool checkRes = IsPubKeyClassMatch(&obj, nullptr);
bool checkRes = CfIsPubKeyClassMatch(&obj, nullptr);
EXPECT_EQ(checkRes, false);
}
} // end of namespace