Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions
crlgen.h File Reference
#include "prio.h"
#include "prprf.h"
#include "plhash.h"
#include "seccomon.h"
#include "certt.h"
#include "secoidt.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  CRLGENExtensionEntryStr
struct  CRLGENCertEntrySrt
struct  CRLGENCrlFieldStr
struct  CRLGENEntryDataStr
struct  CRLGENGeneratorDataStr

Defines

#define CRLGEN_UNKNOWN_CONTEXT   0
#define CRLGEN_ISSUER_CONTEXT   1
#define CRLGEN_UPDATE_CONTEXT   2
#define CRLGEN_NEXT_UPDATE_CONTEXT   3
#define CRLGEN_ADD_EXTENSION_CONTEXT   4
#define CRLGEN_ADD_CERT_CONTEXT   6
#define CRLGEN_CHANGE_RANGE_CONTEXT   7
#define CRLGEN_RM_CERT_CONTEXT   8
#define CRLGEN_TYPE_DATE   0
#define CRLGEN_TYPE_ZDATE   1
#define CRLGEN_TYPE_DIGIT   2
#define CRLGEN_TYPE_DIGIT_RANGE   3
#define CRLGEN_TYPE_OID   4
#define CRLGEN_TYPE_STRING   5
#define CRLGEN_TYPE_ID   6

Typedefs

typedef struct CRLGENGeneratorDataStr
typedef struct CRLGENEntryDataStr
typedef struct CRLGENExtensionEntryStr
typedef struct CRLGENCertEntrySrt
typedef struct CRLGENCrlFieldStr
typedef struct CRLGENEntriesSortedDataStr
typedef SECStatus updateCrlFn_t (CRLGENGeneratorData *crlGenData, void *str)
typedef SECStatus setNextDataFn_t (CRLGENGeneratorData *crlGenData, void *str, void *data, unsigned short dtype)
typedef SECStatus createNewLangStructFn_t (CRLGENGeneratorData *crlGenData, void *str, unsigned i)

Functions

SECStatus CRLGEN_ExtHandleInit (CRLGENGeneratorData *crlGenData)
SECStatus CRLGEN_CommitExtensionsAndEntries (CRLGENGeneratorData *crlGenData)
SECStatus CRLGEN_StartCrlGen (CRLGENGeneratorData *crlGenData)
void CRLGEN_FinalizeCrlGeneration (CRLGENGeneratorData *crlGenData)
CRLGENGeneratorData * CRLGEN_InitCrlGeneration (CERTSignedCrl *newCrl, PRFileDesc *src)
void CRLGEN_InitCrlGenParserLock ()
void CRLGEN_DestroyCrlGenParserLock ()
void crlgen_setFailure (CRLGENGeneratorData *str, char *)
SECStatus crlgen_setNextData (CRLGENGeneratorData *str, void *data, unsigned short dtype)
SECStatus crlgen_updateCrl (CRLGENGeneratorData *str)
SECStatus crlgen_createNewLangStruct (CRLGENGeneratorData *str, unsigned structType)

Class Documentation

struct CRLGENExtensionEntryStr

Definition at line 101 of file crlgen.h.

Collaboration diagram for CRLGENExtensionEntryStr:
Class Members
char ** extData
int nextUpdatedData
setNextDataFn_t * setNextDataFn
updateCrlFn_t * updateCrlFn
struct CRLGENCertEntrySrt

Definition at line 113 of file crlgen.h.

Class Members
char * certId
char * revocationTime
setNextDataFn_t * setNextDataFn
updateCrlFn_t * updateCrlFn
struct CRLGENCrlFieldStr

Definition at line 124 of file crlgen.h.

Class Members
setNextDataFn_t * setNextDataFn
updateCrlFn_t * updateCrlFn
char * value
struct CRLGENEntryDataStr

Definition at line 136 of file crlgen.h.

Class Members
SECItem * certId
CERTCrlEntry * entry
void * extHandle
struct CRLGENGeneratorDataStr

Definition at line 166 of file crlgen.h.

Collaboration diagram for CRLGENGeneratorDataStr:
Class Members
CRLGENCertEntry * certEntry
unsigned short contextId
void * crlExtHandle
CRLGENCrlField * crlField
PLHashTable * entryDataHashTable
CRLGENExtensionEntry * extensionEntry
int parsedLineNum
PRUint64 rangeFrom
PRUint64 rangeTo
CERTSignedCrl * signCrl
PRFileDesc * src

Define Documentation

Definition at line 18 of file crlgen.h.

Definition at line 17 of file crlgen.h.

Definition at line 19 of file crlgen.h.

Definition at line 14 of file crlgen.h.

Definition at line 16 of file crlgen.h.

Definition at line 20 of file crlgen.h.

Definition at line 22 of file crlgen.h.

Definition at line 24 of file crlgen.h.

Definition at line 25 of file crlgen.h.

Definition at line 28 of file crlgen.h.

Definition at line 26 of file crlgen.h.

Definition at line 27 of file crlgen.h.

Definition at line 23 of file crlgen.h.

Definition at line 13 of file crlgen.h.

Definition at line 15 of file crlgen.h.


Typedef Documentation

typedef SECStatus createNewLangStructFn_t(CRLGENGeneratorData *crlGenData, void *str, unsigned i)

Definition at line 72 of file crlgen.h.

typedef struct CRLGENCertEntrySrt

Definition at line 34 of file crlgen.h.

typedef struct CRLGENCrlFieldStr

Definition at line 35 of file crlgen.h.

Definition at line 36 of file crlgen.h.

typedef struct CRLGENEntryDataStr

Definition at line 32 of file crlgen.h.

typedef struct CRLGENExtensionEntryStr

Definition at line 33 of file crlgen.h.

typedef struct CRLGENGeneratorDataStr

Definition at line 31 of file crlgen.h.

typedef SECStatus setNextDataFn_t(CRLGENGeneratorData *crlGenData, void *str, void *data, unsigned short dtype)

Definition at line 70 of file crlgen.h.

typedef SECStatus updateCrlFn_t(CRLGENGeneratorData *crlGenData, void *str)

Definition at line 69 of file crlgen.h.


Function Documentation

SECStatus CRLGEN_CommitExtensionsAndEntries ( CRLGENGeneratorData *  crlGenData)

Definition at line 791 of file crlgen.c.

{
    int size = 0;
    CERTCrl *crl;
    PRArenaPool *arena;
    SECStatus rv = SECSuccess;
    void *mark;

    PORT_Assert(crlGenData && crlGenData->signCrl && crlGenData->signCrl->arena);
    if (!crlGenData || !crlGenData->signCrl || !crlGenData->signCrl->arena) {
        PORT_SetError(SEC_ERROR_INVALID_ARGS);
        return SECFailure;
    }

    arena = crlGenData->signCrl->arena;
    crl = &crlGenData->signCrl->crl;

    mark = PORT_ArenaMark(arena);

    if (crlGenData->crlExtHandle)
        CERT_FinishExtensions(crlGenData->crlExtHandle);

    size = crlGenData->entryDataHashTable->nentries;
    crl->entries = NULL;
    if (size) {
        crl->entries = PORT_ArenaZNewArray(arena, CERTCrlEntry*, size + 1);
        if (!crl->entries) {
            rv = SECFailure;
        } else {
            struct commitData dt;
            dt.entries = crl->entries;
            dt.pos = 0;
            PL_HashTableEnumerateEntries(crlGenData->entryDataHashTable,
                                         &crlgen_CommitEntryData, &dt);
            /* Last should be NULL */
            crl->entries[size] = NULL;
        }
    }

    if (rv != SECSuccess)
        PORT_ArenaRelease(arena, mark);
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus crlgen_createNewLangStruct ( CRLGENGeneratorData *  str,
unsigned  structType 
)

Definition at line 1520 of file crlgen.c.

{
    PORT_Assert(crlGenData &&
                crlGenData->contextId == CRLGEN_UNKNOWN_CONTEXT);
    if (!crlGenData ||
        crlGenData->contextId != CRLGEN_UNKNOWN_CONTEXT) {
        PORT_SetError(SEC_ERROR_INVALID_ARGS);
        return SECFailure;
    }

    switch(structType) {
      case CRLGEN_ISSUER_CONTEXT:
      case CRLGEN_UPDATE_CONTEXT:
      case CRLGEN_NEXT_UPDATE_CONTEXT:
      case CRLGEN_CHANGE_RANGE_CONTEXT:
          crlGenData->crlField = PORT_New(CRLGENCrlField);
          if (!crlGenData->crlField) {
              return SECFailure;
          }
          crlGenData->contextId = structType;
          crlGenData->crlField->value = NULL;
          crlGenData->crlField->updateCrlFn = &crlgen_updateCrlFn_field;
          crlGenData->crlField->setNextDataFn = &crlgen_setNextDataFn_field;
          break;
      case CRLGEN_RM_CERT_CONTEXT:
      case CRLGEN_ADD_CERT_CONTEXT:
          crlGenData->certEntry = PORT_New(CRLGENCertEntry);
          if (!crlGenData->certEntry) {
              return SECFailure;
          }
          crlGenData->contextId = structType;
          crlGenData->certEntry->certId = 0;
          crlGenData->certEntry->revocationTime = NULL;
          crlGenData->certEntry->updateCrlFn = &crlgen_updateCrlFn_cert;
          crlGenData->certEntry->setNextDataFn = &crlgen_setNextDataFn_cert;
          break;
      case CRLGEN_ADD_EXTENSION_CONTEXT:
          crlGenData->extensionEntry = PORT_New(CRLGENExtensionEntry);
          if (!crlGenData->extensionEntry) {
              return SECFailure;
          }
          crlGenData->contextId = structType;
          crlGenData->extensionEntry->extData = NULL;
          crlGenData->extensionEntry->nextUpdatedData = 0;
          crlGenData->extensionEntry->updateCrlFn =
              &crlgen_updateCrlFn_extension;
          crlGenData->extensionEntry->setNextDataFn =
              &crlgen_setNextDataFn_extension;
          break;
      case CRLGEN_UNKNOWN_CONTEXT:
          break;
      default:
          crlgen_PrintError(crlGenData->parsedLineNum,
                            "unknown context type: %d.\n", structType);
          PORT_Assert(0);
          return SECFailure;
    }
    return SECSuccess;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1760 of file crlgen_lex.c.

Here is the call graph for this function:

SECStatus CRLGEN_ExtHandleInit ( CRLGENGeneratorData *  crlGenData)

Definition at line 865 of file crlgen.c.

{
    CERTCrl *crl = NULL;
    PRUint64 maxSN = 0;

    PORT_Assert(crlGenData && crlGenData->signCrl &&
                crlGenData->entryDataHashTable);
    if (!crlGenData || !crlGenData->signCrl ||
        !crlGenData->entryDataHashTable) {
        PORT_SetError(SEC_ERROR_INVALID_ARGS);
        return SECFailure;
    }

    crl = &crlGenData->signCrl->crl;
    crlGenData->crlExtHandle = CERT_StartCRLExtensions(crl);
    crlgen_InitExtensionHandle(crlGenData->crlExtHandle,
                               crl->extensions);
    crl->extensions = NULL;

    if (crl->entries) {
        CERTCrlEntry **entry = crl->entries;
        while (*entry) {
            PRUint64 sn = DER_GetInteger(&(*entry)->serialNumber);
            CRLGENEntryData *extData =
                crlgen_PlaceAnEntry(crlGenData, *entry, &(*entry)->serialNumber);
            if ((*entry)->extensions) {
                extData->extHandle = 
                    CERT_StartCRLEntryExtensions(&crlGenData->signCrl->crl,
                                                 (CERTCrlEntry*)extData->entry);
                if (crlgen_InitExtensionHandle(extData->extHandle,
                                               (*entry)->extensions) == SECFailure)
                    return SECFailure;
            }
            (*entry)->extensions = NULL;
            entry++;
            maxSN = PR_MAX(maxSN, sn);
        }
    }

    crlGenData->rangeFrom = crlGenData->rangeTo = maxSN + 1;
    return SECSuccess;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CRLGEN_FinalizeCrlGeneration ( CRLGENGeneratorData *  crlGenData)

Definition at line 1621 of file crlgen.c.

{
    if (!crlGenData)
        return;
    if (crlGenData->src)
        PR_Close(crlGenData->src);
    PL_HashTableDestroy(crlGenData->entryDataHashTable);
    PORT_Free(crlGenData);
}

Here is the call graph for this function:

Here is the caller graph for this function:

CRLGENGeneratorData* CRLGEN_InitCrlGeneration ( CERTSignedCrl *  newCrl,
PRFileDesc src 
)

Definition at line 1584 of file crlgen.c.

{
    CRLGENGeneratorData *crlGenData = NULL;

    PORT_Assert(signCrl && src);
    if (!signCrl || !src) {
        PORT_SetError(SEC_ERROR_INVALID_ARGS);
        return NULL;
    }

    crlGenData = PORT_ZNew(CRLGENGeneratorData);
    if (!crlGenData) {
        return NULL;
    }

    crlGenData->entryDataHashTable = 
        PL_NewHashTable(0, SECITEM_Hash, SECITEM_HashCompare,
                        PL_CompareValues, NULL, NULL);
    if (!crlGenData->entryDataHashTable) {
        PORT_Free(crlGenData);
        return NULL;
    }

    crlGenData->src = src;
    crlGenData->parsedLineNum = 1;
    crlGenData->contextId = CRLGEN_UNKNOWN_CONTEXT;
    crlGenData->signCrl = signCrl;
    crlGenData->rangeFrom = 0;
    crlGenData->rangeTo = 0;
    crlGenData->crlExtHandle = NULL;

    PORT_SetError(0);

    return crlGenData;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1755 of file crlgen_lex.c.

Here is the call graph for this function:

void crlgen_setFailure ( CRLGENGeneratorData *  str,
char *   
)
SECStatus crlgen_setNextData ( CRLGENGeneratorData *  str,
void data,
unsigned short  dtype 
)

Definition at line 1478 of file crlgen.c.

{
    SECStatus rv = SECSuccess;

    PORT_Assert(crlGenData);
    if (!crlGenData) {
        PORT_SetError(SEC_ERROR_INVALID_ARGS);
        return SECFailure;
    }

    switch(crlGenData->contextId) {
      case CRLGEN_ISSUER_CONTEXT:
      case CRLGEN_UPDATE_CONTEXT:
      case CRLGEN_NEXT_UPDATE_CONTEXT:
      case CRLGEN_CHANGE_RANGE_CONTEXT:
          rv = crlGenData->crlField->setNextDataFn(crlGenData, crlGenData->crlField,
                                                   data, dtype);
          break;
      case CRLGEN_ADD_CERT_CONTEXT:
      case CRLGEN_RM_CERT_CONTEXT:
          rv = crlGenData->certEntry->setNextDataFn(crlGenData, crlGenData->certEntry,
                                                    data, dtype);
          break;
      case CRLGEN_ADD_EXTENSION_CONTEXT:
          rv =
              crlGenData->extensionEntry->
              setNextDataFn(crlGenData, crlGenData->extensionEntry, data, dtype);
          break;
      case CRLGEN_UNKNOWN_CONTEXT:
          break;
      default:
          crlgen_PrintError(crlGenData->parsedLineNum,
                            "unknown context type: %d.\n",
                            crlGenData->contextId);
          PORT_Assert(0);
          return SECFailure;
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus CRLGEN_StartCrlGen ( CRLGENGeneratorData *  crlGenData)

Definition at line 1766 of file crlgen_lex.c.

{
    SECStatus rv;

    PR_Lock(parserInvocationLock);

    parserStatus = SECSuccess;
    parserData = parserCtlData;
    src = parserCtlData->src;

    rv = yylex();

    PR_Unlock(parserInvocationLock);

    return rv;
}
SECStatus crlgen_updateCrl ( CRLGENGeneratorData *  str)

Definition at line 1435 of file crlgen.c.

{
    SECStatus rv = SECSuccess;

    PORT_Assert(crlGenData);
    if (!crlGenData) {
        PORT_SetError(SEC_ERROR_INVALID_ARGS);
        return SECFailure;
    }

    switch(crlGenData->contextId) {
      case CRLGEN_ISSUER_CONTEXT:
      case CRLGEN_UPDATE_CONTEXT:
      case CRLGEN_NEXT_UPDATE_CONTEXT:
      case CRLGEN_CHANGE_RANGE_CONTEXT:
          rv = crlGenData->crlField->updateCrlFn(crlGenData, crlGenData->crlField);
          break;
      case CRLGEN_RM_CERT_CONTEXT:
      case CRLGEN_ADD_CERT_CONTEXT:
          rv = crlGenData->certEntry->updateCrlFn(crlGenData, crlGenData->certEntry);
          break;
      case CRLGEN_ADD_EXTENSION_CONTEXT:
          rv = crlGenData->extensionEntry->
              updateCrlFn(crlGenData, crlGenData->extensionEntry);
          break;
      case CRLGEN_UNKNOWN_CONTEXT:
          break;
      default:
          crlgen_PrintError(crlGenData->parsedLineNum,
                            "unknown lang context type code: %d.\n",
                            crlGenData->contextId);
          PORT_Assert(0);
          return SECFailure;
    }
    /* Clrean structures after crl update */
    crlgen_destroyTempData(crlGenData);

    crlGenData->parsedLineNum += 1;

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function: