Back to index

lightning-sunbird  0.9+nobinonly
Functions
cmsdigdata.c File Reference
#include "cmslocal.h"
#include "secitem.h"
#include "secasn1.h"
#include "secoid.h"
#include "secerr.h"

Go to the source code of this file.

Functions

NSSCMSDigestedData * NSS_CMSDigestedData_Create (NSSCMSMessage *cmsg, SECAlgorithmID *digestalg)
void NSS_CMSDigestedData_Destroy (NSSCMSDigestedData *digd)
NSSCMSContentInfo * NSS_CMSDigestedData_GetContentInfo (NSSCMSDigestedData *digd)
SECStatus NSS_CMSDigestedData_Encode_BeforeStart (NSSCMSDigestedData *digd)
SECStatus NSS_CMSDigestedData_Encode_BeforeData (NSSCMSDigestedData *digd)
SECStatus NSS_CMSDigestedData_Encode_AfterData (NSSCMSDigestedData *digd)
SECStatus NSS_CMSDigestedData_Decode_BeforeData (NSSCMSDigestedData *digd)
SECStatus NSS_CMSDigestedData_Decode_AfterData (NSSCMSDigestedData *digd)
SECStatus NSS_CMSDigestedData_Decode_AfterEnd (NSSCMSDigestedData *digd)

Function Documentation

NSSCMSDigestedData* NSS_CMSDigestedData_Create ( NSSCMSMessage *  cmsg,
SECAlgorithmID *  digestalg 
)

Definition at line 59 of file cmsdigdata.c.

{
    void *mark;
    NSSCMSDigestedData *digd;
    PLArenaPool *poolp;

    poolp = cmsg->poolp;

    mark = PORT_ArenaMark(poolp);

    digd = (NSSCMSDigestedData *)PORT_ArenaZAlloc(poolp, sizeof(NSSCMSDigestedData));
    if (digd == NULL)
       goto loser;

    digd->cmsg = cmsg;

    if (SECOID_CopyAlgorithmID (poolp, &(digd->digestAlg), digestalg) != SECSuccess)
       goto loser;

    PORT_ArenaUnmark(poolp, mark);
    return digd;

loser:
    PORT_ArenaRelease(poolp, mark);
    return NULL;
}
SECStatus NSS_CMSDigestedData_Decode_AfterData ( NSSCMSDigestedData *  digd)

Definition at line 199 of file cmsdigdata.c.

{
    SECStatus rv = SECSuccess;
    /* did we have digest calculation going on? */
    if (digd->contentInfo.digcx) {
       rv = NSS_CMSDigestContext_FinishSingle(digd->contentInfo.digcx,
                                           digd->cmsg->poolp, 
                                          &(digd->cdigest));
       /* error has been set by NSS_CMSDigestContext_FinishSingle */
       digd->contentInfo.digcx = NULL;
    }

    return rv;
}
SECStatus NSS_CMSDigestedData_Decode_AfterEnd ( NSSCMSDigestedData *  digd)

Definition at line 221 of file cmsdigdata.c.

{
    /* did we have digest calculation going on? */
    if (digd->cdigest.len != 0) {
       /* XXX comparision btw digest & cdigest */
       /* XXX set status */
       /* TODO!!!! */
    }

    return SECSuccess;
}
SECStatus NSS_CMSDigestedData_Decode_BeforeData ( NSSCMSDigestedData *  digd)

Definition at line 178 of file cmsdigdata.c.

{
    /* is there a digest algorithm yet? */
    if (digd->digestAlg.algorithm.len == 0)
       return SECFailure;

    digd->contentInfo.digcx = NSS_CMSDigestContext_StartSingle(&(digd->digestAlg));
    if (digd->contentInfo.digcx == NULL)
       return SECFailure;

    return SECSuccess;
}
void NSS_CMSDigestedData_Destroy ( NSSCMSDigestedData *  digd)

Definition at line 90 of file cmsdigdata.c.

{
    /* everything's in a pool, so don't worry about the storage */
    NSS_CMSContentInfo_Destroy(&(digd->contentInfo));
    return;
}
SECStatus NSS_CMSDigestedData_Encode_AfterData ( NSSCMSDigestedData *  digd)

Definition at line 155 of file cmsdigdata.c.

{
    SECStatus rv = SECSuccess;
    /* did we have digest calculation going on? */
    if (digd->contentInfo.digcx) {
       rv = NSS_CMSDigestContext_FinishSingle(digd->contentInfo.digcx,
                                           digd->cmsg->poolp, 
                                          &(digd->digest));
       /* error has been set by NSS_CMSDigestContext_FinishSingle */
       digd->contentInfo.digcx = NULL;
    }

    return rv;
}
SECStatus NSS_CMSDigestedData_Encode_BeforeData ( NSSCMSDigestedData *  digd)

Definition at line 135 of file cmsdigdata.c.

{
    /* set up the digests */
    if (digd->digestAlg.algorithm.len != 0 && digd->digest.len == 0) {
       /* if digest is already there, do nothing */
       digd->contentInfo.digcx = NSS_CMSDigestContext_StartSingle(&(digd->digestAlg));
       if (digd->contentInfo.digcx == NULL)
           return SECFailure;
    }
    return SECSuccess;
}
SECStatus NSS_CMSDigestedData_Encode_BeforeStart ( NSSCMSDigestedData *  digd)

Definition at line 114 of file cmsdigdata.c.

{
    unsigned long version;
    SECItem *dummy;

    version = NSS_CMS_DIGESTED_DATA_VERSION_DATA;
    if (NSS_CMSContentInfo_GetContentTypeTag(&(digd->contentInfo)) != SEC_OID_PKCS7_DATA)
       version = NSS_CMS_DIGESTED_DATA_VERSION_ENCAP;

    dummy = SEC_ASN1EncodeInteger(digd->cmsg->poolp, &(digd->version), version);
    return (dummy == NULL) ? SECFailure : SECSuccess;
}
NSSCMSContentInfo* NSS_CMSDigestedData_GetContentInfo ( NSSCMSDigestedData *  digd)

Definition at line 101 of file cmsdigdata.c.

{
    return &(digd->contentInfo);
}