Back to index

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

Go to the source code of this file.

Functions

void NSS_CMSContentInfo_Destroy (NSSCMSContentInfo *cinfo)
NSSCMSContentInfo * NSS_CMSContentInfo_GetChildContentInfo (NSSCMSContentInfo *cinfo)
SECStatus NSS_CMSContentInfo_SetContent (NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, SECOidTag type, void *ptr)
SECStatus NSS_CMSContentInfo_SetContent_Data (NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, SECItem *data, PRBool detached)
SECStatus NSS_CMSContentInfo_SetContent_SignedData (NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, NSSCMSSignedData *sigd)
SECStatus NSS_CMSContentInfo_SetContent_EnvelopedData (NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, NSSCMSEnvelopedData *envd)
SECStatus NSS_CMSContentInfo_SetContent_DigestedData (NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, NSSCMSDigestedData *digd)
SECStatus NSS_CMSContentInfo_SetContent_EncryptedData (NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, NSSCMSEncryptedData *encd)
voidNSS_CMSContentInfo_GetContent (NSSCMSContentInfo *cinfo)
SECItem * NSS_CMSContentInfo_GetInnerContent (NSSCMSContentInfo *cinfo)
SECOidTag NSS_CMSContentInfo_GetContentTypeTag (NSSCMSContentInfo *cinfo)
SECItem * NSS_CMSContentInfo_GetContentTypeOID (NSSCMSContentInfo *cinfo)
SECOidTag NSS_CMSContentInfo_GetContentEncAlgTag (NSSCMSContentInfo *cinfo)
SECAlgorithmID * NSS_CMSContentInfo_GetContentEncAlg (NSSCMSContentInfo *cinfo)
SECStatus NSS_CMSContentInfo_SetContentEncAlg (PLArenaPool *poolp, NSSCMSContentInfo *cinfo, SECOidTag bulkalgtag, SECItem *parameters, int keysize)
SECStatus NSS_CMSContentInfo_SetContentEncAlgID (PLArenaPool *poolp, NSSCMSContentInfo *cinfo, SECAlgorithmID *algid, int keysize)
void NSS_CMSContentInfo_SetBulkKey (NSSCMSContentInfo *cinfo, PK11SymKey *bulkkey)
PK11SymKey * NSS_CMSContentInfo_GetBulkKey (NSSCMSContentInfo *cinfo)
int NSS_CMSContentInfo_GetBulkKeySize (NSSCMSContentInfo *cinfo)

Function Documentation

void NSS_CMSContentInfo_Destroy ( NSSCMSContentInfo *  cinfo)

Definition at line 60 of file cmscinfo.c.

{
    SECOidTag kind;

    kind = NSS_CMSContentInfo_GetContentTypeTag(cinfo);
    switch (kind) {
    case SEC_OID_PKCS7_ENVELOPED_DATA:
       NSS_CMSEnvelopedData_Destroy(cinfo->content.envelopedData);
       break;
      case SEC_OID_PKCS7_SIGNED_DATA:
       NSS_CMSSignedData_Destroy(cinfo->content.signedData);
       break;
      case SEC_OID_PKCS7_ENCRYPTED_DATA:
       NSS_CMSEncryptedData_Destroy(cinfo->content.encryptedData);
       break;
      case SEC_OID_PKCS7_DIGESTED_DATA:
       NSS_CMSDigestedData_Destroy(cinfo->content.digestedData);
       break;
      default:
       /* XXX Anything else that needs to be "manually" freed/destroyed? */
       break;
    }
    if (cinfo->digcx) {
       /* must destroy digest objects */
       NSS_CMSDigestContext_Cancel(cinfo->digcx);
       cinfo->digcx = NULL;
    }
    if (cinfo->bulkkey)
       PK11_FreeSymKey(cinfo->bulkkey);

    if (cinfo->ciphcx) {
       NSS_CMSCipherContext_Destroy(cinfo->ciphcx);
       cinfo->ciphcx = NULL;
    }
    
    /* we live in a pool, so no need to worry about storage */
}

Here is the call graph for this function:

Here is the caller graph for this function:

PK11SymKey* NSS_CMSContentInfo_GetBulkKey ( NSSCMSContentInfo *  cinfo)

Definition at line 348 of file cmscinfo.c.

{
    if (cinfo->bulkkey == NULL)
       return NULL;

    return PK11_ReferenceSymKey(cinfo->bulkkey);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int NSS_CMSContentInfo_GetBulkKeySize ( NSSCMSContentInfo *  cinfo)

Definition at line 357 of file cmscinfo.c.

{
    return cinfo->keysize;
}

Here is the caller graph for this function:

NSSCMSContentInfo* NSS_CMSContentInfo_GetChildContentInfo ( NSSCMSContentInfo *  cinfo)

Definition at line 102 of file cmscinfo.c.

{
    void * ptr                  = NULL;
    NSSCMSContentInfo * ccinfo  = NULL;
    SECOidTag tag = NSS_CMSContentInfo_GetContentTypeTag(cinfo);
    switch (tag) {
    case SEC_OID_PKCS7_SIGNED_DATA:
       ptr    = (void *)cinfo->content.signedData;
       ccinfo = &(cinfo->content.signedData->contentInfo);
       break;
    case SEC_OID_PKCS7_ENVELOPED_DATA:
       ptr    = (void *)cinfo->content.envelopedData;
       ccinfo = &(cinfo->content.envelopedData->contentInfo);
       break;
    case SEC_OID_PKCS7_DIGESTED_DATA:
       ptr    = (void *)cinfo->content.digestedData;
       ccinfo = &(cinfo->content.digestedData->contentInfo);
       break;
    case SEC_OID_PKCS7_ENCRYPTED_DATA:
       ptr    = (void *)cinfo->content.encryptedData;
       ccinfo = &(cinfo->content.encryptedData->contentInfo);
       break;
    case SEC_OID_PKCS7_DATA:
    default:
       break;
    }
    return (ptr ? ccinfo : NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* NSS_CMSContentInfo_GetContent ( NSSCMSContentInfo *  cinfo)

Definition at line 213 of file cmscinfo.c.

{
    SECOidTag tag = (cinfo && cinfo->contentTypeTag) 
                       ? cinfo->contentTypeTag->offset 
                       : SEC_OID_UNKNOWN;
    switch (tag) {
    case SEC_OID_PKCS7_DATA:
    case SEC_OID_PKCS7_SIGNED_DATA:
    case SEC_OID_PKCS7_ENVELOPED_DATA:
    case SEC_OID_PKCS7_DIGESTED_DATA:
    case SEC_OID_PKCS7_ENCRYPTED_DATA:
       return cinfo->content.pointer;
    default:
       return NULL;
    }
}

Here is the caller graph for this function:

SECAlgorithmID* NSS_CMSContentInfo_GetContentEncAlg ( NSSCMSContentInfo *  cinfo)

Definition at line 308 of file cmscinfo.c.

{
    return &(cinfo->contentEncAlg);
}

Here is the caller graph for this function:

SECOidTag NSS_CMSContentInfo_GetContentEncAlgTag ( NSSCMSContentInfo *  cinfo)

Definition at line 296 of file cmscinfo.c.

{
    if (cinfo->contentEncAlgTag == SEC_OID_UNKNOWN)
       cinfo->contentEncAlgTag = SECOID_GetAlgorithmTag(&(cinfo->contentEncAlg));

    return cinfo->contentEncAlgTag;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECItem* NSS_CMSContentInfo_GetContentTypeOID ( NSSCMSContentInfo *  cinfo)

Definition at line 280 of file cmscinfo.c.

{
    if (cinfo->contentTypeTag == NULL)
       cinfo->contentTypeTag = SECOID_FindOID(&(cinfo->contentType));

    if (cinfo->contentTypeTag == NULL)
       return NULL;

    return &(cinfo->contentTypeTag->oid);
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECOidTag NSS_CMSContentInfo_GetContentTypeTag ( NSSCMSContentInfo *  cinfo)

Definition at line 268 of file cmscinfo.c.

{
    if (cinfo->contentTypeTag == NULL)
       cinfo->contentTypeTag = SECOID_FindOID(&(cinfo->contentType));

    if (cinfo->contentTypeTag == NULL)
       return SEC_OID_UNKNOWN;

    return cinfo->contentTypeTag->offset;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECItem* NSS_CMSContentInfo_GetInnerContent ( NSSCMSContentInfo *  cinfo)

Definition at line 236 of file cmscinfo.c.

{
    NSSCMSContentInfo *ccinfo;
    SECOidTag          tag;
    SECItem           *pItem = NULL;

    tag = NSS_CMSContentInfo_GetContentTypeTag(cinfo);
    switch (tag) {
    case SEC_OID_PKCS7_DATA:
       /* end of recursion - every message has to have a data cinfo */
       pItem = cinfo->content.data; 
       break;
    case SEC_OID_PKCS7_DIGESTED_DATA:
    case SEC_OID_PKCS7_ENCRYPTED_DATA:
    case SEC_OID_PKCS7_ENVELOPED_DATA:
    case SEC_OID_PKCS7_SIGNED_DATA:
       ccinfo = NSS_CMSContentInfo_GetChildContentInfo(cinfo);
       if (ccinfo != NULL)
           pItem = NSS_CMSContentInfo_GetContent(ccinfo);
       break;
    default:
       PORT_Assert(0);
       break;
    }
    return pItem;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void NSS_CMSContentInfo_SetBulkKey ( NSSCMSContentInfo *  cinfo,
PK11SymKey *  bulkkey 
)

Definition at line 341 of file cmscinfo.c.

{
    cinfo->bulkkey = PK11_ReferenceSymKey(bulkkey);
    cinfo->keysize = PK11_GetKeyStrength(cinfo->bulkkey, &(cinfo->contentEncAlg));
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus NSS_CMSContentInfo_SetContent ( NSSCMSMessage *  cmsg,
NSSCMSContentInfo *  cinfo,
SECOidTag  type,
void ptr 
)

Definition at line 135 of file cmscinfo.c.

{
    SECStatus rv;

    cinfo->contentTypeTag = SECOID_FindOIDByTag(type);
    if (cinfo->contentTypeTag == NULL)
       return SECFailure;
    
    /* do not copy the oid, just create a reference */
    rv = SECITEM_CopyItem (cmsg->poolp, &(cinfo->contentType), &(cinfo->contentTypeTag->oid));
    if (rv != SECSuccess)
       return SECFailure;

    cinfo->content.pointer = ptr;

    if (type != SEC_OID_PKCS7_DATA) {
       /* as we always have some inner data,
        * we need to set it to something, just to fool the encoder enough to work on it
        * and get us into nss_cms_encoder_notify at that point */
       cinfo->rawContent = SECITEM_AllocItem(cmsg->poolp, NULL, 1);
       if (cinfo->rawContent == NULL) {
           PORT_SetError(SEC_ERROR_NO_MEMORY);
           return SECFailure;
       }
    }

    return SECSuccess;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus NSS_CMSContentInfo_SetContent_Data ( NSSCMSMessage *  cmsg,
NSSCMSContentInfo *  cinfo,
SECItem *  data,
PRBool  detached 
)

Definition at line 173 of file cmscinfo.c.

{
    if (NSS_CMSContentInfo_SetContent(cmsg, cinfo, SEC_OID_PKCS7_DATA, (void *)data) != SECSuccess)
       return SECFailure;
    cinfo->rawContent = (detached) ? 
                         NULL : (data) ? 
                            data : SECITEM_AllocItem(cmsg->poolp, NULL, 1);
    return SECSuccess;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus NSS_CMSContentInfo_SetContent_DigestedData ( NSSCMSMessage *  cmsg,
NSSCMSContentInfo *  cinfo,
NSSCMSDigestedData *  digd 
)

Definition at line 196 of file cmscinfo.c.

{
    return NSS_CMSContentInfo_SetContent(cmsg, cinfo, SEC_OID_PKCS7_DIGESTED_DATA, (void *)digd);
}

Here is the call graph for this function:

SECStatus NSS_CMSContentInfo_SetContent_EncryptedData ( NSSCMSMessage *  cmsg,
NSSCMSContentInfo *  cinfo,
NSSCMSEncryptedData *  encd 
)

Definition at line 202 of file cmscinfo.c.

{
    return NSS_CMSContentInfo_SetContent(cmsg, cinfo, SEC_OID_PKCS7_ENCRYPTED_DATA, (void *)encd);
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus NSS_CMSContentInfo_SetContent_EnvelopedData ( NSSCMSMessage *  cmsg,
NSSCMSContentInfo *  cinfo,
NSSCMSEnvelopedData *  envd 
)

Definition at line 190 of file cmscinfo.c.

{
    return NSS_CMSContentInfo_SetContent(cmsg, cinfo, SEC_OID_PKCS7_ENVELOPED_DATA, (void *)envd);
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus NSS_CMSContentInfo_SetContent_SignedData ( NSSCMSMessage *  cmsg,
NSSCMSContentInfo *  cinfo,
NSSCMSSignedData *  sigd 
)

Definition at line 184 of file cmscinfo.c.

{
    return NSS_CMSContentInfo_SetContent(cmsg, cinfo, SEC_OID_PKCS7_SIGNED_DATA, (void *)sigd);
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus NSS_CMSContentInfo_SetContentEncAlg ( PLArenaPool poolp,
NSSCMSContentInfo *  cinfo,
SECOidTag  bulkalgtag,
SECItem *  parameters,
int  keysize 
)

Definition at line 314 of file cmscinfo.c.

{
    SECStatus rv;

    rv = SECOID_SetAlgorithmID(poolp, &(cinfo->contentEncAlg), bulkalgtag, parameters);
    if (rv != SECSuccess)
       return SECFailure;
    cinfo->keysize = keysize;
    return SECSuccess;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus NSS_CMSContentInfo_SetContentEncAlgID ( PLArenaPool poolp,
NSSCMSContentInfo *  cinfo,
SECAlgorithmID *  algid,
int  keysize 
)

Definition at line 327 of file cmscinfo.c.

{
    SECStatus rv;

    rv = SECOID_CopyAlgorithmID(poolp, &(cinfo->contentEncAlg), algid);
    if (rv != SECSuccess)
       return SECFailure;
    if (keysize >= 0)
       cinfo->keysize = keysize;
    return SECSuccess;
}

Here is the call graph for this function:

Here is the caller graph for this function: