michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: #ifndef _CRLGEN_H_ michael@0: #define _CRLGEN_H_ michael@0: michael@0: #include "prio.h" michael@0: #include "prprf.h" michael@0: #include "plhash.h" michael@0: #include "seccomon.h" michael@0: #include "certt.h" michael@0: #include "secoidt.h" michael@0: michael@0: michael@0: #define CRLGEN_UNKNOWN_CONTEXT 0 michael@0: #define CRLGEN_ISSUER_CONTEXT 1 michael@0: #define CRLGEN_UPDATE_CONTEXT 2 michael@0: #define CRLGEN_NEXT_UPDATE_CONTEXT 3 michael@0: #define CRLGEN_ADD_EXTENSION_CONTEXT 4 michael@0: #define CRLGEN_ADD_CERT_CONTEXT 6 michael@0: #define CRLGEN_CHANGE_RANGE_CONTEXT 7 michael@0: #define CRLGEN_RM_CERT_CONTEXT 8 michael@0: michael@0: #define CRLGEN_TYPE_DATE 0 michael@0: #define CRLGEN_TYPE_ZDATE 1 michael@0: #define CRLGEN_TYPE_DIGIT 2 michael@0: #define CRLGEN_TYPE_DIGIT_RANGE 3 michael@0: #define CRLGEN_TYPE_OID 4 michael@0: #define CRLGEN_TYPE_STRING 5 michael@0: #define CRLGEN_TYPE_ID 6 michael@0: michael@0: michael@0: typedef struct CRLGENGeneratorDataStr CRLGENGeneratorData; michael@0: typedef struct CRLGENEntryDataStr CRLGENEntryData; michael@0: typedef struct CRLGENExtensionEntryStr CRLGENExtensionEntry; michael@0: typedef struct CRLGENCertEntrySrt CRLGENCertEntry; michael@0: typedef struct CRLGENCrlFieldStr CRLGENCrlField; michael@0: typedef struct CRLGENEntriesSortedDataStr CRLGENEntriesSortedData; michael@0: michael@0: /* Exported functions */ michael@0: michael@0: /* Used for initialization of extension handles for crl and certs michael@0: * extensions from existing CRL data then modifying existing CRL.*/ michael@0: extern SECStatus CRLGEN_ExtHandleInit(CRLGENGeneratorData *crlGenData); michael@0: michael@0: /* Commits all added entries and their's extensions into CRL. */ michael@0: extern SECStatus CRLGEN_CommitExtensionsAndEntries(CRLGENGeneratorData *crlGenData); michael@0: michael@0: /* Lunches the crl generation script parse */ michael@0: extern SECStatus CRLGEN_StartCrlGen(CRLGENGeneratorData *crlGenData); michael@0: michael@0: /* Closes crl generation script file and frees crlGenData */ michael@0: extern void CRLGEN_FinalizeCrlGeneration(CRLGENGeneratorData *crlGenData); michael@0: michael@0: /* Parser initialization function. Creates CRLGENGeneratorData structure michael@0: * for the current thread */ michael@0: extern CRLGENGeneratorData* CRLGEN_InitCrlGeneration(CERTSignedCrl *newCrl, michael@0: PRFileDesc *src); michael@0: michael@0: michael@0: /* This lock is defined in crlgen_lex.c(derived from crlgen_lex.l). michael@0: * It controls access to invocation of yylex, allows to parse one michael@0: * script at a time */ michael@0: extern void CRLGEN_InitCrlGenParserLock(); michael@0: extern void CRLGEN_DestroyCrlGenParserLock(); michael@0: michael@0: michael@0: /* The following function types are used to define functions for each of michael@0: * CRLGENExtensionEntryStr, CRLGENCertEntrySrt, CRLGENCrlFieldStr to michael@0: * provide functionality needed for these structures*/ michael@0: typedef SECStatus updateCrlFn_t(CRLGENGeneratorData *crlGenData, void *str); michael@0: typedef SECStatus setNextDataFn_t(CRLGENGeneratorData *crlGenData, void *str, michael@0: void *data, unsigned short dtype); michael@0: typedef SECStatus createNewLangStructFn_t(CRLGENGeneratorData *crlGenData, michael@0: void *str, unsigned i); michael@0: michael@0: /* Sets reports failure to parser if anything goes wrong */ michael@0: extern void crlgen_setFailure(CRLGENGeneratorData *str, char *); michael@0: michael@0: /* Collects data in to one of the current data structure that corresponds michael@0: * to the correct context type. This function gets called after each token michael@0: * is found for a particular line */ michael@0: extern SECStatus crlgen_setNextData(CRLGENGeneratorData *str, void *data, michael@0: unsigned short dtype); michael@0: michael@0: /* initiates crl update with collected data. This function is called at the michael@0: * end of each line */ michael@0: extern SECStatus crlgen_updateCrl(CRLGENGeneratorData *str); michael@0: michael@0: /* Creates new context structure depending on token that was parsed michael@0: * at the beginning of a line */ michael@0: extern SECStatus crlgen_createNewLangStruct(CRLGENGeneratorData *str, michael@0: unsigned structType); michael@0: michael@0: michael@0: /* CRLGENExtensionEntry is used to store addext request data for either michael@0: * CRL extensions or CRL entry extensions. The differentiation between michael@0: * is based on order and type of extension been added. michael@0: * - extData : all data in request staring from name of the extension are michael@0: * in saved here. michael@0: * - nextUpdatedData: counter of elements added to extData michael@0: */ michael@0: struct CRLGENExtensionEntryStr { michael@0: char **extData; michael@0: int nextUpdatedData; michael@0: updateCrlFn_t *updateCrlFn; michael@0: setNextDataFn_t *setNextDataFn; michael@0: }; michael@0: michael@0: /* CRLGENCeryestEntry is used to store addcert request data michael@0: * - certId : certificate id or range of certificate with dash as a delimiter michael@0: * All certs from range will be inclusively added to crl michael@0: * - revocationTime: revocation time of cert(s) michael@0: */ michael@0: struct CRLGENCertEntrySrt { michael@0: char *certId; michael@0: char *revocationTime; michael@0: updateCrlFn_t *updateCrlFn; michael@0: setNextDataFn_t *setNextDataFn; michael@0: }; michael@0: michael@0: michael@0: /* CRLGENCrlField is used to store crl fields record like update time, next michael@0: * update time, etc. michael@0: * - value: value of the parsed field data*/ michael@0: struct CRLGENCrlFieldStr { michael@0: char *value; michael@0: updateCrlFn_t *updateCrlFn; michael@0: setNextDataFn_t *setNextDataFn; michael@0: }; michael@0: michael@0: /* Can not create entries extension until completely done with parsing. michael@0: * Therefore need to keep joined data michael@0: * - certId : serial number of certificate michael@0: * - extHandle: head pointer to a list of extensions that belong to michael@0: * entry michael@0: * - entry : CERTCrlEntry structure pointer*/ michael@0: struct CRLGENEntryDataStr { michael@0: SECItem *certId; michael@0: void *extHandle; michael@0: CERTCrlEntry *entry; michael@0: }; michael@0: michael@0: /* Crl generator/parser main structure. Keeps info regarding current state of michael@0: * parser(context, status), parser helper functions pointers, parsed data and michael@0: * generated data. michael@0: * - contextId : current parsing context. Context in this parser environment michael@0: * defines what type of crl operations parser is going through michael@0: * in the current line of crl generation script. michael@0: * setting or new cert or an extension addition, etc. michael@0: * - createNewLangStructFn: pointer to top level function which creates michael@0: * data structures according contextId michael@0: * - setNextDataFn : pointer to top level function which sets new parsed data michael@0: * in temporary structure michael@0: * - updateCrlFn : pointer to top level function which triggers actual michael@0: * crl update functions with gathered data michael@0: * - union : data union create according to contextId michael@0: * - rangeFrom, rangeTo : holds last range in which certs was added michael@0: * - newCrl : pointer to CERTSignedCrl newly created crl michael@0: * - crlExtHandle : pointer to crl extension handle michael@0: * - entryDataHashTable: hash of CRLGENEntryData. michael@0: * key: cert serial number michael@0: * data: CRLGENEntryData pointer michael@0: * - parserStatus : current status of parser. Triggers parser to abort when michael@0: * set to SECFailure michael@0: * - src : PRFileDesc structure pointer of crl generator config file michael@0: * - parsedLineNum : currently parsing line. Keeping it to report errors */ michael@0: struct CRLGENGeneratorDataStr { michael@0: unsigned short contextId; michael@0: CRLGENCrlField *crlField; michael@0: CRLGENCertEntry *certEntry; michael@0: CRLGENExtensionEntry *extensionEntry; michael@0: PRUint64 rangeFrom; michael@0: PRUint64 rangeTo; michael@0: CERTSignedCrl *signCrl; michael@0: void *crlExtHandle; michael@0: PLHashTable *entryDataHashTable; michael@0: michael@0: PRFileDesc *src; michael@0: int parsedLineNum; michael@0: }; michael@0: michael@0: michael@0: #endif /* _CRLGEN_H_ */