• 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 
16 #ifndef HITLS_CSR_LOCAL_H
17 #define HITLS_CSR_LOCAL_H
18 
19 #include "hitls_build.h"
20 #ifdef HITLS_PKI_X509_CSR
21 #include <stdint.h>
22 #include "bsl_asn1.h"
23 #include "bsl_obj.h"
24 #include "sal_atomic.h"
25 #include "hitls_x509_local.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 typedef struct _HITLS_X509_ReqInfo {
32     uint8_t *reqInfoRawData;
33     uint32_t reqInfoRawDataLen;
34     int32_t version;
35     BSL_ASN1_List *subjectName; /* Entry is HITLS_X509_NameNode */
36     void *ealPubKey;
37     HITLS_X509_Attrs *attributes;
38 } HITLS_X509_ReqInfo;
39 
40 typedef enum {
41     HITLS_X509_CSR_STATE_NEW = 0,
42     HITLS_X509_CSR_STATE_SET,
43     HITLS_X509_CSR_STATE_SIGN,
44     HITLS_X509_CSR_STATE_GEN,
45 } HITLS_X509_CSR_STATE;
46 
47 /* PKCS #10 */
48 typedef struct _HITLS_X509_Csr {
49     uint8_t flag; // Used to mark csr parsing or generation, indicating resource release behavior.
50     uint8_t state;
51 
52     uint8_t *rawData;
53     uint32_t rawDataLen;
54 
55     HITLS_X509_ReqInfo reqInfo;
56     HITLS_X509_Asn1AlgId signAlgId;
57     BSL_ASN1_BitString signature;
58 
59     BSL_SAL_RefCount references;
60     CRYPT_EAL_LibCtx *libCtx;         // Provider context
61     const char *attrName;             // Provider attribute name
62 } HITLS_X509_Csr;
63 
64 #ifdef __cplusplus
65 }
66 #endif
67 
68 #endif // HITLS_PKI_X509_CSR
69 
70 #endif // HITLS_CSR_LOCAL_H