• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is part of the openHiTLS project.
3  *
4  * openHiTLS is licensed under the Mulan PSL v2.
5  * You can use this software according to the terms and conditions of the Mulan PSL v2.
6  * You may obtain a copy of Mulan PSL v2 at:
7  *
8  *     http://license.coscl.org.cn/MulanPSL2
9  *
10  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13  * See the Mulan PSL v2 for more details.
14  */
15 #include "hitls_build.h"
16 #include <stdint.h>
17 #include <stddef.h>
18 #include "hitls_error.h"
19 #include "hitls_cert_reg.h"
20 #include "hitls_x509_adapt.h"
21 
HITLS_CertMethodInit(void)22 int32_t HITLS_CertMethodInit(void)
23 {
24 #ifdef HITLS_TLS_CALLBACK_CERT
25     HITLS_CERT_MgrMethod mgr = {
26         .certStoreNew = HITLS_X509_Adapt_StoreNew,
27         .certStoreDup = HITLS_X509_Adapt_StoreDup,
28         .certStoreFree = HITLS_X509_Adapt_StoreFree,
29         .certStoreCtrl = HITLS_X509_Adapt_StoreCtrl,
30         .buildCertChain = HITLS_X509_Adapt_BuildCertChain,
31         .verifyCertChain = HITLS_X509_Adapt_VerifyCertChain,
32 
33         .certEncode = HITLS_X509_Adapt_CertEncode,
34         .certParse = HITLS_X509_Adapt_CertParse,
35         .certDup = HITLS_X509_Adapt_CertDup,
36         .certRef = HITLS_X509_Adapt_CertRef,
37         .certFree = HITLS_X509_Adapt_CertFree,
38         .certCtrl = HITLS_X509_Adapt_CertCtrl,
39 
40         .keyParse = HITLS_X509_Adapt_KeyParse,
41         .keyDup = HITLS_X509_Adapt_KeyDup,
42         .keyFree = HITLS_X509_Adapt_KeyFree,
43         .keyCtrl = HITLS_X509_Adapt_KeyCtrl,
44 
45         .createSign = HITLS_X509_Adapt_CreateSign,
46         .verifySign = HITLS_X509_Adapt_VerifySign,
47 #if defined(HITLS_TLS_SUITE_KX_RSA) || defined(HITLS_TLS_PROTO_TLCP11)
48         .encrypt = HITLS_X509_Adapt_Encrypt,
49         .decrypt = HITLS_X509_Adapt_Decrypt,
50 #endif
51 
52         .checkPrivateKey = HITLS_X509_Adapt_CheckPrivateKey,
53     };
54 
55     return HITLS_CERT_RegisterMgrMethod(&mgr);
56 #else
57     return HITLS_SUCCESS;
58 #endif
59 }
60 
HITLS_CertMethodDeinit(void)61 void HITLS_CertMethodDeinit(void)
62 {
63 #ifdef HITLS_TLS_CALLBACK_CERT
64     HITLS_CERT_DeinitMgrMethod();
65 #endif
66 }
67