Back to index

lightning-sunbird  0.9+nobinonly
Functions
certdecode.c File Reference
#include "pkit.h"
#include "pkim.h"

Go to the source code of this file.

Functions

NSS_EXTERN nssDecodedCert * nssDecodedPKIXCertificate_Create (NSSArena *arenaOpt, NSSDER *encoding)
NSS_IMPLEMENT PRStatus nssDecodedPKIXCertificate_Destroy (nssDecodedCert *dc)
NSS_IMPLEMENT nssDecodedCert * nssDecodedCert_Create (NSSArena *arenaOpt, NSSDER *encoding, NSSCertificateType type)
NSS_IMPLEMENT PRStatus nssDecodedCert_Destroy (nssDecodedCert *dc)

Function Documentation

NSS_IMPLEMENT nssDecodedCert* nssDecodedCert_Create ( NSSArena *  arenaOpt,
NSSDER encoding,
NSSCertificateType  type 
)

Definition at line 62 of file certdecode.c.

{
    nssDecodedCert *rvDC = NULL;
    switch(type) {
    case NSSCertificateType_PKIX:
       rvDC = nssDecodedPKIXCertificate_Create(arenaOpt, encoding);
       break;
    default:
#if 0
       nss_SetError(NSS_ERROR_INVALID_ARGUMENT);
#endif
       return (nssDecodedCert *)NULL;
    }
    return rvDC;
}

Here is the caller graph for this function:

NSS_IMPLEMENT PRStatus nssDecodedCert_Destroy ( nssDecodedCert *  dc)

Definition at line 83 of file certdecode.c.

{
    if (!dc) {
       return PR_FAILURE;
    }
    switch(dc->type) {
    case NSSCertificateType_PKIX:
       return nssDecodedPKIXCertificate_Destroy(dc);
    default:
#if 0
       nss_SetError(NSS_ERROR_INVALID_ARGUMENT);
#endif
       break;
    }
    return PR_FAILURE;
}

Here is the caller graph for this function:

NSS_EXTERN nssDecodedCert* nssDecodedPKIXCertificate_Create ( NSSArena *  arenaOpt,
NSSDER encoding 
)

Definition at line 472 of file pki3hack.c.

{
    nssDecodedCert  *rvDC = NULL;
    CERTCertificate *cert;
    SECItem          secDER;

    SECITEM_FROM_NSSITEM(&secDER, encoding);
    cert = CERT_DecodeDERCertificate(&secDER, PR_TRUE, NULL);
    if (cert) {
       rvDC = nss_ZNEW(arenaOpt, nssDecodedCert);
       if (rvDC) {
           rvDC->type                = NSSCertificateType_PKIX;
           rvDC->data                = (void *)cert;
           rvDC->getIdentifier       = nss3certificate_getIdentifier;
           rvDC->getIssuerIdentifier = nss3certificate_getIssuerIdentifier;
           rvDC->matchIdentifier     = nss3certificate_matchIdentifier;
           rvDC->isValidIssuer       = nss3certificate_isValidIssuer;
           rvDC->getUsage            = nss3certificate_getUsage;
           rvDC->isValidAtTime       = nss3certificate_isValidAtTime;
           rvDC->isNewerThan         = nss3certificate_isNewerThan;
           rvDC->matchUsage          = nss3certificate_matchUsage;
           rvDC->getEmailAddress     = nss3certificate_getEmailAddress;
           rvDC->getDERSerialNumber  = nss3certificate_getDERSerialNumber;
       } else {
           CERT_DestroyCertificate(cert);
       }
    }
    return rvDC;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 529 of file pki3hack.c.

{
    CERTCertificate *cert = (CERTCertificate *)dc->data;

    /* The decoder may only be half initialized (the case where we find we 
     * could not decode the certificate). In this case, there is not cert to
     * free, just free the dc structure. */
    if (cert) {
       PRBool freeSlot = cert->ownSlot;
       PK11SlotInfo *slot = cert->slot;
       PRArenaPool *arena  = cert->arena;
       /* zero cert before freeing. Any stale references to this cert
        * after this point will probably cause an exception.  */
       PORT_Memset(cert, 0, sizeof *cert);
       /* free the arena that contains the cert. */
       PORT_FreeArena(arena, PR_FALSE);
       if (slot && freeSlot) {
           PK11_FreeSlot(slot);
       }
    }
    nss_ZFreeIf(dc);
    return PR_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function: