/security/nss/cmd/crlutil/crlgen.h

http://github.com/zpao/v8monkey · C Header · 182 lines · 84 code · 31 blank · 67 comment · 0 complexity · 8ae743a26f902f3edda35212a092e2a5 MD5 · raw file

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