diff options
Diffstat (limited to 'src/lib/libcrypto/cms/cms_asn1.c')
| -rw-r--r-- | src/lib/libcrypto/cms/cms_asn1.c | 1503 |
1 files changed, 0 insertions, 1503 deletions
diff --git a/src/lib/libcrypto/cms/cms_asn1.c b/src/lib/libcrypto/cms/cms_asn1.c deleted file mode 100644 index 42e33d5b46..0000000000 --- a/src/lib/libcrypto/cms/cms_asn1.c +++ /dev/null | |||
| @@ -1,1503 +0,0 @@ | |||
| 1 | /* $OpenBSD: cms_asn1.c,v 1.8 2016/03/11 07:08:44 mmcc Exp $ */ | ||
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | ||
| 3 | * project. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 2008 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | */ | ||
| 53 | |||
| 54 | #include <openssl/asn1t.h> | ||
| 55 | #include <openssl/pem.h> | ||
| 56 | #include <openssl/x509v3.h> | ||
| 57 | #include "cms.h" | ||
| 58 | #include "cms_lcl.h" | ||
| 59 | |||
| 60 | static const ASN1_TEMPLATE CMS_IssuerAndSerialNumber_seq_tt[] = { | ||
| 61 | { | ||
| 62 | .flags = 0, | ||
| 63 | .tag = 0, | ||
| 64 | .offset = offsetof(CMS_IssuerAndSerialNumber, issuer), | ||
| 65 | .field_name = "issuer", | ||
| 66 | .item = &X509_NAME_it, | ||
| 67 | }, | ||
| 68 | { | ||
| 69 | .flags = 0, | ||
| 70 | .tag = 0, | ||
| 71 | .offset = offsetof(CMS_IssuerAndSerialNumber, serialNumber), | ||
| 72 | .field_name = "serialNumber", | ||
| 73 | .item = &ASN1_INTEGER_it, | ||
| 74 | }, | ||
| 75 | }; | ||
| 76 | |||
| 77 | const ASN1_ITEM CMS_IssuerAndSerialNumber_it = { | ||
| 78 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 79 | .utype = V_ASN1_SEQUENCE, | ||
| 80 | .templates = CMS_IssuerAndSerialNumber_seq_tt, | ||
| 81 | .tcount = sizeof(CMS_IssuerAndSerialNumber_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 82 | .funcs = NULL, | ||
| 83 | .size = sizeof(CMS_IssuerAndSerialNumber), | ||
| 84 | .sname = "CMS_IssuerAndSerialNumber", | ||
| 85 | }; | ||
| 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 | }; | ||
| 215 | |||
| 216 | /* Minor tweak to operation: free up signer key, cert */ | ||
| 217 | static int | ||
| 218 | cms_si_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | ||
| 219 | { | ||
| 220 | if (operation == ASN1_OP_FREE_POST) { | ||
| 221 | CMS_SignerInfo *si = (CMS_SignerInfo *)*pval; | ||
| 222 | EVP_PKEY_free(si->pkey); | ||
| 223 | X509_free(si->signer); | ||
| 224 | } | ||
| 225 | return 1; | ||
| 226 | } | ||
| 227 | |||
| 228 | static const ASN1_AUX CMS_SignerInfo_aux = { | ||
| 229 | .app_data = NULL, | ||
| 230 | .flags = 0, | ||
| 231 | .ref_offset = 0, | ||
| 232 | .ref_lock = 0, | ||
| 233 | .asn1_cb = cms_si_cb, | ||
| 234 | .enc_offset = 0, | ||
| 235 | }; | ||
| 236 | static const ASN1_TEMPLATE CMS_SignerInfo_seq_tt[] = { | ||
| 237 | { | ||
| 238 | .flags = 0, | ||
| 239 | .tag = 0, | ||
| 240 | .offset = offsetof(CMS_SignerInfo, version), | ||
| 241 | .field_name = "version", | ||
| 242 | .item = &LONG_it, | ||
| 243 | }, | ||
| 244 | { | ||
| 245 | .flags = 0, | ||
| 246 | .tag = 0, | ||
| 247 | .offset = offsetof(CMS_SignerInfo, sid), | ||
| 248 | .field_name = "sid", | ||
| 249 | .item = &CMS_SignerIdentifier_it, | ||
| 250 | }, | ||
| 251 | { | ||
| 252 | .flags = 0, | ||
| 253 | .tag = 0, | ||
| 254 | .offset = offsetof(CMS_SignerInfo, digestAlgorithm), | ||
| 255 | .field_name = "digestAlgorithm", | ||
| 256 | .item = &X509_ALGOR_it, | ||
| 257 | }, | ||
| 258 | { | ||
| 259 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
| 260 | .tag = 0, | ||
| 261 | .offset = offsetof(CMS_SignerInfo, signedAttrs), | ||
| 262 | .field_name = "signedAttrs", | ||
| 263 | .item = &X509_ATTRIBUTE_it, | ||
| 264 | }, | ||
| 265 | { | ||
| 266 | .flags = 0, | ||
| 267 | .tag = 0, | ||
| 268 | .offset = offsetof(CMS_SignerInfo, signatureAlgorithm), | ||
| 269 | .field_name = "signatureAlgorithm", | ||
| 270 | .item = &X509_ALGOR_it, | ||
| 271 | }, | ||
| 272 | { | ||
| 273 | .flags = 0, | ||
| 274 | .tag = 0, | ||
| 275 | .offset = offsetof(CMS_SignerInfo, signature), | ||
| 276 | .field_name = "signature", | ||
| 277 | .item = &ASN1_OCTET_STRING_it, | ||
| 278 | }, | ||
| 279 | { | ||
| 280 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
| 281 | .tag = 1, | ||
| 282 | .offset = offsetof(CMS_SignerInfo, unsignedAttrs), | ||
| 283 | .field_name = "unsignedAttrs", | ||
| 284 | .item = &X509_ATTRIBUTE_it, | ||
| 285 | }, | ||
| 286 | }; | ||
| 287 | |||
| 288 | const ASN1_ITEM CMS_SignerInfo_it = { | ||
| 289 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 290 | .utype = V_ASN1_SEQUENCE, | ||
| 291 | .templates = CMS_SignerInfo_seq_tt, | ||
| 292 | .tcount = sizeof(CMS_SignerInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 293 | .funcs = &CMS_SignerInfo_aux, | ||
| 294 | .size = sizeof(CMS_SignerInfo), | ||
| 295 | .sname = "CMS_SignerInfo", | ||
| 296 | }; | ||
| 297 | |||
| 298 | static const ASN1_TEMPLATE CMS_OtherRevocationInfoFormat_seq_tt[] = { | ||
| 299 | { | ||
| 300 | .flags = 0, | ||
| 301 | .tag = 0, | ||
| 302 | .offset = offsetof(CMS_OtherRevocationInfoFormat, otherRevInfoFormat), | ||
| 303 | .field_name = "otherRevInfoFormat", | ||
| 304 | .item = &ASN1_OBJECT_it, | ||
| 305 | }, | ||
| 306 | { | ||
| 307 | .flags = ASN1_TFLG_OPTIONAL, | ||
| 308 | .tag = 0, | ||
| 309 | .offset = offsetof(CMS_OtherRevocationInfoFormat, otherRevInfo), | ||
| 310 | .field_name = "otherRevInfo", | ||
| 311 | .item = &ASN1_ANY_it, | ||
| 312 | }, | ||
| 313 | }; | ||
| 314 | |||
| 315 | const ASN1_ITEM CMS_OtherRevocationInfoFormat_it = { | ||
| 316 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 317 | .utype = V_ASN1_SEQUENCE, | ||
| 318 | .templates = CMS_OtherRevocationInfoFormat_seq_tt, | ||
| 319 | .tcount = sizeof(CMS_OtherRevocationInfoFormat_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 320 | .funcs = NULL, | ||
| 321 | .size = sizeof(CMS_OtherRevocationInfoFormat), | ||
| 322 | .sname = "CMS_OtherRevocationInfoFormat", | ||
| 323 | }; | ||
| 324 | |||
| 325 | static const ASN1_TEMPLATE CMS_RevocationInfoChoice_ch_tt[] = { | ||
| 326 | { | ||
| 327 | .flags = 0, | ||
| 328 | .tag = 0, | ||
| 329 | .offset = offsetof(CMS_RevocationInfoChoice, d.crl), | ||
| 330 | .field_name = "d.crl", | ||
| 331 | .item = &X509_CRL_it, | ||
| 332 | }, | ||
| 333 | { | ||
| 334 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 335 | .tag = 1, | ||
| 336 | .offset = offsetof(CMS_RevocationInfoChoice, d.other), | ||
| 337 | .field_name = "d.other", | ||
| 338 | .item = &CMS_OtherRevocationInfoFormat_it, | ||
| 339 | }, | ||
| 340 | }; | ||
| 341 | |||
| 342 | const ASN1_ITEM CMS_RevocationInfoChoice_it = { | ||
| 343 | .itype = ASN1_ITYPE_CHOICE, | ||
| 344 | .utype = offsetof(CMS_RevocationInfoChoice, type), | ||
| 345 | .templates = CMS_RevocationInfoChoice_ch_tt, | ||
| 346 | .tcount = sizeof(CMS_RevocationInfoChoice_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
| 347 | .funcs = NULL, | ||
| 348 | .size = sizeof(CMS_RevocationInfoChoice), | ||
| 349 | .sname = "CMS_RevocationInfoChoice", | ||
| 350 | }; | ||
| 351 | |||
| 352 | static const ASN1_TEMPLATE CMS_SignedData_seq_tt[] = { | ||
| 353 | { | ||
| 354 | .flags = 0, | ||
| 355 | .tag = 0, | ||
| 356 | .offset = offsetof(CMS_SignedData, version), | ||
| 357 | .field_name = "version", | ||
| 358 | .item = &LONG_it, | ||
| 359 | }, | ||
| 360 | { | ||
| 361 | .flags = ASN1_TFLG_SET_OF, | ||
| 362 | .tag = 0, | ||
| 363 | .offset = offsetof(CMS_SignedData, digestAlgorithms), | ||
| 364 | .field_name = "digestAlgorithms", | ||
| 365 | .item = &X509_ALGOR_it, | ||
| 366 | }, | ||
| 367 | { | ||
| 368 | .flags = 0, | ||
| 369 | .tag = 0, | ||
| 370 | .offset = offsetof(CMS_SignedData, encapContentInfo), | ||
| 371 | .field_name = "encapContentInfo", | ||
| 372 | .item = &CMS_EncapsulatedContentInfo_it, | ||
| 373 | }, | ||
| 374 | { | ||
| 375 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
| 376 | .tag = 0, | ||
| 377 | .offset = offsetof(CMS_SignedData, certificates), | ||
| 378 | .field_name = "certificates", | ||
| 379 | .item = &CMS_CertificateChoices_it, | ||
| 380 | }, | ||
| 381 | { | ||
| 382 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
| 383 | .tag = 1, | ||
| 384 | .offset = offsetof(CMS_SignedData, crls), | ||
| 385 | .field_name = "crls", | ||
| 386 | .item = &CMS_RevocationInfoChoice_it, | ||
| 387 | }, | ||
| 388 | { | ||
| 389 | .flags = ASN1_TFLG_SET_OF, | ||
| 390 | .tag = 0, | ||
| 391 | .offset = offsetof(CMS_SignedData, signerInfos), | ||
| 392 | .field_name = "signerInfos", | ||
| 393 | .item = &CMS_SignerInfo_it, | ||
| 394 | }, | ||
| 395 | }; | ||
| 396 | |||
| 397 | const ASN1_ITEM CMS_SignedData_it = { | ||
| 398 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
| 399 | .utype = V_ASN1_SEQUENCE, | ||
| 400 | .templates = CMS_SignedData_seq_tt, | ||
| 401 | .tcount = sizeof(CMS_SignedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 402 | .funcs = NULL, | ||
| 403 | .size = sizeof(CMS_SignedData), | ||
| 404 | .sname = "CMS_SignedData", | ||
| 405 | }; | ||
| 406 | |||
| 407 | static const ASN1_TEMPLATE CMS_OriginatorInfo_seq_tt[] = { | ||
| 408 | { | ||
| 409 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
| 410 | .tag = 0, | ||
| 411 | .offset = offsetof(CMS_OriginatorInfo, certificates), | ||
| 412 | .field_name = "certificates", | ||
| 413 | .item = &CMS_CertificateChoices_it, | ||
| 414 | }, | ||
| 415 | { | ||
| 416 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
| 417 | .tag = 1, | ||
| 418 | .offset = offsetof(CMS_OriginatorInfo, crls), | ||
| 419 | .field_name = "crls", | ||
| 420 | .item = &CMS_RevocationInfoChoice_it, | ||
| 421 | }, | ||
| 422 | }; | ||
| 423 | |||
| 424 | const ASN1_ITEM CMS_OriginatorInfo_it = { | ||
| 425 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 426 | .utype = V_ASN1_SEQUENCE, | ||
| 427 | .templates = CMS_OriginatorInfo_seq_tt, | ||
| 428 | .tcount = sizeof(CMS_OriginatorInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 429 | .funcs = NULL, | ||
| 430 | .size = sizeof(CMS_OriginatorInfo), | ||
| 431 | .sname = "CMS_OriginatorInfo", | ||
| 432 | }; | ||
| 433 | |||
| 434 | static const ASN1_TEMPLATE CMS_EncryptedContentInfo_seq_tt[] = { | ||
| 435 | { | ||
| 436 | .flags = 0, | ||
| 437 | .tag = 0, | ||
| 438 | .offset = offsetof(CMS_EncryptedContentInfo, contentType), | ||
| 439 | .field_name = "contentType", | ||
| 440 | .item = &ASN1_OBJECT_it, | ||
| 441 | }, | ||
| 442 | { | ||
| 443 | .flags = 0, | ||
| 444 | .tag = 0, | ||
| 445 | .offset = offsetof(CMS_EncryptedContentInfo, contentEncryptionAlgorithm), | ||
| 446 | .field_name = "contentEncryptionAlgorithm", | ||
| 447 | .item = &X509_ALGOR_it, | ||
| 448 | }, | ||
| 449 | { | ||
| 450 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, | ||
| 451 | .tag = 0, | ||
| 452 | .offset = offsetof(CMS_EncryptedContentInfo, encryptedContent), | ||
| 453 | .field_name = "encryptedContent", | ||
| 454 | .item = &ASN1_OCTET_STRING_NDEF_it, | ||
| 455 | }, | ||
| 456 | }; | ||
| 457 | |||
| 458 | const ASN1_ITEM CMS_EncryptedContentInfo_it = { | ||
| 459 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
| 460 | .utype = V_ASN1_SEQUENCE, | ||
| 461 | .templates = CMS_EncryptedContentInfo_seq_tt, | ||
| 462 | .tcount = sizeof(CMS_EncryptedContentInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 463 | .funcs = NULL, | ||
| 464 | .size = sizeof(CMS_EncryptedContentInfo), | ||
| 465 | .sname = "CMS_EncryptedContentInfo", | ||
| 466 | }; | ||
| 467 | |||
| 468 | static const ASN1_TEMPLATE CMS_KeyTransRecipientInfo_seq_tt[] = { | ||
| 469 | { | ||
| 470 | .flags = 0, | ||
| 471 | .tag = 0, | ||
| 472 | .offset = offsetof(CMS_KeyTransRecipientInfo, version), | ||
| 473 | .field_name = "version", | ||
| 474 | .item = &LONG_it, | ||
| 475 | }, | ||
| 476 | { | ||
| 477 | .flags = 0, | ||
| 478 | .tag = 0, | ||
| 479 | .offset = offsetof(CMS_KeyTransRecipientInfo, rid), | ||
| 480 | .field_name = "rid", | ||
| 481 | .item = &CMS_SignerIdentifier_it, | ||
| 482 | }, | ||
| 483 | { | ||
| 484 | .flags = 0, | ||
| 485 | .tag = 0, | ||
| 486 | .offset = offsetof(CMS_KeyTransRecipientInfo, keyEncryptionAlgorithm), | ||
| 487 | .field_name = "keyEncryptionAlgorithm", | ||
| 488 | .item = &X509_ALGOR_it, | ||
| 489 | }, | ||
| 490 | { | ||
| 491 | .flags = 0, | ||
| 492 | .tag = 0, | ||
| 493 | .offset = offsetof(CMS_KeyTransRecipientInfo, encryptedKey), | ||
| 494 | .field_name = "encryptedKey", | ||
| 495 | .item = &ASN1_OCTET_STRING_it, | ||
| 496 | }, | ||
| 497 | }; | ||
| 498 | |||
| 499 | const ASN1_ITEM CMS_KeyTransRecipientInfo_it = { | ||
| 500 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 501 | .utype = V_ASN1_SEQUENCE, | ||
| 502 | .templates = CMS_KeyTransRecipientInfo_seq_tt, | ||
| 503 | .tcount = sizeof(CMS_KeyTransRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 504 | .funcs = NULL, | ||
| 505 | .size = sizeof(CMS_KeyTransRecipientInfo), | ||
| 506 | .sname = "CMS_KeyTransRecipientInfo", | ||
| 507 | }; | ||
| 508 | |||
| 509 | static const ASN1_TEMPLATE CMS_OtherKeyAttribute_seq_tt[] = { | ||
| 510 | { | ||
| 511 | .flags = 0, | ||
| 512 | .tag = 0, | ||
| 513 | .offset = offsetof(CMS_OtherKeyAttribute, keyAttrId), | ||
| 514 | .field_name = "keyAttrId", | ||
| 515 | .item = &ASN1_OBJECT_it, | ||
| 516 | }, | ||
| 517 | { | ||
| 518 | .flags = ASN1_TFLG_OPTIONAL, | ||
| 519 | .tag = 0, | ||
| 520 | .offset = offsetof(CMS_OtherKeyAttribute, keyAttr), | ||
| 521 | .field_name = "keyAttr", | ||
| 522 | .item = &ASN1_ANY_it, | ||
| 523 | }, | ||
| 524 | }; | ||
| 525 | |||
| 526 | const ASN1_ITEM CMS_OtherKeyAttribute_it = { | ||
| 527 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 528 | .utype = V_ASN1_SEQUENCE, | ||
| 529 | .templates = CMS_OtherKeyAttribute_seq_tt, | ||
| 530 | .tcount = sizeof(CMS_OtherKeyAttribute_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 531 | .funcs = NULL, | ||
| 532 | .size = sizeof(CMS_OtherKeyAttribute), | ||
| 533 | .sname = "CMS_OtherKeyAttribute", | ||
| 534 | }; | ||
| 535 | |||
| 536 | static const ASN1_TEMPLATE CMS_RecipientKeyIdentifier_seq_tt[] = { | ||
| 537 | { | ||
| 538 | .flags = 0, | ||
| 539 | .tag = 0, | ||
| 540 | .offset = offsetof(CMS_RecipientKeyIdentifier, subjectKeyIdentifier), | ||
| 541 | .field_name = "subjectKeyIdentifier", | ||
| 542 | .item = &ASN1_OCTET_STRING_it, | ||
| 543 | }, | ||
| 544 | { | ||
| 545 | .flags = ASN1_TFLG_OPTIONAL, | ||
| 546 | .tag = 0, | ||
| 547 | .offset = offsetof(CMS_RecipientKeyIdentifier, date), | ||
| 548 | .field_name = "date", | ||
| 549 | .item = &ASN1_GENERALIZEDTIME_it, | ||
| 550 | }, | ||
| 551 | { | ||
| 552 | .flags = ASN1_TFLG_OPTIONAL, | ||
| 553 | .tag = 0, | ||
| 554 | .offset = offsetof(CMS_RecipientKeyIdentifier, other), | ||
| 555 | .field_name = "other", | ||
| 556 | .item = &CMS_OtherKeyAttribute_it, | ||
| 557 | }, | ||
| 558 | }; | ||
| 559 | |||
| 560 | const ASN1_ITEM CMS_RecipientKeyIdentifier_it = { | ||
| 561 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 562 | .utype = V_ASN1_SEQUENCE, | ||
| 563 | .templates = CMS_RecipientKeyIdentifier_seq_tt, | ||
| 564 | .tcount = sizeof(CMS_RecipientKeyIdentifier_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 565 | .funcs = NULL, | ||
| 566 | .size = sizeof(CMS_RecipientKeyIdentifier), | ||
| 567 | .sname = "CMS_RecipientKeyIdentifier", | ||
| 568 | }; | ||
| 569 | |||
| 570 | static const ASN1_TEMPLATE CMS_KeyAgreeRecipientIdentifier_ch_tt[] = { | ||
| 571 | { | ||
| 572 | .flags = 0, | ||
| 573 | .tag = 0, | ||
| 574 | .offset = offsetof(CMS_KeyAgreeRecipientIdentifier, d.issuerAndSerialNumber), | ||
| 575 | .field_name = "d.issuerAndSerialNumber", | ||
| 576 | .item = &CMS_IssuerAndSerialNumber_it, | ||
| 577 | }, | ||
| 578 | { | ||
| 579 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 580 | .tag = 0, | ||
| 581 | .offset = offsetof(CMS_KeyAgreeRecipientIdentifier, d.rKeyId), | ||
| 582 | .field_name = "d.rKeyId", | ||
| 583 | .item = &CMS_RecipientKeyIdentifier_it, | ||
| 584 | }, | ||
| 585 | }; | ||
| 586 | |||
| 587 | const ASN1_ITEM CMS_KeyAgreeRecipientIdentifier_it = { | ||
| 588 | .itype = ASN1_ITYPE_CHOICE, | ||
| 589 | .utype = offsetof(CMS_KeyAgreeRecipientIdentifier, type), | ||
| 590 | .templates = CMS_KeyAgreeRecipientIdentifier_ch_tt, | ||
| 591 | .tcount = sizeof(CMS_KeyAgreeRecipientIdentifier_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
| 592 | .funcs = NULL, | ||
| 593 | .size = sizeof(CMS_KeyAgreeRecipientIdentifier), | ||
| 594 | .sname = "CMS_KeyAgreeRecipientIdentifier", | ||
| 595 | }; | ||
| 596 | |||
| 597 | static const ASN1_TEMPLATE CMS_RecipientEncryptedKey_seq_tt[] = { | ||
| 598 | { | ||
| 599 | .flags = 0, | ||
| 600 | .tag = 0, | ||
| 601 | .offset = offsetof(CMS_RecipientEncryptedKey, rid), | ||
| 602 | .field_name = "rid", | ||
| 603 | .item = &CMS_KeyAgreeRecipientIdentifier_it, | ||
| 604 | }, | ||
| 605 | { | ||
| 606 | .flags = 0, | ||
| 607 | .tag = 0, | ||
| 608 | .offset = offsetof(CMS_RecipientEncryptedKey, encryptedKey), | ||
| 609 | .field_name = "encryptedKey", | ||
| 610 | .item = &ASN1_OCTET_STRING_it, | ||
| 611 | }, | ||
| 612 | }; | ||
| 613 | |||
| 614 | const ASN1_ITEM CMS_RecipientEncryptedKey_it = { | ||
| 615 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 616 | .utype = V_ASN1_SEQUENCE, | ||
| 617 | .templates = CMS_RecipientEncryptedKey_seq_tt, | ||
| 618 | .tcount = sizeof(CMS_RecipientEncryptedKey_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 619 | .funcs = NULL, | ||
| 620 | .size = sizeof(CMS_RecipientEncryptedKey), | ||
| 621 | .sname = "CMS_RecipientEncryptedKey", | ||
| 622 | }; | ||
| 623 | |||
| 624 | static const ASN1_TEMPLATE CMS_OriginatorPublicKey_seq_tt[] = { | ||
| 625 | { | ||
| 626 | .flags = 0, | ||
| 627 | .tag = 0, | ||
| 628 | .offset = offsetof(CMS_OriginatorPublicKey, algorithm), | ||
| 629 | .field_name = "algorithm", | ||
| 630 | .item = &X509_ALGOR_it, | ||
| 631 | }, | ||
| 632 | { | ||
| 633 | .flags = 0, | ||
| 634 | .tag = 0, | ||
| 635 | .offset = offsetof(CMS_OriginatorPublicKey, publicKey), | ||
| 636 | .field_name = "publicKey", | ||
| 637 | .item = &ASN1_BIT_STRING_it, | ||
| 638 | }, | ||
| 639 | }; | ||
| 640 | |||
| 641 | const ASN1_ITEM CMS_OriginatorPublicKey_it = { | ||
| 642 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 643 | .utype = V_ASN1_SEQUENCE, | ||
| 644 | .templates = CMS_OriginatorPublicKey_seq_tt, | ||
| 645 | .tcount = sizeof(CMS_OriginatorPublicKey_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 646 | .funcs = NULL, | ||
| 647 | .size = sizeof(CMS_OriginatorPublicKey), | ||
| 648 | .sname = "CMS_OriginatorPublicKey", | ||
| 649 | }; | ||
| 650 | |||
| 651 | static const ASN1_TEMPLATE CMS_OriginatorIdentifierOrKey_ch_tt[] = { | ||
| 652 | { | ||
| 653 | .flags = 0, | ||
| 654 | .tag = 0, | ||
| 655 | .offset = offsetof(CMS_OriginatorIdentifierOrKey, d.issuerAndSerialNumber), | ||
| 656 | .field_name = "d.issuerAndSerialNumber", | ||
| 657 | .item = &CMS_IssuerAndSerialNumber_it, | ||
| 658 | }, | ||
| 659 | { | ||
| 660 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 661 | .tag = 0, | ||
| 662 | .offset = offsetof(CMS_OriginatorIdentifierOrKey, d.subjectKeyIdentifier), | ||
| 663 | .field_name = "d.subjectKeyIdentifier", | ||
| 664 | .item = &ASN1_OCTET_STRING_it, | ||
| 665 | }, | ||
| 666 | { | ||
| 667 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 668 | .tag = 1, | ||
| 669 | .offset = offsetof(CMS_OriginatorIdentifierOrKey, d.originatorKey), | ||
| 670 | .field_name = "d.originatorKey", | ||
| 671 | .item = &CMS_OriginatorPublicKey_it, | ||
| 672 | }, | ||
| 673 | }; | ||
| 674 | |||
| 675 | const ASN1_ITEM CMS_OriginatorIdentifierOrKey_it = { | ||
| 676 | .itype = ASN1_ITYPE_CHOICE, | ||
| 677 | .utype = offsetof(CMS_OriginatorIdentifierOrKey, type), | ||
| 678 | .templates = CMS_OriginatorIdentifierOrKey_ch_tt, | ||
| 679 | .tcount = sizeof(CMS_OriginatorIdentifierOrKey_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
| 680 | .funcs = NULL, | ||
| 681 | .size = sizeof(CMS_OriginatorIdentifierOrKey), | ||
| 682 | .sname = "CMS_OriginatorIdentifierOrKey", | ||
| 683 | }; | ||
| 684 | |||
| 685 | static const ASN1_TEMPLATE CMS_KeyAgreeRecipientInfo_seq_tt[] = { | ||
| 686 | { | ||
| 687 | .flags = 0, | ||
| 688 | .tag = 0, | ||
| 689 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, version), | ||
| 690 | .field_name = "version", | ||
| 691 | .item = &LONG_it, | ||
| 692 | }, | ||
| 693 | { | ||
| 694 | .flags = ASN1_TFLG_EXPLICIT, | ||
| 695 | .tag = 0, | ||
| 696 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, originator), | ||
| 697 | .field_name = "originator", | ||
| 698 | .item = &CMS_OriginatorIdentifierOrKey_it, | ||
| 699 | }, | ||
| 700 | { | ||
| 701 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL, | ||
| 702 | .tag = 1, | ||
| 703 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, ukm), | ||
| 704 | .field_name = "ukm", | ||
| 705 | .item = &ASN1_OCTET_STRING_it, | ||
| 706 | }, | ||
| 707 | { | ||
| 708 | .flags = 0, | ||
| 709 | .tag = 0, | ||
| 710 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, keyEncryptionAlgorithm), | ||
| 711 | .field_name = "keyEncryptionAlgorithm", | ||
| 712 | .item = &X509_ALGOR_it, | ||
| 713 | }, | ||
| 714 | { | ||
| 715 | .flags = ASN1_TFLG_SEQUENCE_OF, | ||
| 716 | .tag = 0, | ||
| 717 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, recipientEncryptedKeys), | ||
| 718 | .field_name = "recipientEncryptedKeys", | ||
| 719 | .item = &CMS_RecipientEncryptedKey_it, | ||
| 720 | }, | ||
| 721 | }; | ||
| 722 | |||
| 723 | const ASN1_ITEM CMS_KeyAgreeRecipientInfo_it = { | ||
| 724 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 725 | .utype = V_ASN1_SEQUENCE, | ||
| 726 | .templates = CMS_KeyAgreeRecipientInfo_seq_tt, | ||
| 727 | .tcount = sizeof(CMS_KeyAgreeRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 728 | .funcs = NULL, | ||
| 729 | .size = sizeof(CMS_KeyAgreeRecipientInfo), | ||
| 730 | .sname = "CMS_KeyAgreeRecipientInfo", | ||
| 731 | }; | ||
| 732 | |||
| 733 | static const ASN1_TEMPLATE CMS_KEKIdentifier_seq_tt[] = { | ||
| 734 | { | ||
| 735 | .flags = 0, | ||
| 736 | .tag = 0, | ||
| 737 | .offset = offsetof(CMS_KEKIdentifier, keyIdentifier), | ||
| 738 | .field_name = "keyIdentifier", | ||
| 739 | .item = &ASN1_OCTET_STRING_it, | ||
| 740 | }, | ||
| 741 | { | ||
| 742 | .flags = ASN1_TFLG_OPTIONAL, | ||
| 743 | .tag = 0, | ||
| 744 | .offset = offsetof(CMS_KEKIdentifier, date), | ||
| 745 | .field_name = "date", | ||
| 746 | .item = &ASN1_GENERALIZEDTIME_it, | ||
| 747 | }, | ||
| 748 | { | ||
| 749 | .flags = ASN1_TFLG_OPTIONAL, | ||
| 750 | .tag = 0, | ||
| 751 | .offset = offsetof(CMS_KEKIdentifier, other), | ||
| 752 | .field_name = "other", | ||
| 753 | .item = &CMS_OtherKeyAttribute_it, | ||
| 754 | }, | ||
| 755 | }; | ||
| 756 | |||
| 757 | const ASN1_ITEM CMS_KEKIdentifier_it = { | ||
| 758 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 759 | .utype = V_ASN1_SEQUENCE, | ||
| 760 | .templates = CMS_KEKIdentifier_seq_tt, | ||
| 761 | .tcount = sizeof(CMS_KEKIdentifier_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 762 | .funcs = NULL, | ||
| 763 | .size = sizeof(CMS_KEKIdentifier), | ||
| 764 | .sname = "CMS_KEKIdentifier", | ||
| 765 | }; | ||
| 766 | |||
| 767 | static const ASN1_TEMPLATE CMS_KEKRecipientInfo_seq_tt[] = { | ||
| 768 | { | ||
| 769 | .flags = 0, | ||
| 770 | .tag = 0, | ||
| 771 | .offset = offsetof(CMS_KEKRecipientInfo, version), | ||
| 772 | .field_name = "version", | ||
| 773 | .item = &LONG_it, | ||
| 774 | }, | ||
| 775 | { | ||
| 776 | .flags = 0, | ||
| 777 | .tag = 0, | ||
| 778 | .offset = offsetof(CMS_KEKRecipientInfo, kekid), | ||
| 779 | .field_name = "kekid", | ||
| 780 | .item = &CMS_KEKIdentifier_it, | ||
| 781 | }, | ||
| 782 | { | ||
| 783 | .flags = 0, | ||
| 784 | .tag = 0, | ||
| 785 | .offset = offsetof(CMS_KEKRecipientInfo, keyEncryptionAlgorithm), | ||
| 786 | .field_name = "keyEncryptionAlgorithm", | ||
| 787 | .item = &X509_ALGOR_it, | ||
| 788 | }, | ||
| 789 | { | ||
| 790 | .flags = 0, | ||
| 791 | .tag = 0, | ||
| 792 | .offset = offsetof(CMS_KEKRecipientInfo, encryptedKey), | ||
| 793 | .field_name = "encryptedKey", | ||
| 794 | .item = &ASN1_OCTET_STRING_it, | ||
| 795 | }, | ||
| 796 | }; | ||
| 797 | |||
| 798 | const ASN1_ITEM CMS_KEKRecipientInfo_it = { | ||
| 799 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 800 | .utype = V_ASN1_SEQUENCE, | ||
| 801 | .templates = CMS_KEKRecipientInfo_seq_tt, | ||
| 802 | .tcount = sizeof(CMS_KEKRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 803 | .funcs = NULL, | ||
| 804 | .size = sizeof(CMS_KEKRecipientInfo), | ||
| 805 | .sname = "CMS_KEKRecipientInfo", | ||
| 806 | }; | ||
| 807 | |||
| 808 | static const ASN1_TEMPLATE CMS_PasswordRecipientInfo_seq_tt[] = { | ||
| 809 | { | ||
| 810 | .flags = 0, | ||
| 811 | .tag = 0, | ||
| 812 | .offset = offsetof(CMS_PasswordRecipientInfo, version), | ||
| 813 | .field_name = "version", | ||
| 814 | .item = &LONG_it, | ||
| 815 | }, | ||
| 816 | { | ||
| 817 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, | ||
| 818 | .tag = 0, | ||
| 819 | .offset = offsetof(CMS_PasswordRecipientInfo, keyDerivationAlgorithm), | ||
| 820 | .field_name = "keyDerivationAlgorithm", | ||
| 821 | .item = &X509_ALGOR_it, | ||
| 822 | }, | ||
| 823 | { | ||
| 824 | .flags = 0, | ||
| 825 | .tag = 0, | ||
| 826 | .offset = offsetof(CMS_PasswordRecipientInfo, keyEncryptionAlgorithm), | ||
| 827 | .field_name = "keyEncryptionAlgorithm", | ||
| 828 | .item = &X509_ALGOR_it, | ||
| 829 | }, | ||
| 830 | { | ||
| 831 | .flags = 0, | ||
| 832 | .tag = 0, | ||
| 833 | .offset = offsetof(CMS_PasswordRecipientInfo, encryptedKey), | ||
| 834 | .field_name = "encryptedKey", | ||
| 835 | .item = &ASN1_OCTET_STRING_it, | ||
| 836 | }, | ||
| 837 | }; | ||
| 838 | |||
| 839 | const ASN1_ITEM CMS_PasswordRecipientInfo_it = { | ||
| 840 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 841 | .utype = V_ASN1_SEQUENCE, | ||
| 842 | .templates = CMS_PasswordRecipientInfo_seq_tt, | ||
| 843 | .tcount = sizeof(CMS_PasswordRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 844 | .funcs = NULL, | ||
| 845 | .size = sizeof(CMS_PasswordRecipientInfo), | ||
| 846 | .sname = "CMS_PasswordRecipientInfo", | ||
| 847 | }; | ||
| 848 | |||
| 849 | static const ASN1_TEMPLATE CMS_OtherRecipientInfo_seq_tt[] = { | ||
| 850 | { | ||
| 851 | .flags = 0, | ||
| 852 | .tag = 0, | ||
| 853 | .offset = offsetof(CMS_OtherRecipientInfo, oriType), | ||
| 854 | .field_name = "oriType", | ||
| 855 | .item = &ASN1_OBJECT_it, | ||
| 856 | }, | ||
| 857 | { | ||
| 858 | .flags = ASN1_TFLG_OPTIONAL, | ||
| 859 | .tag = 0, | ||
| 860 | .offset = offsetof(CMS_OtherRecipientInfo, oriValue), | ||
| 861 | .field_name = "oriValue", | ||
| 862 | .item = &ASN1_ANY_it, | ||
| 863 | }, | ||
| 864 | }; | ||
| 865 | |||
| 866 | const ASN1_ITEM CMS_OtherRecipientInfo_it = { | ||
| 867 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 868 | .utype = V_ASN1_SEQUENCE, | ||
| 869 | .templates = CMS_OtherRecipientInfo_seq_tt, | ||
| 870 | .tcount = sizeof(CMS_OtherRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 871 | .funcs = NULL, | ||
| 872 | .size = sizeof(CMS_OtherRecipientInfo), | ||
| 873 | .sname = "CMS_OtherRecipientInfo", | ||
| 874 | }; | ||
| 875 | |||
| 876 | /* Free up RecipientInfo additional data */ | ||
| 877 | static int | ||
| 878 | cms_ri_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | ||
| 879 | { | ||
| 880 | if (operation == ASN1_OP_FREE_PRE) { | ||
| 881 | CMS_RecipientInfo *ri = (CMS_RecipientInfo *)*pval; | ||
| 882 | if (ri->type == CMS_RECIPINFO_TRANS) { | ||
| 883 | CMS_KeyTransRecipientInfo *ktri = ri->d.ktri; | ||
| 884 | EVP_PKEY_free(ktri->pkey); | ||
| 885 | X509_free(ktri->recip); | ||
| 886 | } else if (ri->type == CMS_RECIPINFO_KEK) { | ||
| 887 | CMS_KEKRecipientInfo *kekri = ri->d.kekri; | ||
| 888 | if (kekri->key) { | ||
| 889 | explicit_bzero(kekri->key, kekri->keylen); | ||
| 890 | free(kekri->key); | ||
| 891 | } | ||
| 892 | } else if (ri->type == CMS_RECIPINFO_PASS) { | ||
| 893 | CMS_PasswordRecipientInfo *pwri = ri->d.pwri; | ||
| 894 | if (pwri->pass) { | ||
| 895 | explicit_bzero(pwri->pass, pwri->passlen); | ||
| 896 | free(pwri->pass); | ||
| 897 | } | ||
| 898 | } | ||
| 899 | } | ||
| 900 | return 1; | ||
| 901 | } | ||
| 902 | |||
| 903 | static const ASN1_AUX CMS_RecipientInfo_aux = { | ||
| 904 | .app_data = NULL, | ||
| 905 | .flags = 0, | ||
| 906 | .ref_offset = 0, | ||
| 907 | .ref_lock = 0, | ||
| 908 | .asn1_cb = cms_ri_cb, | ||
| 909 | .enc_offset = 0, | ||
| 910 | }; | ||
| 911 | static const ASN1_TEMPLATE CMS_RecipientInfo_ch_tt[] = { | ||
| 912 | { | ||
| 913 | .flags = 0, | ||
| 914 | .tag = 0, | ||
| 915 | .offset = offsetof(CMS_RecipientInfo, d.ktri), | ||
| 916 | .field_name = "d.ktri", | ||
| 917 | .item = &CMS_KeyTransRecipientInfo_it, | ||
| 918 | }, | ||
| 919 | { | ||
| 920 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 921 | .tag = 1, | ||
| 922 | .offset = offsetof(CMS_RecipientInfo, d.kari), | ||
| 923 | .field_name = "d.kari", | ||
| 924 | .item = &CMS_KeyAgreeRecipientInfo_it, | ||
| 925 | }, | ||
| 926 | { | ||
| 927 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 928 | .tag = 2, | ||
| 929 | .offset = offsetof(CMS_RecipientInfo, d.kekri), | ||
| 930 | .field_name = "d.kekri", | ||
| 931 | .item = &CMS_KEKRecipientInfo_it, | ||
| 932 | }, | ||
| 933 | { | ||
| 934 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 935 | .tag = 3, | ||
| 936 | .offset = offsetof(CMS_RecipientInfo, d.pwri), | ||
| 937 | .field_name = "d.pwri", | ||
| 938 | .item = &CMS_PasswordRecipientInfo_it, | ||
| 939 | }, | ||
| 940 | { | ||
| 941 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 942 | .tag = 4, | ||
| 943 | .offset = offsetof(CMS_RecipientInfo, d.ori), | ||
| 944 | .field_name = "d.ori", | ||
| 945 | .item = &CMS_OtherRecipientInfo_it, | ||
| 946 | }, | ||
| 947 | }; | ||
| 948 | |||
| 949 | const ASN1_ITEM CMS_RecipientInfo_it = { | ||
| 950 | .itype = ASN1_ITYPE_CHOICE, | ||
| 951 | .utype = offsetof(CMS_RecipientInfo, type), | ||
| 952 | .templates = CMS_RecipientInfo_ch_tt, | ||
| 953 | .tcount = sizeof(CMS_RecipientInfo_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
| 954 | .funcs = &CMS_RecipientInfo_aux, | ||
| 955 | .size = sizeof(CMS_RecipientInfo), | ||
| 956 | .sname = "CMS_RecipientInfo", | ||
| 957 | }; | ||
| 958 | |||
| 959 | static const ASN1_TEMPLATE CMS_EnvelopedData_seq_tt[] = { | ||
| 960 | { | ||
| 961 | .flags = 0, | ||
| 962 | .tag = 0, | ||
| 963 | .offset = offsetof(CMS_EnvelopedData, version), | ||
| 964 | .field_name = "version", | ||
| 965 | .item = &LONG_it, | ||
| 966 | }, | ||
| 967 | { | ||
| 968 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, | ||
| 969 | .tag = 0, | ||
| 970 | .offset = offsetof(CMS_EnvelopedData, originatorInfo), | ||
| 971 | .field_name = "originatorInfo", | ||
| 972 | .item = &CMS_OriginatorInfo_it, | ||
| 973 | }, | ||
| 974 | { | ||
| 975 | .flags = ASN1_TFLG_SET_OF, | ||
| 976 | .tag = 0, | ||
| 977 | .offset = offsetof(CMS_EnvelopedData, recipientInfos), | ||
| 978 | .field_name = "recipientInfos", | ||
| 979 | .item = &CMS_RecipientInfo_it, | ||
| 980 | }, | ||
| 981 | { | ||
| 982 | .flags = 0, | ||
| 983 | .tag = 0, | ||
| 984 | .offset = offsetof(CMS_EnvelopedData, encryptedContentInfo), | ||
| 985 | .field_name = "encryptedContentInfo", | ||
| 986 | .item = &CMS_EncryptedContentInfo_it, | ||
| 987 | }, | ||
| 988 | { | ||
| 989 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
| 990 | .tag = 1, | ||
| 991 | .offset = offsetof(CMS_EnvelopedData, unprotectedAttrs), | ||
| 992 | .field_name = "unprotectedAttrs", | ||
| 993 | .item = &X509_ATTRIBUTE_it, | ||
| 994 | }, | ||
| 995 | }; | ||
| 996 | |||
| 997 | const ASN1_ITEM CMS_EnvelopedData_it = { | ||
| 998 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
| 999 | .utype = V_ASN1_SEQUENCE, | ||
| 1000 | .templates = CMS_EnvelopedData_seq_tt, | ||
| 1001 | .tcount = sizeof(CMS_EnvelopedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 1002 | .funcs = NULL, | ||
| 1003 | .size = sizeof(CMS_EnvelopedData), | ||
| 1004 | .sname = "CMS_EnvelopedData", | ||
| 1005 | }; | ||
| 1006 | |||
| 1007 | static const ASN1_TEMPLATE CMS_DigestedData_seq_tt[] = { | ||
| 1008 | { | ||
| 1009 | .flags = 0, | ||
| 1010 | .tag = 0, | ||
| 1011 | .offset = offsetof(CMS_DigestedData, version), | ||
| 1012 | .field_name = "version", | ||
| 1013 | .item = &LONG_it, | ||
| 1014 | }, | ||
| 1015 | { | ||
| 1016 | .flags = 0, | ||
| 1017 | .tag = 0, | ||
| 1018 | .offset = offsetof(CMS_DigestedData, digestAlgorithm), | ||
| 1019 | .field_name = "digestAlgorithm", | ||
| 1020 | .item = &X509_ALGOR_it, | ||
| 1021 | }, | ||
| 1022 | { | ||
| 1023 | .flags = 0, | ||
| 1024 | .tag = 0, | ||
| 1025 | .offset = offsetof(CMS_DigestedData, encapContentInfo), | ||
| 1026 | .field_name = "encapContentInfo", | ||
| 1027 | .item = &CMS_EncapsulatedContentInfo_it, | ||
| 1028 | }, | ||
| 1029 | { | ||
| 1030 | .flags = 0, | ||
| 1031 | .tag = 0, | ||
| 1032 | .offset = offsetof(CMS_DigestedData, digest), | ||
| 1033 | .field_name = "digest", | ||
| 1034 | .item = &ASN1_OCTET_STRING_it, | ||
| 1035 | }, | ||
| 1036 | }; | ||
| 1037 | |||
| 1038 | const ASN1_ITEM CMS_DigestedData_it = { | ||
| 1039 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
| 1040 | .utype = V_ASN1_SEQUENCE, | ||
| 1041 | .templates = CMS_DigestedData_seq_tt, | ||
| 1042 | .tcount = sizeof(CMS_DigestedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 1043 | .funcs = NULL, | ||
| 1044 | .size = sizeof(CMS_DigestedData), | ||
| 1045 | .sname = "CMS_DigestedData", | ||
| 1046 | }; | ||
| 1047 | |||
| 1048 | static const ASN1_TEMPLATE CMS_EncryptedData_seq_tt[] = { | ||
| 1049 | { | ||
| 1050 | .flags = 0, | ||
| 1051 | .tag = 0, | ||
| 1052 | .offset = offsetof(CMS_EncryptedData, version), | ||
| 1053 | .field_name = "version", | ||
| 1054 | .item = &LONG_it, | ||
| 1055 | }, | ||
| 1056 | { | ||
| 1057 | .flags = 0, | ||
| 1058 | .tag = 0, | ||
| 1059 | .offset = offsetof(CMS_EncryptedData, encryptedContentInfo), | ||
| 1060 | .field_name = "encryptedContentInfo", | ||
| 1061 | .item = &CMS_EncryptedContentInfo_it, | ||
| 1062 | }, | ||
| 1063 | { | ||
| 1064 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
| 1065 | .tag = 1, | ||
| 1066 | .offset = offsetof(CMS_EncryptedData, unprotectedAttrs), | ||
| 1067 | .field_name = "unprotectedAttrs", | ||
| 1068 | .item = &X509_ATTRIBUTE_it, | ||
| 1069 | }, | ||
| 1070 | }; | ||
| 1071 | |||
| 1072 | const ASN1_ITEM CMS_EncryptedData_it = { | ||
| 1073 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
| 1074 | .utype = V_ASN1_SEQUENCE, | ||
| 1075 | .templates = CMS_EncryptedData_seq_tt, | ||
| 1076 | .tcount = sizeof(CMS_EncryptedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 1077 | .funcs = NULL, | ||
| 1078 | .size = sizeof(CMS_EncryptedData), | ||
| 1079 | .sname = "CMS_EncryptedData", | ||
| 1080 | }; | ||
| 1081 | |||
| 1082 | static const ASN1_TEMPLATE CMS_AuthenticatedData_seq_tt[] = { | ||
| 1083 | { | ||
| 1084 | .flags = 0, | ||
| 1085 | .tag = 0, | ||
| 1086 | .offset = offsetof(CMS_AuthenticatedData, version), | ||
| 1087 | .field_name = "version", | ||
| 1088 | .item = &LONG_it, | ||
| 1089 | }, | ||
| 1090 | { | ||
| 1091 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, | ||
| 1092 | .tag = 0, | ||
| 1093 | .offset = offsetof(CMS_AuthenticatedData, originatorInfo), | ||
| 1094 | .field_name = "originatorInfo", | ||
| 1095 | .item = &CMS_OriginatorInfo_it, | ||
| 1096 | }, | ||
| 1097 | { | ||
| 1098 | .flags = ASN1_TFLG_SET_OF, | ||
| 1099 | .tag = 0, | ||
| 1100 | .offset = offsetof(CMS_AuthenticatedData, recipientInfos), | ||
| 1101 | .field_name = "recipientInfos", | ||
| 1102 | .item = &CMS_RecipientInfo_it, | ||
| 1103 | }, | ||
| 1104 | { | ||
| 1105 | .flags = 0, | ||
| 1106 | .tag = 0, | ||
| 1107 | .offset = offsetof(CMS_AuthenticatedData, macAlgorithm), | ||
| 1108 | .field_name = "macAlgorithm", | ||
| 1109 | .item = &X509_ALGOR_it, | ||
| 1110 | }, | ||
| 1111 | { | ||
| 1112 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 1113 | .tag = 1, | ||
| 1114 | .offset = offsetof(CMS_AuthenticatedData, digestAlgorithm), | ||
| 1115 | .field_name = "digestAlgorithm", | ||
| 1116 | .item = &X509_ALGOR_it, | ||
| 1117 | }, | ||
| 1118 | { | ||
| 1119 | .flags = 0, | ||
| 1120 | .tag = 0, | ||
| 1121 | .offset = offsetof(CMS_AuthenticatedData, encapContentInfo), | ||
| 1122 | .field_name = "encapContentInfo", | ||
| 1123 | .item = &CMS_EncapsulatedContentInfo_it, | ||
| 1124 | }, | ||
| 1125 | { | ||
| 1126 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
| 1127 | .tag = 2, | ||
| 1128 | .offset = offsetof(CMS_AuthenticatedData, authAttrs), | ||
| 1129 | .field_name = "authAttrs", | ||
| 1130 | .item = &X509_ALGOR_it, | ||
| 1131 | }, | ||
| 1132 | { | ||
| 1133 | .flags = 0, | ||
| 1134 | .tag = 0, | ||
| 1135 | .offset = offsetof(CMS_AuthenticatedData, mac), | ||
| 1136 | .field_name = "mac", | ||
| 1137 | .item = &ASN1_OCTET_STRING_it, | ||
| 1138 | }, | ||
| 1139 | { | ||
| 1140 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
| 1141 | .tag = 3, | ||
| 1142 | .offset = offsetof(CMS_AuthenticatedData, unauthAttrs), | ||
| 1143 | .field_name = "unauthAttrs", | ||
| 1144 | .item = &X509_ALGOR_it, | ||
| 1145 | }, | ||
| 1146 | }; | ||
| 1147 | |||
| 1148 | const ASN1_ITEM CMS_AuthenticatedData_it = { | ||
| 1149 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
| 1150 | .utype = V_ASN1_SEQUENCE, | ||
| 1151 | .templates = CMS_AuthenticatedData_seq_tt, | ||
| 1152 | .tcount = sizeof(CMS_AuthenticatedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 1153 | .funcs = NULL, | ||
| 1154 | .size = sizeof(CMS_AuthenticatedData), | ||
| 1155 | .sname = "CMS_AuthenticatedData", | ||
| 1156 | }; | ||
| 1157 | |||
| 1158 | static const ASN1_TEMPLATE CMS_CompressedData_seq_tt[] = { | ||
| 1159 | { | ||
| 1160 | .flags = 0, | ||
| 1161 | .tag = 0, | ||
| 1162 | .offset = offsetof(CMS_CompressedData, version), | ||
| 1163 | .field_name = "version", | ||
| 1164 | .item = &LONG_it, | ||
| 1165 | }, | ||
| 1166 | { | ||
| 1167 | .flags = 0, | ||
| 1168 | .tag = 0, | ||
| 1169 | .offset = offsetof(CMS_CompressedData, compressionAlgorithm), | ||
| 1170 | .field_name = "compressionAlgorithm", | ||
| 1171 | .item = &X509_ALGOR_it, | ||
| 1172 | }, | ||
| 1173 | { | ||
| 1174 | .flags = 0, | ||
| 1175 | .tag = 0, | ||
| 1176 | .offset = offsetof(CMS_CompressedData, encapContentInfo), | ||
| 1177 | .field_name = "encapContentInfo", | ||
| 1178 | .item = &CMS_EncapsulatedContentInfo_it, | ||
| 1179 | }, | ||
| 1180 | }; | ||
| 1181 | |||
| 1182 | const ASN1_ITEM CMS_CompressedData_it = { | ||
| 1183 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
| 1184 | .utype = V_ASN1_SEQUENCE, | ||
| 1185 | .templates = CMS_CompressedData_seq_tt, | ||
| 1186 | .tcount = sizeof(CMS_CompressedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 1187 | .funcs = NULL, | ||
| 1188 | .size = sizeof(CMS_CompressedData), | ||
| 1189 | .sname = "CMS_CompressedData", | ||
| 1190 | }; | ||
| 1191 | |||
| 1192 | /* This is the ANY DEFINED BY table for the top level ContentInfo structure */ | ||
| 1193 | |||
| 1194 | static const ASN1_TEMPLATE cms_default_tt = { | ||
| 1195 | .flags = ASN1_TFLG_EXPLICIT, | ||
| 1196 | .tag = 0, | ||
| 1197 | .offset = offsetof(CMS_ContentInfo, d.other), | ||
| 1198 | .field_name = "d.other", | ||
| 1199 | .item = &ASN1_ANY_it, | ||
| 1200 | }; | ||
| 1201 | |||
| 1202 | static const ASN1_ADB_TABLE CMS_ContentInfo_adbtbl[] = { | ||
| 1203 | { | ||
| 1204 | .value = NID_pkcs7_data, | ||
| 1205 | .tt = { | ||
| 1206 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
| 1207 | .tag = 0, | ||
| 1208 | .offset = offsetof(CMS_ContentInfo, d.data), | ||
| 1209 | .field_name = "d.data", | ||
| 1210 | .item = &ASN1_OCTET_STRING_NDEF_it, | ||
| 1211 | }, | ||
| 1212 | |||
| 1213 | }, | ||
| 1214 | { | ||
| 1215 | .value = NID_pkcs7_signed, | ||
| 1216 | .tt = { | ||
| 1217 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
| 1218 | .tag = 0, | ||
| 1219 | .offset = offsetof(CMS_ContentInfo, d.signedData), | ||
| 1220 | .field_name = "d.signedData", | ||
| 1221 | .item = &CMS_SignedData_it, | ||
| 1222 | }, | ||
| 1223 | |||
| 1224 | }, | ||
| 1225 | { | ||
| 1226 | .value = NID_pkcs7_enveloped, | ||
| 1227 | .tt = { | ||
| 1228 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
| 1229 | .tag = 0, | ||
| 1230 | .offset = offsetof(CMS_ContentInfo, d.envelopedData), | ||
| 1231 | .field_name = "d.envelopedData", | ||
| 1232 | .item = &CMS_EnvelopedData_it, | ||
| 1233 | }, | ||
| 1234 | |||
| 1235 | }, | ||
| 1236 | { | ||
| 1237 | .value = NID_pkcs7_digest, | ||
| 1238 | .tt = { | ||
| 1239 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
| 1240 | .tag = 0, | ||
| 1241 | .offset = offsetof(CMS_ContentInfo, d.digestedData), | ||
| 1242 | .field_name = "d.digestedData", | ||
| 1243 | .item = &CMS_DigestedData_it, | ||
| 1244 | }, | ||
| 1245 | |||
| 1246 | }, | ||
| 1247 | { | ||
| 1248 | .value = NID_pkcs7_encrypted, | ||
| 1249 | .tt = { | ||
| 1250 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
| 1251 | .tag = 0, | ||
| 1252 | .offset = offsetof(CMS_ContentInfo, d.encryptedData), | ||
| 1253 | .field_name = "d.encryptedData", | ||
| 1254 | .item = &CMS_EncryptedData_it, | ||
| 1255 | }, | ||
| 1256 | |||
| 1257 | }, | ||
| 1258 | { | ||
| 1259 | .value = NID_id_smime_ct_authData, | ||
| 1260 | .tt = { | ||
| 1261 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
| 1262 | .tag = 0, | ||
| 1263 | .offset = offsetof(CMS_ContentInfo, d.authenticatedData), | ||
| 1264 | .field_name = "d.authenticatedData", | ||
| 1265 | .item = &CMS_AuthenticatedData_it, | ||
| 1266 | }, | ||
| 1267 | |||
| 1268 | }, | ||
| 1269 | { | ||
| 1270 | .value = NID_id_smime_ct_compressedData, | ||
| 1271 | .tt = { | ||
| 1272 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
| 1273 | .tag = 0, | ||
| 1274 | .offset = offsetof(CMS_ContentInfo, d.compressedData), | ||
| 1275 | .field_name = "d.compressedData", | ||
| 1276 | .item = &CMS_CompressedData_it, | ||
| 1277 | }, | ||
| 1278 | |||
| 1279 | }, | ||
| 1280 | }; | ||
| 1281 | |||
| 1282 | static const ASN1_ADB CMS_ContentInfo_adb = { | ||
| 1283 | .flags = 0, | ||
| 1284 | .offset = offsetof(CMS_ContentInfo, contentType), | ||
| 1285 | .app_items = 0, | ||
| 1286 | .tbl = CMS_ContentInfo_adbtbl, | ||
| 1287 | .tblcount = sizeof(CMS_ContentInfo_adbtbl) / sizeof(ASN1_ADB_TABLE), | ||
| 1288 | .default_tt = &cms_default_tt, | ||
| 1289 | .null_tt = NULL, | ||
| 1290 | }; | ||
| 1291 | |||
| 1292 | /* CMS streaming support */ | ||
| 1293 | static int | ||
| 1294 | cms_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | ||
| 1295 | { | ||
| 1296 | ASN1_STREAM_ARG *sarg = exarg; | ||
| 1297 | CMS_ContentInfo *cms = NULL; | ||
| 1298 | |||
| 1299 | if (pval) | ||
| 1300 | cms = (CMS_ContentInfo *)*pval; | ||
| 1301 | else | ||
| 1302 | return 1; | ||
| 1303 | |||
| 1304 | switch (operation) { | ||
| 1305 | case ASN1_OP_STREAM_PRE: | ||
| 1306 | if (CMS_stream(&sarg->boundary, cms) <= 0) | ||
| 1307 | return 0; | ||
| 1308 | case ASN1_OP_DETACHED_PRE: | ||
| 1309 | sarg->ndef_bio = CMS_dataInit(cms, sarg->out); | ||
| 1310 | if (!sarg->ndef_bio) | ||
| 1311 | return 0; | ||
| 1312 | break; | ||
| 1313 | case ASN1_OP_STREAM_POST: | ||
| 1314 | case ASN1_OP_DETACHED_POST: | ||
| 1315 | if (CMS_dataFinal(cms, sarg->ndef_bio) <= 0) | ||
| 1316 | return 0; | ||
| 1317 | break; | ||
| 1318 | } | ||
| 1319 | return 1; | ||
| 1320 | } | ||
| 1321 | |||
| 1322 | static const ASN1_AUX CMS_ContentInfo_aux = { | ||
| 1323 | .app_data = NULL, | ||
| 1324 | .flags = 0, | ||
| 1325 | .ref_offset = 0, | ||
| 1326 | .ref_lock = 0, | ||
| 1327 | .asn1_cb = cms_cb, | ||
| 1328 | .enc_offset = 0, | ||
| 1329 | }; | ||
| 1330 | static const ASN1_TEMPLATE CMS_ContentInfo_seq_tt[] = { | ||
| 1331 | { | ||
| 1332 | .flags = 0, | ||
| 1333 | .tag = 0, | ||
| 1334 | .offset = offsetof(CMS_ContentInfo, contentType), | ||
| 1335 | .field_name = "contentType", | ||
| 1336 | .item = &ASN1_OBJECT_it, | ||
| 1337 | }, | ||
| 1338 | { | ||
| 1339 | .flags = ASN1_TFLG_ADB_OID, | ||
| 1340 | .tag = -1, | ||
| 1341 | .offset = 0, | ||
| 1342 | .field_name = "CMS_ContentInfo", | ||
| 1343 | .item = (const ASN1_ITEM *)&CMS_ContentInfo_adb, | ||
| 1344 | }, | ||
| 1345 | }; | ||
| 1346 | |||
| 1347 | const ASN1_ITEM CMS_ContentInfo_it = { | ||
| 1348 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
| 1349 | .utype = V_ASN1_SEQUENCE, | ||
| 1350 | .templates = CMS_ContentInfo_seq_tt, | ||
| 1351 | .tcount = sizeof(CMS_ContentInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 1352 | .funcs = &CMS_ContentInfo_aux, | ||
| 1353 | .size = sizeof(CMS_ContentInfo), | ||
| 1354 | .sname = "CMS_ContentInfo", | ||
| 1355 | }; | ||
| 1356 | |||
| 1357 | /* Specials for signed attributes */ | ||
| 1358 | |||
| 1359 | /* When signing attributes we want to reorder them to match the sorted | ||
| 1360 | * encoding. | ||
| 1361 | */ | ||
| 1362 | |||
| 1363 | static const ASN1_TEMPLATE CMS_Attributes_Sign_item_tt = { | ||
| 1364 | .flags = ASN1_TFLG_SET_ORDER, | ||
| 1365 | .tag = 0, | ||
| 1366 | .offset = 0, | ||
| 1367 | .field_name = "CMS_ATTRIBUTES", | ||
| 1368 | .item = &X509_ATTRIBUTE_it, | ||
| 1369 | }; | ||
| 1370 | |||
| 1371 | const ASN1_ITEM CMS_Attributes_Sign_it = { | ||
| 1372 | .itype = ASN1_ITYPE_PRIMITIVE, | ||
| 1373 | .utype = -1, | ||
| 1374 | .templates = &CMS_Attributes_Sign_item_tt, | ||
| 1375 | .tcount = 0, | ||
| 1376 | .funcs = NULL, | ||
| 1377 | .size = 0, | ||
| 1378 | .sname = "CMS_Attributes_Sign", | ||
| 1379 | }; | ||
| 1380 | |||
| 1381 | /* When verifying attributes we need to use the received order. So | ||
| 1382 | * we use SEQUENCE OF and tag it to SET OF | ||
| 1383 | */ | ||
| 1384 | |||
| 1385 | static const ASN1_TEMPLATE CMS_Attributes_Verify_item_tt = { | ||
| 1386 | .flags = ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_IMPTAG | ASN1_TFLG_UNIVERSAL, | ||
| 1387 | .tag = V_ASN1_SET, | ||
| 1388 | .offset = 0, | ||
| 1389 | .field_name = "CMS_ATTRIBUTES", | ||
| 1390 | .item = &X509_ATTRIBUTE_it, | ||
| 1391 | }; | ||
| 1392 | |||
| 1393 | const ASN1_ITEM CMS_Attributes_Verify_it = { | ||
| 1394 | .itype = ASN1_ITYPE_PRIMITIVE, | ||
| 1395 | .utype = -1, | ||
| 1396 | .templates = &CMS_Attributes_Verify_item_tt, | ||
| 1397 | .tcount = 0, | ||
| 1398 | .funcs = NULL, | ||
| 1399 | .size = 0, | ||
| 1400 | .sname = "CMS_Attributes_Verify", | ||
| 1401 | }; | ||
| 1402 | |||
| 1403 | static const ASN1_TEMPLATE CMS_ReceiptsFrom_ch_tt[] = { | ||
| 1404 | { | ||
| 1405 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 1406 | .tag = 0, | ||
| 1407 | .offset = offsetof(CMS_ReceiptsFrom, d.allOrFirstTier), | ||
| 1408 | .field_name = "d.allOrFirstTier", | ||
| 1409 | .item = &LONG_it, | ||
| 1410 | }, | ||
| 1411 | { | ||
| 1412 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SEQUENCE_OF, | ||
| 1413 | .tag = 1, | ||
| 1414 | .offset = offsetof(CMS_ReceiptsFrom, d.receiptList), | ||
| 1415 | .field_name = "d.receiptList", | ||
| 1416 | .item = &GENERAL_NAMES_it, | ||
| 1417 | }, | ||
| 1418 | }; | ||
| 1419 | |||
| 1420 | const ASN1_ITEM CMS_ReceiptsFrom_it = { | ||
| 1421 | .itype = ASN1_ITYPE_CHOICE, | ||
| 1422 | .utype = offsetof(CMS_ReceiptsFrom, type), | ||
| 1423 | .templates = CMS_ReceiptsFrom_ch_tt, | ||
| 1424 | .tcount = sizeof(CMS_ReceiptsFrom_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
| 1425 | .funcs = NULL, | ||
| 1426 | .size = sizeof(CMS_ReceiptsFrom), | ||
| 1427 | .sname = "CMS_ReceiptsFrom", | ||
| 1428 | }; | ||
| 1429 | |||
| 1430 | static const ASN1_TEMPLATE CMS_ReceiptRequest_seq_tt[] = { | ||
| 1431 | { | ||
| 1432 | .flags = 0, | ||
| 1433 | .tag = 0, | ||
| 1434 | .offset = offsetof(CMS_ReceiptRequest, signedContentIdentifier), | ||
| 1435 | .field_name = "signedContentIdentifier", | ||
| 1436 | .item = &ASN1_OCTET_STRING_it, | ||
| 1437 | }, | ||
| 1438 | { | ||
| 1439 | .flags = 0, | ||
| 1440 | .tag = 0, | ||
| 1441 | .offset = offsetof(CMS_ReceiptRequest, receiptsFrom), | ||
| 1442 | .field_name = "receiptsFrom", | ||
| 1443 | .item = &CMS_ReceiptsFrom_it, | ||
| 1444 | }, | ||
| 1445 | { | ||
| 1446 | .flags = ASN1_TFLG_SEQUENCE_OF, | ||
| 1447 | .tag = 0, | ||
| 1448 | .offset = offsetof(CMS_ReceiptRequest, receiptsTo), | ||
| 1449 | .field_name = "receiptsTo", | ||
| 1450 | .item = &GENERAL_NAMES_it, | ||
| 1451 | }, | ||
| 1452 | }; | ||
| 1453 | |||
| 1454 | const ASN1_ITEM CMS_ReceiptRequest_it = { | ||
| 1455 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 1456 | .utype = V_ASN1_SEQUENCE, | ||
| 1457 | .templates = CMS_ReceiptRequest_seq_tt, | ||
| 1458 | .tcount = sizeof(CMS_ReceiptRequest_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 1459 | .funcs = NULL, | ||
| 1460 | .size = sizeof(CMS_ReceiptRequest), | ||
| 1461 | .sname = "CMS_ReceiptRequest", | ||
| 1462 | }; | ||
| 1463 | |||
| 1464 | static const ASN1_TEMPLATE CMS_Receipt_seq_tt[] = { | ||
| 1465 | { | ||
| 1466 | .flags = 0, | ||
| 1467 | .tag = 0, | ||
| 1468 | .offset = offsetof(CMS_Receipt, version), | ||
| 1469 | .field_name = "version", | ||
| 1470 | .item = &LONG_it, | ||
| 1471 | }, | ||
| 1472 | { | ||
| 1473 | .flags = 0, | ||
| 1474 | .tag = 0, | ||
| 1475 | .offset = offsetof(CMS_Receipt, contentType), | ||
| 1476 | .field_name = "contentType", | ||
| 1477 | .item = &ASN1_OBJECT_it, | ||
| 1478 | }, | ||
| 1479 | { | ||
| 1480 | .flags = 0, | ||
| 1481 | .tag = 0, | ||
| 1482 | .offset = offsetof(CMS_Receipt, signedContentIdentifier), | ||
| 1483 | .field_name = "signedContentIdentifier", | ||
| 1484 | .item = &ASN1_OCTET_STRING_it, | ||
| 1485 | }, | ||
| 1486 | { | ||
| 1487 | .flags = 0, | ||
| 1488 | .tag = 0, | ||
| 1489 | .offset = offsetof(CMS_Receipt, originatorSignatureValue), | ||
| 1490 | .field_name = "originatorSignatureValue", | ||
| 1491 | .item = &ASN1_OCTET_STRING_it, | ||
| 1492 | }, | ||
| 1493 | }; | ||
| 1494 | |||
| 1495 | const ASN1_ITEM CMS_Receipt_it = { | ||
| 1496 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 1497 | .utype = V_ASN1_SEQUENCE, | ||
| 1498 | .templates = CMS_Receipt_seq_tt, | ||
| 1499 | .tcount = sizeof(CMS_Receipt_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 1500 | .funcs = NULL, | ||
| 1501 | .size = sizeof(CMS_Receipt), | ||
| 1502 | .sname = "CMS_Receipt", | ||
| 1503 | }; | ||
