security/nss/cmd/crlutil/crlgen.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial