cmsasn1.c

来自「支持SSL v2/v3, TLS, PKCS #5, PKCS #7, PKCS」· C语言 代码 · 共 561 行 · 第 1/2 页

C
561
字号
    { SEC_ASN1_INLINE,	  offsetof(NSSCMSOriginatorPublicKey,publicKey),	  SEC_BitStringTemplate },    { 0 }};static const SEC_ASN1Template NSSCMSOriginatorIdentifierOrKeyTemplate[] = {    { SEC_ASN1_CHOICE,	  offsetof(NSSCMSOriginatorIdentifierOrKey,identifierType), NULL,	  sizeof(NSSCMSOriginatorIdentifierOrKey) },    { SEC_ASN1_POINTER,	  offsetof(NSSCMSOriginatorIdentifierOrKey,id.issuerAndSN),	  CERT_IssuerAndSNTemplate,	  NSSCMSOriginatorIDOrKey_IssuerSN },    { SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1,	  offsetof(NSSCMSOriginatorIdentifierOrKey,id.subjectKeyID),	  SEC_PointerToOctetStringTemplate,	  NSSCMSOriginatorIDOrKey_SubjectKeyID },    { SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 2,	  offsetof(NSSCMSOriginatorIdentifierOrKey,id.originatorPublicKey),	  NSSCMSOriginatorPublicKeyTemplate,	  NSSCMSOriginatorIDOrKey_OriginatorPublicKey },    { 0 }};const SEC_ASN1Template NSSCMSRecipientKeyIdentifierTemplate[] = {    { SEC_ASN1_SEQUENCE,	  0, NULL, sizeof(NSSCMSRecipientKeyIdentifier) },    { SEC_ASN1_OCTET_STRING,	  offsetof(NSSCMSRecipientKeyIdentifier,subjectKeyIdentifier) },    { SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING,	  offsetof(NSSCMSRecipientKeyIdentifier,date) },    { SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING,	  offsetof(NSSCMSRecipientKeyIdentifier,other) },    { 0 }};static const SEC_ASN1Template NSSCMSKeyAgreeRecipientIdentifierTemplate[] = {    { SEC_ASN1_CHOICE,	  offsetof(NSSCMSKeyAgreeRecipientIdentifier,identifierType), NULL,	  sizeof(NSSCMSKeyAgreeRecipientIdentifier) },    { SEC_ASN1_POINTER,	  offsetof(NSSCMSKeyAgreeRecipientIdentifier,id.issuerAndSN),	  CERT_IssuerAndSNTemplate,	  NSSCMSKeyAgreeRecipientID_IssuerSN },    { SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0,	  offsetof(NSSCMSKeyAgreeRecipientIdentifier,id.recipientKeyIdentifier),	  NSSCMSRecipientKeyIdentifierTemplate,	  NSSCMSKeyAgreeRecipientID_RKeyID },    { 0 }};static const SEC_ASN1Template NSSCMSRecipientEncryptedKeyTemplate[] = {    { SEC_ASN1_SEQUENCE,	  0, NULL, sizeof(NSSCMSRecipientEncryptedKey) },    { SEC_ASN1_INLINE,	  offsetof(NSSCMSRecipientEncryptedKey,recipientIdentifier),	  NSSCMSKeyAgreeRecipientIdentifierTemplate },    { SEC_ASN1_INLINE,	  offsetof(NSSCMSRecipientEncryptedKey,encKey),	  SEC_BitStringTemplate },    { 0 }};static const SEC_ASN1Template NSSCMSKeyAgreeRecipientInfoTemplate[] = {    { SEC_ASN1_SEQUENCE,	  0, NULL, sizeof(NSSCMSKeyAgreeRecipientInfo) },    { SEC_ASN1_INTEGER,	  offsetof(NSSCMSKeyAgreeRecipientInfo,version) },    { SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0,	  offsetof(NSSCMSKeyAgreeRecipientInfo,originatorIdentifierOrKey),	  NSSCMSOriginatorIdentifierOrKeyTemplate },    { SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_EXPLICIT |						    SEC_ASN1_CONTEXT_SPECIFIC | 1,	  offsetof(NSSCMSKeyAgreeRecipientInfo,ukm),	  SEC_OctetStringTemplate },    { SEC_ASN1_INLINE,	  offsetof(NSSCMSKeyAgreeRecipientInfo,keyEncAlg),	  SECOID_AlgorithmIDTemplate },    { SEC_ASN1_SEQUENCE_OF,	  offsetof(NSSCMSKeyAgreeRecipientInfo,recipientEncryptedKeys),	  NSSCMSRecipientEncryptedKeyTemplate },    { 0 }};/* ----------------------------------------------------------------------------- * KEK recipient info */static const SEC_ASN1Template NSSCMSKEKIdentifierTemplate[] = {    { SEC_ASN1_SEQUENCE,	  0, NULL, sizeof(NSSCMSKEKIdentifier) },    { SEC_ASN1_OCTET_STRING,	  offsetof(NSSCMSKEKIdentifier,keyIdentifier) },    { SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING,	  offsetof(NSSCMSKEKIdentifier,date) },    { SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING,	  offsetof(NSSCMSKEKIdentifier,other) },    { 0 }};static const SEC_ASN1Template NSSCMSKEKRecipientInfoTemplate[] = {    { SEC_ASN1_SEQUENCE,	  0, NULL, sizeof(NSSCMSKEKRecipientInfo) },    { SEC_ASN1_INTEGER,	  offsetof(NSSCMSKEKRecipientInfo,version) },    { SEC_ASN1_INLINE,	  offsetof(NSSCMSKEKRecipientInfo,kekIdentifier),	  NSSCMSKEKIdentifierTemplate },    { SEC_ASN1_INLINE,	  offsetof(NSSCMSKEKRecipientInfo,keyEncAlg),	  SECOID_AlgorithmIDTemplate },    { SEC_ASN1_OCTET_STRING,	  offsetof(NSSCMSKEKRecipientInfo,encKey) },    { 0 }};/* ----------------------------------------------------------------------------- * recipient info */const SEC_ASN1Template NSSCMSRecipientInfoTemplate[] = {    { SEC_ASN1_CHOICE,	  offsetof(NSSCMSRecipientInfo,recipientInfoType), NULL,	  sizeof(NSSCMSRecipientInfo) },    { SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1,	  offsetof(NSSCMSRecipientInfo,ri.keyAgreeRecipientInfo),	  NSSCMSKeyAgreeRecipientInfoTemplate,	  NSSCMSRecipientInfoID_KeyAgree },    { SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 2,	  offsetof(NSSCMSRecipientInfo,ri.kekRecipientInfo),	  NSSCMSKEKRecipientInfoTemplate,	  NSSCMSRecipientInfoID_KEK },    { SEC_ASN1_INLINE,	  offsetof(NSSCMSRecipientInfo,ri.keyTransRecipientInfo),	  NSSCMSKeyTransRecipientInfoTemplate,	  NSSCMSRecipientInfoID_KeyTrans },    { 0 }};/* ----------------------------------------------------------------------------- * */const SEC_ASN1Template NSSCMSDigestedDataTemplate[] = {    { SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM,	  0, NULL, sizeof(NSSCMSDigestedData) },    { SEC_ASN1_INTEGER,	  offsetof(NSSCMSDigestedData,version) },    { SEC_ASN1_INLINE,	  offsetof(NSSCMSDigestedData,digestAlg),	  SECOID_AlgorithmIDTemplate },    { SEC_ASN1_INLINE,	  offsetof(NSSCMSDigestedData,contentInfo),	  NSSCMSEncapsulatedContentInfoTemplate },    { SEC_ASN1_OCTET_STRING,	  offsetof(NSSCMSDigestedData,digest) },    { 0 }};const SEC_ASN1Template NSS_PointerToCMSDigestedDataTemplate[] = {    { SEC_ASN1_POINTER, 0, NSSCMSDigestedDataTemplate }};const SEC_ASN1Template NSSCMSEncryptedDataTemplate[] = {    { SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM,	  0, NULL, sizeof(NSSCMSEncryptedData) },    { SEC_ASN1_INTEGER,	  offsetof(NSSCMSEncryptedData,version) },    { SEC_ASN1_INLINE,	  offsetof(NSSCMSEncryptedData,contentInfo),	  NSSCMSEncryptedContentInfoTemplate },    { SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1,	  offsetof(NSSCMSEncryptedData,unprotectedAttr),	  nss_cms_set_of_attribute_template },    { 0 }};const SEC_ASN1Template NSS_PointerToCMSEncryptedDataTemplate[] = {    { SEC_ASN1_POINTER, 0, NSSCMSEncryptedDataTemplate }};/* ----------------------------------------------------------------------------- * FORTEZZA KEA */const SEC_ASN1Template NSS_SMIMEKEAParamTemplateSkipjack[] = {	{ SEC_ASN1_SEQUENCE,	  0, NULL, sizeof(NSSCMSSMIMEKEAParameters) },	{ SEC_ASN1_OCTET_STRING /* | SEC_ASN1_OPTIONAL */,	  offsetof(NSSCMSSMIMEKEAParameters,originatorKEAKey) },	{ SEC_ASN1_OCTET_STRING,	  offsetof(NSSCMSSMIMEKEAParameters,originatorRA) },	{ 0 }};const SEC_ASN1Template NSS_SMIMEKEAParamTemplateNoSkipjack[] = {	{ SEC_ASN1_SEQUENCE,	  0, NULL, sizeof(NSSCMSSMIMEKEAParameters) },	{ SEC_ASN1_OCTET_STRING /* | SEC_ASN1_OPTIONAL */,	  offsetof(NSSCMSSMIMEKEAParameters,originatorKEAKey) },	{ SEC_ASN1_OCTET_STRING,	  offsetof(NSSCMSSMIMEKEAParameters,originatorRA) },	{ SEC_ASN1_OCTET_STRING  | SEC_ASN1_OPTIONAL ,	  offsetof(NSSCMSSMIMEKEAParameters,nonSkipjackIV) },	{ 0 }};const SEC_ASN1Template NSS_SMIMEKEAParamTemplateAllParams[] = {	{ SEC_ASN1_SEQUENCE,	  0, NULL, sizeof(NSSCMSSMIMEKEAParameters) },	{ SEC_ASN1_OCTET_STRING /* | SEC_ASN1_OPTIONAL */,	  offsetof(NSSCMSSMIMEKEAParameters,originatorKEAKey) },	{ SEC_ASN1_OCTET_STRING,	  offsetof(NSSCMSSMIMEKEAParameters,originatorRA) },	{ SEC_ASN1_OCTET_STRING  | SEC_ASN1_OPTIONAL ,	  offsetof(NSSCMSSMIMEKEAParameters,nonSkipjackIV) },	{ SEC_ASN1_OCTET_STRING  | SEC_ASN1_OPTIONAL ,	  offsetof(NSSCMSSMIMEKEAParameters,bulkKeySize) },	{ 0 }};const SEC_ASN1Template *nss_cms_get_kea_template(NSSCMSKEATemplateSelector whichTemplate){	const SEC_ASN1Template *returnVal = NULL;	switch(whichTemplate)	{	case NSSCMSKEAUsesNonSkipjack:		returnVal = NSS_SMIMEKEAParamTemplateNoSkipjack;		break;	case NSSCMSKEAUsesSkipjack:		returnVal = NSS_SMIMEKEAParamTemplateSkipjack;		break;	case NSSCMSKEAUsesNonSkipjackWithPaddedEncKey:	default:		returnVal = NSS_SMIMEKEAParamTemplateAllParams;		break;	}	return returnVal;}/* ----------------------------------------------------------------------------- * */static const SEC_ASN1Template *nss_cms_choose_content_template(void *src_or_dest, PRBool encoding){    const SEC_ASN1Template *theTemplate;    NSSCMSContentInfo *cinfo;    PORT_Assert (src_or_dest != NULL);    if (src_or_dest == NULL)	return NULL;    cinfo = (NSSCMSContentInfo *)src_or_dest;    switch (NSS_CMSContentInfo_GetContentTypeTag(cinfo)) {    default:	theTemplate = SEC_PointerToAnyTemplate;	break;    case SEC_OID_PKCS7_DATA:	theTemplate = 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;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?