~ubuntu-branches/ubuntu/quantal/nss/quantal-updates

« back to all changes in this revision

Viewing changes to mozilla/security/nss/cmd/crlutil/crlgen.h

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2013-11-14 14:58:07 UTC
  • mfrom: (1.1.19)
  • Revision ID: package-import@ubuntu.com-20131114145807-vj6v4erz8xj6kwz3
Tags: 3.15.3-0ubuntu0.12.10.1
* SECURITY UPDATE: New upstream release to fix multiple security issues
  and add TLSv1.2 support.
  - CVE-2013-1739
  - CVE-2013-1741
  - CVE-2013-5605
  - CVE-2013-5606
* Adjusted packaging for 3.15.3:
  - debian/patches/*: refreshed.
  - debian/patches/lower-dhe-priority.patch: removed, no longer needed,
    was a workaround for an old version of firefox.
  - debian/libnss3.symbols: added new symbols.
  - debian/rules: updated for new source layout.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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/. */
4
 
 
5
 
 
6
 
#ifndef _CRLGEN_H_
7
 
#define _CRLGEN_H_
8
 
 
9
 
#include "prio.h"
10
 
#include "prprf.h"
11
 
#include "plhash.h"
12
 
#include "seccomon.h"
13
 
#include "certt.h"
14
 
#include "secoidt.h"
15
 
 
16
 
 
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
25
 
 
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
33
 
 
34
 
 
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;
41
 
 
42
 
/* Exported functions */
43
 
 
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);
47
 
 
48
 
/* Commits all added entries and their's extensions into CRL. */
49
 
extern SECStatus CRLGEN_CommitExtensionsAndEntries(CRLGENGeneratorData *crlGenData);
50
 
 
51
 
/* Lunches the crl generation script parse */
52
 
extern SECStatus CRLGEN_StartCrlGen(CRLGENGeneratorData *crlGenData);
53
 
 
54
 
/* Closes crl generation script file and frees crlGenData */
55
 
extern void CRLGEN_FinalizeCrlGeneration(CRLGENGeneratorData *crlGenData);
56
 
 
57
 
/* Parser initialization function. Creates CRLGENGeneratorData structure
58
 
 *  for the current thread */
59
 
extern CRLGENGeneratorData* CRLGEN_InitCrlGeneration(CERTSignedCrl *newCrl,
60
 
                                                     PRFileDesc *src);
61
 
 
62
 
 
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
65
 
 * script at a time */
66
 
extern void CRLGEN_InitCrlGenParserLock();
67
 
extern void CRLGEN_DestroyCrlGenParserLock();
68
 
 
69
 
 
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);
78
 
 
79
 
/* Sets reports failure to parser if anything goes wrong */
80
 
extern void      crlgen_setFailure(CRLGENGeneratorData *str, char *);
81
 
 
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);
87
 
 
88
 
/* initiates crl update with collected data. This function is called at the
89
 
 * end of each line */
90
 
extern SECStatus crlgen_updateCrl(CRLGENGeneratorData *str);
91
 
 
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,
95
 
                                            unsigned structType);
96
 
 
97
 
 
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
102
 
 *                in saved here.
103
 
 *    - nextUpdatedData: counter of elements added to extData
104
 
 */
105
 
struct CRLGENExtensionEntryStr {
106
 
    char **extData;
107
 
    int    nextUpdatedData;
108
 
    updateCrlFn_t    *updateCrlFn;
109
 
    setNextDataFn_t  *setNextDataFn;
110
 
};
111
 
 
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)
116
 
 */
117
 
struct CRLGENCertEntrySrt {
118
 
    char *certId;
119
 
    char *revocationTime;
120
 
    updateCrlFn_t   *updateCrlFn;
121
 
    setNextDataFn_t *setNextDataFn;
122
 
};
123
 
 
124
 
 
125
 
/* CRLGENCrlField is used to store crl fields record like update time, next
126
 
 * update time, etc.
127
 
 *  - value: value of the parsed field data*/
128
 
struct CRLGENCrlFieldStr {
129
 
    char *value;
130
 
    updateCrlFn_t   *updateCrlFn;
131
 
    setNextDataFn_t *setNextDataFn;
132
 
};
133
 
 
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
138
 
 *                 entry
139
 
 *   - entry : CERTCrlEntry structure pointer*/
140
 
struct CRLGENEntryDataStr {
141
 
    SECItem *certId;
142
 
    void *extHandle;
143
 
    CERTCrlEntry *entry;
144
 
};
145
 
 
146
 
/* Crl generator/parser main structure. Keeps info regarding current state of
147
 
 * parser(context, status), parser helper functions pointers, parsed data and
148
 
 * generated data.
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
167
 
 *                    set to SECFailure
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;       
175
 
    PRUint64 rangeFrom;
176
 
    PRUint64 rangeTo;
177
 
    CERTSignedCrl *signCrl;
178
 
    void *crlExtHandle;
179
 
    PLHashTable *entryDataHashTable;
180
 
    
181
 
    PRFileDesc *src;
182
 
    int parsedLineNum;
183
 
};
184
 
 
185
 
 
186
 
#endif /* _CRLGEN_H_ */