OLD | NEW |
1 /* crypto/cms/cms_asn1.c */ | 1 /* crypto/cms/cms_asn1.c */ |
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 */ |
5 /* ==================================================================== | 5 /* ==================================================================== |
6 * Copyright (c) 2008 The OpenSSL Project. All rights reserved. | 6 * Copyright (c) 2008 The OpenSSL Project. All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 ASN1_SIMPLE(CMS_SignerIdentifier, d.issuerAndSerialNumber, CMS_IssuerAnd
SerialNumber), | 80 ASN1_SIMPLE(CMS_SignerIdentifier, d.issuerAndSerialNumber, CMS_IssuerAnd
SerialNumber), |
81 ASN1_IMP(CMS_SignerIdentifier, d.subjectKeyIdentifier, ASN1_OCTET_STRING
, 0) | 81 ASN1_IMP(CMS_SignerIdentifier, d.subjectKeyIdentifier, ASN1_OCTET_STRING
, 0) |
82 } ASN1_CHOICE_END(CMS_SignerIdentifier) | 82 } ASN1_CHOICE_END(CMS_SignerIdentifier) |
83 | 83 |
84 ASN1_NDEF_SEQUENCE(CMS_EncapsulatedContentInfo) = { | 84 ASN1_NDEF_SEQUENCE(CMS_EncapsulatedContentInfo) = { |
85 ASN1_SIMPLE(CMS_EncapsulatedContentInfo, eContentType, ASN1_OBJECT), | 85 ASN1_SIMPLE(CMS_EncapsulatedContentInfo, eContentType, ASN1_OBJECT), |
86 ASN1_NDEF_EXP_OPT(CMS_EncapsulatedContentInfo, eContent, ASN1_OCTET_STRI
NG_NDEF, 0) | 86 ASN1_NDEF_EXP_OPT(CMS_EncapsulatedContentInfo, eContent, ASN1_OCTET_STRI
NG_NDEF, 0) |
87 } ASN1_NDEF_SEQUENCE_END(CMS_EncapsulatedContentInfo) | 87 } ASN1_NDEF_SEQUENCE_END(CMS_EncapsulatedContentInfo) |
88 | 88 |
89 /* Minor tweak to operation: free up signer key, cert */ | 89 /* Minor tweak to operation: free up signer key, cert */ |
90 static int cms_si_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) | 90 static int cms_si_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, |
| 91 » » » » » » » void *exarg) |
91 { | 92 { |
92 if(operation == ASN1_OP_FREE_POST) | 93 if(operation == ASN1_OP_FREE_POST) |
93 { | 94 { |
94 CMS_SignerInfo *si = (CMS_SignerInfo *)*pval; | 95 CMS_SignerInfo *si = (CMS_SignerInfo *)*pval; |
95 if (si->pkey) | 96 if (si->pkey) |
96 EVP_PKEY_free(si->pkey); | 97 EVP_PKEY_free(si->pkey); |
97 if (si->signer) | 98 if (si->signer) |
98 X509_free(si->signer); | 99 X509_free(si->signer); |
99 } | 100 } |
100 return 1; | 101 return 1; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 ASN1_SIMPLE(CMS_PasswordRecipientInfo, keyEncryptionAlgorithm, X509_ALGO
R), | 207 ASN1_SIMPLE(CMS_PasswordRecipientInfo, keyEncryptionAlgorithm, X509_ALGO
R), |
207 ASN1_SIMPLE(CMS_PasswordRecipientInfo, encryptedKey, ASN1_OCTET_STRING) | 208 ASN1_SIMPLE(CMS_PasswordRecipientInfo, encryptedKey, ASN1_OCTET_STRING) |
208 } ASN1_SEQUENCE_END(CMS_PasswordRecipientInfo) | 209 } ASN1_SEQUENCE_END(CMS_PasswordRecipientInfo) |
209 | 210 |
210 ASN1_SEQUENCE(CMS_OtherRecipientInfo) = { | 211 ASN1_SEQUENCE(CMS_OtherRecipientInfo) = { |
211 ASN1_SIMPLE(CMS_OtherRecipientInfo, oriType, ASN1_OBJECT), | 212 ASN1_SIMPLE(CMS_OtherRecipientInfo, oriType, ASN1_OBJECT), |
212 ASN1_OPT(CMS_OtherRecipientInfo, oriValue, ASN1_ANY) | 213 ASN1_OPT(CMS_OtherRecipientInfo, oriValue, ASN1_ANY) |
213 } ASN1_SEQUENCE_END(CMS_OtherRecipientInfo) | 214 } ASN1_SEQUENCE_END(CMS_OtherRecipientInfo) |
214 | 215 |
215 /* Free up RecipientInfo additional data */ | 216 /* Free up RecipientInfo additional data */ |
216 static int cms_ri_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) | 217 static int cms_ri_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, |
| 218 » » » » » » » void *exarg) |
217 { | 219 { |
218 if(operation == ASN1_OP_FREE_PRE) | 220 if(operation == ASN1_OP_FREE_PRE) |
219 { | 221 { |
220 CMS_RecipientInfo *ri = (CMS_RecipientInfo *)*pval; | 222 CMS_RecipientInfo *ri = (CMS_RecipientInfo *)*pval; |
221 if (ri->type == CMS_RECIPINFO_TRANS) | 223 if (ri->type == CMS_RECIPINFO_TRANS) |
222 { | 224 { |
223 CMS_KeyTransRecipientInfo *ktri = ri->d.ktri; | 225 CMS_KeyTransRecipientInfo *ktri = ri->d.ktri; |
224 if (ktri->pkey) | 226 if (ktri->pkey) |
225 EVP_PKEY_free(ktri->pkey); | 227 EVP_PKEY_free(ktri->pkey); |
226 if (ktri->recip) | 228 if (ktri->recip) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 ASN1_ADB(CMS_ContentInfo) = { | 295 ASN1_ADB(CMS_ContentInfo) = { |
294 ADB_ENTRY(NID_pkcs7_data, ASN1_NDEF_EXP(CMS_ContentInfo, d.data, ASN1_OC
TET_STRING_NDEF, 0)), | 296 ADB_ENTRY(NID_pkcs7_data, ASN1_NDEF_EXP(CMS_ContentInfo, d.data, ASN1_OC
TET_STRING_NDEF, 0)), |
295 ADB_ENTRY(NID_pkcs7_signed, ASN1_NDEF_EXP(CMS_ContentInfo, d.signedData,
CMS_SignedData, 0)), | 297 ADB_ENTRY(NID_pkcs7_signed, ASN1_NDEF_EXP(CMS_ContentInfo, d.signedData,
CMS_SignedData, 0)), |
296 ADB_ENTRY(NID_pkcs7_enveloped, ASN1_NDEF_EXP(CMS_ContentInfo, d.envelope
dData, CMS_EnvelopedData, 0)), | 298 ADB_ENTRY(NID_pkcs7_enveloped, ASN1_NDEF_EXP(CMS_ContentInfo, d.envelope
dData, CMS_EnvelopedData, 0)), |
297 ADB_ENTRY(NID_pkcs7_digest, ASN1_NDEF_EXP(CMS_ContentInfo, d.digestedDat
a, CMS_DigestedData, 0)), | 299 ADB_ENTRY(NID_pkcs7_digest, ASN1_NDEF_EXP(CMS_ContentInfo, d.digestedDat
a, CMS_DigestedData, 0)), |
298 ADB_ENTRY(NID_pkcs7_encrypted, ASN1_NDEF_EXP(CMS_ContentInfo, d.encrypte
dData, CMS_EncryptedData, 0)), | 300 ADB_ENTRY(NID_pkcs7_encrypted, ASN1_NDEF_EXP(CMS_ContentInfo, d.encrypte
dData, CMS_EncryptedData, 0)), |
299 ADB_ENTRY(NID_id_smime_ct_authData, ASN1_NDEF_EXP(CMS_ContentInfo, d.aut
henticatedData, CMS_AuthenticatedData, 0)), | 301 ADB_ENTRY(NID_id_smime_ct_authData, ASN1_NDEF_EXP(CMS_ContentInfo, d.aut
henticatedData, CMS_AuthenticatedData, 0)), |
300 ADB_ENTRY(NID_id_smime_ct_compressedData, ASN1_NDEF_EXP(CMS_ContentInfo,
d.compressedData, CMS_CompressedData, 0)), | 302 ADB_ENTRY(NID_id_smime_ct_compressedData, ASN1_NDEF_EXP(CMS_ContentInfo,
d.compressedData, CMS_CompressedData, 0)), |
301 } ASN1_ADB_END(CMS_ContentInfo, 0, contentType, 0, &cms_default_tt, NULL); | 303 } ASN1_ADB_END(CMS_ContentInfo, 0, contentType, 0, &cms_default_tt, NULL); |
302 | 304 |
303 ASN1_NDEF_SEQUENCE(CMS_ContentInfo) = { | 305 /* CMS streaming support */ |
| 306 static int cms_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, |
| 307 » » » » » » » void *exarg) |
| 308 » { |
| 309 » ASN1_STREAM_ARG *sarg = exarg; |
| 310 » CMS_ContentInfo *cms = NULL; |
| 311 » if (pval) |
| 312 » » cms = (CMS_ContentInfo *)*pval; |
| 313 » else |
| 314 » » return 1; |
| 315 » switch(operation) |
| 316 » » { |
| 317 |
| 318 » » case ASN1_OP_STREAM_PRE: |
| 319 » » if (CMS_stream(&sarg->boundary, cms) <= 0) |
| 320 » » » return 0; |
| 321 » » case ASN1_OP_DETACHED_PRE: |
| 322 » » sarg->ndef_bio = CMS_dataInit(cms, sarg->out); |
| 323 » » if (!sarg->ndef_bio) |
| 324 » » » return 0; |
| 325 » » break; |
| 326 |
| 327 » » case ASN1_OP_STREAM_POST: |
| 328 » » case ASN1_OP_DETACHED_POST: |
| 329 » » if (CMS_dataFinal(cms, sarg->ndef_bio) <= 0) |
| 330 » » » return 0; |
| 331 » » break; |
| 332 |
| 333 » » } |
| 334 » return 1; |
| 335 » } |
| 336 |
| 337 ASN1_NDEF_SEQUENCE_cb(CMS_ContentInfo, cms_cb) = { |
304 ASN1_SIMPLE(CMS_ContentInfo, contentType, ASN1_OBJECT), | 338 ASN1_SIMPLE(CMS_ContentInfo, contentType, ASN1_OBJECT), |
305 ASN1_ADB_OBJECT(CMS_ContentInfo) | 339 ASN1_ADB_OBJECT(CMS_ContentInfo) |
306 } ASN1_NDEF_SEQUENCE_END(CMS_ContentInfo) | 340 } ASN1_NDEF_SEQUENCE_END_cb(CMS_ContentInfo, CMS_ContentInfo) |
307 | 341 |
308 /* Specials for signed attributes */ | 342 /* Specials for signed attributes */ |
309 | 343 |
310 /* When signing attributes we want to reorder them to match the sorted | 344 /* When signing attributes we want to reorder them to match the sorted |
311 * encoding. | 345 * encoding. |
312 */ | 346 */ |
313 | 347 |
314 ASN1_ITEM_TEMPLATE(CMS_Attributes_Sign) = | 348 ASN1_ITEM_TEMPLATE(CMS_Attributes_Sign) = |
315 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SET_ORDER, 0, CMS_ATTRIBUTES, X509_ATTRI
BUTE) | 349 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SET_ORDER, 0, CMS_ATTRIBUTES, X509_ATTRI
BUTE) |
316 ASN1_ITEM_TEMPLATE_END(CMS_Attributes_Sign) | 350 ASN1_ITEM_TEMPLATE_END(CMS_Attributes_Sign) |
(...skipping 20 matching lines...) Expand all Loading... |
337 ASN1_SEQUENCE_OF(CMS_ReceiptRequest, receiptsTo, GENERAL_NAMES) | 371 ASN1_SEQUENCE_OF(CMS_ReceiptRequest, receiptsTo, GENERAL_NAMES) |
338 } ASN1_SEQUENCE_END(CMS_ReceiptRequest) | 372 } ASN1_SEQUENCE_END(CMS_ReceiptRequest) |
339 | 373 |
340 ASN1_SEQUENCE(CMS_Receipt) = { | 374 ASN1_SEQUENCE(CMS_Receipt) = { |
341 ASN1_SIMPLE(CMS_Receipt, version, LONG), | 375 ASN1_SIMPLE(CMS_Receipt, version, LONG), |
342 ASN1_SIMPLE(CMS_Receipt, contentType, ASN1_OBJECT), | 376 ASN1_SIMPLE(CMS_Receipt, contentType, ASN1_OBJECT), |
343 ASN1_SIMPLE(CMS_Receipt, signedContentIdentifier, ASN1_OCTET_STRING), | 377 ASN1_SIMPLE(CMS_Receipt, signedContentIdentifier, ASN1_OCTET_STRING), |
344 ASN1_SIMPLE(CMS_Receipt, originatorSignatureValue, ASN1_OCTET_STRING) | 378 ASN1_SIMPLE(CMS_Receipt, originatorSignatureValue, ASN1_OCTET_STRING) |
345 } ASN1_SEQUENCE_END(CMS_Receipt) | 379 } ASN1_SEQUENCE_END(CMS_Receipt) |
346 | 380 |
OLD | NEW |