diff options
| author | cvs2svn <admin@example.com> | 2015-03-08 16:48:48 +0000 |
|---|---|---|
| committer | cvs2svn <admin@example.com> | 2015-03-08 16:48:48 +0000 |
| commit | da1a9ad3a4a867ba6569c05e6fca66d7f296c553 (patch) | |
| tree | 44872802e872bdfd60730fa9cf01d9d5751251c1 /src/lib/libcrypto/pkcs7/pk7_asn1.c | |
| parent | 973703db67a8e73d70e63afa8f2cde19da09144d (diff) | |
| download | openbsd-OPENBSD_5_7_BASE.tar.gz openbsd-OPENBSD_5_7_BASE.tar.bz2 openbsd-OPENBSD_5_7_BASE.zip | |
This commit was manufactured by cvs2git to create tag 'OPENBSD_5_7_BASE'.OPENBSD_5_7_BASE
Diffstat (limited to 'src/lib/libcrypto/pkcs7/pk7_asn1.c')
| -rw-r--r-- | src/lib/libcrypto/pkcs7/pk7_asn1.c | 512 |
1 files changed, 0 insertions, 512 deletions
diff --git a/src/lib/libcrypto/pkcs7/pk7_asn1.c b/src/lib/libcrypto/pkcs7/pk7_asn1.c deleted file mode 100644 index 2699ace988..0000000000 --- a/src/lib/libcrypto/pkcs7/pk7_asn1.c +++ /dev/null | |||
| @@ -1,512 +0,0 @@ | |||
| 1 | /* $OpenBSD: pk7_asn1.c,v 1.11 2015/02/10 06:37:38 jsing Exp $ */ | ||
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | ||
| 3 | * project 2000. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 2000 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 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | |||
| 61 | #include <openssl/asn1t.h> | ||
| 62 | #include <openssl/pkcs7.h> | ||
| 63 | #include <openssl/x509.h> | ||
| 64 | |||
| 65 | /* PKCS#7 ASN1 module */ | ||
| 66 | |||
| 67 | /* This is the ANY DEFINED BY table for the top level PKCS#7 structure */ | ||
| 68 | |||
| 69 | ASN1_ADB_TEMPLATE(p7default) = ASN1_EXP_OPT(PKCS7, d.other, ASN1_ANY, 0); | ||
| 70 | |||
| 71 | ASN1_ADB(PKCS7) = { | ||
| 72 | ADB_ENTRY(NID_pkcs7_data, | ||
| 73 | ASN1_NDEF_EXP_OPT(PKCS7, d.data, ASN1_OCTET_STRING_NDEF, 0)), | ||
| 74 | ADB_ENTRY(NID_pkcs7_signed, | ||
| 75 | ASN1_NDEF_EXP_OPT(PKCS7, d.sign, PKCS7_SIGNED, 0)), | ||
| 76 | ADB_ENTRY(NID_pkcs7_enveloped, | ||
| 77 | ASN1_NDEF_EXP_OPT(PKCS7, d.enveloped, PKCS7_ENVELOPE, 0)), | ||
| 78 | ADB_ENTRY(NID_pkcs7_signedAndEnveloped, | ||
| 79 | ASN1_NDEF_EXP_OPT(PKCS7, d.signed_and_enveloped, | ||
| 80 | PKCS7_SIGN_ENVELOPE, 0)), | ||
| 81 | ADB_ENTRY(NID_pkcs7_digest, | ||
| 82 | ASN1_NDEF_EXP_OPT(PKCS7, d.digest, PKCS7_DIGEST, 0)), | ||
| 83 | ADB_ENTRY(NID_pkcs7_encrypted, | ||
| 84 | ASN1_NDEF_EXP_OPT(PKCS7, d.encrypted, PKCS7_ENCRYPT, 0)) | ||
| 85 | } ASN1_ADB_END(PKCS7, 0, type, 0, &p7default_tt, NULL); | ||
| 86 | |||
| 87 | /* PKCS#7 streaming support */ | ||
| 88 | static int | ||
| 89 | pk7_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | ||
| 90 | { | ||
| 91 | ASN1_STREAM_ARG *sarg = exarg; | ||
| 92 | PKCS7 **pp7 = (PKCS7 **)pval; | ||
| 93 | |||
| 94 | switch (operation) { | ||
| 95 | case ASN1_OP_STREAM_PRE: | ||
| 96 | if (PKCS7_stream(&sarg->boundary, *pp7) <= 0) | ||
| 97 | return 0; | ||
| 98 | |||
| 99 | case ASN1_OP_DETACHED_PRE: | ||
| 100 | sarg->ndef_bio = PKCS7_dataInit(*pp7, sarg->out); | ||
| 101 | if (!sarg->ndef_bio) | ||
| 102 | return 0; | ||
| 103 | break; | ||
| 104 | |||
| 105 | case ASN1_OP_STREAM_POST: | ||
| 106 | case ASN1_OP_DETACHED_POST: | ||
| 107 | if (PKCS7_dataFinal(*pp7, sarg->ndef_bio) <= 0) | ||
| 108 | return 0; | ||
| 109 | break; | ||
| 110 | } | ||
| 111 | return 1; | ||
| 112 | } | ||
| 113 | |||
| 114 | ASN1_NDEF_SEQUENCE_cb(PKCS7, pk7_cb) = { | ||
| 115 | ASN1_SIMPLE(PKCS7, type, ASN1_OBJECT), | ||
| 116 | ASN1_ADB_OBJECT(PKCS7) | ||
| 117 | }ASN1_NDEF_SEQUENCE_END_cb(PKCS7, PKCS7) | ||
| 118 | |||
| 119 | |||
| 120 | PKCS7 * | ||
| 121 | d2i_PKCS7(PKCS7 **a, const unsigned char **in, long len) | ||
| 122 | { | ||
| 123 | return (PKCS7 *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, | ||
| 124 | &PKCS7_it); | ||
| 125 | } | ||
| 126 | |||
| 127 | int | ||
| 128 | i2d_PKCS7(PKCS7 *a, unsigned char **out) | ||
| 129 | { | ||
| 130 | return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_it); | ||
| 131 | } | ||
| 132 | |||
| 133 | PKCS7 * | ||
| 134 | PKCS7_new(void) | ||
| 135 | { | ||
| 136 | return (PKCS7 *)ASN1_item_new(&PKCS7_it); | ||
| 137 | } | ||
| 138 | |||
| 139 | void | ||
| 140 | PKCS7_free(PKCS7 *a) | ||
| 141 | { | ||
| 142 | ASN1_item_free((ASN1_VALUE *)a, &PKCS7_it); | ||
| 143 | } | ||
| 144 | |||
| 145 | int | ||
| 146 | i2d_PKCS7_NDEF(PKCS7 *a, unsigned char **out) | ||
| 147 | { | ||
| 148 | return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, &PKCS7_it); | ||
| 149 | } | ||
| 150 | |||
| 151 | PKCS7 * | ||
| 152 | PKCS7_dup(PKCS7 *x) | ||
| 153 | { | ||
| 154 | return ASN1_item_dup(&PKCS7_it, x); | ||
| 155 | } | ||
| 156 | |||
| 157 | ASN1_NDEF_SEQUENCE(PKCS7_SIGNED) = { | ||
| 158 | ASN1_SIMPLE(PKCS7_SIGNED, version, ASN1_INTEGER), | ||
| 159 | ASN1_SET_OF(PKCS7_SIGNED, md_algs, X509_ALGOR), | ||
| 160 | ASN1_SIMPLE(PKCS7_SIGNED, contents, PKCS7), | ||
| 161 | ASN1_IMP_SEQUENCE_OF_OPT(PKCS7_SIGNED, cert, X509, 0), | ||
| 162 | ASN1_IMP_SET_OF_OPT(PKCS7_SIGNED, crl, X509_CRL, 1), | ||
| 163 | ASN1_SET_OF(PKCS7_SIGNED, signer_info, PKCS7_SIGNER_INFO) | ||
| 164 | } ASN1_NDEF_SEQUENCE_END(PKCS7_SIGNED) | ||
| 165 | |||
| 166 | |||
| 167 | PKCS7_SIGNED * | ||
| 168 | d2i_PKCS7_SIGNED(PKCS7_SIGNED **a, const unsigned char **in, long len) | ||
| 169 | { | ||
| 170 | return (PKCS7_SIGNED *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, | ||
| 171 | &PKCS7_SIGNED_it); | ||
| 172 | } | ||
| 173 | |||
| 174 | int | ||
| 175 | i2d_PKCS7_SIGNED(PKCS7_SIGNED *a, unsigned char **out) | ||
| 176 | { | ||
| 177 | return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_SIGNED_it); | ||
| 178 | } | ||
| 179 | |||
| 180 | PKCS7_SIGNED * | ||
| 181 | PKCS7_SIGNED_new(void) | ||
| 182 | { | ||
| 183 | return (PKCS7_SIGNED *)ASN1_item_new(&PKCS7_SIGNED_it); | ||
| 184 | } | ||
| 185 | |||
| 186 | void | ||
| 187 | PKCS7_SIGNED_free(PKCS7_SIGNED *a) | ||
| 188 | { | ||
| 189 | ASN1_item_free((ASN1_VALUE *)a, &PKCS7_SIGNED_it); | ||
| 190 | } | ||
| 191 | |||
| 192 | /* Minor tweak to operation: free up EVP_PKEY */ | ||
| 193 | static int | ||
| 194 | si_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | ||
| 195 | { | ||
| 196 | if (operation == ASN1_OP_FREE_POST) { | ||
| 197 | PKCS7_SIGNER_INFO *si = (PKCS7_SIGNER_INFO *)*pval; | ||
| 198 | EVP_PKEY_free(si->pkey); | ||
| 199 | } | ||
| 200 | return 1; | ||
| 201 | } | ||
| 202 | |||
| 203 | ASN1_SEQUENCE_cb(PKCS7_SIGNER_INFO, si_cb) = { | ||
| 204 | ASN1_SIMPLE(PKCS7_SIGNER_INFO, version, ASN1_INTEGER), | ||
| 205 | ASN1_SIMPLE(PKCS7_SIGNER_INFO, issuer_and_serial, | ||
| 206 | PKCS7_ISSUER_AND_SERIAL), | ||
| 207 | ASN1_SIMPLE(PKCS7_SIGNER_INFO, digest_alg, X509_ALGOR), | ||
| 208 | /* NB this should be a SET OF but we use a SEQUENCE OF so the | ||
| 209 | * original order * is retained when the structure is reencoded. | ||
| 210 | * Since the attributes are implicitly tagged this will not affect | ||
| 211 | * the encoding. | ||
| 212 | */ | ||
| 213 | ASN1_IMP_SEQUENCE_OF_OPT(PKCS7_SIGNER_INFO, auth_attr, | ||
| 214 | X509_ATTRIBUTE, 0), | ||
| 215 | ASN1_SIMPLE(PKCS7_SIGNER_INFO, digest_enc_alg, X509_ALGOR), | ||
| 216 | ASN1_SIMPLE(PKCS7_SIGNER_INFO, enc_digest, ASN1_OCTET_STRING), | ||
| 217 | ASN1_IMP_SET_OF_OPT(PKCS7_SIGNER_INFO, unauth_attr, X509_ATTRIBUTE, 1) | ||
| 218 | } ASN1_SEQUENCE_END_cb(PKCS7_SIGNER_INFO, PKCS7_SIGNER_INFO) | ||
| 219 | |||
| 220 | |||
| 221 | PKCS7_SIGNER_INFO * | ||
| 222 | d2i_PKCS7_SIGNER_INFO(PKCS7_SIGNER_INFO **a, const unsigned char **in, long len) | ||
| 223 | { | ||
| 224 | return (PKCS7_SIGNER_INFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, | ||
| 225 | &PKCS7_SIGNER_INFO_it); | ||
| 226 | } | ||
| 227 | |||
| 228 | int | ||
| 229 | i2d_PKCS7_SIGNER_INFO(PKCS7_SIGNER_INFO *a, unsigned char **out) | ||
| 230 | { | ||
| 231 | return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_SIGNER_INFO_it); | ||
| 232 | } | ||
| 233 | |||
| 234 | PKCS7_SIGNER_INFO * | ||
| 235 | PKCS7_SIGNER_INFO_new(void) | ||
| 236 | { | ||
| 237 | return (PKCS7_SIGNER_INFO *)ASN1_item_new(&PKCS7_SIGNER_INFO_it); | ||
| 238 | } | ||
| 239 | |||
| 240 | void | ||
| 241 | PKCS7_SIGNER_INFO_free(PKCS7_SIGNER_INFO *a) | ||
| 242 | { | ||
| 243 | ASN1_item_free((ASN1_VALUE *)a, &PKCS7_SIGNER_INFO_it); | ||
| 244 | } | ||
| 245 | |||
| 246 | ASN1_SEQUENCE(PKCS7_ISSUER_AND_SERIAL) = { | ||
| 247 | ASN1_SIMPLE(PKCS7_ISSUER_AND_SERIAL, issuer, X509_NAME), | ||
| 248 | ASN1_SIMPLE(PKCS7_ISSUER_AND_SERIAL, serial, ASN1_INTEGER) | ||
| 249 | } ASN1_SEQUENCE_END(PKCS7_ISSUER_AND_SERIAL) | ||
| 250 | |||
| 251 | |||
| 252 | PKCS7_ISSUER_AND_SERIAL * | ||
| 253 | d2i_PKCS7_ISSUER_AND_SERIAL(PKCS7_ISSUER_AND_SERIAL **a, const unsigned char **in, long len) | ||
| 254 | { | ||
| 255 | return (PKCS7_ISSUER_AND_SERIAL *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, | ||
| 256 | &PKCS7_ISSUER_AND_SERIAL_it); | ||
| 257 | } | ||
| 258 | |||
| 259 | int | ||
| 260 | i2d_PKCS7_ISSUER_AND_SERIAL(PKCS7_ISSUER_AND_SERIAL *a, unsigned char **out) | ||
| 261 | { | ||
| 262 | return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_ISSUER_AND_SERIAL_it); | ||
| 263 | } | ||
| 264 | |||
| 265 | PKCS7_ISSUER_AND_SERIAL * | ||
| 266 | PKCS7_ISSUER_AND_SERIAL_new(void) | ||
| 267 | { | ||
| 268 | return (PKCS7_ISSUER_AND_SERIAL *)ASN1_item_new(&PKCS7_ISSUER_AND_SERIAL_it); | ||
| 269 | } | ||
| 270 | |||
| 271 | void | ||
| 272 | PKCS7_ISSUER_AND_SERIAL_free(PKCS7_ISSUER_AND_SERIAL *a) | ||
| 273 | { | ||
| 274 | ASN1_item_free((ASN1_VALUE *)a, &PKCS7_ISSUER_AND_SERIAL_it); | ||
| 275 | } | ||
| 276 | |||
| 277 | ASN1_NDEF_SEQUENCE(PKCS7_ENVELOPE) = { | ||
| 278 | ASN1_SIMPLE(PKCS7_ENVELOPE, version, ASN1_INTEGER), | ||
| 279 | ASN1_SET_OF(PKCS7_ENVELOPE, recipientinfo, PKCS7_RECIP_INFO), | ||
| 280 | ASN1_SIMPLE(PKCS7_ENVELOPE, enc_data, PKCS7_ENC_CONTENT) | ||
| 281 | } ASN1_NDEF_SEQUENCE_END(PKCS7_ENVELOPE) | ||
| 282 | |||
| 283 | |||
| 284 | PKCS7_ENVELOPE * | ||
| 285 | d2i_PKCS7_ENVELOPE(PKCS7_ENVELOPE **a, const unsigned char **in, long len) | ||
| 286 | { | ||
| 287 | return (PKCS7_ENVELOPE *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, | ||
| 288 | &PKCS7_ENVELOPE_it); | ||
| 289 | } | ||
| 290 | |||
| 291 | int | ||
| 292 | i2d_PKCS7_ENVELOPE(PKCS7_ENVELOPE *a, unsigned char **out) | ||
| 293 | { | ||
| 294 | return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_ENVELOPE_it); | ||
| 295 | } | ||
| 296 | |||
| 297 | PKCS7_ENVELOPE * | ||
| 298 | PKCS7_ENVELOPE_new(void) | ||
| 299 | { | ||
| 300 | return (PKCS7_ENVELOPE *)ASN1_item_new(&PKCS7_ENVELOPE_it); | ||
| 301 | } | ||
| 302 | |||
| 303 | void | ||
| 304 | PKCS7_ENVELOPE_free(PKCS7_ENVELOPE *a) | ||
| 305 | { | ||
| 306 | ASN1_item_free((ASN1_VALUE *)a, &PKCS7_ENVELOPE_it); | ||
| 307 | } | ||
| 308 | |||
| 309 | /* Minor tweak to operation: free up X509 */ | ||
| 310 | static int | ||
| 311 | ri_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | ||
| 312 | { | ||
| 313 | if (operation == ASN1_OP_FREE_POST) { | ||
| 314 | PKCS7_RECIP_INFO *ri = (PKCS7_RECIP_INFO *)*pval; | ||
| 315 | X509_free(ri->cert); | ||
| 316 | } | ||
| 317 | return 1; | ||
| 318 | } | ||
| 319 | |||
| 320 | ASN1_SEQUENCE_cb(PKCS7_RECIP_INFO, ri_cb) = { | ||
| 321 | ASN1_SIMPLE(PKCS7_RECIP_INFO, version, ASN1_INTEGER), | ||
| 322 | ASN1_SIMPLE(PKCS7_RECIP_INFO, issuer_and_serial, | ||
| 323 | PKCS7_ISSUER_AND_SERIAL), | ||
| 324 | ASN1_SIMPLE(PKCS7_RECIP_INFO, key_enc_algor, X509_ALGOR), | ||
| 325 | ASN1_SIMPLE(PKCS7_RECIP_INFO, enc_key, ASN1_OCTET_STRING) | ||
| 326 | } ASN1_SEQUENCE_END_cb(PKCS7_RECIP_INFO, PKCS7_RECIP_INFO) | ||
| 327 | |||
| 328 | |||
| 329 | PKCS7_RECIP_INFO * | ||
| 330 | d2i_PKCS7_RECIP_INFO(PKCS7_RECIP_INFO **a, const unsigned char **in, long len) | ||
| 331 | { | ||
| 332 | return (PKCS7_RECIP_INFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, | ||
| 333 | &PKCS7_RECIP_INFO_it); | ||
| 334 | } | ||
| 335 | |||
| 336 | int | ||
| 337 | i2d_PKCS7_RECIP_INFO(PKCS7_RECIP_INFO *a, unsigned char **out) | ||
| 338 | { | ||
| 339 | return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_RECIP_INFO_it); | ||
| 340 | } | ||
| 341 | |||
| 342 | PKCS7_RECIP_INFO * | ||
| 343 | PKCS7_RECIP_INFO_new(void) | ||
| 344 | { | ||
| 345 | return (PKCS7_RECIP_INFO *)ASN1_item_new(&PKCS7_RECIP_INFO_it); | ||
| 346 | } | ||
| 347 | |||
| 348 | void | ||
| 349 | PKCS7_RECIP_INFO_free(PKCS7_RECIP_INFO *a) | ||
| 350 | { | ||
| 351 | ASN1_item_free((ASN1_VALUE *)a, &PKCS7_RECIP_INFO_it); | ||
| 352 | } | ||
| 353 | |||
| 354 | ASN1_NDEF_SEQUENCE(PKCS7_ENC_CONTENT) = { | ||
| 355 | ASN1_SIMPLE(PKCS7_ENC_CONTENT, content_type, ASN1_OBJECT), | ||
| 356 | ASN1_SIMPLE(PKCS7_ENC_CONTENT, algorithm, X509_ALGOR), | ||
| 357 | ASN1_IMP_OPT(PKCS7_ENC_CONTENT, enc_data, ASN1_OCTET_STRING_NDEF, 0) | ||
| 358 | } ASN1_NDEF_SEQUENCE_END(PKCS7_ENC_CONTENT) | ||
| 359 | |||
| 360 | |||
| 361 | PKCS7_ENC_CONTENT * | ||
| 362 | d2i_PKCS7_ENC_CONTENT(PKCS7_ENC_CONTENT **a, const unsigned char **in, long len) | ||
| 363 | { | ||
| 364 | return (PKCS7_ENC_CONTENT *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, | ||
| 365 | &PKCS7_ENC_CONTENT_it); | ||
| 366 | } | ||
| 367 | |||
| 368 | int | ||
| 369 | i2d_PKCS7_ENC_CONTENT(PKCS7_ENC_CONTENT *a, unsigned char **out) | ||
| 370 | { | ||
| 371 | return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_ENC_CONTENT_it); | ||
| 372 | } | ||
| 373 | |||
| 374 | PKCS7_ENC_CONTENT * | ||
| 375 | PKCS7_ENC_CONTENT_new(void) | ||
| 376 | { | ||
| 377 | return (PKCS7_ENC_CONTENT *)ASN1_item_new(&PKCS7_ENC_CONTENT_it); | ||
| 378 | } | ||
| 379 | |||
| 380 | void | ||
| 381 | PKCS7_ENC_CONTENT_free(PKCS7_ENC_CONTENT *a) | ||
| 382 | { | ||
| 383 | ASN1_item_free((ASN1_VALUE *)a, &PKCS7_ENC_CONTENT_it); | ||
| 384 | } | ||
| 385 | |||
| 386 | ASN1_NDEF_SEQUENCE(PKCS7_SIGN_ENVELOPE) = { | ||
| 387 | ASN1_SIMPLE(PKCS7_SIGN_ENVELOPE, version, ASN1_INTEGER), | ||
| 388 | ASN1_SET_OF(PKCS7_SIGN_ENVELOPE, recipientinfo, PKCS7_RECIP_INFO), | ||
| 389 | ASN1_SET_OF(PKCS7_SIGN_ENVELOPE, md_algs, X509_ALGOR), | ||
| 390 | ASN1_SIMPLE(PKCS7_SIGN_ENVELOPE, enc_data, PKCS7_ENC_CONTENT), | ||
| 391 | ASN1_IMP_SET_OF_OPT(PKCS7_SIGN_ENVELOPE, cert, X509, 0), | ||
| 392 | ASN1_IMP_SET_OF_OPT(PKCS7_SIGN_ENVELOPE, crl, X509_CRL, 1), | ||
| 393 | ASN1_SET_OF(PKCS7_SIGN_ENVELOPE, signer_info, PKCS7_SIGNER_INFO) | ||
| 394 | } ASN1_NDEF_SEQUENCE_END(PKCS7_SIGN_ENVELOPE) | ||
| 395 | |||
| 396 | |||
| 397 | PKCS7_SIGN_ENVELOPE * | ||
| 398 | d2i_PKCS7_SIGN_ENVELOPE(PKCS7_SIGN_ENVELOPE **a, const unsigned char **in, long len) | ||
| 399 | { | ||
| 400 | return (PKCS7_SIGN_ENVELOPE *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, | ||
| 401 | &PKCS7_SIGN_ENVELOPE_it); | ||
| 402 | } | ||
| 403 | |||
| 404 | int | ||
| 405 | i2d_PKCS7_SIGN_ENVELOPE(PKCS7_SIGN_ENVELOPE *a, unsigned char **out) | ||
| 406 | { | ||
| 407 | return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_SIGN_ENVELOPE_it); | ||
| 408 | } | ||
| 409 | |||
| 410 | PKCS7_SIGN_ENVELOPE * | ||
| 411 | PKCS7_SIGN_ENVELOPE_new(void) | ||
| 412 | { | ||
| 413 | return (PKCS7_SIGN_ENVELOPE *)ASN1_item_new(&PKCS7_SIGN_ENVELOPE_it); | ||
| 414 | } | ||
| 415 | |||
| 416 | void | ||
| 417 | PKCS7_SIGN_ENVELOPE_free(PKCS7_SIGN_ENVELOPE *a) | ||
| 418 | { | ||
| 419 | ASN1_item_free((ASN1_VALUE *)a, &PKCS7_SIGN_ENVELOPE_it); | ||
| 420 | } | ||
| 421 | |||
| 422 | ASN1_NDEF_SEQUENCE(PKCS7_ENCRYPT) = { | ||
| 423 | ASN1_SIMPLE(PKCS7_ENCRYPT, version, ASN1_INTEGER), | ||
| 424 | ASN1_SIMPLE(PKCS7_ENCRYPT, enc_data, PKCS7_ENC_CONTENT) | ||
| 425 | } ASN1_NDEF_SEQUENCE_END(PKCS7_ENCRYPT) | ||
| 426 | |||
| 427 | |||
| 428 | PKCS7_ENCRYPT * | ||
| 429 | d2i_PKCS7_ENCRYPT(PKCS7_ENCRYPT **a, const unsigned char **in, long len) | ||
| 430 | { | ||
| 431 | return (PKCS7_ENCRYPT *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, | ||
| 432 | &PKCS7_ENCRYPT_it); | ||
| 433 | } | ||
| 434 | |||
| 435 | int | ||
| 436 | i2d_PKCS7_ENCRYPT(PKCS7_ENCRYPT *a, unsigned char **out) | ||
| 437 | { | ||
| 438 | return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_ENCRYPT_it); | ||
| 439 | } | ||
| 440 | |||
| 441 | PKCS7_ENCRYPT * | ||
| 442 | PKCS7_ENCRYPT_new(void) | ||
| 443 | { | ||
| 444 | return (PKCS7_ENCRYPT *)ASN1_item_new(&PKCS7_ENCRYPT_it); | ||
| 445 | } | ||
| 446 | |||
| 447 | void | ||
| 448 | PKCS7_ENCRYPT_free(PKCS7_ENCRYPT *a) | ||
| 449 | { | ||
| 450 | ASN1_item_free((ASN1_VALUE *)a, &PKCS7_ENCRYPT_it); | ||
| 451 | } | ||
| 452 | |||
| 453 | ASN1_NDEF_SEQUENCE(PKCS7_DIGEST) = { | ||
| 454 | ASN1_SIMPLE(PKCS7_DIGEST, version, ASN1_INTEGER), | ||
| 455 | ASN1_SIMPLE(PKCS7_DIGEST, md, X509_ALGOR), | ||
| 456 | ASN1_SIMPLE(PKCS7_DIGEST, contents, PKCS7), | ||
| 457 | ASN1_SIMPLE(PKCS7_DIGEST, digest, ASN1_OCTET_STRING) | ||
| 458 | } ASN1_NDEF_SEQUENCE_END(PKCS7_DIGEST) | ||
| 459 | |||
| 460 | |||
| 461 | PKCS7_DIGEST * | ||
| 462 | d2i_PKCS7_DIGEST(PKCS7_DIGEST **a, const unsigned char **in, long len) | ||
| 463 | { | ||
| 464 | return (PKCS7_DIGEST *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, | ||
| 465 | &PKCS7_DIGEST_it); | ||
| 466 | } | ||
| 467 | |||
| 468 | int | ||
| 469 | i2d_PKCS7_DIGEST(PKCS7_DIGEST *a, unsigned char **out) | ||
| 470 | { | ||
| 471 | return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_DIGEST_it); | ||
| 472 | } | ||
| 473 | |||
| 474 | PKCS7_DIGEST * | ||
| 475 | PKCS7_DIGEST_new(void) | ||
| 476 | { | ||
| 477 | return (PKCS7_DIGEST *)ASN1_item_new(&PKCS7_DIGEST_it); | ||
| 478 | } | ||
| 479 | |||
| 480 | void | ||
| 481 | PKCS7_DIGEST_free(PKCS7_DIGEST *a) | ||
| 482 | { | ||
| 483 | ASN1_item_free((ASN1_VALUE *)a, &PKCS7_DIGEST_it); | ||
| 484 | } | ||
| 485 | |||
| 486 | /* Specials for authenticated attributes */ | ||
| 487 | |||
| 488 | /* When signing attributes we want to reorder them to match the sorted | ||
| 489 | * encoding. | ||
| 490 | */ | ||
| 491 | |||
| 492 | ASN1_ITEM_TEMPLATE(PKCS7_ATTR_SIGN) = | ||
| 493 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SET_ORDER, 0, PKCS7_ATTRIBUTES, | ||
| 494 | X509_ATTRIBUTE) | ||
| 495 | ASN1_ITEM_TEMPLATE_END(PKCS7_ATTR_SIGN) | ||
| 496 | |||
| 497 | /* When verifying attributes we need to use the received order. So | ||
| 498 | * we use SEQUENCE OF and tag it to SET OF | ||
| 499 | */ | ||
| 500 | |||
| 501 | ASN1_ITEM_TEMPLATE(PKCS7_ATTR_VERIFY) = | ||
| 502 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_IMPTAG | | ||
| 503 | ASN1_TFLG_UNIVERSAL, V_ASN1_SET, PKCS7_ATTRIBUTES, X509_ATTRIBUTE) | ||
| 504 | ASN1_ITEM_TEMPLATE_END(PKCS7_ATTR_VERIFY) | ||
| 505 | |||
| 506 | |||
| 507 | int | ||
| 508 | PKCS7_print_ctx(BIO *out, PKCS7 *x, int indent, const ASN1_PCTX *pctx) | ||
| 509 | { | ||
| 510 | return ASN1_item_print(out, (ASN1_VALUE *)x, indent, | ||
| 511 | &PKCS7_it, pctx); | ||
| 512 | } | ||
