1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef CF_X509CRL_H 17 #define CF_X509CRL_H 18 19 #include "cf_blob.h" 20 #include "crl.h" 21 #include "x509_certificate.h" 22 #include "x509_crl_entry.h" 23 #include "x509_crl_match_parameters.h" 24 #include "x509_distinguished_name.h" 25 26 typedef struct HcfX509Crl HcfX509Crl; 27 28 struct HcfX509Crl { 29 /** HcfX509Crl inherit HcfCrl. */ 30 HcfCrl base; 31 32 /** Get the der coding format. */ 33 CfResult (*getEncoded)(HcfX509Crl *self, CfEncodingBlob *encodedOut); 34 35 /** Use the public key to verify the signature of CRL. */ 36 CfResult (*verify)(HcfX509Crl *self, void *key); 37 38 /** Get version number from CRL. */ 39 long (*getVersion)(HcfX509Crl *self); 40 41 /** Get the issuer name from CRL. Issuer means the entity that signs and publishes the CRL. */ 42 CfResult (*getIssuerName)(HcfX509Crl *self, CfBlob *out); 43 44 /** Get lastUpdate value from CRL. */ 45 CfResult (*getLastUpdate)(HcfX509Crl *self, CfBlob *out); 46 47 /** Get nextUpdate value from CRL. */ 48 CfResult (*getNextUpdate)(HcfX509Crl *self, CfBlob *out); 49 50 /** This method can be used to find CRL entries in indirect CRLs. */ 51 CfResult (*getRevokedCert)(HcfX509Crl *self, const CfBlob *serialNumber, HcfX509CrlEntry **entryOut); 52 53 /** This method can be used to find CRL entries in indirect cert. */ 54 CfResult (*getRevokedCertWithCert)(HcfX509Crl *self, HcfX509Certificate *cert, 55 HcfX509CrlEntry **entryOut); 56 57 /** Get all entries in this CRL. */ 58 CfResult (*getRevokedCerts)(HcfX509Crl *self, CfArray *entrysOut); 59 60 /** Get the CRL information encoded by Der from this CRL. */ 61 CfResult (*getTbsInfo)(HcfX509Crl *self, CfBlob *tbsCertListOut); 62 63 /** Get signature value from CRL. */ 64 CfResult (*getSignature)(HcfX509Crl *self, CfBlob *signature); 65 66 /** Get the signature algorithm name of the CRL signature algorithm. */ 67 CfResult (*getSignatureAlgName)(HcfX509Crl *self, CfBlob *out); 68 69 /** Get the signature algorithm oid string from CRL. */ 70 CfResult (*getSignatureAlgOid)(HcfX509Crl *self, CfBlob *out); 71 72 /** Get the der encoded signature algorithm parameters from the CRL signature algorithm. */ 73 CfResult (*getSignatureAlgParams)(HcfX509Crl *self, CfBlob *sigAlgParamOut); 74 75 /** Get all the extensions in CRL. */ 76 CfResult (*getExtensions)(HcfX509Crl *self, CfBlob *out); 77 78 /** Match the crl with X509CrlMatchParameters. */ 79 CfResult (*match)(HcfX509Crl *self, const HcfX509CrlMatchParams *matchParams, bool *out); 80 81 /** Get the string of crl. */ 82 CfResult (*toString)(HcfX509Crl *self, CfBlob *out); 83 84 /** Get the hashCode of crl. */ 85 CfResult (*hashCode)(HcfX509Crl *self, CfBlob *out); 86 87 /** Get the Entension Object of crl. */ 88 CfResult (*getExtensionsObject)(HcfX509Crl *self, CfBlob *out); 89 }; 90 91 typedef struct HcfX509CrlArray HcfX509CrlArray; 92 struct HcfX509CrlArray { 93 HcfX509Crl **data; 94 uint32_t count; 95 }; 96 97 #ifdef __cplusplus 98 extern "C" { 99 #endif 100 101 CfResult HcfX509CrlCreate(const CfEncodingBlob *inStream, HcfX509Crl **returnObj); 102 103 #ifdef __cplusplus 104 } 105 #endif 106 107 #endif // CF_X509CRL_H