1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
17
#define CRLGEN_UNKNOWN_CONTEXT 0
18
#define CRLGEN_ISSUER_CONTEXT 1
19
#define CRLGEN_UPDATE_CONTEXT 2
20
#define CRLGEN_NEXT_UPDATE_CONTEXT 3
21
#define CRLGEN_ADD_EXTENSION_CONTEXT 4
22
#define CRLGEN_ADD_CERT_CONTEXT 6
23
#define CRLGEN_CHANGE_RANGE_CONTEXT 7
24
#define CRLGEN_RM_CERT_CONTEXT 8
26
#define CRLGEN_TYPE_DATE 0
27
#define CRLGEN_TYPE_ZDATE 1
28
#define CRLGEN_TYPE_DIGIT 2
29
#define CRLGEN_TYPE_DIGIT_RANGE 3
30
#define CRLGEN_TYPE_OID 4
31
#define CRLGEN_TYPE_STRING 5
32
#define CRLGEN_TYPE_ID 6
35
typedef struct CRLGENGeneratorDataStr CRLGENGeneratorData;
36
typedef struct CRLGENEntryDataStr CRLGENEntryData;
37
typedef struct CRLGENExtensionEntryStr CRLGENExtensionEntry;
38
typedef struct CRLGENCertEntrySrt CRLGENCertEntry;
39
typedef struct CRLGENCrlFieldStr CRLGENCrlField;
40
typedef struct CRLGENEntriesSortedDataStr CRLGENEntriesSortedData;
42
/* Exported functions */
44
/* Used for initialization of extension handles for crl and certs
45
* extensions from existing CRL data then modifying existing CRL.*/
46
extern SECStatus CRLGEN_ExtHandleInit(CRLGENGeneratorData *crlGenData);
48
/* Commits all added entries and their's extensions into CRL. */
49
extern SECStatus CRLGEN_CommitExtensionsAndEntries(CRLGENGeneratorData *crlGenData);
51
/* Lunches the crl generation script parse */
52
extern SECStatus CRLGEN_StartCrlGen(CRLGENGeneratorData *crlGenData);
54
/* Closes crl generation script file and frees crlGenData */
55
extern void CRLGEN_FinalizeCrlGeneration(CRLGENGeneratorData *crlGenData);
57
/* Parser initialization function. Creates CRLGENGeneratorData structure
58
* for the current thread */
59
extern CRLGENGeneratorData* CRLGEN_InitCrlGeneration(CERTSignedCrl *newCrl,
63
/* This lock is defined in crlgen_lex.c(derived from crlgen_lex.l).
64
* It controls access to invocation of yylex, allows to parse one
66
extern void CRLGEN_InitCrlGenParserLock();
67
extern void CRLGEN_DestroyCrlGenParserLock();
70
/* The following function types are used to define functions for each of
71
* CRLGENExtensionEntryStr, CRLGENCertEntrySrt, CRLGENCrlFieldStr to
72
* provide functionality needed for these structures*/
73
typedef SECStatus updateCrlFn_t(CRLGENGeneratorData *crlGenData, void *str);
74
typedef SECStatus setNextDataFn_t(CRLGENGeneratorData *crlGenData, void *str,
75
void *data, unsigned short dtype);
76
typedef SECStatus createNewLangStructFn_t(CRLGENGeneratorData *crlGenData,
77
void *str, unsigned i);
79
/* Sets reports failure to parser if anything goes wrong */
80
extern void crlgen_setFailure(CRLGENGeneratorData *str, char *);
82
/* Collects data in to one of the current data structure that corresponds
83
* to the correct context type. This function gets called after each token
84
* is found for a particular line */
85
extern SECStatus crlgen_setNextData(CRLGENGeneratorData *str, void *data,
86
unsigned short dtype);
88
/* initiates crl update with collected data. This function is called at the
90
extern SECStatus crlgen_updateCrl(CRLGENGeneratorData *str);
92
/* Creates new context structure depending on token that was parsed
93
* at the beginning of a line */
94
extern SECStatus crlgen_createNewLangStruct(CRLGENGeneratorData *str,
98
/* CRLGENExtensionEntry is used to store addext request data for either
99
* CRL extensions or CRL entry extensions. The differentiation between
100
* is based on order and type of extension been added.
101
* - extData : all data in request staring from name of the extension are
103
* - nextUpdatedData: counter of elements added to extData
105
struct CRLGENExtensionEntryStr {
108
updateCrlFn_t *updateCrlFn;
109
setNextDataFn_t *setNextDataFn;
112
/* CRLGENCeryestEntry is used to store addcert request data
113
* - certId : certificate id or range of certificate with dash as a delimiter
114
* All certs from range will be inclusively added to crl
115
* - revocationTime: revocation time of cert(s)
117
struct CRLGENCertEntrySrt {
119
char *revocationTime;
120
updateCrlFn_t *updateCrlFn;
121
setNextDataFn_t *setNextDataFn;
125
/* CRLGENCrlField is used to store crl fields record like update time, next
127
* - value: value of the parsed field data*/
128
struct CRLGENCrlFieldStr {
130
updateCrlFn_t *updateCrlFn;
131
setNextDataFn_t *setNextDataFn;
134
/* Can not create entries extension until completely done with parsing.
135
* Therefore need to keep joined data
136
* - certId : serial number of certificate
137
* - extHandle: head pointer to a list of extensions that belong to
139
* - entry : CERTCrlEntry structure pointer*/
140
struct CRLGENEntryDataStr {
146
/* Crl generator/parser main structure. Keeps info regarding current state of
147
* parser(context, status), parser helper functions pointers, parsed data and
149
* - contextId : current parsing context. Context in this parser environment
150
* defines what type of crl operations parser is going through
151
* in the current line of crl generation script.
152
* setting or new cert or an extension addition, etc.
153
* - createNewLangStructFn: pointer to top level function which creates
154
* data structures according contextId
155
* - setNextDataFn : pointer to top level function which sets new parsed data
156
* in temporary structure
157
* - updateCrlFn : pointer to top level function which triggers actual
158
* crl update functions with gathered data
159
* - union : data union create according to contextId
160
* - rangeFrom, rangeTo : holds last range in which certs was added
161
* - newCrl : pointer to CERTSignedCrl newly created crl
162
* - crlExtHandle : pointer to crl extension handle
163
* - entryDataHashTable: hash of CRLGENEntryData.
164
* key: cert serial number
165
* data: CRLGENEntryData pointer
166
* - parserStatus : current status of parser. Triggers parser to abort when
168
* - src : PRFileDesc structure pointer of crl generator config file
169
* - parsedLineNum : currently parsing line. Keeping it to report errors */
170
struct CRLGENGeneratorDataStr {
171
unsigned short contextId;
172
CRLGENCrlField *crlField;
173
CRLGENCertEntry *certEntry;
174
CRLGENExtensionEntry *extensionEntry;
177
CERTSignedCrl *signCrl;
179
PLHashTable *entryDataHashTable;
186
#endif /* _CRLGEN_H_ */