summaryrefslogtreecommitdiff
path: root/nss/lib/smime/cmsmessage.c
diff options
context:
space:
mode:
Diffstat (limited to 'nss/lib/smime/cmsmessage.c')
-rw-r--r--nss/lib/smime/cmsmessage.c112
1 files changed, 57 insertions, 55 deletions
diff --git a/nss/lib/smime/cmsmessage.c b/nss/lib/smime/cmsmessage.c
index a44fb0b..27d1256 100644
--- a/nss/lib/smime/cmsmessage.c
+++ b/nss/lib/smime/cmsmessage.c
@@ -28,7 +28,7 @@ NSS_CMSMessage_Create(PLArenaPool *poolp)
PRBool poolp_is_ours = PR_FALSE;
if (poolp == NULL) {
- poolp = PORT_NewArena (1024); /* XXX what is right value? */
+ poolp = PORT_NewArena(1024); /* XXX what is right value? */
if (poolp == NULL)
return NULL;
poolp_is_ours = PR_TRUE;
@@ -54,7 +54,7 @@ NSS_CMSMessage_Create(PLArenaPool *poolp)
cmsg->refCount = 1;
if (mark)
- PORT_ArenaUnmark(poolp, mark);
+ PORT_ArenaUnmark(poolp, mark);
return cmsg;
}
@@ -69,12 +69,12 @@ 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)
+ PK11PasswordFunc pwfn, void *pwfn_arg,
+ NSSCMSGetDecryptKeyCallback decrypt_key_cb, void *decrypt_key_cb_arg,
+ SECAlgorithmID **detached_digestalgs, SECItem **detached_digests)
{
if (pwfn)
- PK11_SetPasswordFunc(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;
@@ -88,23 +88,23 @@ NSS_CMSMessage_SetEncodingParams(NSSCMSMessage *cmsg,
void
NSS_CMSMessage_Destroy(NSSCMSMessage *cmsg)
{
- PORT_Assert (cmsg->refCount > 0);
- if (cmsg->refCount <= 0) /* oops */
- return;
+ PORT_Assert(cmsg->refCount > 0);
+ if (cmsg->refCount <= 0) /* oops */
+ return;
- cmsg->refCount--; /* thread safety? */
+ cmsg->refCount--; /* thread safety? */
if (cmsg->refCount > 0)
- return;
+ 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? */
+ PORT_FreeArena(cmsg->poolp, PR_FALSE); /* XXX clear it? */
}
/*
- * NSS_CMSMessage_Copy - return a copy of the given message.
+ * NSS_CMSMessage_Copy - return a copy of the given message.
*
* The copy may be virtual or may be real -- either way, the result needs
* to be passed to NSS_CMSMessage_Destroy later (as does the original).
@@ -113,9 +113,9 @@ NSSCMSMessage *
NSS_CMSMessage_Copy(NSSCMSMessage *cmsg)
{
if (cmsg == NULL)
- return NULL;
+ return NULL;
- PORT_Assert (cmsg->refCount > 0);
+ PORT_Assert(cmsg->refCount > 0);
cmsg->refCount++; /* XXX chrisk thread safety? */
return cmsg;
@@ -140,7 +140,7 @@ NSS_CMSMessage_GetContentInfo(NSSCMSMessage *cmsg)
}
/*
- * Return a pointer to the actual content.
+ * Return a pointer to the actual content.
* In the case of those types which are encrypted, this returns the *plain* content.
* In case of nested contentInfos, this descends and retrieves the innermost content.
*/
@@ -148,8 +148,8 @@ SECItem *
NSS_CMSMessage_GetContent(NSSCMSMessage *cmsg)
{
/* this is a shortcut */
- NSSCMSContentInfo * cinfo = NSS_CMSMessage_GetContentInfo(cmsg);
- SECItem * pItem = NSS_CMSContentInfo_GetInnerContent(cinfo);
+ NSSCMSContentInfo *cinfo = NSS_CMSMessage_GetContentInfo(cmsg);
+ SECItem *pItem = NSS_CMSContentInfo_GetInnerContent(cinfo);
return pItem;
}
@@ -165,9 +165,9 @@ NSS_CMSMessage_ContentLevelCount(NSSCMSMessage *cmsg)
NSSCMSContentInfo *cinfo;
/* walk down the chain of contentinfos */
- for (cinfo = &(cmsg->contentInfo); cinfo != NULL; ) {
- count++;
- cinfo = NSS_CMSContentInfo_GetChildContentInfo(cinfo);
+ for (cinfo = &(cmsg->contentInfo); cinfo != NULL;) {
+ count++;
+ cinfo = NSS_CMSContentInfo_GetChildContentInfo(cinfo);
}
return count;
}
@@ -184,8 +184,9 @@ NSS_CMSMessage_ContentLevel(NSSCMSMessage *cmsg, int n)
NSSCMSContentInfo *cinfo;
/* walk down the chain of contentinfos */
- for (cinfo = &(cmsg->contentInfo); cinfo != NULL && count < n; cinfo = NSS_CMSContentInfo_GetChildContentInfo(cinfo)) {
- count++;
+ for (cinfo = &(cmsg->contentInfo); cinfo != NULL && count < n;
+ cinfo = NSS_CMSContentInfo_GetChildContentInfo(cinfo)) {
+ count++;
}
return cinfo;
@@ -200,13 +201,14 @@ NSS_CMSMessage_ContainsCertsOrCrls(NSSCMSMessage *cmsg)
NSSCMSContentInfo *cinfo;
/* descend into CMS message */
- for (cinfo = &(cmsg->contentInfo); cinfo != NULL; cinfo = NSS_CMSContentInfo_GetChildContentInfo(cinfo)) {
- if (!NSS_CMSType_IsData(NSS_CMSContentInfo_GetContentTypeTag(cinfo)))
- continue; /* next level */
-
- if (NSS_CMSSignedData_ContainsCertsOrCrls(cinfo->content.signedData))
- return PR_TRUE;
- /* callback here for generic wrappers? */
+ for (cinfo = &(cmsg->contentInfo); cinfo != NULL;
+ cinfo = NSS_CMSContentInfo_GetChildContentInfo(cinfo)) {
+ if (!NSS_CMSType_IsData(NSS_CMSContentInfo_GetContentTypeTag(cinfo)))
+ continue; /* next level */
+
+ if (NSS_CMSSignedData_ContainsCertsOrCrls(cinfo->content.signedData))
+ return PR_TRUE;
+ /* callback here for generic wrappers? */
}
return PR_FALSE;
}
@@ -220,16 +222,16 @@ NSS_CMSMessage_IsEncrypted(NSSCMSMessage *cmsg)
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:
- /* callback here for generic wrappers? */
- break;
- }
+ 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:
+ /* callback here for generic wrappers? */
+ break;
+ }
}
return PR_FALSE;
}
@@ -250,17 +252,17 @@ NSS_CMSMessage_IsSigned(NSSCMSMessage *cmsg)
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:
- /* callback here for generic wrappers? */
- break;
- }
+ 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:
+ /* callback here for generic wrappers? */
+ break;
+ }
}
return PR_FALSE;
}
@@ -277,14 +279,14 @@ NSS_CMSMessage_IsContentEmpty(NSSCMSMessage *cmsg, unsigned int minLen)
SECItem *item = NULL;
if (cmsg == NULL)
- return PR_TRUE;
+ 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_TRUE;
+ } else if (item->len <= minLen) {
+ return PR_TRUE;
}
return PR_FALSE;