#include "cmslocal.h"
#include "secasn1.h"
#include "secoid.h"
#include "secerr.h"
extern const SEC_ASN1Template nss_cms_set_of_attribute_template[];
SEC_ASN1_MKSUB(SECOID_AlgorithmIDTemplate)
SEC_ASN1_MKSUB(SEC_BitStringTemplate)
SEC_ASN1_MKSUB(SEC_OctetStringTemplate)
SEC_ASN1_MKSUB(SEC_PointerToOctetStringTemplate)
SEC_ASN1_MKSUB(SEC_SetOfAnyTemplate)
static const SEC_ASN1Template *
nss_cms_choose_content_template(void *src_or_dest, PRBool encoding, const char *buf, void *dest);
static const SEC_ASN1TemplateChooserPtr nss_cms_chooser
= nss_cms_choose_content_template;
const SEC_ASN1Template SecCmsMessageTemplate[] = {
{ SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM,
0, NULL, sizeof(SecCmsMessage) },
{ SEC_ASN1_OBJECT_ID,
offsetof(SecCmsMessage,contentInfo.contentType) },
{ SEC_ASN1_OPTIONAL | SEC_ASN1_DYNAMIC | SEC_ASN1_MAY_STREAM
| SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0,
offsetof(SecCmsMessage,contentInfo.content),
&nss_cms_chooser },
{ 0 }
};
static const SEC_ASN1Template NSS_PointerToCMSMessageTemplate[] = {
{ SEC_ASN1_POINTER, 0, SecCmsMessageTemplate }
};
static const SEC_ASN1Template SecCmsEncapsulatedContentInfoTemplate[] = {
{ SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM,
0, NULL, sizeof(SecCmsContentInfo) },
{ SEC_ASN1_OBJECT_ID,
offsetof(SecCmsContentInfo,contentType) },
{ SEC_ASN1_OPTIONAL | SEC_ASN1_EXPLICIT | SEC_ASN1_MAY_STREAM |
SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | SEC_ASN1_XTRN | 0,
offsetof(SecCmsContentInfo,rawContent),
SEC_ASN1_SUB(SEC_PointerToOctetStringTemplate) },
{ 0 }
};
static const SEC_ASN1Template SecCmsEncryptedContentInfoTemplate[] = {
{ SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM,
0, NULL, sizeof(SecCmsContentInfo) },
{ SEC_ASN1_OBJECT_ID,
offsetof(SecCmsContentInfo,contentType) },
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
offsetof(SecCmsContentInfo,contentEncAlg),
SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
{ SEC_ASN1_OPTIONAL | SEC_ASN1_POINTER | SEC_ASN1_MAY_STREAM |
SEC_ASN1_CONTEXT_SPECIFIC | SEC_ASN1_XTRN | 0,
offsetof(SecCmsContentInfo,rawContent),
SEC_ASN1_SUB(SEC_OctetStringTemplate) },
{ 0 }
};
const SEC_ASN1Template SecCmsSignerInfoTemplate[];
const SEC_ASN1Template SecCmsSignedDataTemplate[] = {
{ SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM,
0, NULL, sizeof(SecCmsSignedData) },
{ SEC_ASN1_INTEGER | SEC_ASN1_SIGNED_INT,
offsetof(SecCmsSignedData,version) },
{ SEC_ASN1_SET_OF | SEC_ASN1_XTRN,
offsetof(SecCmsSignedData,digestAlgorithms),
SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
{ SEC_ASN1_INLINE,
offsetof(SecCmsSignedData,contentInfo),
SecCmsEncapsulatedContentInfoTemplate },
{ SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC |
SEC_ASN1_XTRN | 0,
offsetof(SecCmsSignedData,rawCerts),
SEC_ASN1_SUB(SEC_SetOfAnyTemplate) },
{ SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC |
SEC_ASN1_XTRN | 1,
offsetof(SecCmsSignedData,rawCrls),
SEC_ASN1_SUB(SEC_SetOfAnyTemplate) },
{ SEC_ASN1_SET_OF,
offsetof(SecCmsSignedData,signerInfos),
SecCmsSignerInfoTemplate },
{ 0 }
};
const SEC_ASN1Template NSS_PointerToCMSSignedDataTemplate[] = {
{ SEC_ASN1_POINTER, 0, SecCmsSignedDataTemplate }
};
static const SEC_ASN1Template SecCmsSignerIdentifierTemplate[] = {
{ SEC_ASN1_CHOICE,
offsetof(SecCmsSignerIdentifier,identifierType), NULL,
sizeof(SecCmsSignerIdentifier) },
{ SEC_ASN1_POINTER | SEC_ASN1_CONTEXT_SPECIFIC | SEC_ASN1_XTRN | 0,
offsetof(SecCmsSignerIdentifier,id.subjectKeyID),
SEC_ASN1_SUB(SEC_OctetStringTemplate) ,
SecCmsRecipientIDSubjectKeyID },
{ SEC_ASN1_POINTER | SEC_ASN1_XTRN,
offsetof(SecCmsSignerIdentifier,id.issuerAndSN),
SEC_ASN1_SUB(SecCmsIssuerAndSNTemplate),
SecCmsRecipientIDIssuerSN },
{ 0 }
};
const SEC_ASN1Template SecCmsSignerInfoTemplate[] = {
{ SEC_ASN1_SEQUENCE,
0, NULL, sizeof(SecCmsSignerInfo) },
{ SEC_ASN1_INTEGER | SEC_ASN1_SIGNED_INT,
offsetof(SecCmsSignerInfo,version) },
{ SEC_ASN1_INLINE,
offsetof(SecCmsSignerInfo,signerIdentifier),
SecCmsSignerIdentifierTemplate },
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
offsetof(SecCmsSignerInfo,digestAlg),
SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
{ SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0,
offsetof(SecCmsSignerInfo,authAttr),
nss_cms_set_of_attribute_template },
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
offsetof(SecCmsSignerInfo,digestEncAlg),
SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
{ SEC_ASN1_OCTET_STRING,
offsetof(SecCmsSignerInfo,encDigest) },
{ SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1,
offsetof(SecCmsSignerInfo,unAuthAttr),
nss_cms_set_of_attribute_template },
{ 0 }
};
static const SEC_ASN1Template SecCmsOriginatorInfoTemplate[] = {
{ SEC_ASN1_SEQUENCE,
0, NULL, sizeof(SecCmsOriginatorInfo) },
{ SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC |
SEC_ASN1_XTRN | 0,
offsetof(SecCmsOriginatorInfo,rawCerts),
SEC_ASN1_SUB(SEC_SetOfAnyTemplate) },
{ SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC |
SEC_ASN1_XTRN | 1,
offsetof(SecCmsOriginatorInfo,rawCrls),
SEC_ASN1_SUB(SEC_SetOfAnyTemplate) },
{ 0 }
};
const SEC_ASN1Template SecCmsRecipientInfoTemplate[];
const SEC_ASN1Template SecCmsEnvelopedDataTemplate[] = {
{ SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM,
0, NULL, sizeof(SecCmsEnvelopedData) },
{ SEC_ASN1_INTEGER | SEC_ASN1_SIGNED_INT,
offsetof(SecCmsEnvelopedData,version) },
{ SEC_ASN1_OPTIONAL | SEC_ASN1_POINTER | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0,
offsetof(SecCmsEnvelopedData,originatorInfo),
SecCmsOriginatorInfoTemplate },
{ SEC_ASN1_SET_OF,
offsetof(SecCmsEnvelopedData,recipientInfos),
SecCmsRecipientInfoTemplate },
{ SEC_ASN1_INLINE,
offsetof(SecCmsEnvelopedData,contentInfo),
SecCmsEncryptedContentInfoTemplate },
{ SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1,
offsetof(SecCmsEnvelopedData,unprotectedAttr),
nss_cms_set_of_attribute_template },
{ 0 }
};
const SEC_ASN1Template NSS_PointerToCMSEnvelopedDataTemplate[] = {
{ SEC_ASN1_POINTER, 0, SecCmsEnvelopedDataTemplate }
};
static const SEC_ASN1Template SecCmsRecipientIdentifierTemplate[] = {
{ SEC_ASN1_CHOICE,
offsetof(SecCmsRecipientIdentifier,identifierType), NULL,
sizeof(SecCmsRecipientIdentifier) },
{ SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC |
SEC_ASN1_XTRN | 0,
offsetof(SecCmsRecipientIdentifier,id.subjectKeyID),
SEC_ASN1_SUB(SEC_PointerToOctetStringTemplate) ,
SecCmsRecipientIDSubjectKeyID },
{ SEC_ASN1_POINTER | SEC_ASN1_XTRN,
offsetof(SecCmsRecipientIdentifier,id.issuerAndSN),
SEC_ASN1_SUB(SecCmsIssuerAndSNTemplate),
SecCmsRecipientIDIssuerSN },
{ 0 }
};
static const SEC_ASN1Template SecCmsKeyTransRecipientInfoTemplate[] = {
{ SEC_ASN1_SEQUENCE,
0, NULL, sizeof(SecCmsKeyTransRecipientInfo) },
{ SEC_ASN1_INTEGER | SEC_ASN1_SIGNED_INT,
offsetof(SecCmsKeyTransRecipientInfo,version) },
{ SEC_ASN1_INLINE,
offsetof(SecCmsKeyTransRecipientInfo,recipientIdentifier),
SecCmsRecipientIdentifierTemplate },
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
offsetof(SecCmsKeyTransRecipientInfo,keyEncAlg),
SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
{ SEC_ASN1_OCTET_STRING,
offsetof(SecCmsKeyTransRecipientInfo,encKey) },
{ 0 }
};
static const SEC_ASN1Template SecCmsOriginatorPublicKeyTemplate[] = {
{ SEC_ASN1_SEQUENCE,
0, NULL, sizeof(SecCmsOriginatorPublicKey) },
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
offsetof(SecCmsOriginatorPublicKey,algorithmIdentifier),
SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
offsetof(SecCmsOriginatorPublicKey,publicKey),
SEC_ASN1_SUB(SEC_BitStringTemplate) },
{ 0 }
};
static const SEC_ASN1Template SecCmsOriginatorIdentifierOrKeyTemplate[] = {
{ SEC_ASN1_CHOICE,
offsetof(SecCmsOriginatorIdentifierOrKey,identifierType), NULL,
sizeof(SecCmsOriginatorIdentifierOrKey) },
{ SEC_ASN1_POINTER | SEC_ASN1_XTRN,
offsetof(SecCmsOriginatorIdentifierOrKey,id.issuerAndSN),
SEC_ASN1_SUB(SecCmsIssuerAndSNTemplate),
SecCmsOriginatorIDOrKeyIssuerSN },
{ SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC |
SEC_ASN1_XTRN | 1,
offsetof(SecCmsOriginatorIdentifierOrKey,id.subjectKeyID),
SEC_ASN1_SUB(SEC_PointerToOctetStringTemplate) ,
SecCmsOriginatorIDOrKeySubjectKeyID },
{ SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 2,
offsetof(SecCmsOriginatorIdentifierOrKey,id.originatorPublicKey),
SecCmsOriginatorPublicKeyTemplate,
SecCmsOriginatorIDOrKeyOriginatorPublicKey },
{ 0 }
};
const SEC_ASN1Template SecCmsRecipientKeyIdentifierTemplate[] = {
{ SEC_ASN1_SEQUENCE,
0, NULL, sizeof(SecCmsRecipientKeyIdentifier) },
{ SEC_ASN1_OCTET_STRING,
offsetof(SecCmsRecipientKeyIdentifier,subjectKeyIdentifier) },
{ SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING,
offsetof(SecCmsRecipientKeyIdentifier,date) },
{ SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING,
offsetof(SecCmsRecipientKeyIdentifier,other) },
{ 0 }
};
static const SEC_ASN1Template SecCmsKeyAgreeRecipientIdentifierTemplate[] = {
{ SEC_ASN1_CHOICE,
offsetof(SecCmsKeyAgreeRecipientIdentifier,identifierType), NULL,
sizeof(SecCmsKeyAgreeRecipientIdentifier) },
{ SEC_ASN1_POINTER | SEC_ASN1_XTRN,
offsetof(SecCmsKeyAgreeRecipientIdentifier,id.issuerAndSN),
SEC_ASN1_SUB(SecCmsIssuerAndSNTemplate),
SecCmsKeyAgreeRecipientIDIssuerSN },
{ SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0,
offsetof(SecCmsKeyAgreeRecipientIdentifier,id.recipientKeyIdentifier),
SecCmsRecipientKeyIdentifierTemplate,
SecCmsKeyAgreeRecipientIDRKeyID },
{ 0 }
};
static const SEC_ASN1Template SecCmsRecipientEncryptedKeyTemplate[] = {
{ SEC_ASN1_SEQUENCE,
0, NULL, sizeof(SecCmsRecipientEncryptedKey) },
{ SEC_ASN1_INLINE,
offsetof(SecCmsRecipientEncryptedKey,recipientIdentifier),
SecCmsKeyAgreeRecipientIdentifierTemplate },
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
offsetof(SecCmsRecipientEncryptedKey,encKey),
SEC_ASN1_SUB(SEC_BitStringTemplate) },
{ 0 }
};
static const SEC_ASN1Template SecCmsKeyAgreeRecipientInfoTemplate[] = {
{ SEC_ASN1_SEQUENCE,
0, NULL, sizeof(SecCmsKeyAgreeRecipientInfo) },
{ SEC_ASN1_INTEGER | SEC_ASN1_SIGNED_INT,
offsetof(SecCmsKeyAgreeRecipientInfo,version) },
{ SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0,
offsetof(SecCmsKeyAgreeRecipientInfo,originatorIdentifierOrKey),
SecCmsOriginatorIdentifierOrKeyTemplate },
{ SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_EXPLICIT |
SEC_ASN1_CONTEXT_SPECIFIC | SEC_ASN1_XTRN | 1,
offsetof(SecCmsKeyAgreeRecipientInfo,ukm),
SEC_ASN1_SUB(SEC_OctetStringTemplate) },
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
offsetof(SecCmsKeyAgreeRecipientInfo,keyEncAlg),
SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
{ SEC_ASN1_SEQUENCE_OF,
offsetof(SecCmsKeyAgreeRecipientInfo,recipientEncryptedKeys),
SecCmsRecipientEncryptedKeyTemplate },
{ 0 }
};
static const SEC_ASN1Template SecCmsKEKIdentifierTemplate[] = {
{ SEC_ASN1_SEQUENCE,
0, NULL, sizeof(SecCmsKEKIdentifier) },
{ SEC_ASN1_OCTET_STRING,
offsetof(SecCmsKEKIdentifier,keyIdentifier) },
{ SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING,
offsetof(SecCmsKEKIdentifier,date) },
{ SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING,
offsetof(SecCmsKEKIdentifier,other) },
{ 0 }
};
static const SEC_ASN1Template SecCmsKEKRecipientInfoTemplate[] = {
{ SEC_ASN1_SEQUENCE,
0, NULL, sizeof(SecCmsKEKRecipientInfo) },
{ SEC_ASN1_INTEGER | SEC_ASN1_SIGNED_INT,
offsetof(SecCmsKEKRecipientInfo,version) },
{ SEC_ASN1_INLINE,
offsetof(SecCmsKEKRecipientInfo,kekIdentifier),
SecCmsKEKIdentifierTemplate },
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
offsetof(SecCmsKEKRecipientInfo,keyEncAlg),
SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
{ SEC_ASN1_OCTET_STRING,
offsetof(SecCmsKEKRecipientInfo,encKey) },
{ 0 }
};
const SEC_ASN1Template SecCmsRecipientInfoTemplate[] = {
{ SEC_ASN1_CHOICE,
offsetof(SecCmsRecipientInfo,recipientInfoType), NULL,
sizeof(SecCmsRecipientInfo) },
{ SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1,
offsetof(SecCmsRecipientInfo,ri.keyAgreeRecipientInfo),
SecCmsKeyAgreeRecipientInfoTemplate,
SecCmsRecipientInfoIDKeyAgree },
{ SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 2,
offsetof(SecCmsRecipientInfo,ri.kekRecipientInfo),
SecCmsKEKRecipientInfoTemplate,
SecCmsRecipientInfoIDKEK },
{ SEC_ASN1_INLINE,
offsetof(SecCmsRecipientInfo,ri.keyTransRecipientInfo),
SecCmsKeyTransRecipientInfoTemplate,
SecCmsRecipientInfoIDKeyTrans },
{ 0 }
};
const SEC_ASN1Template SecCmsDigestedDataTemplate[] = {
{ SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM,
0, NULL, sizeof(SecCmsDigestedData) },
{ SEC_ASN1_INTEGER | SEC_ASN1_SIGNED_INT,
offsetof(SecCmsDigestedData,version) },
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
offsetof(SecCmsDigestedData,digestAlg),
SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
{ SEC_ASN1_INLINE,
offsetof(SecCmsDigestedData,contentInfo),
SecCmsEncapsulatedContentInfoTemplate },
{ SEC_ASN1_OCTET_STRING,
offsetof(SecCmsDigestedData,digest) },
{ 0 }
};
const SEC_ASN1Template NSS_PointerToCMSDigestedDataTemplate[] = {
{ SEC_ASN1_POINTER, 0, SecCmsDigestedDataTemplate }
};
const SEC_ASN1Template SecCmsEncryptedDataTemplate[] = {
{ SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM,
0, NULL, sizeof(SecCmsEncryptedData) },
{ SEC_ASN1_INTEGER | SEC_ASN1_SIGNED_INT,
offsetof(SecCmsEncryptedData,version) },
{ SEC_ASN1_INLINE,
offsetof(SecCmsEncryptedData,contentInfo),
SecCmsEncryptedContentInfoTemplate },
{ SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1,
offsetof(SecCmsEncryptedData,unprotectedAttr),
nss_cms_set_of_attribute_template },
{ 0 }
};
const SEC_ASN1Template NSS_PointerToCMSEncryptedDataTemplate[] = {
{ SEC_ASN1_POINTER, 0, SecCmsEncryptedDataTemplate }
};
const SEC_ASN1Template SecCmsIssuerAndSNTemplate[] = {
{ SEC_ASN1_SEQUENCE,
0, NULL, sizeof(SecCmsIssuerAndSN) },
#if 1 // @@@ Switch to using NSS_NameTemplate
{ SEC_ASN1_ANY,
offsetof(SecCmsIssuerAndSN,derIssuer) },
#else
{ SEC_ASN1_INLINE,
offsetof(SecCmsIssuerAndSN,issuer),
NSS_NameTemplate },
#endif
{ SEC_ASN1_INTEGER | SEC_ASN1_SIGNED_INT,
offsetof(SecCmsIssuerAndSN,serialNumber) },
{ 0 }
};
const SEC_ASN1Template NSS_SMIMEKEAParamTemplateSkipjack[] = {
{ SEC_ASN1_SEQUENCE,
0, NULL, sizeof(SecCmsSMIMEKEAParameters) },
{ SEC_ASN1_OCTET_STRING ,
offsetof(SecCmsSMIMEKEAParameters,originatorKEAKey) },
{ SEC_ASN1_OCTET_STRING,
offsetof(SecCmsSMIMEKEAParameters,originatorRA) },
{ 0 }
};
const SEC_ASN1Template NSS_SMIMEKEAParamTemplateNoSkipjack[] = {
{ SEC_ASN1_SEQUENCE,
0, NULL, sizeof(SecCmsSMIMEKEAParameters) },
{ SEC_ASN1_OCTET_STRING ,
offsetof(SecCmsSMIMEKEAParameters,originatorKEAKey) },
{ SEC_ASN1_OCTET_STRING,
offsetof(SecCmsSMIMEKEAParameters,originatorRA) },
{ SEC_ASN1_OCTET_STRING | SEC_ASN1_OPTIONAL ,
offsetof(SecCmsSMIMEKEAParameters,nonSkipjackIV) },
{ 0 }
};
const SEC_ASN1Template NSS_SMIMEKEAParamTemplateAllParams[] = {
{ SEC_ASN1_SEQUENCE,
0, NULL, sizeof(SecCmsSMIMEKEAParameters) },
{ SEC_ASN1_OCTET_STRING ,
offsetof(SecCmsSMIMEKEAParameters,originatorKEAKey) },
{ SEC_ASN1_OCTET_STRING,
offsetof(SecCmsSMIMEKEAParameters,originatorRA) },
{ SEC_ASN1_OCTET_STRING | SEC_ASN1_OPTIONAL ,
offsetof(SecCmsSMIMEKEAParameters,nonSkipjackIV) },
{ SEC_ASN1_OCTET_STRING | SEC_ASN1_OPTIONAL ,
offsetof(SecCmsSMIMEKEAParameters,bulkKeySize) },
{ 0 }
};
const SEC_ASN1Template *
nss_cms_get_kea_template(SecCmsKEATemplateSelector whichTemplate)
{
const SEC_ASN1Template *returnVal = NULL;
switch(whichTemplate)
{
case SecCmsKEAUsesNonSkipjack:
returnVal = NSS_SMIMEKEAParamTemplateNoSkipjack;
break;
case SecCmsKEAUsesSkipjack:
returnVal = NSS_SMIMEKEAParamTemplateSkipjack;
break;
case SecCmsKEAUsesNonSkipjackWithPaddedEncKey:
default:
returnVal = NSS_SMIMEKEAParamTemplateAllParams;
break;
}
return returnVal;
}
static const SEC_ASN1Template *
nss_cms_choose_content_template(void *src_or_dest, PRBool encoding, const char *buf, void *dest)
{
const SEC_ASN1Template *theTemplate;
SecCmsContentInfo *cinfo;
PORT_Assert (src_or_dest != NULL);
if (src_or_dest == NULL)
return NULL;
cinfo = (SecCmsContentInfo *)src_or_dest;
switch (SecCmsContentInfoGetContentTypeTag(cinfo)) {
default:
theTemplate = SEC_ASN1_GET(SEC_PointerToAnyTemplate);
break;
case SEC_OID_PKCS7_DATA:
theTemplate = SEC_ASN1_GET(SEC_PointerToOctetStringTemplate);
break;
case SEC_OID_PKCS7_SIGNED_DATA:
theTemplate = NSS_PointerToCMSSignedDataTemplate;
break;
case SEC_OID_PKCS7_ENVELOPED_DATA:
theTemplate = NSS_PointerToCMSEnvelopedDataTemplate;
break;
case SEC_OID_PKCS7_DIGESTED_DATA:
theTemplate = NSS_PointerToCMSDigestedDataTemplate;
break;
case SEC_OID_PKCS7_ENCRYPTED_DATA:
theTemplate = NSS_PointerToCMSEncryptedDataTemplate;
break;
}
return theTemplate;
}