API参考
载入中...
搜索中...
未找到
hitls_x509_verify.h
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
16#ifndef HITLS_X509_VERIFY_H
17#define HITLS_X509_VERIFY_H
18
19#include "hitls_build.h"
20#ifdef HITLS_PKI_X509_VFY
21#include <stdint.h>
22#include "bsl_asn1_internal.h"
23#include "bsl_list.h"
24#include "hitls_pki_x509.h"
25#include "sal_atomic.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31typedef enum {
32 HITLS_X509_VFY_FLAG_SECBITS = 0x100000000,
33 HITLS_X509_VFY_FLAG_TIME = 0x200000000,
34} HITLS_X509_IN_VerifyFlag;
35
36typedef struct _HITLS_X509_VerifyParam {
37 int32_t maxDepth;
38 uint32_t securityBits;
39 int64_t time;
40 uint64_t flags;
41 int32_t purpose;
42#ifdef HITLS_CRYPTO_SM2
43 BSL_Buffer sm2UserId;
44#endif
45} HITLS_X509_VerifyParam;
46
47struct _HITLS_X509_StoreCtx {
48 HITLS_X509_List *store;
49 HITLS_X509_List *crl;
50 BSL_SAL_RefCount references;
51 HITLS_X509_VerifyParam verifyParam;
52 CRYPT_EAL_LibCtx *libCtx; // Provider context
53 const char *attrName; // Provider attribute name
54 HITLS_X509_List *certChain; // Certificate chain built during verification
55#ifdef HITLS_PKI_X509_VFY_LOCATION
56 BslList *caPaths; // List of CA directory paths for on-demand loading (char*)
57#endif
58#ifdef HITLS_PKI_X509_VFY_CB
59 int32_t error; // Error code
60 int32_t curDepth; // Current verification depth
61 HITLS_X509_Cert *curCert; // Current certificate being verified
62 X509_STORECTX_VerifyCb verifyCb; // Verification callback function
63 void *usrData; // user data
64#endif
65};
66
67
68int32_t HITLS_X509_VerifyParamAndExt(HITLS_X509_StoreCtx *storeCtx, HITLS_X509_List *chain);
69
70/*
71 * Verify the CRL, which is the default full certificate chain validation.
72 * You can configure not to verify or only verify the terminal certificate
73 */
74int32_t HITLS_X509_VerifyCrl(HITLS_X509_StoreCtx *storeCtx, HITLS_X509_List *chain);
75
76int32_t HITLS_X509_CertCmp(HITLS_X509_Cert *certOri, HITLS_X509_Cert *cert);
77
78int32_t HITLS_X509_CrlCmp(HITLS_X509_Crl *crlOri, HITLS_X509_Crl *crl);
79
80int32_t HITLS_X509_GetIssuerFromStore(HITLS_X509_StoreCtx *storeCtx, HITLS_X509_Cert *cert, HITLS_X509_Cert **issuer);
81
82#ifdef __cplusplus
83}
84#endif
85
86#endif // HITLS_PKI_X509_VFY
87
88#endif // HITLS_X509_VERIFY_H
int32_t(* X509_STORECTX_VerifyCb)(int32_t, HITLS_X509_StoreCtx *)
Certificate chain build function.
定义 hitls_pki_x509.h:39