Back to index

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

Go to the source code of this file.

Functions

NSSCMSMessage * NSS_CMSMessage_Create (PLArenaPool *poolp)
void NSS_CMSMessage_SetEncodingParams (NSSCMSMessage *cmsg, PK11PasswordFunc pwfn, void *pwfn_arg, NSSCMSGetDecryptKeyCallback decrypt_key_cb, void *decrypt_key_cb_arg, SECAlgorithmID **detached_digestalgs, SECItem **detached_digests)
void NSS_CMSMessage_Destroy (NSSCMSMessage *cmsg)
NSSCMSMessage * NSS_CMSMessage_Copy (NSSCMSMessage *cmsg)
PLArenaPoolNSS_CMSMessage_GetArena (NSSCMSMessage *cmsg)
NSSCMSContentInfo * NSS_CMSMessage_GetContentInfo (NSSCMSMessage *cmsg)
SECItem * NSS_CMSMessage_GetContent (NSSCMSMessage *cmsg)
int NSS_CMSMessage_ContentLevelCount (NSSCMSMessage *cmsg)
NSSCMSContentInfo * NSS_CMSMessage_ContentLevel (NSSCMSMessage *cmsg, int n)
PRBool NSS_CMSMessage_ContainsCertsOrCrls (NSSCMSMessage *cmsg)
PRBool NSS_CMSMessage_IsEncrypted (NSSCMSMessage *cmsg)
PRBool NSS_CMSMessage_IsSigned (NSSCMSMessage *cmsg)
PRBool NSS_CMSMessage_IsContentEmpty (NSSCMSMessage *cmsg, unsigned int minLen)

Function Documentation

PRBool NSS_CMSMessage_ContainsCertsOrCrls ( NSSCMSMessage *  cmsg)

Definition at line 231 of file cmsmessage.c.

{
    NSSCMSContentInfo *cinfo;

    /* descend into CMS message */
    for (cinfo = &(cmsg->contentInfo); cinfo != NULL; cinfo = NSS_CMSContentInfo_GetChildContentInfo(cinfo)) {
       if (NSS_CMSContentInfo_GetContentTypeTag(cinfo) != SEC_OID_PKCS7_SIGNED_DATA)
           continue; /* next level */
       
       if (NSS_CMSSignedData_ContainsCertsOrCrls(cinfo->content.signedData))
           return PR_TRUE;
    }
    return PR_FALSE;
}

Here is the call graph for this function:

NSSCMSContentInfo* NSS_CMSMessage_ContentLevel ( NSSCMSMessage *  cmsg,
int  n 
)

Definition at line 214 of file cmsmessage.c.

{
    int count = 0;
    NSSCMSContentInfo *cinfo;

    /* walk down the chain of contentinfos */
    for (cinfo = &(cmsg->contentInfo); cinfo != NULL && count < n; cinfo = NSS_CMSContentInfo_GetChildContentInfo(cinfo)) {
       count++;
    }

    return cinfo;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int NSS_CMSMessage_ContentLevelCount ( NSSCMSMessage *  cmsg)

Definition at line 195 of file cmsmessage.c.

{
    int count = 0;
    NSSCMSContentInfo *cinfo;

    /* walk down the chain of contentinfos */
    for (cinfo = &(cmsg->contentInfo); cinfo != NULL; ) {
       count++;
       cinfo = NSS_CMSContentInfo_GetChildContentInfo(cinfo);
    }
    return count;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSSCMSMessage* NSS_CMSMessage_Copy ( NSSCMSMessage *  cmsg)

Definition at line 146 of file cmsmessage.c.

{
    if (cmsg == NULL)
       return NULL;

    PORT_Assert (cmsg->refCount > 0);

    cmsg->refCount++; /* XXX chrisk thread safety? */
    return cmsg;
}
NSSCMSMessage* NSS_CMSMessage_Create ( PLArenaPool poolp)

Definition at line 58 of file cmsmessage.c.

{
    void *mark = NULL;
    NSSCMSMessage *cmsg;
    PRBool poolp_is_ours = PR_FALSE;

    if (poolp == NULL) {
       poolp = PORT_NewArena (1024);           /* XXX what is right value? */
       if (poolp == NULL)
           return NULL;
       poolp_is_ours = PR_TRUE;
    } 

    if (!poolp_is_ours)
       mark = PORT_ArenaMark(poolp);

    cmsg = (NSSCMSMessage *)PORT_ArenaZAlloc (poolp, sizeof(NSSCMSMessage));
    if (cmsg == NULL) {
       if (!poolp_is_ours) {
           if (mark) {
              PORT_ArenaRelease(poolp, mark);
           }
       } else
           PORT_FreeArena(poolp, PR_FALSE);
       return NULL;
    }

    cmsg->poolp = poolp;
    cmsg->poolp_is_ours = poolp_is_ours;
    cmsg->refCount = 1;

    if (mark)
       PORT_ArenaUnmark(poolp, mark);

    return cmsg;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void NSS_CMSMessage_Destroy ( NSSCMSMessage *  cmsg)

Definition at line 122 of file cmsmessage.c.

{
    PORT_Assert (cmsg->refCount > 0);
    if (cmsg->refCount <= 0)       /* oops */
       return;

    cmsg->refCount--;              /* thread safety? */
    if (cmsg->refCount > 0)
       return;

    NSS_CMSContentInfo_Destroy(&(cmsg->contentInfo));

    /* if poolp is not NULL, cmsg is the owner of its arena */
    if (cmsg->poolp_is_ours)
       PORT_FreeArena (cmsg->poolp, PR_FALSE);   /* XXX clear it? */
}

Here is the call graph for this function:

Here is the caller graph for this function:

PLArenaPool* NSS_CMSMessage_GetArena ( NSSCMSMessage *  cmsg)

Definition at line 161 of file cmsmessage.c.

{
    return cmsg->poolp;
}
SECItem* NSS_CMSMessage_GetContent ( NSSCMSMessage *  cmsg)

Definition at line 181 of file cmsmessage.c.

{
    /* this is a shortcut */
    NSSCMSContentInfo * cinfo = NSS_CMSMessage_GetContentInfo(cmsg);
    SECItem           * pItem = NSS_CMSContentInfo_GetInnerContent(cinfo);
    return pItem;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSSCMSContentInfo* NSS_CMSMessage_GetContentInfo ( NSSCMSMessage *  cmsg)

Definition at line 170 of file cmsmessage.c.

{
    return &(cmsg->contentInfo);
}

Here is the caller graph for this function:

PRBool NSS_CMSMessage_IsContentEmpty ( NSSCMSMessage *  cmsg,
unsigned int  minLen 
)

Definition at line 305 of file cmsmessage.c.

{
    SECItem *item = NULL;

    if (cmsg == NULL)
       return PR_TRUE;

    item = NSS_CMSContentInfo_GetContent(NSS_CMSMessage_GetContentInfo(cmsg));

    if (!item) {
       return PR_TRUE;
    } else if(item->len <= minLen) {
       return PR_TRUE;
    }

    return PR_FALSE;
}

Here is the call graph for this function:

PRBool NSS_CMSMessage_IsEncrypted ( NSSCMSMessage *  cmsg)

Definition at line 250 of file cmsmessage.c.

{
    NSSCMSContentInfo *cinfo;

    /* walk down the chain of contentinfos */
    for (cinfo = &(cmsg->contentInfo); cinfo != NULL; cinfo = NSS_CMSContentInfo_GetChildContentInfo(cinfo))
    {
       switch (NSS_CMSContentInfo_GetContentTypeTag(cinfo)) {
       case SEC_OID_PKCS7_ENVELOPED_DATA:
       case SEC_OID_PKCS7_ENCRYPTED_DATA:
           return PR_TRUE;
       default:
           break;
       }
    }
    return PR_FALSE;
}

Here is the call graph for this function:

PRBool NSS_CMSMessage_IsSigned ( NSSCMSMessage *  cmsg)

Definition at line 279 of file cmsmessage.c.

{
    NSSCMSContentInfo *cinfo;

    /* walk down the chain of contentinfos */
    for (cinfo = &(cmsg->contentInfo); cinfo != NULL; cinfo = NSS_CMSContentInfo_GetChildContentInfo(cinfo))
    {
       switch (NSS_CMSContentInfo_GetContentTypeTag(cinfo)) {
       case SEC_OID_PKCS7_SIGNED_DATA:
           if (!NSS_CMSArray_IsEmpty((void **)cinfo->content.signedData->signerInfos))
              return PR_TRUE;
           break;
       default:
           break;
       }
    }
    return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void NSS_CMSMessage_SetEncodingParams ( NSSCMSMessage *  cmsg,
PK11PasswordFunc  pwfn,
void pwfn_arg,
NSSCMSGetDecryptKeyCallback  decrypt_key_cb,
void decrypt_key_cb_arg,
SECAlgorithmID **  detached_digestalgs,
SECItem **  detached_digests 
)

Definition at line 104 of file cmsmessage.c.

{
    if (pwfn)
       PK11_SetPasswordFunc(pwfn);
    cmsg->pwfn_arg = pwfn_arg;
    cmsg->decrypt_key_cb = decrypt_key_cb;
    cmsg->decrypt_key_cb_arg = decrypt_key_cb_arg;
    cmsg->detached_digestalgs = detached_digestalgs;
    cmsg->detached_digests = detached_digests;
}

Here is the call graph for this function:

Here is the caller graph for this function: