• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 CfResult X509ToHcfX509Certificate(X509 *cert, HcfX509Certificate **returnObj);
44 void FreeResources(X509 *cert, EVP_PKEY *pkey, STACK_OF(X509) *caStack);
45 void FreeHcfX509P12Collection(HcfX509P12Collection *p12Collection);
46 CfResult AllocateAndConvertCert(X509 *cert, HcfX509P12Collection *collection, bool isGet);
47 CfResult AllocateAndConvertPkey(EVP_PKEY *pkey, HcfX509P12Collection *collection, bool isGet);
48 CfResult AllocateAndConvertCertStack(STACK_OF(X509) *ca, HcfX509P12Collection *collection, bool isGet);
49 void FreeCertificateArray(HcfX509CertificateArray *certs);
50 #ifdef __cplusplus
51 }
52 #endif
53 
54 #endif // X509_CERT_CHAIN_OEPNSSL_EX_H
55