1
/* ***** BEGIN LICENSE BLOCK *****
2
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
* The contents of this file are subject to the Mozilla Public License Version
5
* 1.1 (the "License"); you may not use this file except in compliance with
6
* the License. You may obtain a copy of the License at
7
* http://www.mozilla.org/MPL/
9
* Software distributed under the License is distributed on an "AS IS" basis,
10
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
* for the specific language governing rights and limitations under the
14
* The Original Code is the Netscape security libraries.
16
* The Initial Developer of the Original Code is
17
* Netscape Communications Corporation.
18
* Portions created by the Initial Developer are Copyright (C) 1994-2000
19
* the Initial Developer. All Rights Reserved.
23
* Alternatively, the contents of this file may be used under the terms of
24
* either the GNU General Public License Version 2 or later (the "GPL"), or
25
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26
* in which case the provisions of the GPL or the LGPL are applicable instead
27
* of those above. If you wish to allow use of your version of this file only
28
* under the terms of either the GPL or the LGPL, and not to allow others to
29
* use your version of this file under the terms of the MPL, indicate your
30
* decision by deleting the provisions above and replace them with the notice
31
* and other provisions required by the GPL or the LGPL. If you do not delete
32
* the provisions above, a recipient may use your version of this file under
33
* the terms of any one of the MPL, the GPL or the LGPL.
35
* ***** END LICENSE BLOCK ***** */
40
* $Id: cmsasn1.c,v 1.6 2004/04/25 15:03:15 gerv%gerv.net Exp $
54
extern const SEC_ASN1Template nss_cms_set_of_attribute_template[];
56
SEC_ASN1_MKSUB(CERT_IssuerAndSNTemplate)
57
SEC_ASN1_MKSUB(CERT_SetOfSignedCrlTemplate)
58
SEC_ASN1_MKSUB(SECOID_AlgorithmIDTemplate)
59
SEC_ASN1_MKSUB(SEC_BitStringTemplate)
60
SEC_ASN1_MKSUB(SEC_OctetStringTemplate)
61
SEC_ASN1_MKSUB(SEC_PointerToOctetStringTemplate)
62
SEC_ASN1_MKSUB(SEC_SetOfAnyTemplate)
64
/* -----------------------------------------------------------------------------
66
* (uses NSSCMSContentInfo)
69
/* forward declaration */
70
static const SEC_ASN1Template *
71
nss_cms_choose_content_template(void *src_or_dest, PRBool encoding);
73
static const SEC_ASN1TemplateChooserPtr nss_cms_chooser
74
= nss_cms_choose_content_template;
76
const SEC_ASN1Template NSSCMSMessageTemplate[] = {
77
{ SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM,
78
0, NULL, sizeof(NSSCMSMessage) },
80
offsetof(NSSCMSMessage,contentInfo.contentType) },
81
{ SEC_ASN1_OPTIONAL | SEC_ASN1_DYNAMIC | SEC_ASN1_MAY_STREAM
82
| SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0,
83
offsetof(NSSCMSMessage,contentInfo.content),
88
static const SEC_ASN1Template NSS_PointerToCMSMessageTemplate[] = {
89
{ SEC_ASN1_POINTER, 0, NSSCMSMessageTemplate }
92
/* -----------------------------------------------------------------------------
93
* ENCAPSULATED & ENCRYPTED CONTENTINFO
94
* (both use a NSSCMSContentInfo)
96
static const SEC_ASN1Template NSSCMSEncapsulatedContentInfoTemplate[] = {
97
{ SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM,
98
0, NULL, sizeof(NSSCMSContentInfo) },
100
offsetof(NSSCMSContentInfo,contentType) },
101
{ SEC_ASN1_OPTIONAL | SEC_ASN1_EXPLICIT | SEC_ASN1_MAY_STREAM |
102
SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | SEC_ASN1_XTRN | 0,
103
offsetof(NSSCMSContentInfo,rawContent),
104
SEC_ASN1_SUB(SEC_PointerToOctetStringTemplate) },
108
static const SEC_ASN1Template NSSCMSEncryptedContentInfoTemplate[] = {
109
{ SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM,
110
0, NULL, sizeof(NSSCMSContentInfo) },
111
{ SEC_ASN1_OBJECT_ID,
112
offsetof(NSSCMSContentInfo,contentType) },
113
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
114
offsetof(NSSCMSContentInfo,contentEncAlg),
115
SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
116
{ SEC_ASN1_OPTIONAL | SEC_ASN1_POINTER | SEC_ASN1_MAY_STREAM |
117
SEC_ASN1_CONTEXT_SPECIFIC | SEC_ASN1_XTRN | 0,
118
offsetof(NSSCMSContentInfo,rawContent),
119
SEC_ASN1_SUB(SEC_OctetStringTemplate) },
123
/* -----------------------------------------------------------------------------
127
const SEC_ASN1Template NSSCMSSignerInfoTemplate[];
129
const SEC_ASN1Template NSSCMSSignedDataTemplate[] = {
130
{ SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM,
131
0, NULL, sizeof(NSSCMSSignedData) },
133
offsetof(NSSCMSSignedData,version) },
134
{ SEC_ASN1_SET_OF | SEC_ASN1_XTRN,
135
offsetof(NSSCMSSignedData,digestAlgorithms),
136
SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
138
offsetof(NSSCMSSignedData,contentInfo),
139
NSSCMSEncapsulatedContentInfoTemplate },
140
{ SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC |
142
offsetof(NSSCMSSignedData,rawCerts),
143
SEC_ASN1_SUB(SEC_SetOfAnyTemplate) },
144
{ SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC |
146
offsetof(NSSCMSSignedData,crls),
147
SEC_ASN1_SUB(CERT_SetOfSignedCrlTemplate) },
149
offsetof(NSSCMSSignedData,signerInfos),
150
NSSCMSSignerInfoTemplate },
154
const SEC_ASN1Template NSS_PointerToCMSSignedDataTemplate[] = {
155
{ SEC_ASN1_POINTER, 0, NSSCMSSignedDataTemplate }
158
/* -----------------------------------------------------------------------------
162
static const SEC_ASN1Template NSSCMSSignerIdentifierTemplate[] = {
164
offsetof(NSSCMSSignerIdentifier,identifierType), NULL,
165
sizeof(NSSCMSSignerIdentifier) },
166
{ SEC_ASN1_POINTER | SEC_ASN1_CONTEXT_SPECIFIC | SEC_ASN1_XTRN | 0,
167
offsetof(NSSCMSSignerIdentifier,id.subjectKeyID),
168
SEC_ASN1_SUB(SEC_OctetStringTemplate) ,
169
NSSCMSRecipientID_SubjectKeyID },
170
{ SEC_ASN1_POINTER | SEC_ASN1_XTRN,
171
offsetof(NSSCMSSignerIdentifier,id.issuerAndSN),
172
SEC_ASN1_SUB(CERT_IssuerAndSNTemplate),
173
NSSCMSRecipientID_IssuerSN },
177
/* -----------------------------------------------------------------------------
181
const SEC_ASN1Template NSSCMSSignerInfoTemplate[] = {
183
0, NULL, sizeof(NSSCMSSignerInfo) },
185
offsetof(NSSCMSSignerInfo,version) },
187
offsetof(NSSCMSSignerInfo,signerIdentifier),
188
NSSCMSSignerIdentifierTemplate },
189
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
190
offsetof(NSSCMSSignerInfo,digestAlg),
191
SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
192
{ SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0,
193
offsetof(NSSCMSSignerInfo,authAttr),
194
nss_cms_set_of_attribute_template },
195
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
196
offsetof(NSSCMSSignerInfo,digestEncAlg),
197
SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
198
{ SEC_ASN1_OCTET_STRING,
199
offsetof(NSSCMSSignerInfo,encDigest) },
200
{ SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1,
201
offsetof(NSSCMSSignerInfo,unAuthAttr),
202
nss_cms_set_of_attribute_template },
206
/* -----------------------------------------------------------------------------
210
static const SEC_ASN1Template NSSCMSOriginatorInfoTemplate[] = {
212
0, NULL, sizeof(NSSCMSOriginatorInfo) },
213
{ SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC |
215
offsetof(NSSCMSOriginatorInfo,rawCerts),
216
SEC_ASN1_SUB(SEC_SetOfAnyTemplate) },
217
{ SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC |
219
offsetof(NSSCMSOriginatorInfo,crls),
220
SEC_ASN1_SUB(CERT_SetOfSignedCrlTemplate) },
224
const SEC_ASN1Template NSSCMSRecipientInfoTemplate[];
226
const SEC_ASN1Template NSSCMSEnvelopedDataTemplate[] = {
227
{ SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM,
228
0, NULL, sizeof(NSSCMSEnvelopedData) },
230
offsetof(NSSCMSEnvelopedData,version) },
231
{ SEC_ASN1_OPTIONAL | SEC_ASN1_POINTER | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0,
232
offsetof(NSSCMSEnvelopedData,originatorInfo),
233
NSSCMSOriginatorInfoTemplate },
235
offsetof(NSSCMSEnvelopedData,recipientInfos),
236
NSSCMSRecipientInfoTemplate },
238
offsetof(NSSCMSEnvelopedData,contentInfo),
239
NSSCMSEncryptedContentInfoTemplate },
240
{ SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1,
241
offsetof(NSSCMSEnvelopedData,unprotectedAttr),
242
nss_cms_set_of_attribute_template },
246
const SEC_ASN1Template NSS_PointerToCMSEnvelopedDataTemplate[] = {
247
{ SEC_ASN1_POINTER, 0, NSSCMSEnvelopedDataTemplate }
250
/* here come the 15 gazillion templates for all the v3 varieties of RecipientInfo */
252
/* -----------------------------------------------------------------------------
253
* key transport recipient info
256
static const SEC_ASN1Template NSSCMSRecipientIdentifierTemplate[] = {
258
offsetof(NSSCMSRecipientIdentifier,identifierType), NULL,
259
sizeof(NSSCMSRecipientIdentifier) },
260
{ SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC |
262
offsetof(NSSCMSRecipientIdentifier,id.subjectKeyID),
263
SEC_ASN1_SUB(SEC_PointerToOctetStringTemplate) ,
264
NSSCMSRecipientID_SubjectKeyID },
265
{ SEC_ASN1_POINTER | SEC_ASN1_XTRN,
266
offsetof(NSSCMSRecipientIdentifier,id.issuerAndSN),
267
SEC_ASN1_SUB(CERT_IssuerAndSNTemplate),
268
NSSCMSRecipientID_IssuerSN },
273
static const SEC_ASN1Template NSSCMSKeyTransRecipientInfoTemplate[] = {
275
0, NULL, sizeof(NSSCMSKeyTransRecipientInfo) },
277
offsetof(NSSCMSKeyTransRecipientInfo,version) },
279
offsetof(NSSCMSKeyTransRecipientInfo,recipientIdentifier),
280
NSSCMSRecipientIdentifierTemplate },
281
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
282
offsetof(NSSCMSKeyTransRecipientInfo,keyEncAlg),
283
SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
284
{ SEC_ASN1_OCTET_STRING,
285
offsetof(NSSCMSKeyTransRecipientInfo,encKey) },
289
/* -----------------------------------------------------------------------------
290
* key agreement recipient info
293
static const SEC_ASN1Template NSSCMSOriginatorPublicKeyTemplate[] = {
295
0, NULL, sizeof(NSSCMSOriginatorPublicKey) },
296
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
297
offsetof(NSSCMSOriginatorPublicKey,algorithmIdentifier),
298
SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
299
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
300
offsetof(NSSCMSOriginatorPublicKey,publicKey),
301
SEC_ASN1_SUB(SEC_BitStringTemplate) },
306
static const SEC_ASN1Template NSSCMSOriginatorIdentifierOrKeyTemplate[] = {
308
offsetof(NSSCMSOriginatorIdentifierOrKey,identifierType), NULL,
309
sizeof(NSSCMSOriginatorIdentifierOrKey) },
310
{ SEC_ASN1_POINTER | SEC_ASN1_XTRN,
311
offsetof(NSSCMSOriginatorIdentifierOrKey,id.issuerAndSN),
312
SEC_ASN1_SUB(CERT_IssuerAndSNTemplate),
313
NSSCMSOriginatorIDOrKey_IssuerSN },
314
{ SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC |
316
offsetof(NSSCMSOriginatorIdentifierOrKey,id.subjectKeyID),
317
SEC_ASN1_SUB(SEC_PointerToOctetStringTemplate) ,
318
NSSCMSOriginatorIDOrKey_SubjectKeyID },
319
{ SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 2,
320
offsetof(NSSCMSOriginatorIdentifierOrKey,id.originatorPublicKey),
321
NSSCMSOriginatorPublicKeyTemplate,
322
NSSCMSOriginatorIDOrKey_OriginatorPublicKey },
326
const SEC_ASN1Template NSSCMSRecipientKeyIdentifierTemplate[] = {
328
0, NULL, sizeof(NSSCMSRecipientKeyIdentifier) },
329
{ SEC_ASN1_OCTET_STRING,
330
offsetof(NSSCMSRecipientKeyIdentifier,subjectKeyIdentifier) },
331
{ SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING,
332
offsetof(NSSCMSRecipientKeyIdentifier,date) },
333
{ SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING,
334
offsetof(NSSCMSRecipientKeyIdentifier,other) },
339
static const SEC_ASN1Template NSSCMSKeyAgreeRecipientIdentifierTemplate[] = {
341
offsetof(NSSCMSKeyAgreeRecipientIdentifier,identifierType), NULL,
342
sizeof(NSSCMSKeyAgreeRecipientIdentifier) },
343
{ SEC_ASN1_POINTER | SEC_ASN1_XTRN,
344
offsetof(NSSCMSKeyAgreeRecipientIdentifier,id.issuerAndSN),
345
SEC_ASN1_SUB(CERT_IssuerAndSNTemplate),
346
NSSCMSKeyAgreeRecipientID_IssuerSN },
347
{ SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0,
348
offsetof(NSSCMSKeyAgreeRecipientIdentifier,id.recipientKeyIdentifier),
349
NSSCMSRecipientKeyIdentifierTemplate,
350
NSSCMSKeyAgreeRecipientID_RKeyID },
354
static const SEC_ASN1Template NSSCMSRecipientEncryptedKeyTemplate[] = {
356
0, NULL, sizeof(NSSCMSRecipientEncryptedKey) },
358
offsetof(NSSCMSRecipientEncryptedKey,recipientIdentifier),
359
NSSCMSKeyAgreeRecipientIdentifierTemplate },
360
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
361
offsetof(NSSCMSRecipientEncryptedKey,encKey),
362
SEC_ASN1_SUB(SEC_BitStringTemplate) },
366
static const SEC_ASN1Template NSSCMSKeyAgreeRecipientInfoTemplate[] = {
368
0, NULL, sizeof(NSSCMSKeyAgreeRecipientInfo) },
370
offsetof(NSSCMSKeyAgreeRecipientInfo,version) },
371
{ SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0,
372
offsetof(NSSCMSKeyAgreeRecipientInfo,originatorIdentifierOrKey),
373
NSSCMSOriginatorIdentifierOrKeyTemplate },
374
{ SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_EXPLICIT |
375
SEC_ASN1_CONTEXT_SPECIFIC | SEC_ASN1_XTRN | 1,
376
offsetof(NSSCMSKeyAgreeRecipientInfo,ukm),
377
SEC_ASN1_SUB(SEC_OctetStringTemplate) },
378
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
379
offsetof(NSSCMSKeyAgreeRecipientInfo,keyEncAlg),
380
SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
381
{ SEC_ASN1_SEQUENCE_OF,
382
offsetof(NSSCMSKeyAgreeRecipientInfo,recipientEncryptedKeys),
383
NSSCMSRecipientEncryptedKeyTemplate },
387
/* -----------------------------------------------------------------------------
391
static const SEC_ASN1Template NSSCMSKEKIdentifierTemplate[] = {
393
0, NULL, sizeof(NSSCMSKEKIdentifier) },
394
{ SEC_ASN1_OCTET_STRING,
395
offsetof(NSSCMSKEKIdentifier,keyIdentifier) },
396
{ SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING,
397
offsetof(NSSCMSKEKIdentifier,date) },
398
{ SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING,
399
offsetof(NSSCMSKEKIdentifier,other) },
403
static const SEC_ASN1Template NSSCMSKEKRecipientInfoTemplate[] = {
405
0, NULL, sizeof(NSSCMSKEKRecipientInfo) },
407
offsetof(NSSCMSKEKRecipientInfo,version) },
409
offsetof(NSSCMSKEKRecipientInfo,kekIdentifier),
410
NSSCMSKEKIdentifierTemplate },
411
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
412
offsetof(NSSCMSKEKRecipientInfo,keyEncAlg),
413
SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
414
{ SEC_ASN1_OCTET_STRING,
415
offsetof(NSSCMSKEKRecipientInfo,encKey) },
419
/* -----------------------------------------------------------------------------
422
const SEC_ASN1Template NSSCMSRecipientInfoTemplate[] = {
424
offsetof(NSSCMSRecipientInfo,recipientInfoType), NULL,
425
sizeof(NSSCMSRecipientInfo) },
426
{ SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1,
427
offsetof(NSSCMSRecipientInfo,ri.keyAgreeRecipientInfo),
428
NSSCMSKeyAgreeRecipientInfoTemplate,
429
NSSCMSRecipientInfoID_KeyAgree },
430
{ SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 2,
431
offsetof(NSSCMSRecipientInfo,ri.kekRecipientInfo),
432
NSSCMSKEKRecipientInfoTemplate,
433
NSSCMSRecipientInfoID_KEK },
435
offsetof(NSSCMSRecipientInfo,ri.keyTransRecipientInfo),
436
NSSCMSKeyTransRecipientInfoTemplate,
437
NSSCMSRecipientInfoID_KeyTrans },
441
/* -----------------------------------------------------------------------------
445
const SEC_ASN1Template NSSCMSDigestedDataTemplate[] = {
446
{ SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM,
447
0, NULL, sizeof(NSSCMSDigestedData) },
449
offsetof(NSSCMSDigestedData,version) },
450
{ SEC_ASN1_INLINE | SEC_ASN1_XTRN,
451
offsetof(NSSCMSDigestedData,digestAlg),
452
SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
454
offsetof(NSSCMSDigestedData,contentInfo),
455
NSSCMSEncapsulatedContentInfoTemplate },
456
{ SEC_ASN1_OCTET_STRING,
457
offsetof(NSSCMSDigestedData,digest) },
461
const SEC_ASN1Template NSS_PointerToCMSDigestedDataTemplate[] = {
462
{ SEC_ASN1_POINTER, 0, NSSCMSDigestedDataTemplate }
465
const SEC_ASN1Template NSSCMSEncryptedDataTemplate[] = {
466
{ SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM,
467
0, NULL, sizeof(NSSCMSEncryptedData) },
469
offsetof(NSSCMSEncryptedData,version) },
471
offsetof(NSSCMSEncryptedData,contentInfo),
472
NSSCMSEncryptedContentInfoTemplate },
473
{ SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1,
474
offsetof(NSSCMSEncryptedData,unprotectedAttr),
475
nss_cms_set_of_attribute_template },
479
const SEC_ASN1Template NSS_PointerToCMSEncryptedDataTemplate[] = {
480
{ SEC_ASN1_POINTER, 0, NSSCMSEncryptedDataTemplate }
483
/* -----------------------------------------------------------------------------
486
const SEC_ASN1Template NSS_SMIMEKEAParamTemplateSkipjack[] = {
488
0, NULL, sizeof(NSSCMSSMIMEKEAParameters) },
489
{ SEC_ASN1_OCTET_STRING /* | SEC_ASN1_OPTIONAL */,
490
offsetof(NSSCMSSMIMEKEAParameters,originatorKEAKey) },
491
{ SEC_ASN1_OCTET_STRING,
492
offsetof(NSSCMSSMIMEKEAParameters,originatorRA) },
496
const SEC_ASN1Template NSS_SMIMEKEAParamTemplateNoSkipjack[] = {
498
0, NULL, sizeof(NSSCMSSMIMEKEAParameters) },
499
{ SEC_ASN1_OCTET_STRING /* | SEC_ASN1_OPTIONAL */,
500
offsetof(NSSCMSSMIMEKEAParameters,originatorKEAKey) },
501
{ SEC_ASN1_OCTET_STRING,
502
offsetof(NSSCMSSMIMEKEAParameters,originatorRA) },
503
{ SEC_ASN1_OCTET_STRING | SEC_ASN1_OPTIONAL ,
504
offsetof(NSSCMSSMIMEKEAParameters,nonSkipjackIV) },
508
const SEC_ASN1Template NSS_SMIMEKEAParamTemplateAllParams[] = {
510
0, NULL, sizeof(NSSCMSSMIMEKEAParameters) },
511
{ SEC_ASN1_OCTET_STRING /* | SEC_ASN1_OPTIONAL */,
512
offsetof(NSSCMSSMIMEKEAParameters,originatorKEAKey) },
513
{ SEC_ASN1_OCTET_STRING,
514
offsetof(NSSCMSSMIMEKEAParameters,originatorRA) },
515
{ SEC_ASN1_OCTET_STRING | SEC_ASN1_OPTIONAL ,
516
offsetof(NSSCMSSMIMEKEAParameters,nonSkipjackIV) },
517
{ SEC_ASN1_OCTET_STRING | SEC_ASN1_OPTIONAL ,
518
offsetof(NSSCMSSMIMEKEAParameters,bulkKeySize) },
522
const SEC_ASN1Template *
523
nss_cms_get_kea_template(NSSCMSKEATemplateSelector whichTemplate)
525
const SEC_ASN1Template *returnVal = NULL;
527
switch(whichTemplate)
529
case NSSCMSKEAUsesNonSkipjack:
530
returnVal = NSS_SMIMEKEAParamTemplateNoSkipjack;
532
case NSSCMSKEAUsesSkipjack:
533
returnVal = NSS_SMIMEKEAParamTemplateSkipjack;
535
case NSSCMSKEAUsesNonSkipjackWithPaddedEncKey:
537
returnVal = NSS_SMIMEKEAParamTemplateAllParams;
543
/* -----------------------------------------------------------------------------
546
static const SEC_ASN1Template *
547
nss_cms_choose_content_template(void *src_or_dest, PRBool encoding)
549
const SEC_ASN1Template *theTemplate;
550
NSSCMSContentInfo *cinfo;
552
PORT_Assert (src_or_dest != NULL);
553
if (src_or_dest == NULL)
556
cinfo = (NSSCMSContentInfo *)src_or_dest;
557
switch (NSS_CMSContentInfo_GetContentTypeTag(cinfo)) {
559
theTemplate = SEC_ASN1_GET(SEC_PointerToAnyTemplate);
561
case SEC_OID_PKCS7_DATA:
562
theTemplate = SEC_ASN1_GET(SEC_PointerToOctetStringTemplate);
564
case SEC_OID_PKCS7_SIGNED_DATA:
565
theTemplate = NSS_PointerToCMSSignedDataTemplate;
567
case SEC_OID_PKCS7_ENVELOPED_DATA:
568
theTemplate = NSS_PointerToCMSEnvelopedDataTemplate;
570
case SEC_OID_PKCS7_DIGESTED_DATA:
571
theTemplate = NSS_PointerToCMSDigestedDataTemplate;
573
case SEC_OID_PKCS7_ENCRYPTED_DATA:
574
theTemplate = NSS_PointerToCMSEncryptedDataTemplate;