diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/cms/cms_asn1.c | 1581 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/cms/cms_asn1.c | 1581 |
2 files changed, 2714 insertions, 448 deletions
diff --git a/src/lib/libcrypto/cms/cms_asn1.c b/src/lib/libcrypto/cms/cms_asn1.c index fbdac5b1ba..02a594575d 100644 --- a/src/lib/libcrypto/cms/cms_asn1.c +++ b/src/lib/libcrypto/cms/cms_asn1.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: cms_asn1.c,v 1.5 2014/07/12 16:03:37 miod Exp $ */ | 1 | /* $OpenBSD: cms_asn1.c,v 1.6 2015/07/25 15:22:10 jsing Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project. | 3 | * project. |
4 | */ | 4 | */ |
@@ -57,33 +57,161 @@ | |||
57 | #include "cms.h" | 57 | #include "cms.h" |
58 | #include "cms_lcl.h" | 58 | #include "cms_lcl.h" |
59 | 59 | ||
60 | ASN1_SEQUENCE(CMS_IssuerAndSerialNumber) = { | 60 | static const ASN1_TEMPLATE CMS_IssuerAndSerialNumber_seq_tt[] = { |
61 | ASN1_SIMPLE(CMS_IssuerAndSerialNumber, issuer, X509_NAME), | 61 | { |
62 | ASN1_SIMPLE(CMS_IssuerAndSerialNumber, serialNumber, ASN1_INTEGER) | 62 | .flags = 0, |
63 | } ASN1_SEQUENCE_END(CMS_IssuerAndSerialNumber) | 63 | .tag = 0, |
64 | 64 | .offset = offsetof(CMS_IssuerAndSerialNumber, issuer), | |
65 | ASN1_SEQUENCE(CMS_OtherCertificateFormat) = { | 65 | .field_name = "issuer", |
66 | ASN1_SIMPLE(CMS_OtherCertificateFormat, otherCertFormat, ASN1_OBJECT), | 66 | .item = &X509_NAME_it, |
67 | ASN1_OPT(CMS_OtherCertificateFormat, otherCert, ASN1_ANY) | 67 | }, |
68 | } ASN1_SEQUENCE_END(CMS_OtherCertificateFormat) | 68 | { |
69 | 69 | .flags = 0, | |
70 | ASN1_CHOICE(CMS_CertificateChoices) = { | 70 | .tag = 0, |
71 | ASN1_SIMPLE(CMS_CertificateChoices, d.certificate, X509), | 71 | .offset = offsetof(CMS_IssuerAndSerialNumber, serialNumber), |
72 | ASN1_IMP(CMS_CertificateChoices, d.extendedCertificate, ASN1_SEQUENCE, 0), | 72 | .field_name = "serialNumber", |
73 | ASN1_IMP(CMS_CertificateChoices, d.v1AttrCert, ASN1_SEQUENCE, 1), | 73 | .item = &ASN1_INTEGER_it, |
74 | ASN1_IMP(CMS_CertificateChoices, d.v2AttrCert, ASN1_SEQUENCE, 2), | 74 | }, |
75 | ASN1_IMP(CMS_CertificateChoices, d.other, CMS_OtherCertificateFormat, 3) | 75 | }; |
76 | } ASN1_CHOICE_END(CMS_CertificateChoices) | 76 | |
77 | 77 | const ASN1_ITEM CMS_IssuerAndSerialNumber_it = { | |
78 | ASN1_CHOICE(CMS_SignerIdentifier) = { | 78 | .itype = ASN1_ITYPE_SEQUENCE, |
79 | ASN1_SIMPLE(CMS_SignerIdentifier, d.issuerAndSerialNumber, CMS_IssuerAndSerialNumber), | 79 | .utype = V_ASN1_SEQUENCE, |
80 | ASN1_IMP(CMS_SignerIdentifier, d.subjectKeyIdentifier, ASN1_OCTET_STRING, 0) | 80 | .templates = CMS_IssuerAndSerialNumber_seq_tt, |
81 | } ASN1_CHOICE_END(CMS_SignerIdentifier) | 81 | .tcount = sizeof(CMS_IssuerAndSerialNumber_seq_tt) / sizeof(ASN1_TEMPLATE), |
82 | 82 | .funcs = NULL, | |
83 | ASN1_NDEF_SEQUENCE(CMS_EncapsulatedContentInfo) = { | 83 | .size = sizeof(CMS_IssuerAndSerialNumber), |
84 | ASN1_SIMPLE(CMS_EncapsulatedContentInfo, eContentType, ASN1_OBJECT), | 84 | .sname = "CMS_IssuerAndSerialNumber", |
85 | ASN1_NDEF_EXP_OPT(CMS_EncapsulatedContentInfo, eContent, ASN1_OCTET_STRING_NDEF, 0) | 85 | }; |
86 | } ASN1_NDEF_SEQUENCE_END(CMS_EncapsulatedContentInfo) | 86 | |
87 | static const ASN1_TEMPLATE CMS_OtherCertificateFormat_seq_tt[] = { | ||
88 | { | ||
89 | .flags = 0, | ||
90 | .tag = 0, | ||
91 | .offset = offsetof(CMS_OtherCertificateFormat, otherCertFormat), | ||
92 | .field_name = "otherCertFormat", | ||
93 | .item = &ASN1_OBJECT_it, | ||
94 | }, | ||
95 | { | ||
96 | .flags = ASN1_TFLG_OPTIONAL, | ||
97 | .tag = 0, | ||
98 | .offset = offsetof(CMS_OtherCertificateFormat, otherCert), | ||
99 | .field_name = "otherCert", | ||
100 | .item = &ASN1_ANY_it, | ||
101 | }, | ||
102 | }; | ||
103 | |||
104 | const ASN1_ITEM CMS_OtherCertificateFormat_it = { | ||
105 | .itype = ASN1_ITYPE_SEQUENCE, | ||
106 | .utype = V_ASN1_SEQUENCE, | ||
107 | .templates = CMS_OtherCertificateFormat_seq_tt, | ||
108 | .tcount = sizeof(CMS_OtherCertificateFormat_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
109 | .funcs = NULL, | ||
110 | .size = sizeof(CMS_OtherCertificateFormat), | ||
111 | .sname = "CMS_OtherCertificateFormat", | ||
112 | }; | ||
113 | |||
114 | static const ASN1_TEMPLATE CMS_CertificateChoices_ch_tt[] = { | ||
115 | { | ||
116 | .flags = 0, | ||
117 | .tag = 0, | ||
118 | .offset = offsetof(CMS_CertificateChoices, d.certificate), | ||
119 | .field_name = "d.certificate", | ||
120 | .item = &X509_it, | ||
121 | }, | ||
122 | { | ||
123 | .flags = ASN1_TFLG_IMPLICIT, | ||
124 | .tag = 0, | ||
125 | .offset = offsetof(CMS_CertificateChoices, d.extendedCertificate), | ||
126 | .field_name = "d.extendedCertificate", | ||
127 | .item = &ASN1_SEQUENCE_it, | ||
128 | }, | ||
129 | { | ||
130 | .flags = ASN1_TFLG_IMPLICIT, | ||
131 | .tag = 1, | ||
132 | .offset = offsetof(CMS_CertificateChoices, d.v1AttrCert), | ||
133 | .field_name = "d.v1AttrCert", | ||
134 | .item = &ASN1_SEQUENCE_it, | ||
135 | }, | ||
136 | { | ||
137 | .flags = ASN1_TFLG_IMPLICIT, | ||
138 | .tag = 2, | ||
139 | .offset = offsetof(CMS_CertificateChoices, d.v2AttrCert), | ||
140 | .field_name = "d.v2AttrCert", | ||
141 | .item = &ASN1_SEQUENCE_it, | ||
142 | }, | ||
143 | { | ||
144 | .flags = ASN1_TFLG_IMPLICIT, | ||
145 | .tag = 3, | ||
146 | .offset = offsetof(CMS_CertificateChoices, d.other), | ||
147 | .field_name = "d.other", | ||
148 | .item = &CMS_OtherCertificateFormat_it, | ||
149 | }, | ||
150 | }; | ||
151 | |||
152 | const ASN1_ITEM CMS_CertificateChoices_it = { | ||
153 | .itype = ASN1_ITYPE_CHOICE, | ||
154 | .utype = offsetof(CMS_CertificateChoices, type), | ||
155 | .templates = CMS_CertificateChoices_ch_tt, | ||
156 | .tcount = sizeof(CMS_CertificateChoices_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
157 | .funcs = NULL, | ||
158 | .size = sizeof(CMS_CertificateChoices), | ||
159 | .sname = "CMS_CertificateChoices", | ||
160 | }; | ||
161 | |||
162 | static const ASN1_TEMPLATE CMS_SignerIdentifier_ch_tt[] = { | ||
163 | { | ||
164 | .flags = 0, | ||
165 | .tag = 0, | ||
166 | .offset = offsetof(CMS_SignerIdentifier, d.issuerAndSerialNumber), | ||
167 | .field_name = "d.issuerAndSerialNumber", | ||
168 | .item = &CMS_IssuerAndSerialNumber_it, | ||
169 | }, | ||
170 | { | ||
171 | .flags = ASN1_TFLG_IMPLICIT, | ||
172 | .tag = 0, | ||
173 | .offset = offsetof(CMS_SignerIdentifier, d.subjectKeyIdentifier), | ||
174 | .field_name = "d.subjectKeyIdentifier", | ||
175 | .item = &ASN1_OCTET_STRING_it, | ||
176 | }, | ||
177 | }; | ||
178 | |||
179 | const ASN1_ITEM CMS_SignerIdentifier_it = { | ||
180 | .itype = ASN1_ITYPE_CHOICE, | ||
181 | .utype = offsetof(CMS_SignerIdentifier, type), | ||
182 | .templates = CMS_SignerIdentifier_ch_tt, | ||
183 | .tcount = sizeof(CMS_SignerIdentifier_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
184 | .funcs = NULL, | ||
185 | .size = sizeof(CMS_SignerIdentifier), | ||
186 | .sname = "CMS_SignerIdentifier", | ||
187 | }; | ||
188 | |||
189 | static const ASN1_TEMPLATE CMS_EncapsulatedContentInfo_seq_tt[] = { | ||
190 | { | ||
191 | .flags = 0, | ||
192 | .tag = 0, | ||
193 | .offset = offsetof(CMS_EncapsulatedContentInfo, eContentType), | ||
194 | .field_name = "eContentType", | ||
195 | .item = &ASN1_OBJECT_it, | ||
196 | }, | ||
197 | { | ||
198 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL | ASN1_TFLG_NDEF, | ||
199 | .tag = 0, | ||
200 | .offset = offsetof(CMS_EncapsulatedContentInfo, eContent), | ||
201 | .field_name = "eContent", | ||
202 | .item = &ASN1_OCTET_STRING_NDEF_it, | ||
203 | }, | ||
204 | }; | ||
205 | |||
206 | const ASN1_ITEM CMS_EncapsulatedContentInfo_it = { | ||
207 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
208 | .utype = V_ASN1_SEQUENCE, | ||
209 | .templates = CMS_EncapsulatedContentInfo_seq_tt, | ||
210 | .tcount = sizeof(CMS_EncapsulatedContentInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
211 | .funcs = NULL, | ||
212 | .size = sizeof(CMS_EncapsulatedContentInfo), | ||
213 | .sname = "CMS_EncapsulatedContentInfo", | ||
214 | }; | ||
87 | 215 | ||
88 | /* Minor tweak to operation: free up signer key, cert */ | 216 | /* Minor tweak to operation: free up signer key, cert */ |
89 | static int | 217 | static int |
@@ -98,117 +226,653 @@ cms_si_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | |||
98 | return 1; | 226 | return 1; |
99 | } | 227 | } |
100 | 228 | ||
101 | ASN1_SEQUENCE_cb(CMS_SignerInfo, cms_si_cb) = { | 229 | static const ASN1_AUX CMS_SignerInfo_aux = { |
102 | ASN1_SIMPLE(CMS_SignerInfo, version, LONG), | 230 | .app_data = NULL, |
103 | ASN1_SIMPLE(CMS_SignerInfo, sid, CMS_SignerIdentifier), | 231 | .flags = 0, |
104 | ASN1_SIMPLE(CMS_SignerInfo, digestAlgorithm, X509_ALGOR), | 232 | .ref_offset = 0, |
105 | ASN1_IMP_SET_OF_OPT(CMS_SignerInfo, signedAttrs, X509_ATTRIBUTE, 0), | 233 | .ref_lock = 0, |
106 | ASN1_SIMPLE(CMS_SignerInfo, signatureAlgorithm, X509_ALGOR), | 234 | .asn1_cb = cms_si_cb, |
107 | ASN1_SIMPLE(CMS_SignerInfo, signature, ASN1_OCTET_STRING), | 235 | .enc_offset = 0, |
108 | ASN1_IMP_SET_OF_OPT(CMS_SignerInfo, unsignedAttrs, X509_ATTRIBUTE, 1) | 236 | }; |
109 | } ASN1_SEQUENCE_END_cb(CMS_SignerInfo, CMS_SignerInfo) | 237 | static const ASN1_TEMPLATE CMS_SignerInfo_seq_tt[] = { |
110 | 238 | { | |
111 | ASN1_SEQUENCE(CMS_OtherRevocationInfoFormat) = { | 239 | .flags = 0, |
112 | ASN1_SIMPLE(CMS_OtherRevocationInfoFormat, otherRevInfoFormat, ASN1_OBJECT), | 240 | .tag = 0, |
113 | ASN1_OPT(CMS_OtherRevocationInfoFormat, otherRevInfo, ASN1_ANY) | 241 | .offset = offsetof(CMS_SignerInfo, version), |
114 | } ASN1_SEQUENCE_END(CMS_OtherRevocationInfoFormat) | 242 | .field_name = "version", |
115 | 243 | .item = &LONG_it, | |
116 | ASN1_CHOICE(CMS_RevocationInfoChoice) = { | 244 | }, |
117 | ASN1_SIMPLE(CMS_RevocationInfoChoice, d.crl, X509_CRL), | 245 | { |
118 | ASN1_IMP(CMS_RevocationInfoChoice, d.other, CMS_OtherRevocationInfoFormat, 1) | 246 | .flags = 0, |
119 | } ASN1_CHOICE_END(CMS_RevocationInfoChoice) | 247 | .tag = 0, |
120 | 248 | .offset = offsetof(CMS_SignerInfo, sid), | |
121 | ASN1_NDEF_SEQUENCE(CMS_SignedData) = { | 249 | .field_name = "sid", |
122 | ASN1_SIMPLE(CMS_SignedData, version, LONG), | 250 | .item = &CMS_SignerIdentifier_it, |
123 | ASN1_SET_OF(CMS_SignedData, digestAlgorithms, X509_ALGOR), | 251 | }, |
124 | ASN1_SIMPLE(CMS_SignedData, encapContentInfo, CMS_EncapsulatedContentInfo), | 252 | { |
125 | ASN1_IMP_SET_OF_OPT(CMS_SignedData, certificates, CMS_CertificateChoices, 0), | 253 | .flags = 0, |
126 | ASN1_IMP_SET_OF_OPT(CMS_SignedData, crls, CMS_RevocationInfoChoice, 1), | 254 | .tag = 0, |
127 | ASN1_SET_OF(CMS_SignedData, signerInfos, CMS_SignerInfo) | 255 | .offset = offsetof(CMS_SignerInfo, digestAlgorithm), |
128 | } ASN1_NDEF_SEQUENCE_END(CMS_SignedData) | 256 | .field_name = "digestAlgorithm", |
129 | 257 | .item = &X509_ALGOR_it, | |
130 | ASN1_SEQUENCE(CMS_OriginatorInfo) = { | 258 | }, |
131 | ASN1_IMP_SET_OF_OPT(CMS_OriginatorInfo, certificates, CMS_CertificateChoices, 0), | 259 | { |
132 | ASN1_IMP_SET_OF_OPT(CMS_OriginatorInfo, crls, CMS_RevocationInfoChoice, 1) | 260 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, |
133 | } ASN1_SEQUENCE_END(CMS_OriginatorInfo) | 261 | .tag = 0, |
134 | 262 | .offset = offsetof(CMS_SignerInfo, signedAttrs), | |
135 | ASN1_NDEF_SEQUENCE(CMS_EncryptedContentInfo) = { | 263 | .field_name = "signedAttrs", |
136 | ASN1_SIMPLE(CMS_EncryptedContentInfo, contentType, ASN1_OBJECT), | 264 | .item = &X509_ATTRIBUTE_it, |
137 | ASN1_SIMPLE(CMS_EncryptedContentInfo, contentEncryptionAlgorithm, X509_ALGOR), | 265 | }, |
138 | ASN1_IMP_OPT(CMS_EncryptedContentInfo, encryptedContent, ASN1_OCTET_STRING_NDEF, 0) | 266 | { |
139 | } ASN1_NDEF_SEQUENCE_END(CMS_EncryptedContentInfo) | 267 | .flags = 0, |
140 | 268 | .tag = 0, | |
141 | ASN1_SEQUENCE(CMS_KeyTransRecipientInfo) = { | 269 | .offset = offsetof(CMS_SignerInfo, signatureAlgorithm), |
142 | ASN1_SIMPLE(CMS_KeyTransRecipientInfo, version, LONG), | 270 | .field_name = "signatureAlgorithm", |
143 | ASN1_SIMPLE(CMS_KeyTransRecipientInfo, rid, CMS_SignerIdentifier), | 271 | .item = &X509_ALGOR_it, |
144 | ASN1_SIMPLE(CMS_KeyTransRecipientInfo, keyEncryptionAlgorithm, X509_ALGOR), | 272 | }, |
145 | ASN1_SIMPLE(CMS_KeyTransRecipientInfo, encryptedKey, ASN1_OCTET_STRING) | 273 | { |
146 | } ASN1_SEQUENCE_END(CMS_KeyTransRecipientInfo) | 274 | .flags = 0, |
147 | 275 | .tag = 0, | |
148 | ASN1_SEQUENCE(CMS_OtherKeyAttribute) = { | 276 | .offset = offsetof(CMS_SignerInfo, signature), |
149 | ASN1_SIMPLE(CMS_OtherKeyAttribute, keyAttrId, ASN1_OBJECT), | 277 | .field_name = "signature", |
150 | ASN1_OPT(CMS_OtherKeyAttribute, keyAttr, ASN1_ANY) | 278 | .item = &ASN1_OCTET_STRING_it, |
151 | } ASN1_SEQUENCE_END(CMS_OtherKeyAttribute) | 279 | }, |
152 | 280 | { | |
153 | ASN1_SEQUENCE(CMS_RecipientKeyIdentifier) = { | 281 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, |
154 | ASN1_SIMPLE(CMS_RecipientKeyIdentifier, subjectKeyIdentifier, ASN1_OCTET_STRING), | 282 | .tag = 1, |
155 | ASN1_OPT(CMS_RecipientKeyIdentifier, date, ASN1_GENERALIZEDTIME), | 283 | .offset = offsetof(CMS_SignerInfo, unsignedAttrs), |
156 | ASN1_OPT(CMS_RecipientKeyIdentifier, other, CMS_OtherKeyAttribute) | 284 | .field_name = "unsignedAttrs", |
157 | } ASN1_SEQUENCE_END(CMS_RecipientKeyIdentifier) | 285 | .item = &X509_ATTRIBUTE_it, |
158 | 286 | }, | |
159 | ASN1_CHOICE(CMS_KeyAgreeRecipientIdentifier) = { | 287 | }; |
160 | ASN1_SIMPLE(CMS_KeyAgreeRecipientIdentifier, d.issuerAndSerialNumber, CMS_IssuerAndSerialNumber), | 288 | |
161 | ASN1_IMP(CMS_KeyAgreeRecipientIdentifier, d.rKeyId, CMS_RecipientKeyIdentifier, 0) | 289 | const ASN1_ITEM CMS_SignerInfo_it = { |
162 | } ASN1_CHOICE_END(CMS_KeyAgreeRecipientIdentifier) | 290 | .itype = ASN1_ITYPE_SEQUENCE, |
163 | 291 | .utype = V_ASN1_SEQUENCE, | |
164 | ASN1_SEQUENCE(CMS_RecipientEncryptedKey) = { | 292 | .templates = CMS_SignerInfo_seq_tt, |
165 | ASN1_SIMPLE(CMS_RecipientEncryptedKey, rid, CMS_KeyAgreeRecipientIdentifier), | 293 | .tcount = sizeof(CMS_SignerInfo_seq_tt) / sizeof(ASN1_TEMPLATE), |
166 | ASN1_SIMPLE(CMS_RecipientEncryptedKey, encryptedKey, ASN1_OCTET_STRING) | 294 | .funcs = &CMS_SignerInfo_aux, |
167 | } ASN1_SEQUENCE_END(CMS_RecipientEncryptedKey) | 295 | .size = sizeof(CMS_SignerInfo), |
168 | 296 | .sname = "CMS_SignerInfo", | |
169 | ASN1_SEQUENCE(CMS_OriginatorPublicKey) = { | 297 | }; |
170 | ASN1_SIMPLE(CMS_OriginatorPublicKey, algorithm, X509_ALGOR), | 298 | |
171 | ASN1_SIMPLE(CMS_OriginatorPublicKey, publicKey, ASN1_BIT_STRING) | 299 | static const ASN1_TEMPLATE CMS_OtherRevocationInfoFormat_seq_tt[] = { |
172 | } ASN1_SEQUENCE_END(CMS_OriginatorPublicKey) | 300 | { |
173 | 301 | .flags = 0, | |
174 | ASN1_CHOICE(CMS_OriginatorIdentifierOrKey) = { | 302 | .tag = 0, |
175 | ASN1_SIMPLE(CMS_OriginatorIdentifierOrKey, d.issuerAndSerialNumber, CMS_IssuerAndSerialNumber), | 303 | .offset = offsetof(CMS_OtherRevocationInfoFormat, otherRevInfoFormat), |
176 | ASN1_IMP(CMS_OriginatorIdentifierOrKey, d.subjectKeyIdentifier, ASN1_OCTET_STRING, 0), | 304 | .field_name = "otherRevInfoFormat", |
177 | ASN1_IMP(CMS_OriginatorIdentifierOrKey, d.originatorKey, CMS_OriginatorPublicKey, 1) | 305 | .item = &ASN1_OBJECT_it, |
178 | } ASN1_CHOICE_END(CMS_OriginatorIdentifierOrKey) | 306 | }, |
179 | 307 | { | |
180 | ASN1_SEQUENCE(CMS_KeyAgreeRecipientInfo) = { | 308 | .flags = ASN1_TFLG_OPTIONAL, |
181 | ASN1_SIMPLE(CMS_KeyAgreeRecipientInfo, version, LONG), | 309 | .tag = 0, |
182 | ASN1_EXP(CMS_KeyAgreeRecipientInfo, originator, CMS_OriginatorIdentifierOrKey, 0), | 310 | .offset = offsetof(CMS_OtherRevocationInfoFormat, otherRevInfo), |
183 | ASN1_EXP_OPT(CMS_KeyAgreeRecipientInfo, ukm, ASN1_OCTET_STRING, 1), | 311 | .field_name = "otherRevInfo", |
184 | ASN1_SIMPLE(CMS_KeyAgreeRecipientInfo, keyEncryptionAlgorithm, X509_ALGOR), | 312 | .item = &ASN1_ANY_it, |
185 | ASN1_SEQUENCE_OF(CMS_KeyAgreeRecipientInfo, recipientEncryptedKeys, CMS_RecipientEncryptedKey) | 313 | }, |
186 | } ASN1_SEQUENCE_END(CMS_KeyAgreeRecipientInfo) | 314 | }; |
187 | 315 | ||
188 | ASN1_SEQUENCE(CMS_KEKIdentifier) = { | 316 | const ASN1_ITEM CMS_OtherRevocationInfoFormat_it = { |
189 | ASN1_SIMPLE(CMS_KEKIdentifier, keyIdentifier, ASN1_OCTET_STRING), | 317 | .itype = ASN1_ITYPE_SEQUENCE, |
190 | ASN1_OPT(CMS_KEKIdentifier, date, ASN1_GENERALIZEDTIME), | 318 | .utype = V_ASN1_SEQUENCE, |
191 | ASN1_OPT(CMS_KEKIdentifier, other, CMS_OtherKeyAttribute) | 319 | .templates = CMS_OtherRevocationInfoFormat_seq_tt, |
192 | } ASN1_SEQUENCE_END(CMS_KEKIdentifier) | 320 | .tcount = sizeof(CMS_OtherRevocationInfoFormat_seq_tt) / sizeof(ASN1_TEMPLATE), |
193 | 321 | .funcs = NULL, | |
194 | ASN1_SEQUENCE(CMS_KEKRecipientInfo) = { | 322 | .size = sizeof(CMS_OtherRevocationInfoFormat), |
195 | ASN1_SIMPLE(CMS_KEKRecipientInfo, version, LONG), | 323 | .sname = "CMS_OtherRevocationInfoFormat", |
196 | ASN1_SIMPLE(CMS_KEKRecipientInfo, kekid, CMS_KEKIdentifier), | 324 | }; |
197 | ASN1_SIMPLE(CMS_KEKRecipientInfo, keyEncryptionAlgorithm, X509_ALGOR), | 325 | |
198 | ASN1_SIMPLE(CMS_KEKRecipientInfo, encryptedKey, ASN1_OCTET_STRING) | 326 | static const ASN1_TEMPLATE CMS_RevocationInfoChoice_ch_tt[] = { |
199 | } ASN1_SEQUENCE_END(CMS_KEKRecipientInfo) | 327 | { |
200 | 328 | .flags = 0, | |
201 | ASN1_SEQUENCE(CMS_PasswordRecipientInfo) = { | 329 | .tag = 0, |
202 | ASN1_SIMPLE(CMS_PasswordRecipientInfo, version, LONG), | 330 | .offset = offsetof(CMS_RevocationInfoChoice, d.crl), |
203 | ASN1_IMP_OPT(CMS_PasswordRecipientInfo, keyDerivationAlgorithm, X509_ALGOR, 0), | 331 | .field_name = "d.crl", |
204 | ASN1_SIMPLE(CMS_PasswordRecipientInfo, keyEncryptionAlgorithm, X509_ALGOR), | 332 | .item = &X509_CRL_it, |
205 | ASN1_SIMPLE(CMS_PasswordRecipientInfo, encryptedKey, ASN1_OCTET_STRING) | 333 | }, |
206 | } ASN1_SEQUENCE_END(CMS_PasswordRecipientInfo) | 334 | { |
207 | 335 | .flags = ASN1_TFLG_IMPLICIT, | |
208 | ASN1_SEQUENCE(CMS_OtherRecipientInfo) = { | 336 | .tag = 1, |
209 | ASN1_SIMPLE(CMS_OtherRecipientInfo, oriType, ASN1_OBJECT), | 337 | .offset = offsetof(CMS_RevocationInfoChoice, d.other), |
210 | ASN1_OPT(CMS_OtherRecipientInfo, oriValue, ASN1_ANY) | 338 | .field_name = "d.other", |
211 | } ASN1_SEQUENCE_END(CMS_OtherRecipientInfo) | 339 | .item = &CMS_OtherRevocationInfoFormat_it, |
340 | }, | ||
341 | }; | ||
342 | |||
343 | const ASN1_ITEM CMS_RevocationInfoChoice_it = { | ||
344 | .itype = ASN1_ITYPE_CHOICE, | ||
345 | .utype = offsetof(CMS_RevocationInfoChoice, type), | ||
346 | .templates = CMS_RevocationInfoChoice_ch_tt, | ||
347 | .tcount = sizeof(CMS_RevocationInfoChoice_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
348 | .funcs = NULL, | ||
349 | .size = sizeof(CMS_RevocationInfoChoice), | ||
350 | .sname = "CMS_RevocationInfoChoice", | ||
351 | }; | ||
352 | |||
353 | static const ASN1_TEMPLATE CMS_SignedData_seq_tt[] = { | ||
354 | { | ||
355 | .flags = 0, | ||
356 | .tag = 0, | ||
357 | .offset = offsetof(CMS_SignedData, version), | ||
358 | .field_name = "version", | ||
359 | .item = &LONG_it, | ||
360 | }, | ||
361 | { | ||
362 | .flags = ASN1_TFLG_SET_OF, | ||
363 | .tag = 0, | ||
364 | .offset = offsetof(CMS_SignedData, digestAlgorithms), | ||
365 | .field_name = "digestAlgorithms", | ||
366 | .item = &X509_ALGOR_it, | ||
367 | }, | ||
368 | { | ||
369 | .flags = 0, | ||
370 | .tag = 0, | ||
371 | .offset = offsetof(CMS_SignedData, encapContentInfo), | ||
372 | .field_name = "encapContentInfo", | ||
373 | .item = &CMS_EncapsulatedContentInfo_it, | ||
374 | }, | ||
375 | { | ||
376 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
377 | .tag = 0, | ||
378 | .offset = offsetof(CMS_SignedData, certificates), | ||
379 | .field_name = "certificates", | ||
380 | .item = &CMS_CertificateChoices_it, | ||
381 | }, | ||
382 | { | ||
383 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
384 | .tag = 1, | ||
385 | .offset = offsetof(CMS_SignedData, crls), | ||
386 | .field_name = "crls", | ||
387 | .item = &CMS_RevocationInfoChoice_it, | ||
388 | }, | ||
389 | { | ||
390 | .flags = ASN1_TFLG_SET_OF, | ||
391 | .tag = 0, | ||
392 | .offset = offsetof(CMS_SignedData, signerInfos), | ||
393 | .field_name = "signerInfos", | ||
394 | .item = &CMS_SignerInfo_it, | ||
395 | }, | ||
396 | }; | ||
397 | |||
398 | const ASN1_ITEM CMS_SignedData_it = { | ||
399 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
400 | .utype = V_ASN1_SEQUENCE, | ||
401 | .templates = CMS_SignedData_seq_tt, | ||
402 | .tcount = sizeof(CMS_SignedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
403 | .funcs = NULL, | ||
404 | .size = sizeof(CMS_SignedData), | ||
405 | .sname = "CMS_SignedData", | ||
406 | }; | ||
407 | |||
408 | static const ASN1_TEMPLATE CMS_OriginatorInfo_seq_tt[] = { | ||
409 | { | ||
410 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
411 | .tag = 0, | ||
412 | .offset = offsetof(CMS_OriginatorInfo, certificates), | ||
413 | .field_name = "certificates", | ||
414 | .item = &CMS_CertificateChoices_it, | ||
415 | }, | ||
416 | { | ||
417 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
418 | .tag = 1, | ||
419 | .offset = offsetof(CMS_OriginatorInfo, crls), | ||
420 | .field_name = "crls", | ||
421 | .item = &CMS_RevocationInfoChoice_it, | ||
422 | }, | ||
423 | }; | ||
424 | |||
425 | const ASN1_ITEM CMS_OriginatorInfo_it = { | ||
426 | .itype = ASN1_ITYPE_SEQUENCE, | ||
427 | .utype = V_ASN1_SEQUENCE, | ||
428 | .templates = CMS_OriginatorInfo_seq_tt, | ||
429 | .tcount = sizeof(CMS_OriginatorInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
430 | .funcs = NULL, | ||
431 | .size = sizeof(CMS_OriginatorInfo), | ||
432 | .sname = "CMS_OriginatorInfo", | ||
433 | }; | ||
434 | |||
435 | static const ASN1_TEMPLATE CMS_EncryptedContentInfo_seq_tt[] = { | ||
436 | { | ||
437 | .flags = 0, | ||
438 | .tag = 0, | ||
439 | .offset = offsetof(CMS_EncryptedContentInfo, contentType), | ||
440 | .field_name = "contentType", | ||
441 | .item = &ASN1_OBJECT_it, | ||
442 | }, | ||
443 | { | ||
444 | .flags = 0, | ||
445 | .tag = 0, | ||
446 | .offset = offsetof(CMS_EncryptedContentInfo, contentEncryptionAlgorithm), | ||
447 | .field_name = "contentEncryptionAlgorithm", | ||
448 | .item = &X509_ALGOR_it, | ||
449 | }, | ||
450 | { | ||
451 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, | ||
452 | .tag = 0, | ||
453 | .offset = offsetof(CMS_EncryptedContentInfo, encryptedContent), | ||
454 | .field_name = "encryptedContent", | ||
455 | .item = &ASN1_OCTET_STRING_NDEF_it, | ||
456 | }, | ||
457 | }; | ||
458 | |||
459 | const ASN1_ITEM CMS_EncryptedContentInfo_it = { | ||
460 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
461 | .utype = V_ASN1_SEQUENCE, | ||
462 | .templates = CMS_EncryptedContentInfo_seq_tt, | ||
463 | .tcount = sizeof(CMS_EncryptedContentInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
464 | .funcs = NULL, | ||
465 | .size = sizeof(CMS_EncryptedContentInfo), | ||
466 | .sname = "CMS_EncryptedContentInfo", | ||
467 | }; | ||
468 | |||
469 | static const ASN1_TEMPLATE CMS_KeyTransRecipientInfo_seq_tt[] = { | ||
470 | { | ||
471 | .flags = 0, | ||
472 | .tag = 0, | ||
473 | .offset = offsetof(CMS_KeyTransRecipientInfo, version), | ||
474 | .field_name = "version", | ||
475 | .item = &LONG_it, | ||
476 | }, | ||
477 | { | ||
478 | .flags = 0, | ||
479 | .tag = 0, | ||
480 | .offset = offsetof(CMS_KeyTransRecipientInfo, rid), | ||
481 | .field_name = "rid", | ||
482 | .item = &CMS_SignerIdentifier_it, | ||
483 | }, | ||
484 | { | ||
485 | .flags = 0, | ||
486 | .tag = 0, | ||
487 | .offset = offsetof(CMS_KeyTransRecipientInfo, keyEncryptionAlgorithm), | ||
488 | .field_name = "keyEncryptionAlgorithm", | ||
489 | .item = &X509_ALGOR_it, | ||
490 | }, | ||
491 | { | ||
492 | .flags = 0, | ||
493 | .tag = 0, | ||
494 | .offset = offsetof(CMS_KeyTransRecipientInfo, encryptedKey), | ||
495 | .field_name = "encryptedKey", | ||
496 | .item = &ASN1_OCTET_STRING_it, | ||
497 | }, | ||
498 | }; | ||
499 | |||
500 | const ASN1_ITEM CMS_KeyTransRecipientInfo_it = { | ||
501 | .itype = ASN1_ITYPE_SEQUENCE, | ||
502 | .utype = V_ASN1_SEQUENCE, | ||
503 | .templates = CMS_KeyTransRecipientInfo_seq_tt, | ||
504 | .tcount = sizeof(CMS_KeyTransRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
505 | .funcs = NULL, | ||
506 | .size = sizeof(CMS_KeyTransRecipientInfo), | ||
507 | .sname = "CMS_KeyTransRecipientInfo", | ||
508 | }; | ||
509 | |||
510 | static const ASN1_TEMPLATE CMS_OtherKeyAttribute_seq_tt[] = { | ||
511 | { | ||
512 | .flags = 0, | ||
513 | .tag = 0, | ||
514 | .offset = offsetof(CMS_OtherKeyAttribute, keyAttrId), | ||
515 | .field_name = "keyAttrId", | ||
516 | .item = &ASN1_OBJECT_it, | ||
517 | }, | ||
518 | { | ||
519 | .flags = ASN1_TFLG_OPTIONAL, | ||
520 | .tag = 0, | ||
521 | .offset = offsetof(CMS_OtherKeyAttribute, keyAttr), | ||
522 | .field_name = "keyAttr", | ||
523 | .item = &ASN1_ANY_it, | ||
524 | }, | ||
525 | }; | ||
526 | |||
527 | const ASN1_ITEM CMS_OtherKeyAttribute_it = { | ||
528 | .itype = ASN1_ITYPE_SEQUENCE, | ||
529 | .utype = V_ASN1_SEQUENCE, | ||
530 | .templates = CMS_OtherKeyAttribute_seq_tt, | ||
531 | .tcount = sizeof(CMS_OtherKeyAttribute_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
532 | .funcs = NULL, | ||
533 | .size = sizeof(CMS_OtherKeyAttribute), | ||
534 | .sname = "CMS_OtherKeyAttribute", | ||
535 | }; | ||
536 | |||
537 | static const ASN1_TEMPLATE CMS_RecipientKeyIdentifier_seq_tt[] = { | ||
538 | { | ||
539 | .flags = 0, | ||
540 | .tag = 0, | ||
541 | .offset = offsetof(CMS_RecipientKeyIdentifier, subjectKeyIdentifier), | ||
542 | .field_name = "subjectKeyIdentifier", | ||
543 | .item = &ASN1_OCTET_STRING_it, | ||
544 | }, | ||
545 | { | ||
546 | .flags = ASN1_TFLG_OPTIONAL, | ||
547 | .tag = 0, | ||
548 | .offset = offsetof(CMS_RecipientKeyIdentifier, date), | ||
549 | .field_name = "date", | ||
550 | .item = &ASN1_GENERALIZEDTIME_it, | ||
551 | }, | ||
552 | { | ||
553 | .flags = ASN1_TFLG_OPTIONAL, | ||
554 | .tag = 0, | ||
555 | .offset = offsetof(CMS_RecipientKeyIdentifier, other), | ||
556 | .field_name = "other", | ||
557 | .item = &CMS_OtherKeyAttribute_it, | ||
558 | }, | ||
559 | }; | ||
560 | |||
561 | const ASN1_ITEM CMS_RecipientKeyIdentifier_it = { | ||
562 | .itype = ASN1_ITYPE_SEQUENCE, | ||
563 | .utype = V_ASN1_SEQUENCE, | ||
564 | .templates = CMS_RecipientKeyIdentifier_seq_tt, | ||
565 | .tcount = sizeof(CMS_RecipientKeyIdentifier_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
566 | .funcs = NULL, | ||
567 | .size = sizeof(CMS_RecipientKeyIdentifier), | ||
568 | .sname = "CMS_RecipientKeyIdentifier", | ||
569 | }; | ||
570 | |||
571 | static const ASN1_TEMPLATE CMS_KeyAgreeRecipientIdentifier_ch_tt[] = { | ||
572 | { | ||
573 | .flags = 0, | ||
574 | .tag = 0, | ||
575 | .offset = offsetof(CMS_KeyAgreeRecipientIdentifier, d.issuerAndSerialNumber), | ||
576 | .field_name = "d.issuerAndSerialNumber", | ||
577 | .item = &CMS_IssuerAndSerialNumber_it, | ||
578 | }, | ||
579 | { | ||
580 | .flags = ASN1_TFLG_IMPLICIT, | ||
581 | .tag = 0, | ||
582 | .offset = offsetof(CMS_KeyAgreeRecipientIdentifier, d.rKeyId), | ||
583 | .field_name = "d.rKeyId", | ||
584 | .item = &CMS_RecipientKeyIdentifier_it, | ||
585 | }, | ||
586 | }; | ||
587 | |||
588 | const ASN1_ITEM CMS_KeyAgreeRecipientIdentifier_it = { | ||
589 | .itype = ASN1_ITYPE_CHOICE, | ||
590 | .utype = offsetof(CMS_KeyAgreeRecipientIdentifier, type), | ||
591 | .templates = CMS_KeyAgreeRecipientIdentifier_ch_tt, | ||
592 | .tcount = sizeof(CMS_KeyAgreeRecipientIdentifier_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
593 | .funcs = NULL, | ||
594 | .size = sizeof(CMS_KeyAgreeRecipientIdentifier), | ||
595 | .sname = "CMS_KeyAgreeRecipientIdentifier", | ||
596 | }; | ||
597 | |||
598 | static const ASN1_TEMPLATE CMS_RecipientEncryptedKey_seq_tt[] = { | ||
599 | { | ||
600 | .flags = 0, | ||
601 | .tag = 0, | ||
602 | .offset = offsetof(CMS_RecipientEncryptedKey, rid), | ||
603 | .field_name = "rid", | ||
604 | .item = &CMS_KeyAgreeRecipientIdentifier_it, | ||
605 | }, | ||
606 | { | ||
607 | .flags = 0, | ||
608 | .tag = 0, | ||
609 | .offset = offsetof(CMS_RecipientEncryptedKey, encryptedKey), | ||
610 | .field_name = "encryptedKey", | ||
611 | .item = &ASN1_OCTET_STRING_it, | ||
612 | }, | ||
613 | }; | ||
614 | |||
615 | const ASN1_ITEM CMS_RecipientEncryptedKey_it = { | ||
616 | .itype = ASN1_ITYPE_SEQUENCE, | ||
617 | .utype = V_ASN1_SEQUENCE, | ||
618 | .templates = CMS_RecipientEncryptedKey_seq_tt, | ||
619 | .tcount = sizeof(CMS_RecipientEncryptedKey_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
620 | .funcs = NULL, | ||
621 | .size = sizeof(CMS_RecipientEncryptedKey), | ||
622 | .sname = "CMS_RecipientEncryptedKey", | ||
623 | }; | ||
624 | |||
625 | static const ASN1_TEMPLATE CMS_OriginatorPublicKey_seq_tt[] = { | ||
626 | { | ||
627 | .flags = 0, | ||
628 | .tag = 0, | ||
629 | .offset = offsetof(CMS_OriginatorPublicKey, algorithm), | ||
630 | .field_name = "algorithm", | ||
631 | .item = &X509_ALGOR_it, | ||
632 | }, | ||
633 | { | ||
634 | .flags = 0, | ||
635 | .tag = 0, | ||
636 | .offset = offsetof(CMS_OriginatorPublicKey, publicKey), | ||
637 | .field_name = "publicKey", | ||
638 | .item = &ASN1_BIT_STRING_it, | ||
639 | }, | ||
640 | }; | ||
641 | |||
642 | const ASN1_ITEM CMS_OriginatorPublicKey_it = { | ||
643 | .itype = ASN1_ITYPE_SEQUENCE, | ||
644 | .utype = V_ASN1_SEQUENCE, | ||
645 | .templates = CMS_OriginatorPublicKey_seq_tt, | ||
646 | .tcount = sizeof(CMS_OriginatorPublicKey_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
647 | .funcs = NULL, | ||
648 | .size = sizeof(CMS_OriginatorPublicKey), | ||
649 | .sname = "CMS_OriginatorPublicKey", | ||
650 | }; | ||
651 | |||
652 | static const ASN1_TEMPLATE CMS_OriginatorIdentifierOrKey_ch_tt[] = { | ||
653 | { | ||
654 | .flags = 0, | ||
655 | .tag = 0, | ||
656 | .offset = offsetof(CMS_OriginatorIdentifierOrKey, d.issuerAndSerialNumber), | ||
657 | .field_name = "d.issuerAndSerialNumber", | ||
658 | .item = &CMS_IssuerAndSerialNumber_it, | ||
659 | }, | ||
660 | { | ||
661 | .flags = ASN1_TFLG_IMPLICIT, | ||
662 | .tag = 0, | ||
663 | .offset = offsetof(CMS_OriginatorIdentifierOrKey, d.subjectKeyIdentifier), | ||
664 | .field_name = "d.subjectKeyIdentifier", | ||
665 | .item = &ASN1_OCTET_STRING_it, | ||
666 | }, | ||
667 | { | ||
668 | .flags = ASN1_TFLG_IMPLICIT, | ||
669 | .tag = 1, | ||
670 | .offset = offsetof(CMS_OriginatorIdentifierOrKey, d.originatorKey), | ||
671 | .field_name = "d.originatorKey", | ||
672 | .item = &CMS_OriginatorPublicKey_it, | ||
673 | }, | ||
674 | }; | ||
675 | |||
676 | const ASN1_ITEM CMS_OriginatorIdentifierOrKey_it = { | ||
677 | .itype = ASN1_ITYPE_CHOICE, | ||
678 | .utype = offsetof(CMS_OriginatorIdentifierOrKey, type), | ||
679 | .templates = CMS_OriginatorIdentifierOrKey_ch_tt, | ||
680 | .tcount = sizeof(CMS_OriginatorIdentifierOrKey_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
681 | .funcs = NULL, | ||
682 | .size = sizeof(CMS_OriginatorIdentifierOrKey), | ||
683 | .sname = "CMS_OriginatorIdentifierOrKey", | ||
684 | }; | ||
685 | |||
686 | static const ASN1_TEMPLATE CMS_KeyAgreeRecipientInfo_seq_tt[] = { | ||
687 | { | ||
688 | .flags = 0, | ||
689 | .tag = 0, | ||
690 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, version), | ||
691 | .field_name = "version", | ||
692 | .item = &LONG_it, | ||
693 | }, | ||
694 | { | ||
695 | .flags = ASN1_TFLG_EXPLICIT, | ||
696 | .tag = 0, | ||
697 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, originator), | ||
698 | .field_name = "originator", | ||
699 | .item = &CMS_OriginatorIdentifierOrKey_it, | ||
700 | }, | ||
701 | { | ||
702 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL, | ||
703 | .tag = 1, | ||
704 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, ukm), | ||
705 | .field_name = "ukm", | ||
706 | .item = &ASN1_OCTET_STRING_it, | ||
707 | }, | ||
708 | { | ||
709 | .flags = 0, | ||
710 | .tag = 0, | ||
711 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, keyEncryptionAlgorithm), | ||
712 | .field_name = "keyEncryptionAlgorithm", | ||
713 | .item = &X509_ALGOR_it, | ||
714 | }, | ||
715 | { | ||
716 | .flags = ASN1_TFLG_SEQUENCE_OF, | ||
717 | .tag = 0, | ||
718 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, recipientEncryptedKeys), | ||
719 | .field_name = "recipientEncryptedKeys", | ||
720 | .item = &CMS_RecipientEncryptedKey_it, | ||
721 | }, | ||
722 | }; | ||
723 | |||
724 | const ASN1_ITEM CMS_KeyAgreeRecipientInfo_it = { | ||
725 | .itype = ASN1_ITYPE_SEQUENCE, | ||
726 | .utype = V_ASN1_SEQUENCE, | ||
727 | .templates = CMS_KeyAgreeRecipientInfo_seq_tt, | ||
728 | .tcount = sizeof(CMS_KeyAgreeRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
729 | .funcs = NULL, | ||
730 | .size = sizeof(CMS_KeyAgreeRecipientInfo), | ||
731 | .sname = "CMS_KeyAgreeRecipientInfo", | ||
732 | }; | ||
733 | |||
734 | static const ASN1_TEMPLATE CMS_KEKIdentifier_seq_tt[] = { | ||
735 | { | ||
736 | .flags = 0, | ||
737 | .tag = 0, | ||
738 | .offset = offsetof(CMS_KEKIdentifier, keyIdentifier), | ||
739 | .field_name = "keyIdentifier", | ||
740 | .item = &ASN1_OCTET_STRING_it, | ||
741 | }, | ||
742 | { | ||
743 | .flags = ASN1_TFLG_OPTIONAL, | ||
744 | .tag = 0, | ||
745 | .offset = offsetof(CMS_KEKIdentifier, date), | ||
746 | .field_name = "date", | ||
747 | .item = &ASN1_GENERALIZEDTIME_it, | ||
748 | }, | ||
749 | { | ||
750 | .flags = ASN1_TFLG_OPTIONAL, | ||
751 | .tag = 0, | ||
752 | .offset = offsetof(CMS_KEKIdentifier, other), | ||
753 | .field_name = "other", | ||
754 | .item = &CMS_OtherKeyAttribute_it, | ||
755 | }, | ||
756 | }; | ||
757 | |||
758 | const ASN1_ITEM CMS_KEKIdentifier_it = { | ||
759 | .itype = ASN1_ITYPE_SEQUENCE, | ||
760 | .utype = V_ASN1_SEQUENCE, | ||
761 | .templates = CMS_KEKIdentifier_seq_tt, | ||
762 | .tcount = sizeof(CMS_KEKIdentifier_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
763 | .funcs = NULL, | ||
764 | .size = sizeof(CMS_KEKIdentifier), | ||
765 | .sname = "CMS_KEKIdentifier", | ||
766 | }; | ||
767 | |||
768 | static const ASN1_TEMPLATE CMS_KEKRecipientInfo_seq_tt[] = { | ||
769 | { | ||
770 | .flags = 0, | ||
771 | .tag = 0, | ||
772 | .offset = offsetof(CMS_KEKRecipientInfo, version), | ||
773 | .field_name = "version", | ||
774 | .item = &LONG_it, | ||
775 | }, | ||
776 | { | ||
777 | .flags = 0, | ||
778 | .tag = 0, | ||
779 | .offset = offsetof(CMS_KEKRecipientInfo, kekid), | ||
780 | .field_name = "kekid", | ||
781 | .item = &CMS_KEKIdentifier_it, | ||
782 | }, | ||
783 | { | ||
784 | .flags = 0, | ||
785 | .tag = 0, | ||
786 | .offset = offsetof(CMS_KEKRecipientInfo, keyEncryptionAlgorithm), | ||
787 | .field_name = "keyEncryptionAlgorithm", | ||
788 | .item = &X509_ALGOR_it, | ||
789 | }, | ||
790 | { | ||
791 | .flags = 0, | ||
792 | .tag = 0, | ||
793 | .offset = offsetof(CMS_KEKRecipientInfo, encryptedKey), | ||
794 | .field_name = "encryptedKey", | ||
795 | .item = &ASN1_OCTET_STRING_it, | ||
796 | }, | ||
797 | }; | ||
798 | |||
799 | const ASN1_ITEM CMS_KEKRecipientInfo_it = { | ||
800 | .itype = ASN1_ITYPE_SEQUENCE, | ||
801 | .utype = V_ASN1_SEQUENCE, | ||
802 | .templates = CMS_KEKRecipientInfo_seq_tt, | ||
803 | .tcount = sizeof(CMS_KEKRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
804 | .funcs = NULL, | ||
805 | .size = sizeof(CMS_KEKRecipientInfo), | ||
806 | .sname = "CMS_KEKRecipientInfo", | ||
807 | }; | ||
808 | |||
809 | static const ASN1_TEMPLATE CMS_PasswordRecipientInfo_seq_tt[] = { | ||
810 | { | ||
811 | .flags = 0, | ||
812 | .tag = 0, | ||
813 | .offset = offsetof(CMS_PasswordRecipientInfo, version), | ||
814 | .field_name = "version", | ||
815 | .item = &LONG_it, | ||
816 | }, | ||
817 | { | ||
818 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, | ||
819 | .tag = 0, | ||
820 | .offset = offsetof(CMS_PasswordRecipientInfo, keyDerivationAlgorithm), | ||
821 | .field_name = "keyDerivationAlgorithm", | ||
822 | .item = &X509_ALGOR_it, | ||
823 | }, | ||
824 | { | ||
825 | .flags = 0, | ||
826 | .tag = 0, | ||
827 | .offset = offsetof(CMS_PasswordRecipientInfo, keyEncryptionAlgorithm), | ||
828 | .field_name = "keyEncryptionAlgorithm", | ||
829 | .item = &X509_ALGOR_it, | ||
830 | }, | ||
831 | { | ||
832 | .flags = 0, | ||
833 | .tag = 0, | ||
834 | .offset = offsetof(CMS_PasswordRecipientInfo, encryptedKey), | ||
835 | .field_name = "encryptedKey", | ||
836 | .item = &ASN1_OCTET_STRING_it, | ||
837 | }, | ||
838 | }; | ||
839 | |||
840 | const ASN1_ITEM CMS_PasswordRecipientInfo_it = { | ||
841 | .itype = ASN1_ITYPE_SEQUENCE, | ||
842 | .utype = V_ASN1_SEQUENCE, | ||
843 | .templates = CMS_PasswordRecipientInfo_seq_tt, | ||
844 | .tcount = sizeof(CMS_PasswordRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
845 | .funcs = NULL, | ||
846 | .size = sizeof(CMS_PasswordRecipientInfo), | ||
847 | .sname = "CMS_PasswordRecipientInfo", | ||
848 | }; | ||
849 | |||
850 | static const ASN1_TEMPLATE CMS_OtherRecipientInfo_seq_tt[] = { | ||
851 | { | ||
852 | .flags = 0, | ||
853 | .tag = 0, | ||
854 | .offset = offsetof(CMS_OtherRecipientInfo, oriType), | ||
855 | .field_name = "oriType", | ||
856 | .item = &ASN1_OBJECT_it, | ||
857 | }, | ||
858 | { | ||
859 | .flags = ASN1_TFLG_OPTIONAL, | ||
860 | .tag = 0, | ||
861 | .offset = offsetof(CMS_OtherRecipientInfo, oriValue), | ||
862 | .field_name = "oriValue", | ||
863 | .item = &ASN1_ANY_it, | ||
864 | }, | ||
865 | }; | ||
866 | |||
867 | const ASN1_ITEM CMS_OtherRecipientInfo_it = { | ||
868 | .itype = ASN1_ITYPE_SEQUENCE, | ||
869 | .utype = V_ASN1_SEQUENCE, | ||
870 | .templates = CMS_OtherRecipientInfo_seq_tt, | ||
871 | .tcount = sizeof(CMS_OtherRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
872 | .funcs = NULL, | ||
873 | .size = sizeof(CMS_OtherRecipientInfo), | ||
874 | .sname = "CMS_OtherRecipientInfo", | ||
875 | }; | ||
212 | 876 | ||
213 | /* Free up RecipientInfo additional data */ | 877 | /* Free up RecipientInfo additional data */ |
214 | static int | 878 | static int |
@@ -238,66 +902,394 @@ cms_ri_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | |||
238 | return 1; | 902 | return 1; |
239 | } | 903 | } |
240 | 904 | ||
241 | ASN1_CHOICE_cb(CMS_RecipientInfo, cms_ri_cb) = { | 905 | static const ASN1_AUX CMS_RecipientInfo_aux = { |
242 | ASN1_SIMPLE(CMS_RecipientInfo, d.ktri, CMS_KeyTransRecipientInfo), | 906 | .app_data = NULL, |
243 | ASN1_IMP(CMS_RecipientInfo, d.kari, CMS_KeyAgreeRecipientInfo, 1), | 907 | .flags = 0, |
244 | ASN1_IMP(CMS_RecipientInfo, d.kekri, CMS_KEKRecipientInfo, 2), | 908 | .ref_offset = 0, |
245 | ASN1_IMP(CMS_RecipientInfo, d.pwri, CMS_PasswordRecipientInfo, 3), | 909 | .ref_lock = 0, |
246 | ASN1_IMP(CMS_RecipientInfo, d.ori, CMS_OtherRecipientInfo, 4) | 910 | .asn1_cb = cms_ri_cb, |
247 | } ASN1_CHOICE_END_cb(CMS_RecipientInfo, CMS_RecipientInfo, type) | 911 | .enc_offset = 0, |
248 | 912 | }; | |
249 | ASN1_NDEF_SEQUENCE(CMS_EnvelopedData) = { | 913 | static const ASN1_TEMPLATE CMS_RecipientInfo_ch_tt[] = { |
250 | ASN1_SIMPLE(CMS_EnvelopedData, version, LONG), | 914 | { |
251 | ASN1_IMP_OPT(CMS_EnvelopedData, originatorInfo, CMS_OriginatorInfo, 0), | 915 | .flags = 0, |
252 | ASN1_SET_OF(CMS_EnvelopedData, recipientInfos, CMS_RecipientInfo), | 916 | .tag = 0, |
253 | ASN1_SIMPLE(CMS_EnvelopedData, encryptedContentInfo, CMS_EncryptedContentInfo), | 917 | .offset = offsetof(CMS_RecipientInfo, d.ktri), |
254 | ASN1_IMP_SET_OF_OPT(CMS_EnvelopedData, unprotectedAttrs, X509_ATTRIBUTE, 1) | 918 | .field_name = "d.ktri", |
255 | } ASN1_NDEF_SEQUENCE_END(CMS_EnvelopedData) | 919 | .item = &CMS_KeyTransRecipientInfo_it, |
256 | 920 | }, | |
257 | ASN1_NDEF_SEQUENCE(CMS_DigestedData) = { | 921 | { |
258 | ASN1_SIMPLE(CMS_DigestedData, version, LONG), | 922 | .flags = ASN1_TFLG_IMPLICIT, |
259 | ASN1_SIMPLE(CMS_DigestedData, digestAlgorithm, X509_ALGOR), | 923 | .tag = 1, |
260 | ASN1_SIMPLE(CMS_DigestedData, encapContentInfo, CMS_EncapsulatedContentInfo), | 924 | .offset = offsetof(CMS_RecipientInfo, d.kari), |
261 | ASN1_SIMPLE(CMS_DigestedData, digest, ASN1_OCTET_STRING) | 925 | .field_name = "d.kari", |
262 | } ASN1_NDEF_SEQUENCE_END(CMS_DigestedData) | 926 | .item = &CMS_KeyAgreeRecipientInfo_it, |
263 | 927 | }, | |
264 | ASN1_NDEF_SEQUENCE(CMS_EncryptedData) = { | 928 | { |
265 | ASN1_SIMPLE(CMS_EncryptedData, version, LONG), | 929 | .flags = ASN1_TFLG_IMPLICIT, |
266 | ASN1_SIMPLE(CMS_EncryptedData, encryptedContentInfo, CMS_EncryptedContentInfo), | 930 | .tag = 2, |
267 | ASN1_IMP_SET_OF_OPT(CMS_EncryptedData, unprotectedAttrs, X509_ATTRIBUTE, 1) | 931 | .offset = offsetof(CMS_RecipientInfo, d.kekri), |
268 | } ASN1_NDEF_SEQUENCE_END(CMS_EncryptedData) | 932 | .field_name = "d.kekri", |
269 | 933 | .item = &CMS_KEKRecipientInfo_it, | |
270 | ASN1_NDEF_SEQUENCE(CMS_AuthenticatedData) = { | 934 | }, |
271 | ASN1_SIMPLE(CMS_AuthenticatedData, version, LONG), | 935 | { |
272 | ASN1_IMP_OPT(CMS_AuthenticatedData, originatorInfo, CMS_OriginatorInfo, 0), | 936 | .flags = ASN1_TFLG_IMPLICIT, |
273 | ASN1_SET_OF(CMS_AuthenticatedData, recipientInfos, CMS_RecipientInfo), | 937 | .tag = 3, |
274 | ASN1_SIMPLE(CMS_AuthenticatedData, macAlgorithm, X509_ALGOR), | 938 | .offset = offsetof(CMS_RecipientInfo, d.pwri), |
275 | ASN1_IMP(CMS_AuthenticatedData, digestAlgorithm, X509_ALGOR, 1), | 939 | .field_name = "d.pwri", |
276 | ASN1_SIMPLE(CMS_AuthenticatedData, encapContentInfo, CMS_EncapsulatedContentInfo), | 940 | .item = &CMS_PasswordRecipientInfo_it, |
277 | ASN1_IMP_SET_OF_OPT(CMS_AuthenticatedData, authAttrs, X509_ALGOR, 2), | 941 | }, |
278 | ASN1_SIMPLE(CMS_AuthenticatedData, mac, ASN1_OCTET_STRING), | 942 | { |
279 | ASN1_IMP_SET_OF_OPT(CMS_AuthenticatedData, unauthAttrs, X509_ALGOR, 3) | 943 | .flags = ASN1_TFLG_IMPLICIT, |
280 | } ASN1_NDEF_SEQUENCE_END(CMS_AuthenticatedData) | 944 | .tag = 4, |
281 | 945 | .offset = offsetof(CMS_RecipientInfo, d.ori), | |
282 | ASN1_NDEF_SEQUENCE(CMS_CompressedData) = { | 946 | .field_name = "d.ori", |
283 | ASN1_SIMPLE(CMS_CompressedData, version, LONG), | 947 | .item = &CMS_OtherRecipientInfo_it, |
284 | ASN1_SIMPLE(CMS_CompressedData, compressionAlgorithm, X509_ALGOR), | 948 | }, |
285 | ASN1_SIMPLE(CMS_CompressedData, encapContentInfo, CMS_EncapsulatedContentInfo), | 949 | }; |
286 | } ASN1_NDEF_SEQUENCE_END(CMS_CompressedData) | 950 | |
951 | const ASN1_ITEM CMS_RecipientInfo_it = { | ||
952 | .itype = ASN1_ITYPE_CHOICE, | ||
953 | .utype = offsetof(CMS_RecipientInfo, type), | ||
954 | .templates = CMS_RecipientInfo_ch_tt, | ||
955 | .tcount = sizeof(CMS_RecipientInfo_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
956 | .funcs = &CMS_RecipientInfo_aux, | ||
957 | .size = sizeof(CMS_RecipientInfo), | ||
958 | .sname = "CMS_RecipientInfo", | ||
959 | }; | ||
960 | |||
961 | static const ASN1_TEMPLATE CMS_EnvelopedData_seq_tt[] = { | ||
962 | { | ||
963 | .flags = 0, | ||
964 | .tag = 0, | ||
965 | .offset = offsetof(CMS_EnvelopedData, version), | ||
966 | .field_name = "version", | ||
967 | .item = &LONG_it, | ||
968 | }, | ||
969 | { | ||
970 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, | ||
971 | .tag = 0, | ||
972 | .offset = offsetof(CMS_EnvelopedData, originatorInfo), | ||
973 | .field_name = "originatorInfo", | ||
974 | .item = &CMS_OriginatorInfo_it, | ||
975 | }, | ||
976 | { | ||
977 | .flags = ASN1_TFLG_SET_OF, | ||
978 | .tag = 0, | ||
979 | .offset = offsetof(CMS_EnvelopedData, recipientInfos), | ||
980 | .field_name = "recipientInfos", | ||
981 | .item = &CMS_RecipientInfo_it, | ||
982 | }, | ||
983 | { | ||
984 | .flags = 0, | ||
985 | .tag = 0, | ||
986 | .offset = offsetof(CMS_EnvelopedData, encryptedContentInfo), | ||
987 | .field_name = "encryptedContentInfo", | ||
988 | .item = &CMS_EncryptedContentInfo_it, | ||
989 | }, | ||
990 | { | ||
991 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
992 | .tag = 1, | ||
993 | .offset = offsetof(CMS_EnvelopedData, unprotectedAttrs), | ||
994 | .field_name = "unprotectedAttrs", | ||
995 | .item = &X509_ATTRIBUTE_it, | ||
996 | }, | ||
997 | }; | ||
998 | |||
999 | const ASN1_ITEM CMS_EnvelopedData_it = { | ||
1000 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
1001 | .utype = V_ASN1_SEQUENCE, | ||
1002 | .templates = CMS_EnvelopedData_seq_tt, | ||
1003 | .tcount = sizeof(CMS_EnvelopedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
1004 | .funcs = NULL, | ||
1005 | .size = sizeof(CMS_EnvelopedData), | ||
1006 | .sname = "CMS_EnvelopedData", | ||
1007 | }; | ||
1008 | |||
1009 | static const ASN1_TEMPLATE CMS_DigestedData_seq_tt[] = { | ||
1010 | { | ||
1011 | .flags = 0, | ||
1012 | .tag = 0, | ||
1013 | .offset = offsetof(CMS_DigestedData, version), | ||
1014 | .field_name = "version", | ||
1015 | .item = &LONG_it, | ||
1016 | }, | ||
1017 | { | ||
1018 | .flags = 0, | ||
1019 | .tag = 0, | ||
1020 | .offset = offsetof(CMS_DigestedData, digestAlgorithm), | ||
1021 | .field_name = "digestAlgorithm", | ||
1022 | .item = &X509_ALGOR_it, | ||
1023 | }, | ||
1024 | { | ||
1025 | .flags = 0, | ||
1026 | .tag = 0, | ||
1027 | .offset = offsetof(CMS_DigestedData, encapContentInfo), | ||
1028 | .field_name = "encapContentInfo", | ||
1029 | .item = &CMS_EncapsulatedContentInfo_it, | ||
1030 | }, | ||
1031 | { | ||
1032 | .flags = 0, | ||
1033 | .tag = 0, | ||
1034 | .offset = offsetof(CMS_DigestedData, digest), | ||
1035 | .field_name = "digest", | ||
1036 | .item = &ASN1_OCTET_STRING_it, | ||
1037 | }, | ||
1038 | }; | ||
1039 | |||
1040 | const ASN1_ITEM CMS_DigestedData_it = { | ||
1041 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
1042 | .utype = V_ASN1_SEQUENCE, | ||
1043 | .templates = CMS_DigestedData_seq_tt, | ||
1044 | .tcount = sizeof(CMS_DigestedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
1045 | .funcs = NULL, | ||
1046 | .size = sizeof(CMS_DigestedData), | ||
1047 | .sname = "CMS_DigestedData", | ||
1048 | }; | ||
1049 | |||
1050 | static const ASN1_TEMPLATE CMS_EncryptedData_seq_tt[] = { | ||
1051 | { | ||
1052 | .flags = 0, | ||
1053 | .tag = 0, | ||
1054 | .offset = offsetof(CMS_EncryptedData, version), | ||
1055 | .field_name = "version", | ||
1056 | .item = &LONG_it, | ||
1057 | }, | ||
1058 | { | ||
1059 | .flags = 0, | ||
1060 | .tag = 0, | ||
1061 | .offset = offsetof(CMS_EncryptedData, encryptedContentInfo), | ||
1062 | .field_name = "encryptedContentInfo", | ||
1063 | .item = &CMS_EncryptedContentInfo_it, | ||
1064 | }, | ||
1065 | { | ||
1066 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
1067 | .tag = 1, | ||
1068 | .offset = offsetof(CMS_EncryptedData, unprotectedAttrs), | ||
1069 | .field_name = "unprotectedAttrs", | ||
1070 | .item = &X509_ATTRIBUTE_it, | ||
1071 | }, | ||
1072 | }; | ||
1073 | |||
1074 | const ASN1_ITEM CMS_EncryptedData_it = { | ||
1075 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
1076 | .utype = V_ASN1_SEQUENCE, | ||
1077 | .templates = CMS_EncryptedData_seq_tt, | ||
1078 | .tcount = sizeof(CMS_EncryptedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
1079 | .funcs = NULL, | ||
1080 | .size = sizeof(CMS_EncryptedData), | ||
1081 | .sname = "CMS_EncryptedData", | ||
1082 | }; | ||
1083 | |||
1084 | static const ASN1_TEMPLATE CMS_AuthenticatedData_seq_tt[] = { | ||
1085 | { | ||
1086 | .flags = 0, | ||
1087 | .tag = 0, | ||
1088 | .offset = offsetof(CMS_AuthenticatedData, version), | ||
1089 | .field_name = "version", | ||
1090 | .item = &LONG_it, | ||
1091 | }, | ||
1092 | { | ||
1093 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, | ||
1094 | .tag = 0, | ||
1095 | .offset = offsetof(CMS_AuthenticatedData, originatorInfo), | ||
1096 | .field_name = "originatorInfo", | ||
1097 | .item = &CMS_OriginatorInfo_it, | ||
1098 | }, | ||
1099 | { | ||
1100 | .flags = ASN1_TFLG_SET_OF, | ||
1101 | .tag = 0, | ||
1102 | .offset = offsetof(CMS_AuthenticatedData, recipientInfos), | ||
1103 | .field_name = "recipientInfos", | ||
1104 | .item = &CMS_RecipientInfo_it, | ||
1105 | }, | ||
1106 | { | ||
1107 | .flags = 0, | ||
1108 | .tag = 0, | ||
1109 | .offset = offsetof(CMS_AuthenticatedData, macAlgorithm), | ||
1110 | .field_name = "macAlgorithm", | ||
1111 | .item = &X509_ALGOR_it, | ||
1112 | }, | ||
1113 | { | ||
1114 | .flags = ASN1_TFLG_IMPLICIT, | ||
1115 | .tag = 1, | ||
1116 | .offset = offsetof(CMS_AuthenticatedData, digestAlgorithm), | ||
1117 | .field_name = "digestAlgorithm", | ||
1118 | .item = &X509_ALGOR_it, | ||
1119 | }, | ||
1120 | { | ||
1121 | .flags = 0, | ||
1122 | .tag = 0, | ||
1123 | .offset = offsetof(CMS_AuthenticatedData, encapContentInfo), | ||
1124 | .field_name = "encapContentInfo", | ||
1125 | .item = &CMS_EncapsulatedContentInfo_it, | ||
1126 | }, | ||
1127 | { | ||
1128 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
1129 | .tag = 2, | ||
1130 | .offset = offsetof(CMS_AuthenticatedData, authAttrs), | ||
1131 | .field_name = "authAttrs", | ||
1132 | .item = &X509_ALGOR_it, | ||
1133 | }, | ||
1134 | { | ||
1135 | .flags = 0, | ||
1136 | .tag = 0, | ||
1137 | .offset = offsetof(CMS_AuthenticatedData, mac), | ||
1138 | .field_name = "mac", | ||
1139 | .item = &ASN1_OCTET_STRING_it, | ||
1140 | }, | ||
1141 | { | ||
1142 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
1143 | .tag = 3, | ||
1144 | .offset = offsetof(CMS_AuthenticatedData, unauthAttrs), | ||
1145 | .field_name = "unauthAttrs", | ||
1146 | .item = &X509_ALGOR_it, | ||
1147 | }, | ||
1148 | }; | ||
1149 | |||
1150 | const ASN1_ITEM CMS_AuthenticatedData_it = { | ||
1151 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
1152 | .utype = V_ASN1_SEQUENCE, | ||
1153 | .templates = CMS_AuthenticatedData_seq_tt, | ||
1154 | .tcount = sizeof(CMS_AuthenticatedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
1155 | .funcs = NULL, | ||
1156 | .size = sizeof(CMS_AuthenticatedData), | ||
1157 | .sname = "CMS_AuthenticatedData", | ||
1158 | }; | ||
1159 | |||
1160 | static const ASN1_TEMPLATE CMS_CompressedData_seq_tt[] = { | ||
1161 | { | ||
1162 | .flags = 0, | ||
1163 | .tag = 0, | ||
1164 | .offset = offsetof(CMS_CompressedData, version), | ||
1165 | .field_name = "version", | ||
1166 | .item = &LONG_it, | ||
1167 | }, | ||
1168 | { | ||
1169 | .flags = 0, | ||
1170 | .tag = 0, | ||
1171 | .offset = offsetof(CMS_CompressedData, compressionAlgorithm), | ||
1172 | .field_name = "compressionAlgorithm", | ||
1173 | .item = &X509_ALGOR_it, | ||
1174 | }, | ||
1175 | { | ||
1176 | .flags = 0, | ||
1177 | .tag = 0, | ||
1178 | .offset = offsetof(CMS_CompressedData, encapContentInfo), | ||
1179 | .field_name = "encapContentInfo", | ||
1180 | .item = &CMS_EncapsulatedContentInfo_it, | ||
1181 | }, | ||
1182 | }; | ||
1183 | |||
1184 | const ASN1_ITEM CMS_CompressedData_it = { | ||
1185 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
1186 | .utype = V_ASN1_SEQUENCE, | ||
1187 | .templates = CMS_CompressedData_seq_tt, | ||
1188 | .tcount = sizeof(CMS_CompressedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
1189 | .funcs = NULL, | ||
1190 | .size = sizeof(CMS_CompressedData), | ||
1191 | .sname = "CMS_CompressedData", | ||
1192 | }; | ||
287 | 1193 | ||
288 | /* This is the ANY DEFINED BY table for the top level ContentInfo structure */ | 1194 | /* This is the ANY DEFINED BY table for the top level ContentInfo structure */ |
289 | 1195 | ||
290 | ASN1_ADB_TEMPLATE(cms_default) = ASN1_EXP(CMS_ContentInfo, d.other, ASN1_ANY, 0); | 1196 | static const ASN1_TEMPLATE cms_default_tt = { |
1197 | .flags = ASN1_TFLG_EXPLICIT, | ||
1198 | .tag = 0, | ||
1199 | .offset = offsetof(CMS_ContentInfo, d.other), | ||
1200 | .field_name = "d.other", | ||
1201 | .item = &ASN1_ANY_it, | ||
1202 | }; | ||
291 | 1203 | ||
292 | ASN1_ADB(CMS_ContentInfo) = { | 1204 | static const ASN1_ADB_TABLE CMS_ContentInfo_adbtbl[] = { |
293 | ADB_ENTRY(NID_pkcs7_data, ASN1_NDEF_EXP(CMS_ContentInfo, d.data, ASN1_OCTET_STRING_NDEF, 0)), | 1205 | { |
294 | ADB_ENTRY(NID_pkcs7_signed, ASN1_NDEF_EXP(CMS_ContentInfo, d.signedData, CMS_SignedData, 0)), | 1206 | .value = NID_pkcs7_data, |
295 | ADB_ENTRY(NID_pkcs7_enveloped, ASN1_NDEF_EXP(CMS_ContentInfo, d.envelopedData, CMS_EnvelopedData, 0)), | 1207 | .tt = { |
296 | ADB_ENTRY(NID_pkcs7_digest, ASN1_NDEF_EXP(CMS_ContentInfo, d.digestedData, CMS_DigestedData, 0)), | 1208 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, |
297 | ADB_ENTRY(NID_pkcs7_encrypted, ASN1_NDEF_EXP(CMS_ContentInfo, d.encryptedData, CMS_EncryptedData, 0)), | 1209 | .tag = 0, |
298 | ADB_ENTRY(NID_id_smime_ct_authData, ASN1_NDEF_EXP(CMS_ContentInfo, d.authenticatedData, CMS_AuthenticatedData, 0)), | 1210 | .offset = offsetof(CMS_ContentInfo, d.data), |
299 | ADB_ENTRY(NID_id_smime_ct_compressedData, ASN1_NDEF_EXP(CMS_ContentInfo, d.compressedData, CMS_CompressedData, 0)), | 1211 | .field_name = "d.data", |
300 | } ASN1_ADB_END(CMS_ContentInfo, 0, contentType, 0, &cms_default_tt, NULL); | 1212 | .item = &ASN1_OCTET_STRING_NDEF_it, |
1213 | }, | ||
1214 | |||
1215 | }, | ||
1216 | { | ||
1217 | .value = NID_pkcs7_signed, | ||
1218 | .tt = { | ||
1219 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
1220 | .tag = 0, | ||
1221 | .offset = offsetof(CMS_ContentInfo, d.signedData), | ||
1222 | .field_name = "d.signedData", | ||
1223 | .item = &CMS_SignedData_it, | ||
1224 | }, | ||
1225 | |||
1226 | }, | ||
1227 | { | ||
1228 | .value = NID_pkcs7_enveloped, | ||
1229 | .tt = { | ||
1230 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
1231 | .tag = 0, | ||
1232 | .offset = offsetof(CMS_ContentInfo, d.envelopedData), | ||
1233 | .field_name = "d.envelopedData", | ||
1234 | .item = &CMS_EnvelopedData_it, | ||
1235 | }, | ||
1236 | |||
1237 | }, | ||
1238 | { | ||
1239 | .value = NID_pkcs7_digest, | ||
1240 | .tt = { | ||
1241 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
1242 | .tag = 0, | ||
1243 | .offset = offsetof(CMS_ContentInfo, d.digestedData), | ||
1244 | .field_name = "d.digestedData", | ||
1245 | .item = &CMS_DigestedData_it, | ||
1246 | }, | ||
1247 | |||
1248 | }, | ||
1249 | { | ||
1250 | .value = NID_pkcs7_encrypted, | ||
1251 | .tt = { | ||
1252 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
1253 | .tag = 0, | ||
1254 | .offset = offsetof(CMS_ContentInfo, d.encryptedData), | ||
1255 | .field_name = "d.encryptedData", | ||
1256 | .item = &CMS_EncryptedData_it, | ||
1257 | }, | ||
1258 | |||
1259 | }, | ||
1260 | { | ||
1261 | .value = NID_id_smime_ct_authData, | ||
1262 | .tt = { | ||
1263 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
1264 | .tag = 0, | ||
1265 | .offset = offsetof(CMS_ContentInfo, d.authenticatedData), | ||
1266 | .field_name = "d.authenticatedData", | ||
1267 | .item = &CMS_AuthenticatedData_it, | ||
1268 | }, | ||
1269 | |||
1270 | }, | ||
1271 | { | ||
1272 | .value = NID_id_smime_ct_compressedData, | ||
1273 | .tt = { | ||
1274 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
1275 | .tag = 0, | ||
1276 | .offset = offsetof(CMS_ContentInfo, d.compressedData), | ||
1277 | .field_name = "d.compressedData", | ||
1278 | .item = &CMS_CompressedData_it, | ||
1279 | }, | ||
1280 | |||
1281 | }, | ||
1282 | }; | ||
1283 | |||
1284 | static const ASN1_ADB CMS_ContentInfo_adb = { | ||
1285 | .flags = 0, | ||
1286 | .offset = offsetof(CMS_ContentInfo, contentType), | ||
1287 | .app_items = 0, | ||
1288 | .tbl = CMS_ContentInfo_adbtbl, | ||
1289 | .tblcount = sizeof(CMS_ContentInfo_adbtbl) / sizeof(ASN1_ADB_TABLE), | ||
1290 | .default_tt = &cms_default_tt, | ||
1291 | .null_tt = NULL, | ||
1292 | }; | ||
301 | 1293 | ||
302 | /* CMS streaming support */ | 1294 | /* CMS streaming support */ |
303 | static int | 1295 | static int |
@@ -329,10 +1321,40 @@ cms_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | |||
329 | return 1; | 1321 | return 1; |
330 | } | 1322 | } |
331 | 1323 | ||
332 | ASN1_NDEF_SEQUENCE_cb(CMS_ContentInfo, cms_cb) = { | 1324 | static const ASN1_AUX CMS_ContentInfo_aux = { |
333 | ASN1_SIMPLE(CMS_ContentInfo, contentType, ASN1_OBJECT), | 1325 | .app_data = NULL, |
334 | ASN1_ADB_OBJECT(CMS_ContentInfo) | 1326 | .flags = 0, |
335 | } ASN1_NDEF_SEQUENCE_END_cb(CMS_ContentInfo, CMS_ContentInfo) | 1327 | .ref_offset = 0, |
1328 | .ref_lock = 0, | ||
1329 | .asn1_cb = cms_cb, | ||
1330 | .enc_offset = 0, | ||
1331 | }; | ||
1332 | static const ASN1_TEMPLATE CMS_ContentInfo_seq_tt[] = { | ||
1333 | { | ||
1334 | .flags = 0, | ||
1335 | .tag = 0, | ||
1336 | .offset = offsetof(CMS_ContentInfo, contentType), | ||
1337 | .field_name = "contentType", | ||
1338 | .item = &ASN1_OBJECT_it, | ||
1339 | }, | ||
1340 | { | ||
1341 | .flags = ASN1_TFLG_ADB_OID, | ||
1342 | .tag = -1, | ||
1343 | .offset = 0, | ||
1344 | .field_name = "CMS_ContentInfo", | ||
1345 | .item = (const ASN1_ITEM *)&CMS_ContentInfo_adb, | ||
1346 | }, | ||
1347 | }; | ||
1348 | |||
1349 | const ASN1_ITEM CMS_ContentInfo_it = { | ||
1350 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
1351 | .utype = V_ASN1_SEQUENCE, | ||
1352 | .templates = CMS_ContentInfo_seq_tt, | ||
1353 | .tcount = sizeof(CMS_ContentInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
1354 | .funcs = &CMS_ContentInfo_aux, | ||
1355 | .size = sizeof(CMS_ContentInfo), | ||
1356 | .sname = "CMS_ContentInfo", | ||
1357 | }; | ||
336 | 1358 | ||
337 | /* Specials for signed attributes */ | 1359 | /* Specials for signed attributes */ |
338 | 1360 | ||
@@ -340,33 +1362,144 @@ ASN1_NDEF_SEQUENCE_cb(CMS_ContentInfo, cms_cb) = { | |||
340 | * encoding. | 1362 | * encoding. |
341 | */ | 1363 | */ |
342 | 1364 | ||
343 | ASN1_ITEM_TEMPLATE(CMS_Attributes_Sign) = | 1365 | static const ASN1_TEMPLATE CMS_Attributes_Sign_item_tt = { |
344 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SET_ORDER, 0, CMS_ATTRIBUTES, X509_ATTRIBUTE) | 1366 | .flags = ASN1_TFLG_SET_ORDER, |
345 | ASN1_ITEM_TEMPLATE_END(CMS_Attributes_Sign) | 1367 | .tag = 0, |
1368 | .offset = 0, | ||
1369 | .field_name = "CMS_ATTRIBUTES", | ||
1370 | .item = &X509_ATTRIBUTE_it, | ||
1371 | }; | ||
1372 | |||
1373 | const ASN1_ITEM CMS_Attributes_Sign_it = { | ||
1374 | .itype = ASN1_ITYPE_PRIMITIVE, | ||
1375 | .utype = -1, | ||
1376 | .templates = &CMS_Attributes_Sign_item_tt, | ||
1377 | .tcount = 0, | ||
1378 | .funcs = NULL, | ||
1379 | .size = 0, | ||
1380 | .sname = "CMS_Attributes_Sign", | ||
1381 | }; | ||
346 | 1382 | ||
347 | /* When verifying attributes we need to use the received order. So | 1383 | /* When verifying attributes we need to use the received order. So |
348 | * we use SEQUENCE OF and tag it to SET OF | 1384 | * we use SEQUENCE OF and tag it to SET OF |
349 | */ | 1385 | */ |
350 | 1386 | ||
351 | ASN1_ITEM_TEMPLATE(CMS_Attributes_Verify) = | 1387 | static const ASN1_TEMPLATE CMS_Attributes_Verify_item_tt = { |
352 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_IMPTAG | ASN1_TFLG_UNIVERSAL, | 1388 | .flags = ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_IMPTAG | ASN1_TFLG_UNIVERSAL, |
353 | V_ASN1_SET, CMS_ATTRIBUTES, X509_ATTRIBUTE) | 1389 | .tag = V_ASN1_SET, |
354 | ASN1_ITEM_TEMPLATE_END(CMS_Attributes_Verify) | 1390 | .offset = 0, |
355 | 1391 | .field_name = "CMS_ATTRIBUTES", | |
356 | ASN1_CHOICE(CMS_ReceiptsFrom) = { | 1392 | .item = &X509_ATTRIBUTE_it, |
357 | ASN1_IMP(CMS_ReceiptsFrom, d.allOrFirstTier, LONG, 0), | 1393 | }; |
358 | ASN1_IMP_SEQUENCE_OF(CMS_ReceiptsFrom, d.receiptList, GENERAL_NAMES, 1) | 1394 | |
359 | } ASN1_CHOICE_END(CMS_ReceiptsFrom) | 1395 | const ASN1_ITEM CMS_Attributes_Verify_it = { |
360 | 1396 | .itype = ASN1_ITYPE_PRIMITIVE, | |
361 | ASN1_SEQUENCE(CMS_ReceiptRequest) = { | 1397 | .utype = -1, |
362 | ASN1_SIMPLE(CMS_ReceiptRequest, signedContentIdentifier, ASN1_OCTET_STRING), | 1398 | .templates = &CMS_Attributes_Verify_item_tt, |
363 | ASN1_SIMPLE(CMS_ReceiptRequest, receiptsFrom, CMS_ReceiptsFrom), | 1399 | .tcount = 0, |
364 | ASN1_SEQUENCE_OF(CMS_ReceiptRequest, receiptsTo, GENERAL_NAMES) | 1400 | .funcs = NULL, |
365 | } ASN1_SEQUENCE_END(CMS_ReceiptRequest) | 1401 | .size = 0, |
366 | 1402 | .sname = "CMS_Attributes_Verify", | |
367 | ASN1_SEQUENCE(CMS_Receipt) = { | 1403 | }; |
368 | ASN1_SIMPLE(CMS_Receipt, version, LONG), | 1404 | |
369 | ASN1_SIMPLE(CMS_Receipt, contentType, ASN1_OBJECT), | 1405 | static const ASN1_TEMPLATE CMS_ReceiptsFrom_ch_tt[] = { |
370 | ASN1_SIMPLE(CMS_Receipt, signedContentIdentifier, ASN1_OCTET_STRING), | 1406 | { |
371 | ASN1_SIMPLE(CMS_Receipt, originatorSignatureValue, ASN1_OCTET_STRING) | 1407 | .flags = ASN1_TFLG_IMPLICIT, |
372 | } ASN1_SEQUENCE_END(CMS_Receipt) | 1408 | .tag = 0, |
1409 | .offset = offsetof(CMS_ReceiptsFrom, d.allOrFirstTier), | ||
1410 | .field_name = "d.allOrFirstTier", | ||
1411 | .item = &LONG_it, | ||
1412 | }, | ||
1413 | { | ||
1414 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SEQUENCE_OF, | ||
1415 | .tag = 1, | ||
1416 | .offset = offsetof(CMS_ReceiptsFrom, d.receiptList), | ||
1417 | .field_name = "d.receiptList", | ||
1418 | .item = &GENERAL_NAMES_it, | ||
1419 | }, | ||
1420 | }; | ||
1421 | |||
1422 | const ASN1_ITEM CMS_ReceiptsFrom_it = { | ||
1423 | .itype = ASN1_ITYPE_CHOICE, | ||
1424 | .utype = offsetof(CMS_ReceiptsFrom, type), | ||
1425 | .templates = CMS_ReceiptsFrom_ch_tt, | ||
1426 | .tcount = sizeof(CMS_ReceiptsFrom_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
1427 | .funcs = NULL, | ||
1428 | .size = sizeof(CMS_ReceiptsFrom), | ||
1429 | .sname = "CMS_ReceiptsFrom", | ||
1430 | }; | ||
1431 | |||
1432 | static const ASN1_TEMPLATE CMS_ReceiptRequest_seq_tt[] = { | ||
1433 | { | ||
1434 | .flags = 0, | ||
1435 | .tag = 0, | ||
1436 | .offset = offsetof(CMS_ReceiptRequest, signedContentIdentifier), | ||
1437 | .field_name = "signedContentIdentifier", | ||
1438 | .item = &ASN1_OCTET_STRING_it, | ||
1439 | }, | ||
1440 | { | ||
1441 | .flags = 0, | ||
1442 | .tag = 0, | ||
1443 | .offset = offsetof(CMS_ReceiptRequest, receiptsFrom), | ||
1444 | .field_name = "receiptsFrom", | ||
1445 | .item = &CMS_ReceiptsFrom_it, | ||
1446 | }, | ||
1447 | { | ||
1448 | .flags = ASN1_TFLG_SEQUENCE_OF, | ||
1449 | .tag = 0, | ||
1450 | .offset = offsetof(CMS_ReceiptRequest, receiptsTo), | ||
1451 | .field_name = "receiptsTo", | ||
1452 | .item = &GENERAL_NAMES_it, | ||
1453 | }, | ||
1454 | }; | ||
1455 | |||
1456 | const ASN1_ITEM CMS_ReceiptRequest_it = { | ||
1457 | .itype = ASN1_ITYPE_SEQUENCE, | ||
1458 | .utype = V_ASN1_SEQUENCE, | ||
1459 | .templates = CMS_ReceiptRequest_seq_tt, | ||
1460 | .tcount = sizeof(CMS_ReceiptRequest_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
1461 | .funcs = NULL, | ||
1462 | .size = sizeof(CMS_ReceiptRequest), | ||
1463 | .sname = "CMS_ReceiptRequest", | ||
1464 | }; | ||
1465 | |||
1466 | static const ASN1_TEMPLATE CMS_Receipt_seq_tt[] = { | ||
1467 | { | ||
1468 | .flags = 0, | ||
1469 | .tag = 0, | ||
1470 | .offset = offsetof(CMS_Receipt, version), | ||
1471 | .field_name = "version", | ||
1472 | .item = &LONG_it, | ||
1473 | }, | ||
1474 | { | ||
1475 | .flags = 0, | ||
1476 | .tag = 0, | ||
1477 | .offset = offsetof(CMS_Receipt, contentType), | ||
1478 | .field_name = "contentType", | ||
1479 | .item = &ASN1_OBJECT_it, | ||
1480 | }, | ||
1481 | { | ||
1482 | .flags = 0, | ||
1483 | .tag = 0, | ||
1484 | .offset = offsetof(CMS_Receipt, signedContentIdentifier), | ||
1485 | .field_name = "signedContentIdentifier", | ||
1486 | .item = &ASN1_OCTET_STRING_it, | ||
1487 | }, | ||
1488 | { | ||
1489 | .flags = 0, | ||
1490 | .tag = 0, | ||
1491 | .offset = offsetof(CMS_Receipt, originatorSignatureValue), | ||
1492 | .field_name = "originatorSignatureValue", | ||
1493 | .item = &ASN1_OCTET_STRING_it, | ||
1494 | }, | ||
1495 | }; | ||
1496 | |||
1497 | const ASN1_ITEM CMS_Receipt_it = { | ||
1498 | .itype = ASN1_ITYPE_SEQUENCE, | ||
1499 | .utype = V_ASN1_SEQUENCE, | ||
1500 | .templates = CMS_Receipt_seq_tt, | ||
1501 | .tcount = sizeof(CMS_Receipt_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
1502 | .funcs = NULL, | ||
1503 | .size = sizeof(CMS_Receipt), | ||
1504 | .sname = "CMS_Receipt", | ||
1505 | }; | ||
diff --git a/src/lib/libssl/src/crypto/cms/cms_asn1.c b/src/lib/libssl/src/crypto/cms/cms_asn1.c index fbdac5b1ba..02a594575d 100644 --- a/src/lib/libssl/src/crypto/cms/cms_asn1.c +++ b/src/lib/libssl/src/crypto/cms/cms_asn1.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: cms_asn1.c,v 1.5 2014/07/12 16:03:37 miod Exp $ */ | 1 | /* $OpenBSD: cms_asn1.c,v 1.6 2015/07/25 15:22:10 jsing Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project. | 3 | * project. |
4 | */ | 4 | */ |
@@ -57,33 +57,161 @@ | |||
57 | #include "cms.h" | 57 | #include "cms.h" |
58 | #include "cms_lcl.h" | 58 | #include "cms_lcl.h" |
59 | 59 | ||
60 | ASN1_SEQUENCE(CMS_IssuerAndSerialNumber) = { | 60 | static const ASN1_TEMPLATE CMS_IssuerAndSerialNumber_seq_tt[] = { |
61 | ASN1_SIMPLE(CMS_IssuerAndSerialNumber, issuer, X509_NAME), | 61 | { |
62 | ASN1_SIMPLE(CMS_IssuerAndSerialNumber, serialNumber, ASN1_INTEGER) | 62 | .flags = 0, |
63 | } ASN1_SEQUENCE_END(CMS_IssuerAndSerialNumber) | 63 | .tag = 0, |
64 | 64 | .offset = offsetof(CMS_IssuerAndSerialNumber, issuer), | |
65 | ASN1_SEQUENCE(CMS_OtherCertificateFormat) = { | 65 | .field_name = "issuer", |
66 | ASN1_SIMPLE(CMS_OtherCertificateFormat, otherCertFormat, ASN1_OBJECT), | 66 | .item = &X509_NAME_it, |
67 | ASN1_OPT(CMS_OtherCertificateFormat, otherCert, ASN1_ANY) | 67 | }, |
68 | } ASN1_SEQUENCE_END(CMS_OtherCertificateFormat) | 68 | { |
69 | 69 | .flags = 0, | |
70 | ASN1_CHOICE(CMS_CertificateChoices) = { | 70 | .tag = 0, |
71 | ASN1_SIMPLE(CMS_CertificateChoices, d.certificate, X509), | 71 | .offset = offsetof(CMS_IssuerAndSerialNumber, serialNumber), |
72 | ASN1_IMP(CMS_CertificateChoices, d.extendedCertificate, ASN1_SEQUENCE, 0), | 72 | .field_name = "serialNumber", |
73 | ASN1_IMP(CMS_CertificateChoices, d.v1AttrCert, ASN1_SEQUENCE, 1), | 73 | .item = &ASN1_INTEGER_it, |
74 | ASN1_IMP(CMS_CertificateChoices, d.v2AttrCert, ASN1_SEQUENCE, 2), | 74 | }, |
75 | ASN1_IMP(CMS_CertificateChoices, d.other, CMS_OtherCertificateFormat, 3) | 75 | }; |
76 | } ASN1_CHOICE_END(CMS_CertificateChoices) | 76 | |
77 | 77 | const ASN1_ITEM CMS_IssuerAndSerialNumber_it = { | |
78 | ASN1_CHOICE(CMS_SignerIdentifier) = { | 78 | .itype = ASN1_ITYPE_SEQUENCE, |
79 | ASN1_SIMPLE(CMS_SignerIdentifier, d.issuerAndSerialNumber, CMS_IssuerAndSerialNumber), | 79 | .utype = V_ASN1_SEQUENCE, |
80 | ASN1_IMP(CMS_SignerIdentifier, d.subjectKeyIdentifier, ASN1_OCTET_STRING, 0) | 80 | .templates = CMS_IssuerAndSerialNumber_seq_tt, |
81 | } ASN1_CHOICE_END(CMS_SignerIdentifier) | 81 | .tcount = sizeof(CMS_IssuerAndSerialNumber_seq_tt) / sizeof(ASN1_TEMPLATE), |
82 | 82 | .funcs = NULL, | |
83 | ASN1_NDEF_SEQUENCE(CMS_EncapsulatedContentInfo) = { | 83 | .size = sizeof(CMS_IssuerAndSerialNumber), |
84 | ASN1_SIMPLE(CMS_EncapsulatedContentInfo, eContentType, ASN1_OBJECT), | 84 | .sname = "CMS_IssuerAndSerialNumber", |
85 | ASN1_NDEF_EXP_OPT(CMS_EncapsulatedContentInfo, eContent, ASN1_OCTET_STRING_NDEF, 0) | 85 | }; |
86 | } ASN1_NDEF_SEQUENCE_END(CMS_EncapsulatedContentInfo) | 86 | |
87 | static const ASN1_TEMPLATE CMS_OtherCertificateFormat_seq_tt[] = { | ||
88 | { | ||
89 | .flags = 0, | ||
90 | .tag = 0, | ||
91 | .offset = offsetof(CMS_OtherCertificateFormat, otherCertFormat), | ||
92 | .field_name = "otherCertFormat", | ||
93 | .item = &ASN1_OBJECT_it, | ||
94 | }, | ||
95 | { | ||
96 | .flags = ASN1_TFLG_OPTIONAL, | ||
97 | .tag = 0, | ||
98 | .offset = offsetof(CMS_OtherCertificateFormat, otherCert), | ||
99 | .field_name = "otherCert", | ||
100 | .item = &ASN1_ANY_it, | ||
101 | }, | ||
102 | }; | ||
103 | |||
104 | const ASN1_ITEM CMS_OtherCertificateFormat_it = { | ||
105 | .itype = ASN1_ITYPE_SEQUENCE, | ||
106 | .utype = V_ASN1_SEQUENCE, | ||
107 | .templates = CMS_OtherCertificateFormat_seq_tt, | ||
108 | .tcount = sizeof(CMS_OtherCertificateFormat_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
109 | .funcs = NULL, | ||
110 | .size = sizeof(CMS_OtherCertificateFormat), | ||
111 | .sname = "CMS_OtherCertificateFormat", | ||
112 | }; | ||
113 | |||
114 | static const ASN1_TEMPLATE CMS_CertificateChoices_ch_tt[] = { | ||
115 | { | ||
116 | .flags = 0, | ||
117 | .tag = 0, | ||
118 | .offset = offsetof(CMS_CertificateChoices, d.certificate), | ||
119 | .field_name = "d.certificate", | ||
120 | .item = &X509_it, | ||
121 | }, | ||
122 | { | ||
123 | .flags = ASN1_TFLG_IMPLICIT, | ||
124 | .tag = 0, | ||
125 | .offset = offsetof(CMS_CertificateChoices, d.extendedCertificate), | ||
126 | .field_name = "d.extendedCertificate", | ||
127 | .item = &ASN1_SEQUENCE_it, | ||
128 | }, | ||
129 | { | ||
130 | .flags = ASN1_TFLG_IMPLICIT, | ||
131 | .tag = 1, | ||
132 | .offset = offsetof(CMS_CertificateChoices, d.v1AttrCert), | ||
133 | .field_name = "d.v1AttrCert", | ||
134 | .item = &ASN1_SEQUENCE_it, | ||
135 | }, | ||
136 | { | ||
137 | .flags = ASN1_TFLG_IMPLICIT, | ||
138 | .tag = 2, | ||
139 | .offset = offsetof(CMS_CertificateChoices, d.v2AttrCert), | ||
140 | .field_name = "d.v2AttrCert", | ||
141 | .item = &ASN1_SEQUENCE_it, | ||
142 | }, | ||
143 | { | ||
144 | .flags = ASN1_TFLG_IMPLICIT, | ||
145 | .tag = 3, | ||
146 | .offset = offsetof(CMS_CertificateChoices, d.other), | ||
147 | .field_name = "d.other", | ||
148 | .item = &CMS_OtherCertificateFormat_it, | ||
149 | }, | ||
150 | }; | ||
151 | |||
152 | const ASN1_ITEM CMS_CertificateChoices_it = { | ||
153 | .itype = ASN1_ITYPE_CHOICE, | ||
154 | .utype = offsetof(CMS_CertificateChoices, type), | ||
155 | .templates = CMS_CertificateChoices_ch_tt, | ||
156 | .tcount = sizeof(CMS_CertificateChoices_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
157 | .funcs = NULL, | ||
158 | .size = sizeof(CMS_CertificateChoices), | ||
159 | .sname = "CMS_CertificateChoices", | ||
160 | }; | ||
161 | |||
162 | static const ASN1_TEMPLATE CMS_SignerIdentifier_ch_tt[] = { | ||
163 | { | ||
164 | .flags = 0, | ||
165 | .tag = 0, | ||
166 | .offset = offsetof(CMS_SignerIdentifier, d.issuerAndSerialNumber), | ||
167 | .field_name = "d.issuerAndSerialNumber", | ||
168 | .item = &CMS_IssuerAndSerialNumber_it, | ||
169 | }, | ||
170 | { | ||
171 | .flags = ASN1_TFLG_IMPLICIT, | ||
172 | .tag = 0, | ||
173 | .offset = offsetof(CMS_SignerIdentifier, d.subjectKeyIdentifier), | ||
174 | .field_name = "d.subjectKeyIdentifier", | ||
175 | .item = &ASN1_OCTET_STRING_it, | ||
176 | }, | ||
177 | }; | ||
178 | |||
179 | const ASN1_ITEM CMS_SignerIdentifier_it = { | ||
180 | .itype = ASN1_ITYPE_CHOICE, | ||
181 | .utype = offsetof(CMS_SignerIdentifier, type), | ||
182 | .templates = CMS_SignerIdentifier_ch_tt, | ||
183 | .tcount = sizeof(CMS_SignerIdentifier_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
184 | .funcs = NULL, | ||
185 | .size = sizeof(CMS_SignerIdentifier), | ||
186 | .sname = "CMS_SignerIdentifier", | ||
187 | }; | ||
188 | |||
189 | static const ASN1_TEMPLATE CMS_EncapsulatedContentInfo_seq_tt[] = { | ||
190 | { | ||
191 | .flags = 0, | ||
192 | .tag = 0, | ||
193 | .offset = offsetof(CMS_EncapsulatedContentInfo, eContentType), | ||
194 | .field_name = "eContentType", | ||
195 | .item = &ASN1_OBJECT_it, | ||
196 | }, | ||
197 | { | ||
198 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL | ASN1_TFLG_NDEF, | ||
199 | .tag = 0, | ||
200 | .offset = offsetof(CMS_EncapsulatedContentInfo, eContent), | ||
201 | .field_name = "eContent", | ||
202 | .item = &ASN1_OCTET_STRING_NDEF_it, | ||
203 | }, | ||
204 | }; | ||
205 | |||
206 | const ASN1_ITEM CMS_EncapsulatedContentInfo_it = { | ||
207 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
208 | .utype = V_ASN1_SEQUENCE, | ||
209 | .templates = CMS_EncapsulatedContentInfo_seq_tt, | ||
210 | .tcount = sizeof(CMS_EncapsulatedContentInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
211 | .funcs = NULL, | ||
212 | .size = sizeof(CMS_EncapsulatedContentInfo), | ||
213 | .sname = "CMS_EncapsulatedContentInfo", | ||
214 | }; | ||
87 | 215 | ||
88 | /* Minor tweak to operation: free up signer key, cert */ | 216 | /* Minor tweak to operation: free up signer key, cert */ |
89 | static int | 217 | static int |
@@ -98,117 +226,653 @@ cms_si_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | |||
98 | return 1; | 226 | return 1; |
99 | } | 227 | } |
100 | 228 | ||
101 | ASN1_SEQUENCE_cb(CMS_SignerInfo, cms_si_cb) = { | 229 | static const ASN1_AUX CMS_SignerInfo_aux = { |
102 | ASN1_SIMPLE(CMS_SignerInfo, version, LONG), | 230 | .app_data = NULL, |
103 | ASN1_SIMPLE(CMS_SignerInfo, sid, CMS_SignerIdentifier), | 231 | .flags = 0, |
104 | ASN1_SIMPLE(CMS_SignerInfo, digestAlgorithm, X509_ALGOR), | 232 | .ref_offset = 0, |
105 | ASN1_IMP_SET_OF_OPT(CMS_SignerInfo, signedAttrs, X509_ATTRIBUTE, 0), | 233 | .ref_lock = 0, |
106 | ASN1_SIMPLE(CMS_SignerInfo, signatureAlgorithm, X509_ALGOR), | 234 | .asn1_cb = cms_si_cb, |
107 | ASN1_SIMPLE(CMS_SignerInfo, signature, ASN1_OCTET_STRING), | 235 | .enc_offset = 0, |
108 | ASN1_IMP_SET_OF_OPT(CMS_SignerInfo, unsignedAttrs, X509_ATTRIBUTE, 1) | 236 | }; |
109 | } ASN1_SEQUENCE_END_cb(CMS_SignerInfo, CMS_SignerInfo) | 237 | static const ASN1_TEMPLATE CMS_SignerInfo_seq_tt[] = { |
110 | 238 | { | |
111 | ASN1_SEQUENCE(CMS_OtherRevocationInfoFormat) = { | 239 | .flags = 0, |
112 | ASN1_SIMPLE(CMS_OtherRevocationInfoFormat, otherRevInfoFormat, ASN1_OBJECT), | 240 | .tag = 0, |
113 | ASN1_OPT(CMS_OtherRevocationInfoFormat, otherRevInfo, ASN1_ANY) | 241 | .offset = offsetof(CMS_SignerInfo, version), |
114 | } ASN1_SEQUENCE_END(CMS_OtherRevocationInfoFormat) | 242 | .field_name = "version", |
115 | 243 | .item = &LONG_it, | |
116 | ASN1_CHOICE(CMS_RevocationInfoChoice) = { | 244 | }, |
117 | ASN1_SIMPLE(CMS_RevocationInfoChoice, d.crl, X509_CRL), | 245 | { |
118 | ASN1_IMP(CMS_RevocationInfoChoice, d.other, CMS_OtherRevocationInfoFormat, 1) | 246 | .flags = 0, |
119 | } ASN1_CHOICE_END(CMS_RevocationInfoChoice) | 247 | .tag = 0, |
120 | 248 | .offset = offsetof(CMS_SignerInfo, sid), | |
121 | ASN1_NDEF_SEQUENCE(CMS_SignedData) = { | 249 | .field_name = "sid", |
122 | ASN1_SIMPLE(CMS_SignedData, version, LONG), | 250 | .item = &CMS_SignerIdentifier_it, |
123 | ASN1_SET_OF(CMS_SignedData, digestAlgorithms, X509_ALGOR), | 251 | }, |
124 | ASN1_SIMPLE(CMS_SignedData, encapContentInfo, CMS_EncapsulatedContentInfo), | 252 | { |
125 | ASN1_IMP_SET_OF_OPT(CMS_SignedData, certificates, CMS_CertificateChoices, 0), | 253 | .flags = 0, |
126 | ASN1_IMP_SET_OF_OPT(CMS_SignedData, crls, CMS_RevocationInfoChoice, 1), | 254 | .tag = 0, |
127 | ASN1_SET_OF(CMS_SignedData, signerInfos, CMS_SignerInfo) | 255 | .offset = offsetof(CMS_SignerInfo, digestAlgorithm), |
128 | } ASN1_NDEF_SEQUENCE_END(CMS_SignedData) | 256 | .field_name = "digestAlgorithm", |
129 | 257 | .item = &X509_ALGOR_it, | |
130 | ASN1_SEQUENCE(CMS_OriginatorInfo) = { | 258 | }, |
131 | ASN1_IMP_SET_OF_OPT(CMS_OriginatorInfo, certificates, CMS_CertificateChoices, 0), | 259 | { |
132 | ASN1_IMP_SET_OF_OPT(CMS_OriginatorInfo, crls, CMS_RevocationInfoChoice, 1) | 260 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, |
133 | } ASN1_SEQUENCE_END(CMS_OriginatorInfo) | 261 | .tag = 0, |
134 | 262 | .offset = offsetof(CMS_SignerInfo, signedAttrs), | |
135 | ASN1_NDEF_SEQUENCE(CMS_EncryptedContentInfo) = { | 263 | .field_name = "signedAttrs", |
136 | ASN1_SIMPLE(CMS_EncryptedContentInfo, contentType, ASN1_OBJECT), | 264 | .item = &X509_ATTRIBUTE_it, |
137 | ASN1_SIMPLE(CMS_EncryptedContentInfo, contentEncryptionAlgorithm, X509_ALGOR), | 265 | }, |
138 | ASN1_IMP_OPT(CMS_EncryptedContentInfo, encryptedContent, ASN1_OCTET_STRING_NDEF, 0) | 266 | { |
139 | } ASN1_NDEF_SEQUENCE_END(CMS_EncryptedContentInfo) | 267 | .flags = 0, |
140 | 268 | .tag = 0, | |
141 | ASN1_SEQUENCE(CMS_KeyTransRecipientInfo) = { | 269 | .offset = offsetof(CMS_SignerInfo, signatureAlgorithm), |
142 | ASN1_SIMPLE(CMS_KeyTransRecipientInfo, version, LONG), | 270 | .field_name = "signatureAlgorithm", |
143 | ASN1_SIMPLE(CMS_KeyTransRecipientInfo, rid, CMS_SignerIdentifier), | 271 | .item = &X509_ALGOR_it, |
144 | ASN1_SIMPLE(CMS_KeyTransRecipientInfo, keyEncryptionAlgorithm, X509_ALGOR), | 272 | }, |
145 | ASN1_SIMPLE(CMS_KeyTransRecipientInfo, encryptedKey, ASN1_OCTET_STRING) | 273 | { |
146 | } ASN1_SEQUENCE_END(CMS_KeyTransRecipientInfo) | 274 | .flags = 0, |
147 | 275 | .tag = 0, | |
148 | ASN1_SEQUENCE(CMS_OtherKeyAttribute) = { | 276 | .offset = offsetof(CMS_SignerInfo, signature), |
149 | ASN1_SIMPLE(CMS_OtherKeyAttribute, keyAttrId, ASN1_OBJECT), | 277 | .field_name = "signature", |
150 | ASN1_OPT(CMS_OtherKeyAttribute, keyAttr, ASN1_ANY) | 278 | .item = &ASN1_OCTET_STRING_it, |
151 | } ASN1_SEQUENCE_END(CMS_OtherKeyAttribute) | 279 | }, |
152 | 280 | { | |
153 | ASN1_SEQUENCE(CMS_RecipientKeyIdentifier) = { | 281 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, |
154 | ASN1_SIMPLE(CMS_RecipientKeyIdentifier, subjectKeyIdentifier, ASN1_OCTET_STRING), | 282 | .tag = 1, |
155 | ASN1_OPT(CMS_RecipientKeyIdentifier, date, ASN1_GENERALIZEDTIME), | 283 | .offset = offsetof(CMS_SignerInfo, unsignedAttrs), |
156 | ASN1_OPT(CMS_RecipientKeyIdentifier, other, CMS_OtherKeyAttribute) | 284 | .field_name = "unsignedAttrs", |
157 | } ASN1_SEQUENCE_END(CMS_RecipientKeyIdentifier) | 285 | .item = &X509_ATTRIBUTE_it, |
158 | 286 | }, | |
159 | ASN1_CHOICE(CMS_KeyAgreeRecipientIdentifier) = { | 287 | }; |
160 | ASN1_SIMPLE(CMS_KeyAgreeRecipientIdentifier, d.issuerAndSerialNumber, CMS_IssuerAndSerialNumber), | 288 | |
161 | ASN1_IMP(CMS_KeyAgreeRecipientIdentifier, d.rKeyId, CMS_RecipientKeyIdentifier, 0) | 289 | const ASN1_ITEM CMS_SignerInfo_it = { |
162 | } ASN1_CHOICE_END(CMS_KeyAgreeRecipientIdentifier) | 290 | .itype = ASN1_ITYPE_SEQUENCE, |
163 | 291 | .utype = V_ASN1_SEQUENCE, | |
164 | ASN1_SEQUENCE(CMS_RecipientEncryptedKey) = { | 292 | .templates = CMS_SignerInfo_seq_tt, |
165 | ASN1_SIMPLE(CMS_RecipientEncryptedKey, rid, CMS_KeyAgreeRecipientIdentifier), | 293 | .tcount = sizeof(CMS_SignerInfo_seq_tt) / sizeof(ASN1_TEMPLATE), |
166 | ASN1_SIMPLE(CMS_RecipientEncryptedKey, encryptedKey, ASN1_OCTET_STRING) | 294 | .funcs = &CMS_SignerInfo_aux, |
167 | } ASN1_SEQUENCE_END(CMS_RecipientEncryptedKey) | 295 | .size = sizeof(CMS_SignerInfo), |
168 | 296 | .sname = "CMS_SignerInfo", | |
169 | ASN1_SEQUENCE(CMS_OriginatorPublicKey) = { | 297 | }; |
170 | ASN1_SIMPLE(CMS_OriginatorPublicKey, algorithm, X509_ALGOR), | 298 | |
171 | ASN1_SIMPLE(CMS_OriginatorPublicKey, publicKey, ASN1_BIT_STRING) | 299 | static const ASN1_TEMPLATE CMS_OtherRevocationInfoFormat_seq_tt[] = { |
172 | } ASN1_SEQUENCE_END(CMS_OriginatorPublicKey) | 300 | { |
173 | 301 | .flags = 0, | |
174 | ASN1_CHOICE(CMS_OriginatorIdentifierOrKey) = { | 302 | .tag = 0, |
175 | ASN1_SIMPLE(CMS_OriginatorIdentifierOrKey, d.issuerAndSerialNumber, CMS_IssuerAndSerialNumber), | 303 | .offset = offsetof(CMS_OtherRevocationInfoFormat, otherRevInfoFormat), |
176 | ASN1_IMP(CMS_OriginatorIdentifierOrKey, d.subjectKeyIdentifier, ASN1_OCTET_STRING, 0), | 304 | .field_name = "otherRevInfoFormat", |
177 | ASN1_IMP(CMS_OriginatorIdentifierOrKey, d.originatorKey, CMS_OriginatorPublicKey, 1) | 305 | .item = &ASN1_OBJECT_it, |
178 | } ASN1_CHOICE_END(CMS_OriginatorIdentifierOrKey) | 306 | }, |
179 | 307 | { | |
180 | ASN1_SEQUENCE(CMS_KeyAgreeRecipientInfo) = { | 308 | .flags = ASN1_TFLG_OPTIONAL, |
181 | ASN1_SIMPLE(CMS_KeyAgreeRecipientInfo, version, LONG), | 309 | .tag = 0, |
182 | ASN1_EXP(CMS_KeyAgreeRecipientInfo, originator, CMS_OriginatorIdentifierOrKey, 0), | 310 | .offset = offsetof(CMS_OtherRevocationInfoFormat, otherRevInfo), |
183 | ASN1_EXP_OPT(CMS_KeyAgreeRecipientInfo, ukm, ASN1_OCTET_STRING, 1), | 311 | .field_name = "otherRevInfo", |
184 | ASN1_SIMPLE(CMS_KeyAgreeRecipientInfo, keyEncryptionAlgorithm, X509_ALGOR), | 312 | .item = &ASN1_ANY_it, |
185 | ASN1_SEQUENCE_OF(CMS_KeyAgreeRecipientInfo, recipientEncryptedKeys, CMS_RecipientEncryptedKey) | 313 | }, |
186 | } ASN1_SEQUENCE_END(CMS_KeyAgreeRecipientInfo) | 314 | }; |
187 | 315 | ||
188 | ASN1_SEQUENCE(CMS_KEKIdentifier) = { | 316 | const ASN1_ITEM CMS_OtherRevocationInfoFormat_it = { |
189 | ASN1_SIMPLE(CMS_KEKIdentifier, keyIdentifier, ASN1_OCTET_STRING), | 317 | .itype = ASN1_ITYPE_SEQUENCE, |
190 | ASN1_OPT(CMS_KEKIdentifier, date, ASN1_GENERALIZEDTIME), | 318 | .utype = V_ASN1_SEQUENCE, |
191 | ASN1_OPT(CMS_KEKIdentifier, other, CMS_OtherKeyAttribute) | 319 | .templates = CMS_OtherRevocationInfoFormat_seq_tt, |
192 | } ASN1_SEQUENCE_END(CMS_KEKIdentifier) | 320 | .tcount = sizeof(CMS_OtherRevocationInfoFormat_seq_tt) / sizeof(ASN1_TEMPLATE), |
193 | 321 | .funcs = NULL, | |
194 | ASN1_SEQUENCE(CMS_KEKRecipientInfo) = { | 322 | .size = sizeof(CMS_OtherRevocationInfoFormat), |
195 | ASN1_SIMPLE(CMS_KEKRecipientInfo, version, LONG), | 323 | .sname = "CMS_OtherRevocationInfoFormat", |
196 | ASN1_SIMPLE(CMS_KEKRecipientInfo, kekid, CMS_KEKIdentifier), | 324 | }; |
197 | ASN1_SIMPLE(CMS_KEKRecipientInfo, keyEncryptionAlgorithm, X509_ALGOR), | 325 | |
198 | ASN1_SIMPLE(CMS_KEKRecipientInfo, encryptedKey, ASN1_OCTET_STRING) | 326 | static const ASN1_TEMPLATE CMS_RevocationInfoChoice_ch_tt[] = { |
199 | } ASN1_SEQUENCE_END(CMS_KEKRecipientInfo) | 327 | { |
200 | 328 | .flags = 0, | |
201 | ASN1_SEQUENCE(CMS_PasswordRecipientInfo) = { | 329 | .tag = 0, |
202 | ASN1_SIMPLE(CMS_PasswordRecipientInfo, version, LONG), | 330 | .offset = offsetof(CMS_RevocationInfoChoice, d.crl), |
203 | ASN1_IMP_OPT(CMS_PasswordRecipientInfo, keyDerivationAlgorithm, X509_ALGOR, 0), | 331 | .field_name = "d.crl", |
204 | ASN1_SIMPLE(CMS_PasswordRecipientInfo, keyEncryptionAlgorithm, X509_ALGOR), | 332 | .item = &X509_CRL_it, |
205 | ASN1_SIMPLE(CMS_PasswordRecipientInfo, encryptedKey, ASN1_OCTET_STRING) | 333 | }, |
206 | } ASN1_SEQUENCE_END(CMS_PasswordRecipientInfo) | 334 | { |
207 | 335 | .flags = ASN1_TFLG_IMPLICIT, | |
208 | ASN1_SEQUENCE(CMS_OtherRecipientInfo) = { | 336 | .tag = 1, |
209 | ASN1_SIMPLE(CMS_OtherRecipientInfo, oriType, ASN1_OBJECT), | 337 | .offset = offsetof(CMS_RevocationInfoChoice, d.other), |
210 | ASN1_OPT(CMS_OtherRecipientInfo, oriValue, ASN1_ANY) | 338 | .field_name = "d.other", |
211 | } ASN1_SEQUENCE_END(CMS_OtherRecipientInfo) | 339 | .item = &CMS_OtherRevocationInfoFormat_it, |
340 | }, | ||
341 | }; | ||
342 | |||
343 | const ASN1_ITEM CMS_RevocationInfoChoice_it = { | ||
344 | .itype = ASN1_ITYPE_CHOICE, | ||
345 | .utype = offsetof(CMS_RevocationInfoChoice, type), | ||
346 | .templates = CMS_RevocationInfoChoice_ch_tt, | ||
347 | .tcount = sizeof(CMS_RevocationInfoChoice_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
348 | .funcs = NULL, | ||
349 | .size = sizeof(CMS_RevocationInfoChoice), | ||
350 | .sname = "CMS_RevocationInfoChoice", | ||
351 | }; | ||
352 | |||
353 | static const ASN1_TEMPLATE CMS_SignedData_seq_tt[] = { | ||
354 | { | ||
355 | .flags = 0, | ||
356 | .tag = 0, | ||
357 | .offset = offsetof(CMS_SignedData, version), | ||
358 | .field_name = "version", | ||
359 | .item = &LONG_it, | ||
360 | }, | ||
361 | { | ||
362 | .flags = ASN1_TFLG_SET_OF, | ||
363 | .tag = 0, | ||
364 | .offset = offsetof(CMS_SignedData, digestAlgorithms), | ||
365 | .field_name = "digestAlgorithms", | ||
366 | .item = &X509_ALGOR_it, | ||
367 | }, | ||
368 | { | ||
369 | .flags = 0, | ||
370 | .tag = 0, | ||
371 | .offset = offsetof(CMS_SignedData, encapContentInfo), | ||
372 | .field_name = "encapContentInfo", | ||
373 | .item = &CMS_EncapsulatedContentInfo_it, | ||
374 | }, | ||
375 | { | ||
376 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
377 | .tag = 0, | ||
378 | .offset = offsetof(CMS_SignedData, certificates), | ||
379 | .field_name = "certificates", | ||
380 | .item = &CMS_CertificateChoices_it, | ||
381 | }, | ||
382 | { | ||
383 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
384 | .tag = 1, | ||
385 | .offset = offsetof(CMS_SignedData, crls), | ||
386 | .field_name = "crls", | ||
387 | .item = &CMS_RevocationInfoChoice_it, | ||
388 | }, | ||
389 | { | ||
390 | .flags = ASN1_TFLG_SET_OF, | ||
391 | .tag = 0, | ||
392 | .offset = offsetof(CMS_SignedData, signerInfos), | ||
393 | .field_name = "signerInfos", | ||
394 | .item = &CMS_SignerInfo_it, | ||
395 | }, | ||
396 | }; | ||
397 | |||
398 | const ASN1_ITEM CMS_SignedData_it = { | ||
399 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
400 | .utype = V_ASN1_SEQUENCE, | ||
401 | .templates = CMS_SignedData_seq_tt, | ||
402 | .tcount = sizeof(CMS_SignedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
403 | .funcs = NULL, | ||
404 | .size = sizeof(CMS_SignedData), | ||
405 | .sname = "CMS_SignedData", | ||
406 | }; | ||
407 | |||
408 | static const ASN1_TEMPLATE CMS_OriginatorInfo_seq_tt[] = { | ||
409 | { | ||
410 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
411 | .tag = 0, | ||
412 | .offset = offsetof(CMS_OriginatorInfo, certificates), | ||
413 | .field_name = "certificates", | ||
414 | .item = &CMS_CertificateChoices_it, | ||
415 | }, | ||
416 | { | ||
417 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
418 | .tag = 1, | ||
419 | .offset = offsetof(CMS_OriginatorInfo, crls), | ||
420 | .field_name = "crls", | ||
421 | .item = &CMS_RevocationInfoChoice_it, | ||
422 | }, | ||
423 | }; | ||
424 | |||
425 | const ASN1_ITEM CMS_OriginatorInfo_it = { | ||
426 | .itype = ASN1_ITYPE_SEQUENCE, | ||
427 | .utype = V_ASN1_SEQUENCE, | ||
428 | .templates = CMS_OriginatorInfo_seq_tt, | ||
429 | .tcount = sizeof(CMS_OriginatorInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
430 | .funcs = NULL, | ||
431 | .size = sizeof(CMS_OriginatorInfo), | ||
432 | .sname = "CMS_OriginatorInfo", | ||
433 | }; | ||
434 | |||
435 | static const ASN1_TEMPLATE CMS_EncryptedContentInfo_seq_tt[] = { | ||
436 | { | ||
437 | .flags = 0, | ||
438 | .tag = 0, | ||
439 | .offset = offsetof(CMS_EncryptedContentInfo, contentType), | ||
440 | .field_name = "contentType", | ||
441 | .item = &ASN1_OBJECT_it, | ||
442 | }, | ||
443 | { | ||
444 | .flags = 0, | ||
445 | .tag = 0, | ||
446 | .offset = offsetof(CMS_EncryptedContentInfo, contentEncryptionAlgorithm), | ||
447 | .field_name = "contentEncryptionAlgorithm", | ||
448 | .item = &X509_ALGOR_it, | ||
449 | }, | ||
450 | { | ||
451 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, | ||
452 | .tag = 0, | ||
453 | .offset = offsetof(CMS_EncryptedContentInfo, encryptedContent), | ||
454 | .field_name = "encryptedContent", | ||
455 | .item = &ASN1_OCTET_STRING_NDEF_it, | ||
456 | }, | ||
457 | }; | ||
458 | |||
459 | const ASN1_ITEM CMS_EncryptedContentInfo_it = { | ||
460 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
461 | .utype = V_ASN1_SEQUENCE, | ||
462 | .templates = CMS_EncryptedContentInfo_seq_tt, | ||
463 | .tcount = sizeof(CMS_EncryptedContentInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
464 | .funcs = NULL, | ||
465 | .size = sizeof(CMS_EncryptedContentInfo), | ||
466 | .sname = "CMS_EncryptedContentInfo", | ||
467 | }; | ||
468 | |||
469 | static const ASN1_TEMPLATE CMS_KeyTransRecipientInfo_seq_tt[] = { | ||
470 | { | ||
471 | .flags = 0, | ||
472 | .tag = 0, | ||
473 | .offset = offsetof(CMS_KeyTransRecipientInfo, version), | ||
474 | .field_name = "version", | ||
475 | .item = &LONG_it, | ||
476 | }, | ||
477 | { | ||
478 | .flags = 0, | ||
479 | .tag = 0, | ||
480 | .offset = offsetof(CMS_KeyTransRecipientInfo, rid), | ||
481 | .field_name = "rid", | ||
482 | .item = &CMS_SignerIdentifier_it, | ||
483 | }, | ||
484 | { | ||
485 | .flags = 0, | ||
486 | .tag = 0, | ||
487 | .offset = offsetof(CMS_KeyTransRecipientInfo, keyEncryptionAlgorithm), | ||
488 | .field_name = "keyEncryptionAlgorithm", | ||
489 | .item = &X509_ALGOR_it, | ||
490 | }, | ||
491 | { | ||
492 | .flags = 0, | ||
493 | .tag = 0, | ||
494 | .offset = offsetof(CMS_KeyTransRecipientInfo, encryptedKey), | ||
495 | .field_name = "encryptedKey", | ||
496 | .item = &ASN1_OCTET_STRING_it, | ||
497 | }, | ||
498 | }; | ||
499 | |||
500 | const ASN1_ITEM CMS_KeyTransRecipientInfo_it = { | ||
501 | .itype = ASN1_ITYPE_SEQUENCE, | ||
502 | .utype = V_ASN1_SEQUENCE, | ||
503 | .templates = CMS_KeyTransRecipientInfo_seq_tt, | ||
504 | .tcount = sizeof(CMS_KeyTransRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
505 | .funcs = NULL, | ||
506 | .size = sizeof(CMS_KeyTransRecipientInfo), | ||
507 | .sname = "CMS_KeyTransRecipientInfo", | ||
508 | }; | ||
509 | |||
510 | static const ASN1_TEMPLATE CMS_OtherKeyAttribute_seq_tt[] = { | ||
511 | { | ||
512 | .flags = 0, | ||
513 | .tag = 0, | ||
514 | .offset = offsetof(CMS_OtherKeyAttribute, keyAttrId), | ||
515 | .field_name = "keyAttrId", | ||
516 | .item = &ASN1_OBJECT_it, | ||
517 | }, | ||
518 | { | ||
519 | .flags = ASN1_TFLG_OPTIONAL, | ||
520 | .tag = 0, | ||
521 | .offset = offsetof(CMS_OtherKeyAttribute, keyAttr), | ||
522 | .field_name = "keyAttr", | ||
523 | .item = &ASN1_ANY_it, | ||
524 | }, | ||
525 | }; | ||
526 | |||
527 | const ASN1_ITEM CMS_OtherKeyAttribute_it = { | ||
528 | .itype = ASN1_ITYPE_SEQUENCE, | ||
529 | .utype = V_ASN1_SEQUENCE, | ||
530 | .templates = CMS_OtherKeyAttribute_seq_tt, | ||
531 | .tcount = sizeof(CMS_OtherKeyAttribute_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
532 | .funcs = NULL, | ||
533 | .size = sizeof(CMS_OtherKeyAttribute), | ||
534 | .sname = "CMS_OtherKeyAttribute", | ||
535 | }; | ||
536 | |||
537 | static const ASN1_TEMPLATE CMS_RecipientKeyIdentifier_seq_tt[] = { | ||
538 | { | ||
539 | .flags = 0, | ||
540 | .tag = 0, | ||
541 | .offset = offsetof(CMS_RecipientKeyIdentifier, subjectKeyIdentifier), | ||
542 | .field_name = "subjectKeyIdentifier", | ||
543 | .item = &ASN1_OCTET_STRING_it, | ||
544 | }, | ||
545 | { | ||
546 | .flags = ASN1_TFLG_OPTIONAL, | ||
547 | .tag = 0, | ||
548 | .offset = offsetof(CMS_RecipientKeyIdentifier, date), | ||
549 | .field_name = "date", | ||
550 | .item = &ASN1_GENERALIZEDTIME_it, | ||
551 | }, | ||
552 | { | ||
553 | .flags = ASN1_TFLG_OPTIONAL, | ||
554 | .tag = 0, | ||
555 | .offset = offsetof(CMS_RecipientKeyIdentifier, other), | ||
556 | .field_name = "other", | ||
557 | .item = &CMS_OtherKeyAttribute_it, | ||
558 | }, | ||
559 | }; | ||
560 | |||
561 | const ASN1_ITEM CMS_RecipientKeyIdentifier_it = { | ||
562 | .itype = ASN1_ITYPE_SEQUENCE, | ||
563 | .utype = V_ASN1_SEQUENCE, | ||
564 | .templates = CMS_RecipientKeyIdentifier_seq_tt, | ||
565 | .tcount = sizeof(CMS_RecipientKeyIdentifier_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
566 | .funcs = NULL, | ||
567 | .size = sizeof(CMS_RecipientKeyIdentifier), | ||
568 | .sname = "CMS_RecipientKeyIdentifier", | ||
569 | }; | ||
570 | |||
571 | static const ASN1_TEMPLATE CMS_KeyAgreeRecipientIdentifier_ch_tt[] = { | ||
572 | { | ||
573 | .flags = 0, | ||
574 | .tag = 0, | ||
575 | .offset = offsetof(CMS_KeyAgreeRecipientIdentifier, d.issuerAndSerialNumber), | ||
576 | .field_name = "d.issuerAndSerialNumber", | ||
577 | .item = &CMS_IssuerAndSerialNumber_it, | ||
578 | }, | ||
579 | { | ||
580 | .flags = ASN1_TFLG_IMPLICIT, | ||
581 | .tag = 0, | ||
582 | .offset = offsetof(CMS_KeyAgreeRecipientIdentifier, d.rKeyId), | ||
583 | .field_name = "d.rKeyId", | ||
584 | .item = &CMS_RecipientKeyIdentifier_it, | ||
585 | }, | ||
586 | }; | ||
587 | |||
588 | const ASN1_ITEM CMS_KeyAgreeRecipientIdentifier_it = { | ||
589 | .itype = ASN1_ITYPE_CHOICE, | ||
590 | .utype = offsetof(CMS_KeyAgreeRecipientIdentifier, type), | ||
591 | .templates = CMS_KeyAgreeRecipientIdentifier_ch_tt, | ||
592 | .tcount = sizeof(CMS_KeyAgreeRecipientIdentifier_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
593 | .funcs = NULL, | ||
594 | .size = sizeof(CMS_KeyAgreeRecipientIdentifier), | ||
595 | .sname = "CMS_KeyAgreeRecipientIdentifier", | ||
596 | }; | ||
597 | |||
598 | static const ASN1_TEMPLATE CMS_RecipientEncryptedKey_seq_tt[] = { | ||
599 | { | ||
600 | .flags = 0, | ||
601 | .tag = 0, | ||
602 | .offset = offsetof(CMS_RecipientEncryptedKey, rid), | ||
603 | .field_name = "rid", | ||
604 | .item = &CMS_KeyAgreeRecipientIdentifier_it, | ||
605 | }, | ||
606 | { | ||
607 | .flags = 0, | ||
608 | .tag = 0, | ||
609 | .offset = offsetof(CMS_RecipientEncryptedKey, encryptedKey), | ||
610 | .field_name = "encryptedKey", | ||
611 | .item = &ASN1_OCTET_STRING_it, | ||
612 | }, | ||
613 | }; | ||
614 | |||
615 | const ASN1_ITEM CMS_RecipientEncryptedKey_it = { | ||
616 | .itype = ASN1_ITYPE_SEQUENCE, | ||
617 | .utype = V_ASN1_SEQUENCE, | ||
618 | .templates = CMS_RecipientEncryptedKey_seq_tt, | ||
619 | .tcount = sizeof(CMS_RecipientEncryptedKey_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
620 | .funcs = NULL, | ||
621 | .size = sizeof(CMS_RecipientEncryptedKey), | ||
622 | .sname = "CMS_RecipientEncryptedKey", | ||
623 | }; | ||
624 | |||
625 | static const ASN1_TEMPLATE CMS_OriginatorPublicKey_seq_tt[] = { | ||
626 | { | ||
627 | .flags = 0, | ||
628 | .tag = 0, | ||
629 | .offset = offsetof(CMS_OriginatorPublicKey, algorithm), | ||
630 | .field_name = "algorithm", | ||
631 | .item = &X509_ALGOR_it, | ||
632 | }, | ||
633 | { | ||
634 | .flags = 0, | ||
635 | .tag = 0, | ||
636 | .offset = offsetof(CMS_OriginatorPublicKey, publicKey), | ||
637 | .field_name = "publicKey", | ||
638 | .item = &ASN1_BIT_STRING_it, | ||
639 | }, | ||
640 | }; | ||
641 | |||
642 | const ASN1_ITEM CMS_OriginatorPublicKey_it = { | ||
643 | .itype = ASN1_ITYPE_SEQUENCE, | ||
644 | .utype = V_ASN1_SEQUENCE, | ||
645 | .templates = CMS_OriginatorPublicKey_seq_tt, | ||
646 | .tcount = sizeof(CMS_OriginatorPublicKey_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
647 | .funcs = NULL, | ||
648 | .size = sizeof(CMS_OriginatorPublicKey), | ||
649 | .sname = "CMS_OriginatorPublicKey", | ||
650 | }; | ||
651 | |||
652 | static const ASN1_TEMPLATE CMS_OriginatorIdentifierOrKey_ch_tt[] = { | ||
653 | { | ||
654 | .flags = 0, | ||
655 | .tag = 0, | ||
656 | .offset = offsetof(CMS_OriginatorIdentifierOrKey, d.issuerAndSerialNumber), | ||
657 | .field_name = "d.issuerAndSerialNumber", | ||
658 | .item = &CMS_IssuerAndSerialNumber_it, | ||
659 | }, | ||
660 | { | ||
661 | .flags = ASN1_TFLG_IMPLICIT, | ||
662 | .tag = 0, | ||
663 | .offset = offsetof(CMS_OriginatorIdentifierOrKey, d.subjectKeyIdentifier), | ||
664 | .field_name = "d.subjectKeyIdentifier", | ||
665 | .item = &ASN1_OCTET_STRING_it, | ||
666 | }, | ||
667 | { | ||
668 | .flags = ASN1_TFLG_IMPLICIT, | ||
669 | .tag = 1, | ||
670 | .offset = offsetof(CMS_OriginatorIdentifierOrKey, d.originatorKey), | ||
671 | .field_name = "d.originatorKey", | ||
672 | .item = &CMS_OriginatorPublicKey_it, | ||
673 | }, | ||
674 | }; | ||
675 | |||
676 | const ASN1_ITEM CMS_OriginatorIdentifierOrKey_it = { | ||
677 | .itype = ASN1_ITYPE_CHOICE, | ||
678 | .utype = offsetof(CMS_OriginatorIdentifierOrKey, type), | ||
679 | .templates = CMS_OriginatorIdentifierOrKey_ch_tt, | ||
680 | .tcount = sizeof(CMS_OriginatorIdentifierOrKey_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
681 | .funcs = NULL, | ||
682 | .size = sizeof(CMS_OriginatorIdentifierOrKey), | ||
683 | .sname = "CMS_OriginatorIdentifierOrKey", | ||
684 | }; | ||
685 | |||
686 | static const ASN1_TEMPLATE CMS_KeyAgreeRecipientInfo_seq_tt[] = { | ||
687 | { | ||
688 | .flags = 0, | ||
689 | .tag = 0, | ||
690 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, version), | ||
691 | .field_name = "version", | ||
692 | .item = &LONG_it, | ||
693 | }, | ||
694 | { | ||
695 | .flags = ASN1_TFLG_EXPLICIT, | ||
696 | .tag = 0, | ||
697 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, originator), | ||
698 | .field_name = "originator", | ||
699 | .item = &CMS_OriginatorIdentifierOrKey_it, | ||
700 | }, | ||
701 | { | ||
702 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL, | ||
703 | .tag = 1, | ||
704 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, ukm), | ||
705 | .field_name = "ukm", | ||
706 | .item = &ASN1_OCTET_STRING_it, | ||
707 | }, | ||
708 | { | ||
709 | .flags = 0, | ||
710 | .tag = 0, | ||
711 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, keyEncryptionAlgorithm), | ||
712 | .field_name = "keyEncryptionAlgorithm", | ||
713 | .item = &X509_ALGOR_it, | ||
714 | }, | ||
715 | { | ||
716 | .flags = ASN1_TFLG_SEQUENCE_OF, | ||
717 | .tag = 0, | ||
718 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, recipientEncryptedKeys), | ||
719 | .field_name = "recipientEncryptedKeys", | ||
720 | .item = &CMS_RecipientEncryptedKey_it, | ||
721 | }, | ||
722 | }; | ||
723 | |||
724 | const ASN1_ITEM CMS_KeyAgreeRecipientInfo_it = { | ||
725 | .itype = ASN1_ITYPE_SEQUENCE, | ||
726 | .utype = V_ASN1_SEQUENCE, | ||
727 | .templates = CMS_KeyAgreeRecipientInfo_seq_tt, | ||
728 | .tcount = sizeof(CMS_KeyAgreeRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
729 | .funcs = NULL, | ||
730 | .size = sizeof(CMS_KeyAgreeRecipientInfo), | ||
731 | .sname = "CMS_KeyAgreeRecipientInfo", | ||
732 | }; | ||
733 | |||
734 | static const ASN1_TEMPLATE CMS_KEKIdentifier_seq_tt[] = { | ||
735 | { | ||
736 | .flags = 0, | ||
737 | .tag = 0, | ||
738 | .offset = offsetof(CMS_KEKIdentifier, keyIdentifier), | ||
739 | .field_name = "keyIdentifier", | ||
740 | .item = &ASN1_OCTET_STRING_it, | ||
741 | }, | ||
742 | { | ||
743 | .flags = ASN1_TFLG_OPTIONAL, | ||
744 | .tag = 0, | ||
745 | .offset = offsetof(CMS_KEKIdentifier, date), | ||
746 | .field_name = "date", | ||
747 | .item = &ASN1_GENERALIZEDTIME_it, | ||
748 | }, | ||
749 | { | ||
750 | .flags = ASN1_TFLG_OPTIONAL, | ||
751 | .tag = 0, | ||
752 | .offset = offsetof(CMS_KEKIdentifier, other), | ||
753 | .field_name = "other", | ||
754 | .item = &CMS_OtherKeyAttribute_it, | ||
755 | }, | ||
756 | }; | ||
757 | |||
758 | const ASN1_ITEM CMS_KEKIdentifier_it = { | ||
759 | .itype = ASN1_ITYPE_SEQUENCE, | ||
760 | .utype = V_ASN1_SEQUENCE, | ||
761 | .templates = CMS_KEKIdentifier_seq_tt, | ||
762 | .tcount = sizeof(CMS_KEKIdentifier_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
763 | .funcs = NULL, | ||
764 | .size = sizeof(CMS_KEKIdentifier), | ||
765 | .sname = "CMS_KEKIdentifier", | ||
766 | }; | ||
767 | |||
768 | static const ASN1_TEMPLATE CMS_KEKRecipientInfo_seq_tt[] = { | ||
769 | { | ||
770 | .flags = 0, | ||
771 | .tag = 0, | ||
772 | .offset = offsetof(CMS_KEKRecipientInfo, version), | ||
773 | .field_name = "version", | ||
774 | .item = &LONG_it, | ||
775 | }, | ||
776 | { | ||
777 | .flags = 0, | ||
778 | .tag = 0, | ||
779 | .offset = offsetof(CMS_KEKRecipientInfo, kekid), | ||
780 | .field_name = "kekid", | ||
781 | .item = &CMS_KEKIdentifier_it, | ||
782 | }, | ||
783 | { | ||
784 | .flags = 0, | ||
785 | .tag = 0, | ||
786 | .offset = offsetof(CMS_KEKRecipientInfo, keyEncryptionAlgorithm), | ||
787 | .field_name = "keyEncryptionAlgorithm", | ||
788 | .item = &X509_ALGOR_it, | ||
789 | }, | ||
790 | { | ||
791 | .flags = 0, | ||
792 | .tag = 0, | ||
793 | .offset = offsetof(CMS_KEKRecipientInfo, encryptedKey), | ||
794 | .field_name = "encryptedKey", | ||
795 | .item = &ASN1_OCTET_STRING_it, | ||
796 | }, | ||
797 | }; | ||
798 | |||
799 | const ASN1_ITEM CMS_KEKRecipientInfo_it = { | ||
800 | .itype = ASN1_ITYPE_SEQUENCE, | ||
801 | .utype = V_ASN1_SEQUENCE, | ||
802 | .templates = CMS_KEKRecipientInfo_seq_tt, | ||
803 | .tcount = sizeof(CMS_KEKRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
804 | .funcs = NULL, | ||
805 | .size = sizeof(CMS_KEKRecipientInfo), | ||
806 | .sname = "CMS_KEKRecipientInfo", | ||
807 | }; | ||
808 | |||
809 | static const ASN1_TEMPLATE CMS_PasswordRecipientInfo_seq_tt[] = { | ||
810 | { | ||
811 | .flags = 0, | ||
812 | .tag = 0, | ||
813 | .offset = offsetof(CMS_PasswordRecipientInfo, version), | ||
814 | .field_name = "version", | ||
815 | .item = &LONG_it, | ||
816 | }, | ||
817 | { | ||
818 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, | ||
819 | .tag = 0, | ||
820 | .offset = offsetof(CMS_PasswordRecipientInfo, keyDerivationAlgorithm), | ||
821 | .field_name = "keyDerivationAlgorithm", | ||
822 | .item = &X509_ALGOR_it, | ||
823 | }, | ||
824 | { | ||
825 | .flags = 0, | ||
826 | .tag = 0, | ||
827 | .offset = offsetof(CMS_PasswordRecipientInfo, keyEncryptionAlgorithm), | ||
828 | .field_name = "keyEncryptionAlgorithm", | ||
829 | .item = &X509_ALGOR_it, | ||
830 | }, | ||
831 | { | ||
832 | .flags = 0, | ||
833 | .tag = 0, | ||
834 | .offset = offsetof(CMS_PasswordRecipientInfo, encryptedKey), | ||
835 | .field_name = "encryptedKey", | ||
836 | .item = &ASN1_OCTET_STRING_it, | ||
837 | }, | ||
838 | }; | ||
839 | |||
840 | const ASN1_ITEM CMS_PasswordRecipientInfo_it = { | ||
841 | .itype = ASN1_ITYPE_SEQUENCE, | ||
842 | .utype = V_ASN1_SEQUENCE, | ||
843 | .templates = CMS_PasswordRecipientInfo_seq_tt, | ||
844 | .tcount = sizeof(CMS_PasswordRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
845 | .funcs = NULL, | ||
846 | .size = sizeof(CMS_PasswordRecipientInfo), | ||
847 | .sname = "CMS_PasswordRecipientInfo", | ||
848 | }; | ||
849 | |||
850 | static const ASN1_TEMPLATE CMS_OtherRecipientInfo_seq_tt[] = { | ||
851 | { | ||
852 | .flags = 0, | ||
853 | .tag = 0, | ||
854 | .offset = offsetof(CMS_OtherRecipientInfo, oriType), | ||
855 | .field_name = "oriType", | ||
856 | .item = &ASN1_OBJECT_it, | ||
857 | }, | ||
858 | { | ||
859 | .flags = ASN1_TFLG_OPTIONAL, | ||
860 | .tag = 0, | ||
861 | .offset = offsetof(CMS_OtherRecipientInfo, oriValue), | ||
862 | .field_name = "oriValue", | ||
863 | .item = &ASN1_ANY_it, | ||
864 | }, | ||
865 | }; | ||
866 | |||
867 | const ASN1_ITEM CMS_OtherRecipientInfo_it = { | ||
868 | .itype = ASN1_ITYPE_SEQUENCE, | ||
869 | .utype = V_ASN1_SEQUENCE, | ||
870 | .templates = CMS_OtherRecipientInfo_seq_tt, | ||
871 | .tcount = sizeof(CMS_OtherRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
872 | .funcs = NULL, | ||
873 | .size = sizeof(CMS_OtherRecipientInfo), | ||
874 | .sname = "CMS_OtherRecipientInfo", | ||
875 | }; | ||
212 | 876 | ||
213 | /* Free up RecipientInfo additional data */ | 877 | /* Free up RecipientInfo additional data */ |
214 | static int | 878 | static int |
@@ -238,66 +902,394 @@ cms_ri_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | |||
238 | return 1; | 902 | return 1; |
239 | } | 903 | } |
240 | 904 | ||
241 | ASN1_CHOICE_cb(CMS_RecipientInfo, cms_ri_cb) = { | 905 | static const ASN1_AUX CMS_RecipientInfo_aux = { |
242 | ASN1_SIMPLE(CMS_RecipientInfo, d.ktri, CMS_KeyTransRecipientInfo), | 906 | .app_data = NULL, |
243 | ASN1_IMP(CMS_RecipientInfo, d.kari, CMS_KeyAgreeRecipientInfo, 1), | 907 | .flags = 0, |
244 | ASN1_IMP(CMS_RecipientInfo, d.kekri, CMS_KEKRecipientInfo, 2), | 908 | .ref_offset = 0, |
245 | ASN1_IMP(CMS_RecipientInfo, d.pwri, CMS_PasswordRecipientInfo, 3), | 909 | .ref_lock = 0, |
246 | ASN1_IMP(CMS_RecipientInfo, d.ori, CMS_OtherRecipientInfo, 4) | 910 | .asn1_cb = cms_ri_cb, |
247 | } ASN1_CHOICE_END_cb(CMS_RecipientInfo, CMS_RecipientInfo, type) | 911 | .enc_offset = 0, |
248 | 912 | }; | |
249 | ASN1_NDEF_SEQUENCE(CMS_EnvelopedData) = { | 913 | static const ASN1_TEMPLATE CMS_RecipientInfo_ch_tt[] = { |
250 | ASN1_SIMPLE(CMS_EnvelopedData, version, LONG), | 914 | { |
251 | ASN1_IMP_OPT(CMS_EnvelopedData, originatorInfo, CMS_OriginatorInfo, 0), | 915 | .flags = 0, |
252 | ASN1_SET_OF(CMS_EnvelopedData, recipientInfos, CMS_RecipientInfo), | 916 | .tag = 0, |
253 | ASN1_SIMPLE(CMS_EnvelopedData, encryptedContentInfo, CMS_EncryptedContentInfo), | 917 | .offset = offsetof(CMS_RecipientInfo, d.ktri), |
254 | ASN1_IMP_SET_OF_OPT(CMS_EnvelopedData, unprotectedAttrs, X509_ATTRIBUTE, 1) | 918 | .field_name = "d.ktri", |
255 | } ASN1_NDEF_SEQUENCE_END(CMS_EnvelopedData) | 919 | .item = &CMS_KeyTransRecipientInfo_it, |
256 | 920 | }, | |
257 | ASN1_NDEF_SEQUENCE(CMS_DigestedData) = { | 921 | { |
258 | ASN1_SIMPLE(CMS_DigestedData, version, LONG), | 922 | .flags = ASN1_TFLG_IMPLICIT, |
259 | ASN1_SIMPLE(CMS_DigestedData, digestAlgorithm, X509_ALGOR), | 923 | .tag = 1, |
260 | ASN1_SIMPLE(CMS_DigestedData, encapContentInfo, CMS_EncapsulatedContentInfo), | 924 | .offset = offsetof(CMS_RecipientInfo, d.kari), |
261 | ASN1_SIMPLE(CMS_DigestedData, digest, ASN1_OCTET_STRING) | 925 | .field_name = "d.kari", |
262 | } ASN1_NDEF_SEQUENCE_END(CMS_DigestedData) | 926 | .item = &CMS_KeyAgreeRecipientInfo_it, |
263 | 927 | }, | |
264 | ASN1_NDEF_SEQUENCE(CMS_EncryptedData) = { | 928 | { |
265 | ASN1_SIMPLE(CMS_EncryptedData, version, LONG), | 929 | .flags = ASN1_TFLG_IMPLICIT, |
266 | ASN1_SIMPLE(CMS_EncryptedData, encryptedContentInfo, CMS_EncryptedContentInfo), | 930 | .tag = 2, |
267 | ASN1_IMP_SET_OF_OPT(CMS_EncryptedData, unprotectedAttrs, X509_ATTRIBUTE, 1) | 931 | .offset = offsetof(CMS_RecipientInfo, d.kekri), |
268 | } ASN1_NDEF_SEQUENCE_END(CMS_EncryptedData) | 932 | .field_name = "d.kekri", |
269 | 933 | .item = &CMS_KEKRecipientInfo_it, | |
270 | ASN1_NDEF_SEQUENCE(CMS_AuthenticatedData) = { | 934 | }, |
271 | ASN1_SIMPLE(CMS_AuthenticatedData, version, LONG), | 935 | { |
272 | ASN1_IMP_OPT(CMS_AuthenticatedData, originatorInfo, CMS_OriginatorInfo, 0), | 936 | .flags = ASN1_TFLG_IMPLICIT, |
273 | ASN1_SET_OF(CMS_AuthenticatedData, recipientInfos, CMS_RecipientInfo), | 937 | .tag = 3, |
274 | ASN1_SIMPLE(CMS_AuthenticatedData, macAlgorithm, X509_ALGOR), | 938 | .offset = offsetof(CMS_RecipientInfo, d.pwri), |
275 | ASN1_IMP(CMS_AuthenticatedData, digestAlgorithm, X509_ALGOR, 1), | 939 | .field_name = "d.pwri", |
276 | ASN1_SIMPLE(CMS_AuthenticatedData, encapContentInfo, CMS_EncapsulatedContentInfo), | 940 | .item = &CMS_PasswordRecipientInfo_it, |
277 | ASN1_IMP_SET_OF_OPT(CMS_AuthenticatedData, authAttrs, X509_ALGOR, 2), | 941 | }, |
278 | ASN1_SIMPLE(CMS_AuthenticatedData, mac, ASN1_OCTET_STRING), | 942 | { |
279 | ASN1_IMP_SET_OF_OPT(CMS_AuthenticatedData, unauthAttrs, X509_ALGOR, 3) | 943 | .flags = ASN1_TFLG_IMPLICIT, |
280 | } ASN1_NDEF_SEQUENCE_END(CMS_AuthenticatedData) | 944 | .tag = 4, |
281 | 945 | .offset = offsetof(CMS_RecipientInfo, d.ori), | |
282 | ASN1_NDEF_SEQUENCE(CMS_CompressedData) = { | 946 | .field_name = "d.ori", |
283 | ASN1_SIMPLE(CMS_CompressedData, version, LONG), | 947 | .item = &CMS_OtherRecipientInfo_it, |
284 | ASN1_SIMPLE(CMS_CompressedData, compressionAlgorithm, X509_ALGOR), | 948 | }, |
285 | ASN1_SIMPLE(CMS_CompressedData, encapContentInfo, CMS_EncapsulatedContentInfo), | 949 | }; |
286 | } ASN1_NDEF_SEQUENCE_END(CMS_CompressedData) | 950 | |
951 | const ASN1_ITEM CMS_RecipientInfo_it = { | ||
952 | .itype = ASN1_ITYPE_CHOICE, | ||
953 | .utype = offsetof(CMS_RecipientInfo, type), | ||
954 | .templates = CMS_RecipientInfo_ch_tt, | ||
955 | .tcount = sizeof(CMS_RecipientInfo_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
956 | .funcs = &CMS_RecipientInfo_aux, | ||
957 | .size = sizeof(CMS_RecipientInfo), | ||
958 | .sname = "CMS_RecipientInfo", | ||
959 | }; | ||
960 | |||
961 | static const ASN1_TEMPLATE CMS_EnvelopedData_seq_tt[] = { | ||
962 | { | ||
963 | .flags = 0, | ||
964 | .tag = 0, | ||
965 | .offset = offsetof(CMS_EnvelopedData, version), | ||
966 | .field_name = "version", | ||
967 | .item = &LONG_it, | ||
968 | }, | ||
969 | { | ||
970 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, | ||
971 | .tag = 0, | ||
972 | .offset = offsetof(CMS_EnvelopedData, originatorInfo), | ||
973 | .field_name = "originatorInfo", | ||
974 | .item = &CMS_OriginatorInfo_it, | ||
975 | }, | ||
976 | { | ||
977 | .flags = ASN1_TFLG_SET_OF, | ||
978 | .tag = 0, | ||
979 | .offset = offsetof(CMS_EnvelopedData, recipientInfos), | ||
980 | .field_name = "recipientInfos", | ||
981 | .item = &CMS_RecipientInfo_it, | ||
982 | }, | ||
983 | { | ||
984 | .flags = 0, | ||
985 | .tag = 0, | ||
986 | .offset = offsetof(CMS_EnvelopedData, encryptedContentInfo), | ||
987 | .field_name = "encryptedContentInfo", | ||
988 | .item = &CMS_EncryptedContentInfo_it, | ||
989 | }, | ||
990 | { | ||
991 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
992 | .tag = 1, | ||
993 | .offset = offsetof(CMS_EnvelopedData, unprotectedAttrs), | ||
994 | .field_name = "unprotectedAttrs", | ||
995 | .item = &X509_ATTRIBUTE_it, | ||
996 | }, | ||
997 | }; | ||
998 | |||
999 | const ASN1_ITEM CMS_EnvelopedData_it = { | ||
1000 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
1001 | .utype = V_ASN1_SEQUENCE, | ||
1002 | .templates = CMS_EnvelopedData_seq_tt, | ||
1003 | .tcount = sizeof(CMS_EnvelopedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
1004 | .funcs = NULL, | ||
1005 | .size = sizeof(CMS_EnvelopedData), | ||
1006 | .sname = "CMS_EnvelopedData", | ||
1007 | }; | ||
1008 | |||
1009 | static const ASN1_TEMPLATE CMS_DigestedData_seq_tt[] = { | ||
1010 | { | ||
1011 | .flags = 0, | ||
1012 | .tag = 0, | ||
1013 | .offset = offsetof(CMS_DigestedData, version), | ||
1014 | .field_name = "version", | ||
1015 | .item = &LONG_it, | ||
1016 | }, | ||
1017 | { | ||
1018 | .flags = 0, | ||
1019 | .tag = 0, | ||
1020 | .offset = offsetof(CMS_DigestedData, digestAlgorithm), | ||
1021 | .field_name = "digestAlgorithm", | ||
1022 | .item = &X509_ALGOR_it, | ||
1023 | }, | ||
1024 | { | ||
1025 | .flags = 0, | ||
1026 | .tag = 0, | ||
1027 | .offset = offsetof(CMS_DigestedData, encapContentInfo), | ||
1028 | .field_name = "encapContentInfo", | ||
1029 | .item = &CMS_EncapsulatedContentInfo_it, | ||
1030 | }, | ||
1031 | { | ||
1032 | .flags = 0, | ||
1033 | .tag = 0, | ||
1034 | .offset = offsetof(CMS_DigestedData, digest), | ||
1035 | .field_name = "digest", | ||
1036 | .item = &ASN1_OCTET_STRING_it, | ||
1037 | }, | ||
1038 | }; | ||
1039 | |||
1040 | const ASN1_ITEM CMS_DigestedData_it = { | ||
1041 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
1042 | .utype = V_ASN1_SEQUENCE, | ||
1043 | .templates = CMS_DigestedData_seq_tt, | ||
1044 | .tcount = sizeof(CMS_DigestedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
1045 | .funcs = NULL, | ||
1046 | .size = sizeof(CMS_DigestedData), | ||
1047 | .sname = "CMS_DigestedData", | ||
1048 | }; | ||
1049 | |||
1050 | static const ASN1_TEMPLATE CMS_EncryptedData_seq_tt[] = { | ||
1051 | { | ||
1052 | .flags = 0, | ||
1053 | .tag = 0, | ||
1054 | .offset = offsetof(CMS_EncryptedData, version), | ||
1055 | .field_name = "version", | ||
1056 | .item = &LONG_it, | ||
1057 | }, | ||
1058 | { | ||
1059 | .flags = 0, | ||
1060 | .tag = 0, | ||
1061 | .offset = offsetof(CMS_EncryptedData, encryptedContentInfo), | ||
1062 | .field_name = "encryptedContentInfo", | ||
1063 | .item = &CMS_EncryptedContentInfo_it, | ||
1064 | }, | ||
1065 | { | ||
1066 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
1067 | .tag = 1, | ||
1068 | .offset = offsetof(CMS_EncryptedData, unprotectedAttrs), | ||
1069 | .field_name = "unprotectedAttrs", | ||
1070 | .item = &X509_ATTRIBUTE_it, | ||
1071 | }, | ||
1072 | }; | ||
1073 | |||
1074 | const ASN1_ITEM CMS_EncryptedData_it = { | ||
1075 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
1076 | .utype = V_ASN1_SEQUENCE, | ||
1077 | .templates = CMS_EncryptedData_seq_tt, | ||
1078 | .tcount = sizeof(CMS_EncryptedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
1079 | .funcs = NULL, | ||
1080 | .size = sizeof(CMS_EncryptedData), | ||
1081 | .sname = "CMS_EncryptedData", | ||
1082 | }; | ||
1083 | |||
1084 | static const ASN1_TEMPLATE CMS_AuthenticatedData_seq_tt[] = { | ||
1085 | { | ||
1086 | .flags = 0, | ||
1087 | .tag = 0, | ||
1088 | .offset = offsetof(CMS_AuthenticatedData, version), | ||
1089 | .field_name = "version", | ||
1090 | .item = &LONG_it, | ||
1091 | }, | ||
1092 | { | ||
1093 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, | ||
1094 | .tag = 0, | ||
1095 | .offset = offsetof(CMS_AuthenticatedData, originatorInfo), | ||
1096 | .field_name = "originatorInfo", | ||
1097 | .item = &CMS_OriginatorInfo_it, | ||
1098 | }, | ||
1099 | { | ||
1100 | .flags = ASN1_TFLG_SET_OF, | ||
1101 | .tag = 0, | ||
1102 | .offset = offsetof(CMS_AuthenticatedData, recipientInfos), | ||
1103 | .field_name = "recipientInfos", | ||
1104 | .item = &CMS_RecipientInfo_it, | ||
1105 | }, | ||
1106 | { | ||
1107 | .flags = 0, | ||
1108 | .tag = 0, | ||
1109 | .offset = offsetof(CMS_AuthenticatedData, macAlgorithm), | ||
1110 | .field_name = "macAlgorithm", | ||
1111 | .item = &X509_ALGOR_it, | ||
1112 | }, | ||
1113 | { | ||
1114 | .flags = ASN1_TFLG_IMPLICIT, | ||
1115 | .tag = 1, | ||
1116 | .offset = offsetof(CMS_AuthenticatedData, digestAlgorithm), | ||
1117 | .field_name = "digestAlgorithm", | ||
1118 | .item = &X509_ALGOR_it, | ||
1119 | }, | ||
1120 | { | ||
1121 | .flags = 0, | ||
1122 | .tag = 0, | ||
1123 | .offset = offsetof(CMS_AuthenticatedData, encapContentInfo), | ||
1124 | .field_name = "encapContentInfo", | ||
1125 | .item = &CMS_EncapsulatedContentInfo_it, | ||
1126 | }, | ||
1127 | { | ||
1128 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
1129 | .tag = 2, | ||
1130 | .offset = offsetof(CMS_AuthenticatedData, authAttrs), | ||
1131 | .field_name = "authAttrs", | ||
1132 | .item = &X509_ALGOR_it, | ||
1133 | }, | ||
1134 | { | ||
1135 | .flags = 0, | ||
1136 | .tag = 0, | ||
1137 | .offset = offsetof(CMS_AuthenticatedData, mac), | ||
1138 | .field_name = "mac", | ||
1139 | .item = &ASN1_OCTET_STRING_it, | ||
1140 | }, | ||
1141 | { | ||
1142 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
1143 | .tag = 3, | ||
1144 | .offset = offsetof(CMS_AuthenticatedData, unauthAttrs), | ||
1145 | .field_name = "unauthAttrs", | ||
1146 | .item = &X509_ALGOR_it, | ||
1147 | }, | ||
1148 | }; | ||
1149 | |||
1150 | const ASN1_ITEM CMS_AuthenticatedData_it = { | ||
1151 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
1152 | .utype = V_ASN1_SEQUENCE, | ||
1153 | .templates = CMS_AuthenticatedData_seq_tt, | ||
1154 | .tcount = sizeof(CMS_AuthenticatedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
1155 | .funcs = NULL, | ||
1156 | .size = sizeof(CMS_AuthenticatedData), | ||
1157 | .sname = "CMS_AuthenticatedData", | ||
1158 | }; | ||
1159 | |||
1160 | static const ASN1_TEMPLATE CMS_CompressedData_seq_tt[] = { | ||
1161 | { | ||
1162 | .flags = 0, | ||
1163 | .tag = 0, | ||
1164 | .offset = offsetof(CMS_CompressedData, version), | ||
1165 | .field_name = "version", | ||
1166 | .item = &LONG_it, | ||
1167 | }, | ||
1168 | { | ||
1169 | .flags = 0, | ||
1170 | .tag = 0, | ||
1171 | .offset = offsetof(CMS_CompressedData, compressionAlgorithm), | ||
1172 | .field_name = "compressionAlgorithm", | ||
1173 | .item = &X509_ALGOR_it, | ||
1174 | }, | ||
1175 | { | ||
1176 | .flags = 0, | ||
1177 | .tag = 0, | ||
1178 | .offset = offsetof(CMS_CompressedData, encapContentInfo), | ||
1179 | .field_name = "encapContentInfo", | ||
1180 | .item = &CMS_EncapsulatedContentInfo_it, | ||
1181 | }, | ||
1182 | }; | ||
1183 | |||
1184 | const ASN1_ITEM CMS_CompressedData_it = { | ||
1185 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
1186 | .utype = V_ASN1_SEQUENCE, | ||
1187 | .templates = CMS_CompressedData_seq_tt, | ||
1188 | .tcount = sizeof(CMS_CompressedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
1189 | .funcs = NULL, | ||
1190 | .size = sizeof(CMS_CompressedData), | ||
1191 | .sname = "CMS_CompressedData", | ||
1192 | }; | ||
287 | 1193 | ||
288 | /* This is the ANY DEFINED BY table for the top level ContentInfo structure */ | 1194 | /* This is the ANY DEFINED BY table for the top level ContentInfo structure */ |
289 | 1195 | ||
290 | ASN1_ADB_TEMPLATE(cms_default) = ASN1_EXP(CMS_ContentInfo, d.other, ASN1_ANY, 0); | 1196 | static const ASN1_TEMPLATE cms_default_tt = { |
1197 | .flags = ASN1_TFLG_EXPLICIT, | ||
1198 | .tag = 0, | ||
1199 | .offset = offsetof(CMS_ContentInfo, d.other), | ||
1200 | .field_name = "d.other", | ||
1201 | .item = &ASN1_ANY_it, | ||
1202 | }; | ||
291 | 1203 | ||
292 | ASN1_ADB(CMS_ContentInfo) = { | 1204 | static const ASN1_ADB_TABLE CMS_ContentInfo_adbtbl[] = { |
293 | ADB_ENTRY(NID_pkcs7_data, ASN1_NDEF_EXP(CMS_ContentInfo, d.data, ASN1_OCTET_STRING_NDEF, 0)), | 1205 | { |
294 | ADB_ENTRY(NID_pkcs7_signed, ASN1_NDEF_EXP(CMS_ContentInfo, d.signedData, CMS_SignedData, 0)), | 1206 | .value = NID_pkcs7_data, |
295 | ADB_ENTRY(NID_pkcs7_enveloped, ASN1_NDEF_EXP(CMS_ContentInfo, d.envelopedData, CMS_EnvelopedData, 0)), | 1207 | .tt = { |
296 | ADB_ENTRY(NID_pkcs7_digest, ASN1_NDEF_EXP(CMS_ContentInfo, d.digestedData, CMS_DigestedData, 0)), | 1208 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, |
297 | ADB_ENTRY(NID_pkcs7_encrypted, ASN1_NDEF_EXP(CMS_ContentInfo, d.encryptedData, CMS_EncryptedData, 0)), | 1209 | .tag = 0, |
298 | ADB_ENTRY(NID_id_smime_ct_authData, ASN1_NDEF_EXP(CMS_ContentInfo, d.authenticatedData, CMS_AuthenticatedData, 0)), | 1210 | .offset = offsetof(CMS_ContentInfo, d.data), |
299 | ADB_ENTRY(NID_id_smime_ct_compressedData, ASN1_NDEF_EXP(CMS_ContentInfo, d.compressedData, CMS_CompressedData, 0)), | 1211 | .field_name = "d.data", |
300 | } ASN1_ADB_END(CMS_ContentInfo, 0, contentType, 0, &cms_default_tt, NULL); | 1212 | .item = &ASN1_OCTET_STRING_NDEF_it, |
1213 | }, | ||
1214 | |||
1215 | }, | ||
1216 | { | ||
1217 | .value = NID_pkcs7_signed, | ||
1218 | .tt = { | ||
1219 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
1220 | .tag = 0, | ||
1221 | .offset = offsetof(CMS_ContentInfo, d.signedData), | ||
1222 | .field_name = "d.signedData", | ||
1223 | .item = &CMS_SignedData_it, | ||
1224 | }, | ||
1225 | |||
1226 | }, | ||
1227 | { | ||
1228 | .value = NID_pkcs7_enveloped, | ||
1229 | .tt = { | ||
1230 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
1231 | .tag = 0, | ||
1232 | .offset = offsetof(CMS_ContentInfo, d.envelopedData), | ||
1233 | .field_name = "d.envelopedData", | ||
1234 | .item = &CMS_EnvelopedData_it, | ||
1235 | }, | ||
1236 | |||
1237 | }, | ||
1238 | { | ||
1239 | .value = NID_pkcs7_digest, | ||
1240 | .tt = { | ||
1241 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
1242 | .tag = 0, | ||
1243 | .offset = offsetof(CMS_ContentInfo, d.digestedData), | ||
1244 | .field_name = "d.digestedData", | ||
1245 | .item = &CMS_DigestedData_it, | ||
1246 | }, | ||
1247 | |||
1248 | }, | ||
1249 | { | ||
1250 | .value = NID_pkcs7_encrypted, | ||
1251 | .tt = { | ||
1252 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
1253 | .tag = 0, | ||
1254 | .offset = offsetof(CMS_ContentInfo, d.encryptedData), | ||
1255 | .field_name = "d.encryptedData", | ||
1256 | .item = &CMS_EncryptedData_it, | ||
1257 | }, | ||
1258 | |||
1259 | }, | ||
1260 | { | ||
1261 | .value = NID_id_smime_ct_authData, | ||
1262 | .tt = { | ||
1263 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
1264 | .tag = 0, | ||
1265 | .offset = offsetof(CMS_ContentInfo, d.authenticatedData), | ||
1266 | .field_name = "d.authenticatedData", | ||
1267 | .item = &CMS_AuthenticatedData_it, | ||
1268 | }, | ||
1269 | |||
1270 | }, | ||
1271 | { | ||
1272 | .value = NID_id_smime_ct_compressedData, | ||
1273 | .tt = { | ||
1274 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
1275 | .tag = 0, | ||
1276 | .offset = offsetof(CMS_ContentInfo, d.compressedData), | ||
1277 | .field_name = "d.compressedData", | ||
1278 | .item = &CMS_CompressedData_it, | ||
1279 | }, | ||
1280 | |||
1281 | }, | ||
1282 | }; | ||
1283 | |||
1284 | static const ASN1_ADB CMS_ContentInfo_adb = { | ||
1285 | .flags = 0, | ||
1286 | .offset = offsetof(CMS_ContentInfo, contentType), | ||
1287 | .app_items = 0, | ||
1288 | .tbl = CMS_ContentInfo_adbtbl, | ||
1289 | .tblcount = sizeof(CMS_ContentInfo_adbtbl) / sizeof(ASN1_ADB_TABLE), | ||
1290 | .default_tt = &cms_default_tt, | ||
1291 | .null_tt = NULL, | ||
1292 | }; | ||
301 | 1293 | ||
302 | /* CMS streaming support */ | 1294 | /* CMS streaming support */ |
303 | static int | 1295 | static int |
@@ -329,10 +1321,40 @@ cms_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | |||
329 | return 1; | 1321 | return 1; |
330 | } | 1322 | } |
331 | 1323 | ||
332 | ASN1_NDEF_SEQUENCE_cb(CMS_ContentInfo, cms_cb) = { | 1324 | static const ASN1_AUX CMS_ContentInfo_aux = { |
333 | ASN1_SIMPLE(CMS_ContentInfo, contentType, ASN1_OBJECT), | 1325 | .app_data = NULL, |
334 | ASN1_ADB_OBJECT(CMS_ContentInfo) | 1326 | .flags = 0, |
335 | } ASN1_NDEF_SEQUENCE_END_cb(CMS_ContentInfo, CMS_ContentInfo) | 1327 | .ref_offset = 0, |
1328 | .ref_lock = 0, | ||
1329 | .asn1_cb = cms_cb, | ||
1330 | .enc_offset = 0, | ||
1331 | }; | ||
1332 | static const ASN1_TEMPLATE CMS_ContentInfo_seq_tt[] = { | ||
1333 | { | ||
1334 | .flags = 0, | ||
1335 | .tag = 0, | ||
1336 | .offset = offsetof(CMS_ContentInfo, contentType), | ||
1337 | .field_name = "contentType", | ||
1338 | .item = &ASN1_OBJECT_it, | ||
1339 | }, | ||
1340 | { | ||
1341 | .flags = ASN1_TFLG_ADB_OID, | ||
1342 | .tag = -1, | ||
1343 | .offset = 0, | ||
1344 | .field_name = "CMS_ContentInfo", | ||
1345 | .item = (const ASN1_ITEM *)&CMS_ContentInfo_adb, | ||
1346 | }, | ||
1347 | }; | ||
1348 | |||
1349 | const ASN1_ITEM CMS_ContentInfo_it = { | ||
1350 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
1351 | .utype = V_ASN1_SEQUENCE, | ||
1352 | .templates = CMS_ContentInfo_seq_tt, | ||
1353 | .tcount = sizeof(CMS_ContentInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
1354 | .funcs = &CMS_ContentInfo_aux, | ||
1355 | .size = sizeof(CMS_ContentInfo), | ||
1356 | .sname = "CMS_ContentInfo", | ||
1357 | }; | ||
336 | 1358 | ||
337 | /* Specials for signed attributes */ | 1359 | /* Specials for signed attributes */ |
338 | 1360 | ||
@@ -340,33 +1362,144 @@ ASN1_NDEF_SEQUENCE_cb(CMS_ContentInfo, cms_cb) = { | |||
340 | * encoding. | 1362 | * encoding. |
341 | */ | 1363 | */ |
342 | 1364 | ||
343 | ASN1_ITEM_TEMPLATE(CMS_Attributes_Sign) = | 1365 | static const ASN1_TEMPLATE CMS_Attributes_Sign_item_tt = { |
344 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SET_ORDER, 0, CMS_ATTRIBUTES, X509_ATTRIBUTE) | 1366 | .flags = ASN1_TFLG_SET_ORDER, |
345 | ASN1_ITEM_TEMPLATE_END(CMS_Attributes_Sign) | 1367 | .tag = 0, |
1368 | .offset = 0, | ||
1369 | .field_name = "CMS_ATTRIBUTES", | ||
1370 | .item = &X509_ATTRIBUTE_it, | ||
1371 | }; | ||
1372 | |||
1373 | const ASN1_ITEM CMS_Attributes_Sign_it = { | ||
1374 | .itype = ASN1_ITYPE_PRIMITIVE, | ||
1375 | .utype = -1, | ||
1376 | .templates = &CMS_Attributes_Sign_item_tt, | ||
1377 | .tcount = 0, | ||
1378 | .funcs = NULL, | ||
1379 | .size = 0, | ||
1380 | .sname = "CMS_Attributes_Sign", | ||
1381 | }; | ||
346 | 1382 | ||
347 | /* When verifying attributes we need to use the received order. So | 1383 | /* When verifying attributes we need to use the received order. So |
348 | * we use SEQUENCE OF and tag it to SET OF | 1384 | * we use SEQUENCE OF and tag it to SET OF |
349 | */ | 1385 | */ |
350 | 1386 | ||
351 | ASN1_ITEM_TEMPLATE(CMS_Attributes_Verify) = | 1387 | static const ASN1_TEMPLATE CMS_Attributes_Verify_item_tt = { |
352 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_IMPTAG | ASN1_TFLG_UNIVERSAL, | 1388 | .flags = ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_IMPTAG | ASN1_TFLG_UNIVERSAL, |
353 | V_ASN1_SET, CMS_ATTRIBUTES, X509_ATTRIBUTE) | 1389 | .tag = V_ASN1_SET, |
354 | ASN1_ITEM_TEMPLATE_END(CMS_Attributes_Verify) | 1390 | .offset = 0, |
355 | 1391 | .field_name = "CMS_ATTRIBUTES", | |
356 | ASN1_CHOICE(CMS_ReceiptsFrom) = { | 1392 | .item = &X509_ATTRIBUTE_it, |
357 | ASN1_IMP(CMS_ReceiptsFrom, d.allOrFirstTier, LONG, 0), | 1393 | }; |
358 | ASN1_IMP_SEQUENCE_OF(CMS_ReceiptsFrom, d.receiptList, GENERAL_NAMES, 1) | 1394 | |
359 | } ASN1_CHOICE_END(CMS_ReceiptsFrom) | 1395 | const ASN1_ITEM CMS_Attributes_Verify_it = { |
360 | 1396 | .itype = ASN1_ITYPE_PRIMITIVE, | |
361 | ASN1_SEQUENCE(CMS_ReceiptRequest) = { | 1397 | .utype = -1, |
362 | ASN1_SIMPLE(CMS_ReceiptRequest, signedContentIdentifier, ASN1_OCTET_STRING), | 1398 | .templates = &CMS_Attributes_Verify_item_tt, |
363 | ASN1_SIMPLE(CMS_ReceiptRequest, receiptsFrom, CMS_ReceiptsFrom), | 1399 | .tcount = 0, |
364 | ASN1_SEQUENCE_OF(CMS_ReceiptRequest, receiptsTo, GENERAL_NAMES) | 1400 | .funcs = NULL, |
365 | } ASN1_SEQUENCE_END(CMS_ReceiptRequest) | 1401 | .size = 0, |
366 | 1402 | .sname = "CMS_Attributes_Verify", | |
367 | ASN1_SEQUENCE(CMS_Receipt) = { | 1403 | }; |
368 | ASN1_SIMPLE(CMS_Receipt, version, LONG), | 1404 | |
369 | ASN1_SIMPLE(CMS_Receipt, contentType, ASN1_OBJECT), | 1405 | static const ASN1_TEMPLATE CMS_ReceiptsFrom_ch_tt[] = { |
370 | ASN1_SIMPLE(CMS_Receipt, signedContentIdentifier, ASN1_OCTET_STRING), | 1406 | { |
371 | ASN1_SIMPLE(CMS_Receipt, originatorSignatureValue, ASN1_OCTET_STRING) | 1407 | .flags = ASN1_TFLG_IMPLICIT, |
372 | } ASN1_SEQUENCE_END(CMS_Receipt) | 1408 | .tag = 0, |
1409 | .offset = offsetof(CMS_ReceiptsFrom, d.allOrFirstTier), | ||
1410 | .field_name = "d.allOrFirstTier", | ||
1411 | .item = &LONG_it, | ||
1412 | }, | ||
1413 | { | ||
1414 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SEQUENCE_OF, | ||
1415 | .tag = 1, | ||
1416 | .offset = offsetof(CMS_ReceiptsFrom, d.receiptList), | ||
1417 | .field_name = "d.receiptList", | ||
1418 | .item = &GENERAL_NAMES_it, | ||
1419 | }, | ||
1420 | }; | ||
1421 | |||
1422 | const ASN1_ITEM CMS_ReceiptsFrom_it = { | ||
1423 | .itype = ASN1_ITYPE_CHOICE, | ||
1424 | .utype = offsetof(CMS_ReceiptsFrom, type), | ||
1425 | .templates = CMS_ReceiptsFrom_ch_tt, | ||
1426 | .tcount = sizeof(CMS_ReceiptsFrom_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
1427 | .funcs = NULL, | ||
1428 | .size = sizeof(CMS_ReceiptsFrom), | ||
1429 | .sname = "CMS_ReceiptsFrom", | ||
1430 | }; | ||
1431 | |||
1432 | static const ASN1_TEMPLATE CMS_ReceiptRequest_seq_tt[] = { | ||
1433 | { | ||
1434 | .flags = 0, | ||
1435 | .tag = 0, | ||
1436 | .offset = offsetof(CMS_ReceiptRequest, signedContentIdentifier), | ||
1437 | .field_name = "signedContentIdentifier", | ||
1438 | .item = &ASN1_OCTET_STRING_it, | ||
1439 | }, | ||
1440 | { | ||
1441 | .flags = 0, | ||
1442 | .tag = 0, | ||
1443 | .offset = offsetof(CMS_ReceiptRequest, receiptsFrom), | ||
1444 | .field_name = "receiptsFrom", | ||
1445 | .item = &CMS_ReceiptsFrom_it, | ||
1446 | }, | ||
1447 | { | ||
1448 | .flags = ASN1_TFLG_SEQUENCE_OF, | ||
1449 | .tag = 0, | ||
1450 | .offset = offsetof(CMS_ReceiptRequest, receiptsTo), | ||
1451 | .field_name = "receiptsTo", | ||
1452 | .item = &GENERAL_NAMES_it, | ||
1453 | }, | ||
1454 | }; | ||
1455 | |||
1456 | const ASN1_ITEM CMS_ReceiptRequest_it = { | ||
1457 | .itype = ASN1_ITYPE_SEQUENCE, | ||
1458 | .utype = V_ASN1_SEQUENCE, | ||
1459 | .templates = CMS_ReceiptRequest_seq_tt, | ||
1460 | .tcount = sizeof(CMS_ReceiptRequest_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
1461 | .funcs = NULL, | ||
1462 | .size = sizeof(CMS_ReceiptRequest), | ||
1463 | .sname = "CMS_ReceiptRequest", | ||
1464 | }; | ||
1465 | |||
1466 | static const ASN1_TEMPLATE CMS_Receipt_seq_tt[] = { | ||
1467 | { | ||
1468 | .flags = 0, | ||
1469 | .tag = 0, | ||
1470 | .offset = offsetof(CMS_Receipt, version), | ||
1471 | .field_name = "version", | ||
1472 | .item = &LONG_it, | ||
1473 | }, | ||
1474 | { | ||
1475 | .flags = 0, | ||
1476 | .tag = 0, | ||
1477 | .offset = offsetof(CMS_Receipt, contentType), | ||
1478 | .field_name = "contentType", | ||
1479 | .item = &ASN1_OBJECT_it, | ||
1480 | }, | ||
1481 | { | ||
1482 | .flags = 0, | ||
1483 | .tag = 0, | ||
1484 | .offset = offsetof(CMS_Receipt, signedContentIdentifier), | ||
1485 | .field_name = "signedContentIdentifier", | ||
1486 | .item = &ASN1_OCTET_STRING_it, | ||
1487 | }, | ||
1488 | { | ||
1489 | .flags = 0, | ||
1490 | .tag = 0, | ||
1491 | .offset = offsetof(CMS_Receipt, originatorSignatureValue), | ||
1492 | .field_name = "originatorSignatureValue", | ||
1493 | .item = &ASN1_OCTET_STRING_it, | ||
1494 | }, | ||
1495 | }; | ||
1496 | |||
1497 | const ASN1_ITEM CMS_Receipt_it = { | ||
1498 | .itype = ASN1_ITYPE_SEQUENCE, | ||
1499 | .utype = V_ASN1_SEQUENCE, | ||
1500 | .templates = CMS_Receipt_seq_tt, | ||
1501 | .tcount = sizeof(CMS_Receipt_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
1502 | .funcs = NULL, | ||
1503 | .size = sizeof(CMS_Receipt), | ||
1504 | .sname = "CMS_Receipt", | ||
1505 | }; | ||