1 /*
2  * Copyright (c) 2024 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 X509_CERT_CHAIN_OEPNSSL_EX_H
17 #define X509_CERT_CHAIN_OEPNSSL_EX_H
18 
19 #include "cf_result.h"
20 #include "x509_cert_chain.h"
21 #include "x509_cert_chain_spi.h"
22 #include "x509_certificate.h"
23 #include "fwk_class.h"
24 
25 #include <openssl/x509.h>
26 
27 typedef struct {
28     HcfX509CertChainSpi base;
29     STACK_OF(X509) *x509CertChain;
30     bool isOrder; // is an order chain
31 } HcfX509CertChainOpensslImpl;
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 const char *GetX509CertChainClass(void);
38 CfResult CfToString(HcfX509CertChainSpi *self, CfBlob *out);
39 CfResult CfHashCode(HcfX509CertChainSpi *self, CfBlob *out);
40 X509 *GetX509FromHcfX509Certificate(const HcfCertificate *cert);
41 CfResult GetLeafCertsFromCertStack(
42     const HcfX509CertChainBuildParameters *inParams, STACK_OF(X509) *allCerts, STACK_OF(X509) *leafCerts);
43 
44 #ifdef __cplusplus
45 }
46 #endif
47 
48 #endif // X509_CERT_CHAIN_OEPNSSL_EX_H
49