OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 /* | 5 /* |
6 * CMS ASN.1 templates | 6 * CMS ASN.1 templates |
7 */ | 7 */ |
8 | 8 |
9 #include "cmslocal.h" | 9 #include "cmslocal.h" |
10 | 10 |
11 #include "cert.h" | 11 #include "cert.h" |
12 #include "key.h" | 12 #include "key.h" |
13 #include "secasn1.h" | 13 #include "secasn1.h" |
14 #include "secitem.h" | 14 #include "secitem.h" |
15 #include "secoid.h" | 15 #include "secoid.h" |
16 #include "prtime.h" | 16 #include "prtime.h" |
17 #include "secerr.h" | 17 #include "secerr.h" |
18 | 18 |
19 | |
20 extern const SEC_ASN1Template nss_cms_set_of_attribute_template[]; | 19 extern const SEC_ASN1Template nss_cms_set_of_attribute_template[]; |
21 | 20 |
22 SEC_ASN1_MKSUB(CERT_IssuerAndSNTemplate) | 21 SEC_ASN1_MKSUB(CERT_IssuerAndSNTemplate) |
23 SEC_ASN1_MKSUB(CERT_SetOfSignedCrlTemplate) | 22 SEC_ASN1_MKSUB(CERT_SetOfSignedCrlTemplate) |
24 SEC_ASN1_MKSUB(SECOID_AlgorithmIDTemplate) | 23 SEC_ASN1_MKSUB(SECOID_AlgorithmIDTemplate) |
25 SEC_ASN1_MKSUB(SEC_BitStringTemplate) | 24 SEC_ASN1_MKSUB(SEC_BitStringTemplate) |
26 SEC_ASN1_MKSUB(SEC_OctetStringTemplate) | 25 SEC_ASN1_MKSUB(SEC_OctetStringTemplate) |
27 SEC_ASN1_MKSUB(SEC_PointerToOctetStringTemplate) | 26 SEC_ASN1_MKSUB(SEC_PointerToOctetStringTemplate) |
28 SEC_ASN1_MKSUB(SEC_SetOfAnyTemplate) | 27 SEC_ASN1_MKSUB(SEC_SetOfAnyTemplate) |
29 | 28 |
30 /* ----------------------------------------------------------------------------- | 29 /* ----------------------------------------------------------------------------- |
31 * MESSAGE | 30 * MESSAGE |
32 * (uses NSSCMSContentInfo) | 31 * (uses NSSCMSContentInfo) |
33 */ | 32 */ |
34 | 33 |
35 /* forward declaration */ | 34 /* forward declaration */ |
36 static const SEC_ASN1Template * | 35 static const SEC_ASN1Template *nss_cms_choose_content_template( |
37 nss_cms_choose_content_template(void *src_or_dest, PRBool encoding); | 36 void *src_or_dest, PRBool encoding); |
38 | 37 |
39 static const SEC_ASN1TemplateChooserPtr nss_cms_chooser | 38 static const SEC_ASN1TemplateChooserPtr nss_cms_chooser = |
40 » = nss_cms_choose_content_template; | 39 nss_cms_choose_content_template; |
41 | 40 |
42 const SEC_ASN1Template NSSCMSMessageTemplate[] = { | 41 const SEC_ASN1Template NSSCMSMessageTemplate[] = { |
43 { SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM, | 42 {SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(NSSCMSMessage)}, |
44 » 0, NULL, sizeof(NSSCMSMessage) }, | 43 {SEC_ASN1_OBJECT_ID, offsetof(NSSCMSMessage, contentInfo.contentType)}, |
45 { SEC_ASN1_OBJECT_ID, | 44 {SEC_ASN1_OPTIONAL | SEC_ASN1_DYNAMIC | SEC_ASN1_MAY_STREAM | |
46 » offsetof(NSSCMSMessage,contentInfo.contentType) }, | 45 SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | |
47 { SEC_ASN1_OPTIONAL | SEC_ASN1_DYNAMIC | SEC_ASN1_MAY_STREAM | 46 0, |
48 | SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0, | 47 offsetof(NSSCMSMessage, contentInfo.content), &nss_cms_chooser}, |
49 » offsetof(NSSCMSMessage,contentInfo.content), | 48 {0}}; |
50 » &nss_cms_chooser }, | |
51 { 0 } | |
52 }; | |
53 | 49 |
54 static const SEC_ASN1Template NSS_PointerToCMSMessageTemplate[] = { | 50 static const SEC_ASN1Template NSS_PointerToCMSMessageTemplate[] = { |
55 { SEC_ASN1_POINTER, 0, NSSCMSMessageTemplate } | 51 {SEC_ASN1_POINTER, 0, NSSCMSMessageTemplate}}; |
56 }; | |
57 | 52 |
58 /* ----------------------------------------------------------------------------- | 53 /* ----------------------------------------------------------------------------- |
59 * ENCAPSULATED & ENCRYPTED CONTENTINFO | 54 * ENCAPSULATED & ENCRYPTED CONTENTINFO |
60 * (both use a NSSCMSContentInfo) | 55 * (both use a NSSCMSContentInfo) |
61 */ | 56 */ |
62 static const SEC_ASN1Template NSSCMSEncapsulatedContentInfoTemplate[] = { | 57 static const SEC_ASN1Template NSSCMSEncapsulatedContentInfoTemplate[] = { |
63 { SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM, | 58 {SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM, 0, |
64 » 0, NULL, sizeof(NSSCMSContentInfo) }, | 59 NULL, sizeof(NSSCMSContentInfo)}, |
65 { SEC_ASN1_OBJECT_ID, | 60 {SEC_ASN1_OBJECT_ID, offsetof(NSSCMSContentInfo, contentType)}, |
66 » offsetof(NSSCMSContentInfo,contentType) }, | 61 {SEC_ASN1_OPTIONAL | SEC_ASN1_EXPLICIT | SEC_ASN1_MAY_STREAM | |
67 { SEC_ASN1_OPTIONAL | SEC_ASN1_EXPLICIT | SEC_ASN1_MAY_STREAM | | 62 SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | SEC_ASN1_XTRN | 0, |
68 » SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | SEC_ASN1_XTRN | 0, | 63 offsetof(NSSCMSContentInfo, rawContent), |
69 » offsetof(NSSCMSContentInfo,rawContent), | 64 SEC_ASN1_SUB(SEC_PointerToOctetStringTemplate)}, |
70 » SEC_ASN1_SUB(SEC_PointerToOctetStringTemplate) }, | 65 {0}}; |
71 { 0 } | |
72 }; | |
73 | 66 |
74 static const SEC_ASN1Template NSSCMSEncryptedContentInfoTemplate[] = { | 67 static const SEC_ASN1Template NSSCMSEncryptedContentInfoTemplate[] = { |
75 { SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM, | 68 {SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM, 0, |
76 » 0, NULL, sizeof(NSSCMSContentInfo) }, | 69 NULL, sizeof(NSSCMSContentInfo)}, |
77 { SEC_ASN1_OBJECT_ID, | 70 {SEC_ASN1_OBJECT_ID, offsetof(NSSCMSContentInfo, contentType)}, |
78 » offsetof(NSSCMSContentInfo,contentType) }, | 71 {SEC_ASN1_INLINE | SEC_ASN1_XTRN, |
79 { SEC_ASN1_INLINE | SEC_ASN1_XTRN, | 72 offsetof(NSSCMSContentInfo, contentEncAlg), |
80 » offsetof(NSSCMSContentInfo,contentEncAlg), | 73 SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate)}, |
81 » SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) }, | 74 {SEC_ASN1_OPTIONAL | SEC_ASN1_POINTER | SEC_ASN1_MAY_STREAM | |
82 { SEC_ASN1_OPTIONAL | SEC_ASN1_POINTER | SEC_ASN1_MAY_STREAM |· | 75 SEC_ASN1_CONTEXT_SPECIFIC | SEC_ASN1_XTRN | 0, |
83 SEC_ASN1_CONTEXT_SPECIFIC | SEC_ASN1_XTRN | 0, | 76 offsetof(NSSCMSContentInfo, rawContent), |
84 » offsetof(NSSCMSContentInfo,rawContent), | 77 SEC_ASN1_SUB(SEC_OctetStringTemplate)}, |
85 » SEC_ASN1_SUB(SEC_OctetStringTemplate) }, | 78 {0}}; |
86 { 0 } | |
87 }; | |
88 | 79 |
89 /* ----------------------------------------------------------------------------- | 80 /* ----------------------------------------------------------------------------- |
90 * SIGNED DATA | 81 * SIGNED DATA |
91 */ | 82 */ |
92 | 83 |
93 const SEC_ASN1Template NSSCMSSignerInfoTemplate[]; | 84 const SEC_ASN1Template NSSCMSSignerInfoTemplate[]; |
94 | 85 |
95 const SEC_ASN1Template NSSCMSSignedDataTemplate[] = { | 86 const SEC_ASN1Template NSSCMSSignedDataTemplate[] = { |
96 { SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM, | 87 {SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM, 0, |
97 » 0, NULL, sizeof(NSSCMSSignedData) }, | 88 NULL, sizeof(NSSCMSSignedData)}, |
98 { SEC_ASN1_INTEGER, | 89 {SEC_ASN1_INTEGER, offsetof(NSSCMSSignedData, version)}, |
99 » offsetof(NSSCMSSignedData,version) }, | 90 {SEC_ASN1_SET_OF | SEC_ASN1_XTRN, |
100 { SEC_ASN1_SET_OF | SEC_ASN1_XTRN, | 91 offsetof(NSSCMSSignedData, digestAlgorithms), |
101 » offsetof(NSSCMSSignedData,digestAlgorithms), | 92 SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate)}, |
102 » SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) }, | 93 {SEC_ASN1_INLINE, offsetof(NSSCMSSignedData, contentInfo), |
103 { SEC_ASN1_INLINE, | 94 NSSCMSEncapsulatedContentInfoTemplate}, |
104 » offsetof(NSSCMSSignedData,contentInfo), | 95 {SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | |
105 » NSSCMSEncapsulatedContentInfoTemplate }, | 96 SEC_ASN1_XTRN | 0, |
106 { SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | | 97 offsetof(NSSCMSSignedData, rawCerts), SEC_ASN1_SUB(SEC_SetOfAnyTemplate)}, |
107 SEC_ASN1_XTRN | 0, | 98 {SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | |
108 » offsetof(NSSCMSSignedData,rawCerts), | 99 SEC_ASN1_XTRN | 1, |
109 » SEC_ASN1_SUB(SEC_SetOfAnyTemplate) }, | 100 offsetof(NSSCMSSignedData, crls), |
110 { SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | | 101 SEC_ASN1_SUB(CERT_SetOfSignedCrlTemplate)}, |
111 SEC_ASN1_XTRN | 1, | 102 {SEC_ASN1_SET_OF, offsetof(NSSCMSSignedData, signerInfos), |
112 » offsetof(NSSCMSSignedData,crls), | 103 NSSCMSSignerInfoTemplate}, |
113 » SEC_ASN1_SUB(CERT_SetOfSignedCrlTemplate) }, | 104 {0}}; |
114 { SEC_ASN1_SET_OF, | |
115 » offsetof(NSSCMSSignedData,signerInfos), | |
116 » NSSCMSSignerInfoTemplate }, | |
117 { 0 } | |
118 }; | |
119 | 105 |
120 const SEC_ASN1Template NSS_PointerToCMSSignedDataTemplate[] = { | 106 const SEC_ASN1Template NSS_PointerToCMSSignedDataTemplate[] = { |
121 { SEC_ASN1_POINTER, 0, NSSCMSSignedDataTemplate } | 107 {SEC_ASN1_POINTER, 0, NSSCMSSignedDataTemplate}}; |
122 }; | |
123 | 108 |
124 /* ----------------------------------------------------------------------------- | 109 /* ----------------------------------------------------------------------------- |
125 * signeridentifier | 110 * signeridentifier |
126 */ | 111 */ |
127 | 112 |
128 static const SEC_ASN1Template NSSCMSSignerIdentifierTemplate[] = { | 113 static const SEC_ASN1Template NSSCMSSignerIdentifierTemplate[] = { |
129 { SEC_ASN1_CHOICE, | 114 {SEC_ASN1_CHOICE, offsetof(NSSCMSSignerIdentifier, identifierType), |
130 » offsetof(NSSCMSSignerIdentifier,identifierType), NULL, | 115 NULL, sizeof(NSSCMSSignerIdentifier)}, |
131 » sizeof(NSSCMSSignerIdentifier) }, | 116 {SEC_ASN1_POINTER | SEC_ASN1_CONTEXT_SPECIFIC | SEC_ASN1_XTRN | 0, |
132 { SEC_ASN1_POINTER | SEC_ASN1_CONTEXT_SPECIFIC | SEC_ASN1_XTRN | 0, | 117 offsetof(NSSCMSSignerIdentifier, id.subjectKeyID), |
133 » offsetof(NSSCMSSignerIdentifier,id.subjectKeyID), | 118 SEC_ASN1_SUB(SEC_OctetStringTemplate), |
134 » SEC_ASN1_SUB(SEC_OctetStringTemplate) , | 119 NSSCMSRecipientID_SubjectKeyID}, |
135 » NSSCMSRecipientID_SubjectKeyID }, | 120 {SEC_ASN1_POINTER | SEC_ASN1_XTRN, |
136 { SEC_ASN1_POINTER | SEC_ASN1_XTRN, | 121 offsetof(NSSCMSSignerIdentifier, id.issuerAndSN), |
137 » offsetof(NSSCMSSignerIdentifier,id.issuerAndSN), | 122 SEC_ASN1_SUB(CERT_IssuerAndSNTemplate), |
138 » SEC_ASN1_SUB(CERT_IssuerAndSNTemplate), | 123 NSSCMSRecipientID_IssuerSN}, |
139 » NSSCMSRecipientID_IssuerSN }, | 124 {0}}; |
140 { 0 } | |
141 }; | |
142 | 125 |
143 /* ----------------------------------------------------------------------------- | 126 /* ----------------------------------------------------------------------------- |
144 * signerinfo | 127 * signerinfo |
145 */ | 128 */ |
146 | 129 |
147 const SEC_ASN1Template NSSCMSSignerInfoTemplate[] = { | 130 const SEC_ASN1Template NSSCMSSignerInfoTemplate[] = { |
148 { SEC_ASN1_SEQUENCE, | 131 {SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSSCMSSignerInfo)}, |
149 » 0, NULL, sizeof(NSSCMSSignerInfo) }, | 132 {SEC_ASN1_INTEGER, offsetof(NSSCMSSignerInfo, version)}, |
150 { SEC_ASN1_INTEGER, | 133 {SEC_ASN1_INLINE, offsetof(NSSCMSSignerInfo, signerIdentifier), |
151 » offsetof(NSSCMSSignerInfo,version) }, | 134 NSSCMSSignerIdentifierTemplate}, |
152 { SEC_ASN1_INLINE, | 135 {SEC_ASN1_INLINE | SEC_ASN1_XTRN, offsetof(NSSCMSSignerInfo, digestAlg), |
153 » offsetof(NSSCMSSignerInfo,signerIdentifier), | 136 SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate)}, |
154 » NSSCMSSignerIdentifierTemplate }, | 137 {SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0, |
155 { SEC_ASN1_INLINE | SEC_ASN1_XTRN, | 138 offsetof(NSSCMSSignerInfo, authAttr), nss_cms_set_of_attribute_template}, |
156 » offsetof(NSSCMSSignerInfo,digestAlg), | 139 {SEC_ASN1_INLINE | SEC_ASN1_XTRN, offsetof(NSSCMSSignerInfo, digestEncAlg), |
157 » SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) }, | 140 SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate)}, |
158 { SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0, | 141 {SEC_ASN1_OCTET_STRING, offsetof(NSSCMSSignerInfo, encDigest)}, |
159 » offsetof(NSSCMSSignerInfo,authAttr), | 142 {SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1, |
160 » nss_cms_set_of_attribute_template }, | 143 offsetof(NSSCMSSignerInfo, unAuthAttr), nss_cms_set_of_attribute_template}, |
161 { SEC_ASN1_INLINE | SEC_ASN1_XTRN, | 144 {0}}; |
162 » offsetof(NSSCMSSignerInfo,digestEncAlg), | |
163 » SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) }, | |
164 { SEC_ASN1_OCTET_STRING, | |
165 » offsetof(NSSCMSSignerInfo,encDigest) }, | |
166 { SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1, | |
167 » offsetof(NSSCMSSignerInfo,unAuthAttr), | |
168 » nss_cms_set_of_attribute_template }, | |
169 { 0 } | |
170 }; | |
171 | 145 |
172 /* ----------------------------------------------------------------------------- | 146 /* ----------------------------------------------------------------------------- |
173 * ENVELOPED DATA | 147 * ENVELOPED DATA |
174 */ | 148 */ |
175 | 149 |
176 static const SEC_ASN1Template NSSCMSOriginatorInfoTemplate[] = { | 150 static const SEC_ASN1Template NSSCMSOriginatorInfoTemplate[] = { |
177 { SEC_ASN1_SEQUENCE, | 151 {SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSSCMSOriginatorInfo)}, |
178 » 0, NULL, sizeof(NSSCMSOriginatorInfo) }, | 152 {SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | |
179 { SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | | 153 SEC_ASN1_XTRN | 0, |
180 SEC_ASN1_XTRN | 0, | 154 offsetof(NSSCMSOriginatorInfo, rawCerts), |
181 » offsetof(NSSCMSOriginatorInfo,rawCerts), | 155 SEC_ASN1_SUB(SEC_SetOfAnyTemplate)}, |
182 » SEC_ASN1_SUB(SEC_SetOfAnyTemplate) }, | 156 {SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | |
183 { SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | | 157 SEC_ASN1_XTRN | 1, |
184 SEC_ASN1_XTRN | 1, | 158 offsetof(NSSCMSOriginatorInfo, crls), |
185 » offsetof(NSSCMSOriginatorInfo,crls), | 159 SEC_ASN1_SUB(CERT_SetOfSignedCrlTemplate)}, |
186 » SEC_ASN1_SUB(CERT_SetOfSignedCrlTemplate) }, | 160 {0}}; |
187 { 0 } | |
188 }; | |
189 | 161 |
190 const SEC_ASN1Template NSSCMSRecipientInfoTemplate[]; | 162 const SEC_ASN1Template NSSCMSRecipientInfoTemplate[]; |
191 | 163 |
192 const SEC_ASN1Template NSSCMSEnvelopedDataTemplate[] = { | 164 const SEC_ASN1Template NSSCMSEnvelopedDataTemplate[] = { |
193 { SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM, | 165 {SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM, 0, |
194 » 0, NULL, sizeof(NSSCMSEnvelopedData) }, | 166 NULL, sizeof(NSSCMSEnvelopedData)}, |
195 { SEC_ASN1_INTEGER, | 167 {SEC_ASN1_INTEGER, offsetof(NSSCMSEnvelopedData, version)}, |
196 » offsetof(NSSCMSEnvelopedData,version) }, | 168 {SEC_ASN1_OPTIONAL | SEC_ASN1_POINTER | SEC_ASN1_CONSTRUCTED | |
197 { SEC_ASN1_OPTIONAL | SEC_ASN1_POINTER | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CON
TEXT_SPECIFIC | 0, | 169 SEC_ASN1_CONTEXT_SPECIFIC | 0, |
198 » offsetof(NSSCMSEnvelopedData,originatorInfo), | 170 offsetof(NSSCMSEnvelopedData, originatorInfo), |
199 » NSSCMSOriginatorInfoTemplate }, | 171 NSSCMSOriginatorInfoTemplate}, |
200 { SEC_ASN1_SET_OF, | 172 {SEC_ASN1_SET_OF, offsetof(NSSCMSEnvelopedData, recipientInfos), |
201 » offsetof(NSSCMSEnvelopedData,recipientInfos), | 173 NSSCMSRecipientInfoTemplate}, |
202 » NSSCMSRecipientInfoTemplate }, | 174 {SEC_ASN1_INLINE, offsetof(NSSCMSEnvelopedData, contentInfo), |
203 { SEC_ASN1_INLINE, | 175 NSSCMSEncryptedContentInfoTemplate}, |
204 » offsetof(NSSCMSEnvelopedData,contentInfo), | 176 {SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1, |
205 » NSSCMSEncryptedContentInfoTemplate }, | 177 offsetof(NSSCMSEnvelopedData, unprotectedAttr), |
206 { SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1, | 178 nss_cms_set_of_attribute_template}, |
207 » offsetof(NSSCMSEnvelopedData,unprotectedAttr), | 179 {0}}; |
208 » nss_cms_set_of_attribute_template }, | |
209 { 0 } | |
210 }; | |
211 | 180 |
212 const SEC_ASN1Template NSS_PointerToCMSEnvelopedDataTemplate[] = { | 181 const SEC_ASN1Template NSS_PointerToCMSEnvelopedDataTemplate[] = { |
213 { SEC_ASN1_POINTER, 0, NSSCMSEnvelopedDataTemplate } | 182 {SEC_ASN1_POINTER, 0, NSSCMSEnvelopedDataTemplate}}; |
214 }; | 183 |
215 | 184 /* here come the 15 gazillion templates for all the v3 varieties of |
216 /* here come the 15 gazillion templates for all the v3 varieties of RecipientInf
o */ | 185 * RecipientInfo */ |
217 | 186 |
218 /* ----------------------------------------------------------------------------- | 187 /* ----------------------------------------------------------------------------- |
219 * key transport recipient info | 188 * key transport recipient info |
220 */ | 189 */ |
221 | 190 |
222 static const SEC_ASN1Template NSSCMSRecipientIdentifierTemplate[] = { | 191 static const SEC_ASN1Template NSSCMSRecipientIdentifierTemplate[] = { |
223 { SEC_ASN1_CHOICE, | 192 {SEC_ASN1_CHOICE, offsetof(NSSCMSRecipientIdentifier, identifierType), |
224 » offsetof(NSSCMSRecipientIdentifier,identifierType), NULL, | 193 NULL, sizeof(NSSCMSRecipientIdentifier)}, |
225 » sizeof(NSSCMSRecipientIdentifier) }, | 194 {SEC_ASN1_POINTER | SEC_ASN1_CONTEXT_SPECIFIC | SEC_ASN1_XTRN | 0, |
226 { SEC_ASN1_POINTER | SEC_ASN1_CONTEXT_SPECIFIC | SEC_ASN1_XTRN | 0, | 195 offsetof(NSSCMSRecipientIdentifier, id.subjectKeyID), |
227 » offsetof(NSSCMSRecipientIdentifier,id.subjectKeyID), | 196 SEC_ASN1_SUB(SEC_OctetStringTemplate), |
228 » SEC_ASN1_SUB(SEC_OctetStringTemplate) , | 197 NSSCMSRecipientID_SubjectKeyID}, |
229 » NSSCMSRecipientID_SubjectKeyID }, | 198 {SEC_ASN1_POINTER | SEC_ASN1_XTRN, |
230 { SEC_ASN1_POINTER | SEC_ASN1_XTRN, | 199 offsetof(NSSCMSRecipientIdentifier, id.issuerAndSN), |
231 » offsetof(NSSCMSRecipientIdentifier,id.issuerAndSN), | 200 SEC_ASN1_SUB(CERT_IssuerAndSNTemplate), |
232 » SEC_ASN1_SUB(CERT_IssuerAndSNTemplate), | 201 NSSCMSRecipientID_IssuerSN}, |
233 » NSSCMSRecipientID_IssuerSN }, | 202 {0}}; |
234 { 0 } | |
235 }; | |
236 | |
237 | 203 |
238 static const SEC_ASN1Template NSSCMSKeyTransRecipientInfoTemplate[] = { | 204 static const SEC_ASN1Template NSSCMSKeyTransRecipientInfoTemplate[] = { |
239 { SEC_ASN1_SEQUENCE, | 205 {SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSSCMSKeyTransRecipientInfo)}, |
240 » 0, NULL, sizeof(NSSCMSKeyTransRecipientInfo) }, | 206 {SEC_ASN1_INTEGER, offsetof(NSSCMSKeyTransRecipientInfo, version)}, |
241 { SEC_ASN1_INTEGER, | 207 {SEC_ASN1_INLINE, |
242 » offsetof(NSSCMSKeyTransRecipientInfo,version) }, | 208 offsetof(NSSCMSKeyTransRecipientInfo, recipientIdentifier), |
243 { SEC_ASN1_INLINE, | 209 NSSCMSRecipientIdentifierTemplate}, |
244 » offsetof(NSSCMSKeyTransRecipientInfo,recipientIdentifier), | 210 {SEC_ASN1_INLINE | SEC_ASN1_XTRN, |
245 » NSSCMSRecipientIdentifierTemplate }, | 211 offsetof(NSSCMSKeyTransRecipientInfo, keyEncAlg), |
246 { SEC_ASN1_INLINE | SEC_ASN1_XTRN, | 212 SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate)}, |
247 » offsetof(NSSCMSKeyTransRecipientInfo,keyEncAlg), | 213 {SEC_ASN1_OCTET_STRING, offsetof(NSSCMSKeyTransRecipientInfo, encKey)}, |
248 » SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) }, | 214 {0}}; |
249 { SEC_ASN1_OCTET_STRING, | |
250 » offsetof(NSSCMSKeyTransRecipientInfo,encKey) }, | |
251 { 0 } | |
252 }; | |
253 | 215 |
254 /* ----------------------------------------------------------------------------- | 216 /* ----------------------------------------------------------------------------- |
255 * key agreement recipient info | 217 * key agreement recipient info |
256 */ | 218 */ |
257 | 219 |
258 static const SEC_ASN1Template NSSCMSOriginatorPublicKeyTemplate[] = { | 220 static const SEC_ASN1Template NSSCMSOriginatorPublicKeyTemplate[] = { |
259 { SEC_ASN1_SEQUENCE, | 221 {SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSSCMSOriginatorPublicKey)}, |
260 » 0, NULL, sizeof(NSSCMSOriginatorPublicKey) }, | 222 {SEC_ASN1_INLINE | SEC_ASN1_XTRN, |
261 { SEC_ASN1_INLINE | SEC_ASN1_XTRN, | 223 offsetof(NSSCMSOriginatorPublicKey, algorithmIdentifier), |
262 » offsetof(NSSCMSOriginatorPublicKey,algorithmIdentifier), | 224 SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate)}, |
263 » SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) }, | 225 {SEC_ASN1_INLINE | SEC_ASN1_XTRN, |
264 { SEC_ASN1_INLINE | SEC_ASN1_XTRN, | 226 offsetof(NSSCMSOriginatorPublicKey, publicKey), |
265 » offsetof(NSSCMSOriginatorPublicKey,publicKey), | 227 SEC_ASN1_SUB(SEC_BitStringTemplate)}, |
266 » SEC_ASN1_SUB(SEC_BitStringTemplate) }, | 228 {0}}; |
267 { 0 } | |
268 }; | |
269 | |
270 | 229 |
271 static const SEC_ASN1Template NSSCMSOriginatorIdentifierOrKeyTemplate[] = { | 230 static const SEC_ASN1Template NSSCMSOriginatorIdentifierOrKeyTemplate[] = { |
272 { SEC_ASN1_CHOICE, | 231 {SEC_ASN1_CHOICE, offsetof(NSSCMSOriginatorIdentifierOrKey, identifierType), |
273 » offsetof(NSSCMSOriginatorIdentifierOrKey,identifierType), NULL, | 232 NULL, sizeof(NSSCMSOriginatorIdentifierOrKey)}, |
274 » sizeof(NSSCMSOriginatorIdentifierOrKey) }, | 233 {SEC_ASN1_POINTER | SEC_ASN1_XTRN, |
275 { SEC_ASN1_POINTER | SEC_ASN1_XTRN, | 234 offsetof(NSSCMSOriginatorIdentifierOrKey, id.issuerAndSN), |
276 » offsetof(NSSCMSOriginatorIdentifierOrKey,id.issuerAndSN), | 235 SEC_ASN1_SUB(CERT_IssuerAndSNTemplate), |
277 » SEC_ASN1_SUB(CERT_IssuerAndSNTemplate), | 236 NSSCMSOriginatorIDOrKey_IssuerSN}, |
278 » NSSCMSOriginatorIDOrKey_IssuerSN }, | 237 {SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | |
279 { SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | | 238 SEC_ASN1_XTRN | 1, |
280 SEC_ASN1_XTRN | 1, | 239 offsetof(NSSCMSOriginatorIdentifierOrKey, id.subjectKeyID), |
281 » offsetof(NSSCMSOriginatorIdentifierOrKey,id.subjectKeyID), | 240 SEC_ASN1_SUB(SEC_PointerToOctetStringTemplate), |
282 » SEC_ASN1_SUB(SEC_PointerToOctetStringTemplate) , | 241 NSSCMSOriginatorIDOrKey_SubjectKeyID}, |
283 » NSSCMSOriginatorIDOrKey_SubjectKeyID }, | 242 {SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 2, |
284 { SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 2, | 243 offsetof(NSSCMSOriginatorIdentifierOrKey, id.originatorPublicKey), |
285 » offsetof(NSSCMSOriginatorIdentifierOrKey,id.originatorPublicKey), | 244 NSSCMSOriginatorPublicKeyTemplate, |
286 » NSSCMSOriginatorPublicKeyTemplate, | 245 NSSCMSOriginatorIDOrKey_OriginatorPublicKey}, |
287 » NSSCMSOriginatorIDOrKey_OriginatorPublicKey }, | 246 {0}}; |
288 { 0 } | |
289 }; | |
290 | 247 |
291 const SEC_ASN1Template NSSCMSRecipientKeyIdentifierTemplate[] = { | 248 const SEC_ASN1Template NSSCMSRecipientKeyIdentifierTemplate[] = { |
292 { SEC_ASN1_SEQUENCE, | 249 {SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSSCMSRecipientKeyIdentifier)}, |
293 » 0, NULL, sizeof(NSSCMSRecipientKeyIdentifier) }, | 250 {SEC_ASN1_OCTET_STRING, |
294 { SEC_ASN1_OCTET_STRING, | 251 offsetof(NSSCMSRecipientKeyIdentifier, subjectKeyIdentifier)}, |
295 » offsetof(NSSCMSRecipientKeyIdentifier,subjectKeyIdentifier) }, | 252 {SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING, |
296 { SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING, | 253 offsetof(NSSCMSRecipientKeyIdentifier, date)}, |
297 » offsetof(NSSCMSRecipientKeyIdentifier,date) }, | 254 {SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING, |
298 { SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING, | 255 offsetof(NSSCMSRecipientKeyIdentifier, other)}, |
299 » offsetof(NSSCMSRecipientKeyIdentifier,other) }, | 256 {0}}; |
300 { 0 } | |
301 }; | |
302 | |
303 | 257 |
304 static const SEC_ASN1Template NSSCMSKeyAgreeRecipientIdentifierTemplate[] = { | 258 static const SEC_ASN1Template NSSCMSKeyAgreeRecipientIdentifierTemplate[] = { |
305 { SEC_ASN1_CHOICE, | 259 {SEC_ASN1_CHOICE, |
306 » offsetof(NSSCMSKeyAgreeRecipientIdentifier,identifierType), NULL, | 260 offsetof(NSSCMSKeyAgreeRecipientIdentifier, identifierType), |
307 » sizeof(NSSCMSKeyAgreeRecipientIdentifier) }, | 261 NULL, |
308 { SEC_ASN1_POINTER | SEC_ASN1_XTRN, | 262 sizeof(NSSCMSKeyAgreeRecipientIdentifier)}, |
309 » offsetof(NSSCMSKeyAgreeRecipientIdentifier,id.issuerAndSN), | 263 {SEC_ASN1_POINTER | SEC_ASN1_XTRN, |
310 » SEC_ASN1_SUB(CERT_IssuerAndSNTemplate), | 264 offsetof(NSSCMSKeyAgreeRecipientIdentifier, id.issuerAndSN), |
311 » NSSCMSKeyAgreeRecipientID_IssuerSN }, | 265 SEC_ASN1_SUB(CERT_IssuerAndSNTemplate), |
312 { SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0, | 266 NSSCMSKeyAgreeRecipientID_IssuerSN}, |
313 » offsetof(NSSCMSKeyAgreeRecipientIdentifier,id.recipientKeyIdentifier), | 267 {SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0, |
314 » NSSCMSRecipientKeyIdentifierTemplate, | 268 offsetof(NSSCMSKeyAgreeRecipientIdentifier, id.recipientKeyIdentifier), |
315 » NSSCMSKeyAgreeRecipientID_RKeyID }, | 269 NSSCMSRecipientKeyIdentifierTemplate, |
316 { 0 } | 270 NSSCMSKeyAgreeRecipientID_RKeyID}, |
317 }; | 271 {0}}; |
318 | 272 |
319 static const SEC_ASN1Template NSSCMSRecipientEncryptedKeyTemplate[] = { | 273 static const SEC_ASN1Template NSSCMSRecipientEncryptedKeyTemplate[] = { |
320 { SEC_ASN1_SEQUENCE, | 274 {SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSSCMSRecipientEncryptedKey)}, |
321 » 0, NULL, sizeof(NSSCMSRecipientEncryptedKey) }, | 275 {SEC_ASN1_INLINE, |
322 { SEC_ASN1_INLINE, | 276 offsetof(NSSCMSRecipientEncryptedKey, recipientIdentifier), |
323 » offsetof(NSSCMSRecipientEncryptedKey,recipientIdentifier), | 277 NSSCMSKeyAgreeRecipientIdentifierTemplate}, |
324 » NSSCMSKeyAgreeRecipientIdentifierTemplate }, | 278 {SEC_ASN1_INLINE | SEC_ASN1_XTRN, |
325 { SEC_ASN1_INLINE | SEC_ASN1_XTRN, | 279 offsetof(NSSCMSRecipientEncryptedKey, encKey), |
326 » offsetof(NSSCMSRecipientEncryptedKey,encKey), | 280 SEC_ASN1_SUB(SEC_BitStringTemplate)}, |
327 » SEC_ASN1_SUB(SEC_BitStringTemplate) }, | 281 {0}}; |
328 { 0 } | |
329 }; | |
330 | 282 |
331 static const SEC_ASN1Template NSSCMSKeyAgreeRecipientInfoTemplate[] = { | 283 static const SEC_ASN1Template NSSCMSKeyAgreeRecipientInfoTemplate[] = { |
332 { SEC_ASN1_SEQUENCE, | 284 {SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSSCMSKeyAgreeRecipientInfo)}, |
333 » 0, NULL, sizeof(NSSCMSKeyAgreeRecipientInfo) }, | 285 {SEC_ASN1_INTEGER, offsetof(NSSCMSKeyAgreeRecipientInfo, version)}, |
334 { SEC_ASN1_INTEGER, | 286 {SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0, |
335 » offsetof(NSSCMSKeyAgreeRecipientInfo,version) }, | 287 offsetof(NSSCMSKeyAgreeRecipientInfo, originatorIdentifierOrKey), |
336 { SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 0, | 288 NSSCMSOriginatorIdentifierOrKeyTemplate}, |
337 » offsetof(NSSCMSKeyAgreeRecipientInfo,originatorIdentifierOrKey), | 289 {SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_EXPLICIT | |
338 » NSSCMSOriginatorIdentifierOrKeyTemplate }, | 290 SEC_ASN1_CONTEXT_SPECIFIC | SEC_ASN1_XTRN | 1, |
339 { SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_EXPLICIT | | 291 offsetof(NSSCMSKeyAgreeRecipientInfo, ukm), |
340 SEC_ASN1_CONTEXT_SPECIFIC | SEC_ASN1_XTRN | 1, | 292 SEC_ASN1_SUB(SEC_OctetStringTemplate)}, |
341 » offsetof(NSSCMSKeyAgreeRecipientInfo,ukm), | 293 {SEC_ASN1_INLINE | SEC_ASN1_XTRN, |
342 » SEC_ASN1_SUB(SEC_OctetStringTemplate) }, | 294 offsetof(NSSCMSKeyAgreeRecipientInfo, keyEncAlg), |
343 { SEC_ASN1_INLINE | SEC_ASN1_XTRN, | 295 SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate)}, |
344 » offsetof(NSSCMSKeyAgreeRecipientInfo,keyEncAlg), | 296 {SEC_ASN1_SEQUENCE_OF, |
345 » SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) }, | 297 offsetof(NSSCMSKeyAgreeRecipientInfo, recipientEncryptedKeys), |
346 { SEC_ASN1_SEQUENCE_OF, | 298 NSSCMSRecipientEncryptedKeyTemplate}, |
347 » offsetof(NSSCMSKeyAgreeRecipientInfo,recipientEncryptedKeys), | 299 {0}}; |
348 » NSSCMSRecipientEncryptedKeyTemplate }, | |
349 { 0 } | |
350 }; | |
351 | 300 |
352 /* ----------------------------------------------------------------------------- | 301 /* ----------------------------------------------------------------------------- |
353 * KEK recipient info | 302 * KEK recipient info |
354 */ | 303 */ |
355 | 304 |
356 static const SEC_ASN1Template NSSCMSKEKIdentifierTemplate[] = { | 305 static const SEC_ASN1Template NSSCMSKEKIdentifierTemplate[] = { |
357 { SEC_ASN1_SEQUENCE, | 306 {SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSSCMSKEKIdentifier)}, |
358 » 0, NULL, sizeof(NSSCMSKEKIdentifier) }, | 307 {SEC_ASN1_OCTET_STRING, offsetof(NSSCMSKEKIdentifier, keyIdentifier)}, |
359 { SEC_ASN1_OCTET_STRING, | 308 {SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING, |
360 » offsetof(NSSCMSKEKIdentifier,keyIdentifier) }, | 309 offsetof(NSSCMSKEKIdentifier, date)}, |
361 { SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING, | 310 {SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING, |
362 » offsetof(NSSCMSKEKIdentifier,date) }, | 311 offsetof(NSSCMSKEKIdentifier, other)}, |
363 { SEC_ASN1_OPTIONAL | SEC_ASN1_OCTET_STRING, | 312 {0}}; |
364 » offsetof(NSSCMSKEKIdentifier,other) }, | |
365 { 0 } | |
366 }; | |
367 | 313 |
368 static const SEC_ASN1Template NSSCMSKEKRecipientInfoTemplate[] = { | 314 static const SEC_ASN1Template NSSCMSKEKRecipientInfoTemplate[] = { |
369 { SEC_ASN1_SEQUENCE, | 315 {SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSSCMSKEKRecipientInfo)}, |
370 » 0, NULL, sizeof(NSSCMSKEKRecipientInfo) }, | 316 {SEC_ASN1_INTEGER, offsetof(NSSCMSKEKRecipientInfo, version)}, |
371 { SEC_ASN1_INTEGER, | 317 {SEC_ASN1_INLINE, offsetof(NSSCMSKEKRecipientInfo, kekIdentifier), |
372 » offsetof(NSSCMSKEKRecipientInfo,version) }, | 318 NSSCMSKEKIdentifierTemplate}, |
373 { SEC_ASN1_INLINE, | 319 {SEC_ASN1_INLINE | SEC_ASN1_XTRN, |
374 » offsetof(NSSCMSKEKRecipientInfo,kekIdentifier), | 320 offsetof(NSSCMSKEKRecipientInfo, keyEncAlg), |
375 » NSSCMSKEKIdentifierTemplate }, | 321 SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate)}, |
376 { SEC_ASN1_INLINE | SEC_ASN1_XTRN, | 322 {SEC_ASN1_OCTET_STRING, offsetof(NSSCMSKEKRecipientInfo, encKey)}, {0}}; |
377 » offsetof(NSSCMSKEKRecipientInfo,keyEncAlg), | |
378 » SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) }, | |
379 { SEC_ASN1_OCTET_STRING, | |
380 » offsetof(NSSCMSKEKRecipientInfo,encKey) }, | |
381 { 0 } | |
382 }; | |
383 | 323 |
384 /* ----------------------------------------------------------------------------- | 324 /* ----------------------------------------------------------------------------- |
385 * recipient info | 325 * recipient info |
386 */ | 326 */ |
387 const SEC_ASN1Template NSSCMSRecipientInfoTemplate[] = { | 327 const SEC_ASN1Template NSSCMSRecipientInfoTemplate[] = { |
388 { SEC_ASN1_CHOICE, | 328 {SEC_ASN1_CHOICE, offsetof(NSSCMSRecipientInfo, recipientInfoType), |
389 » offsetof(NSSCMSRecipientInfo,recipientInfoType), NULL, | 329 NULL, sizeof(NSSCMSRecipientInfo)}, |
390 » sizeof(NSSCMSRecipientInfo) }, | 330 {SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1, |
391 { SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1, | 331 offsetof(NSSCMSRecipientInfo, ri.keyAgreeRecipientInfo), |
392 » offsetof(NSSCMSRecipientInfo,ri.keyAgreeRecipientInfo), | 332 NSSCMSKeyAgreeRecipientInfoTemplate, |
393 » NSSCMSKeyAgreeRecipientInfoTemplate, | 333 NSSCMSRecipientInfoID_KeyAgree}, |
394 » NSSCMSRecipientInfoID_KeyAgree }, | 334 {SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 2, |
395 { SEC_ASN1_EXPLICIT | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 2, | 335 offsetof(NSSCMSRecipientInfo, ri.kekRecipientInfo), |
396 » offsetof(NSSCMSRecipientInfo,ri.kekRecipientInfo), | 336 NSSCMSKEKRecipientInfoTemplate, |
397 » NSSCMSKEKRecipientInfoTemplate, | 337 NSSCMSRecipientInfoID_KEK}, |
398 » NSSCMSRecipientInfoID_KEK }, | 338 {SEC_ASN1_INLINE, |
399 { SEC_ASN1_INLINE, | 339 offsetof(NSSCMSRecipientInfo, ri.keyTransRecipientInfo), |
400 » offsetof(NSSCMSRecipientInfo,ri.keyTransRecipientInfo), | 340 NSSCMSKeyTransRecipientInfoTemplate, |
401 » NSSCMSKeyTransRecipientInfoTemplate, | 341 NSSCMSRecipientInfoID_KeyTrans}, |
402 » NSSCMSRecipientInfoID_KeyTrans }, | 342 {0}}; |
403 { 0 } | |
404 }; | |
405 | 343 |
406 /* ----------------------------------------------------------------------------- | 344 /* ----------------------------------------------------------------------------- |
407 * | 345 * |
408 */ | 346 */ |
409 | 347 |
410 const SEC_ASN1Template NSSCMSDigestedDataTemplate[] = { | 348 const SEC_ASN1Template NSSCMSDigestedDataTemplate[] = { |
411 { SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM, | 349 {SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM, 0, |
412 » 0, NULL, sizeof(NSSCMSDigestedData) }, | 350 NULL, sizeof(NSSCMSDigestedData)}, |
413 { SEC_ASN1_INTEGER, | 351 {SEC_ASN1_INTEGER, offsetof(NSSCMSDigestedData, version)}, |
414 » offsetof(NSSCMSDigestedData,version) }, | 352 {SEC_ASN1_INLINE | SEC_ASN1_XTRN, offsetof(NSSCMSDigestedData, digestAlg), |
415 { SEC_ASN1_INLINE | SEC_ASN1_XTRN, | 353 SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate)}, |
416 » offsetof(NSSCMSDigestedData,digestAlg), | 354 {SEC_ASN1_INLINE, offsetof(NSSCMSDigestedData, contentInfo), |
417 » SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) }, | 355 NSSCMSEncapsulatedContentInfoTemplate}, |
418 { SEC_ASN1_INLINE, | 356 {SEC_ASN1_OCTET_STRING, offsetof(NSSCMSDigestedData, digest)}, {0}}; |
419 » offsetof(NSSCMSDigestedData,contentInfo), | |
420 » NSSCMSEncapsulatedContentInfoTemplate }, | |
421 { SEC_ASN1_OCTET_STRING, | |
422 » offsetof(NSSCMSDigestedData,digest) }, | |
423 { 0 } | |
424 }; | |
425 | 357 |
426 const SEC_ASN1Template NSS_PointerToCMSDigestedDataTemplate[] = { | 358 const SEC_ASN1Template NSS_PointerToCMSDigestedDataTemplate[] = { |
427 { SEC_ASN1_POINTER, 0, NSSCMSDigestedDataTemplate } | 359 {SEC_ASN1_POINTER, 0, NSSCMSDigestedDataTemplate}}; |
428 }; | |
429 | 360 |
430 const SEC_ASN1Template NSSCMSEncryptedDataTemplate[] = { | 361 const SEC_ASN1Template NSSCMSEncryptedDataTemplate[] = { |
431 { SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM, | 362 {SEC_ASN1_SEQUENCE | SEC_ASN1_MAY_STREAM, 0, |
432 » 0, NULL, sizeof(NSSCMSEncryptedData) }, | 363 NULL, sizeof(NSSCMSEncryptedData)}, |
433 { SEC_ASN1_INTEGER, | 364 {SEC_ASN1_INTEGER, offsetof(NSSCMSEncryptedData, version)}, |
434 » offsetof(NSSCMSEncryptedData,version) }, | 365 {SEC_ASN1_INLINE, offsetof(NSSCMSEncryptedData, contentInfo), |
435 { SEC_ASN1_INLINE, | 366 NSSCMSEncryptedContentInfoTemplate}, |
436 » offsetof(NSSCMSEncryptedData,contentInfo), | 367 {SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1, |
437 » NSSCMSEncryptedContentInfoTemplate }, | 368 offsetof(NSSCMSEncryptedData, unprotectedAttr), |
438 { SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | 1, | 369 nss_cms_set_of_attribute_template}, |
439 » offsetof(NSSCMSEncryptedData,unprotectedAttr), | 370 {0}}; |
440 » nss_cms_set_of_attribute_template }, | |
441 { 0 } | |
442 }; | |
443 | 371 |
444 const SEC_ASN1Template NSS_PointerToCMSEncryptedDataTemplate[] = { | 372 const SEC_ASN1Template NSS_PointerToCMSEncryptedDataTemplate[] = { |
445 { SEC_ASN1_POINTER, 0, NSSCMSEncryptedDataTemplate } | 373 {SEC_ASN1_POINTER, 0, NSSCMSEncryptedDataTemplate}}; |
446 }; | |
447 | 374 |
448 const SEC_ASN1Template NSSCMSGenericWrapperDataTemplate[] = { | 375 const SEC_ASN1Template NSSCMSGenericWrapperDataTemplate[] = { |
449 { SEC_ASN1_INLINE, | 376 {SEC_ASN1_INLINE, offsetof(NSSCMSGenericWrapperData, contentInfo), |
450 » offsetof(NSSCMSGenericWrapperData,contentInfo), | 377 NSSCMSEncapsulatedContentInfoTemplate}, }; |
451 » NSSCMSEncapsulatedContentInfoTemplate }, | |
452 }; | |
453 | 378 |
454 SEC_ASN1_CHOOSER_IMPLEMENT(NSSCMSGenericWrapperDataTemplate) | 379 SEC_ASN1_CHOOSER_IMPLEMENT(NSSCMSGenericWrapperDataTemplate) |
455 | 380 |
456 const SEC_ASN1Template NSS_PointerToCMSGenericWrapperDataTemplate[] = { | 381 const SEC_ASN1Template NSS_PointerToCMSGenericWrapperDataTemplate[] = { |
457 { SEC_ASN1_POINTER, 0, NSSCMSGenericWrapperDataTemplate } | 382 {SEC_ASN1_POINTER, 0, NSSCMSGenericWrapperDataTemplate}}; |
458 }; | |
459 | 383 |
460 SEC_ASN1_CHOOSER_IMPLEMENT(NSS_PointerToCMSGenericWrapperDataTemplate) | 384 SEC_ASN1_CHOOSER_IMPLEMENT(NSS_PointerToCMSGenericWrapperDataTemplate) |
461 | 385 |
462 /* ----------------------------------------------------------------------------- | 386 /* ----------------------------------------------------------------------------- |
463 * | 387 * |
464 */ | 388 */ |
465 static const SEC_ASN1Template * | 389 static const SEC_ASN1Template *nss_cms_choose_content_template( |
466 nss_cms_choose_content_template(void *src_or_dest, PRBool encoding) | 390 void *src_or_dest, PRBool encoding) { |
467 { | 391 const SEC_ASN1Template *theTemplate; |
468 const SEC_ASN1Template *theTemplate; | 392 NSSCMSContentInfo *cinfo; |
469 NSSCMSContentInfo *cinfo; | 393 SECOidTag type; |
470 SECOidTag type; | 394 |
471 | 395 PORT_Assert(src_or_dest != NULL); |
472 PORT_Assert (src_or_dest != NULL); | 396 if (src_or_dest == NULL) return NULL; |
473 if (src_or_dest == NULL) | 397 |
474 » return NULL; | 398 cinfo = (NSSCMSContentInfo *)src_or_dest; |
475 | 399 type = NSS_CMSContentInfo_GetContentTypeTag(cinfo); |
476 cinfo = (NSSCMSContentInfo *)src_or_dest; | 400 switch (type) { |
477 type = NSS_CMSContentInfo_GetContentTypeTag(cinfo); | |
478 switch (type) { | |
479 default: | 401 default: |
480 » theTemplate = NSS_CMSType_GetTemplate(type); | 402 theTemplate = NSS_CMSType_GetTemplate(type); |
481 » break; | 403 break; |
482 case SEC_OID_PKCS7_DATA: | 404 case SEC_OID_PKCS7_DATA: |
483 » theTemplate = SEC_ASN1_GET(SEC_PointerToOctetStringTemplate); | 405 theTemplate = SEC_ASN1_GET(SEC_PointerToOctetStringTemplate); |
484 » break; | 406 break; |
485 case SEC_OID_PKCS7_SIGNED_DATA: | 407 case SEC_OID_PKCS7_SIGNED_DATA: |
486 » theTemplate = NSS_PointerToCMSSignedDataTemplate; | 408 theTemplate = NSS_PointerToCMSSignedDataTemplate; |
487 » break; | 409 break; |
488 case SEC_OID_PKCS7_ENVELOPED_DATA: | 410 case SEC_OID_PKCS7_ENVELOPED_DATA: |
489 » theTemplate = NSS_PointerToCMSEnvelopedDataTemplate; | 411 theTemplate = NSS_PointerToCMSEnvelopedDataTemplate; |
490 » break; | 412 break; |
491 case SEC_OID_PKCS7_DIGESTED_DATA: | 413 case SEC_OID_PKCS7_DIGESTED_DATA: |
492 » theTemplate = NSS_PointerToCMSDigestedDataTemplate; | 414 theTemplate = NSS_PointerToCMSDigestedDataTemplate; |
493 » break; | 415 break; |
494 case SEC_OID_PKCS7_ENCRYPTED_DATA: | 416 case SEC_OID_PKCS7_ENCRYPTED_DATA: |
495 » theTemplate = NSS_PointerToCMSEncryptedDataTemplate; | 417 theTemplate = NSS_PointerToCMSEncryptedDataTemplate; |
496 » break; | 418 break; |
497 } | 419 } |
498 return theTemplate; | 420 return theTemplate; |
499 } | 421 } |
OLD | NEW |