API参考
载入中...
搜索中...
未找到
hitls_cert_local.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_CERT_LOCAL_H
17#define HITLS_CERT_LOCAL_H
18
19#include "hitls_build.h"
20#ifdef HITLS_PKI_X509_CRT
21#include <stdint.h>
22#include <stdbool.h>
23#include "bsl_asn1_internal.h"
24#include "bsl_obj.h"
25#include "sal_atomic.h"
26#include "hitls_x509_local.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32typedef struct {
33 uint8_t *tbsRawData;
34 uint32_t tbsRawDataLen;
35
36 int32_t version;
37 BSL_ASN1_Buffer serialNum;
38 HITLS_X509_Asn1AlgId signAlgId;
39
40 BSL_ASN1_List *issuerName;
41 HITLS_X509_ValidTime validTime;
42 BSL_ASN1_List *subjectName;
43
44 void *ealPubKey;
45 HITLS_X509_Ext ext;
46} HITLS_X509_CertTbs;
47
48typedef enum {
49 HITLS_X509_CERT_STATE_NEW = 0,
50 HITLS_X509_CERT_STATE_SET,
51 HITLS_X509_CERT_STATE_SIGN,
52 HITLS_X509_CERT_STATE_GEN,
53} HITLS_X509_CERT_STATE;
54
55typedef struct _HITLS_X509_Cert {
56 uint8_t flag; // Used to mark certificate parsing or generation, indicating resource release behavior.
57 uint8_t state;
58 bool isProvider;
59
60 uint8_t *rawData;
61 uint32_t rawDataLen;
62 HITLS_X509_CertTbs tbs;
63 HITLS_X509_Asn1AlgId signAlgId;
64 BSL_ASN1_BitString signature;
65
66 BSL_SAL_RefCount references;
67
68 CRYPT_EAL_LibCtx *libCtx; // Provider context
69 const char *attrName; // Provider attribute name
70} HITLS_X509_Cert;
71
72#ifdef HITLS_PKI_X509_VFY
73bool HITLS_X509_CheckIssued(HITLS_X509_Cert *issue, HITLS_X509_Cert *subject);
74bool HITLS_X509_CertIsCA(HITLS_X509_Cert *cert);
75#endif
76
77#ifdef __cplusplus
78}
79#endif
80
81#endif // HITLS_PKI_X509_CRT
82
83#endif // HITLS_CERT_LOCAL_H