1 =pod 2 3 =head1 NAME 4 5 SMIME_write_ASN1_ex, SMIME_write_ASN1 6 - convert structure to S/MIME format 7 8 =head1 SYNOPSIS 9 10 #include <openssl/asn1.h> 11 12 int SMIME_write_ASN1_ex(BIO *out, ASN1_VALUE *val, BIO *data, int flags, 13 int ctype_nid, int econt_nid, 14 STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it, 15 OSSL_LIB_CTX *libctx, const char *propq); 16 17 int SMIME_write_ASN1(BIO *out, 18 ASN1_VALUE *val, BIO *data, int flags, int ctype_nid, int econt_nid, 19 STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it); 20 21 =head1 DESCRIPTION 22 23 SMIME_write_ASN1_ex() adds the appropriate MIME headers to an object 24 structure to produce an S/MIME message. 25 26 I<out> is the BIO to write the data to. I<value> is the appropriate ASN1_VALUE 27 structure (either CMS_ContentInfo or PKCS7). If streaming is enabled then the 28 content must be supplied via I<data>. 29 I<flags> is an optional set of flags. I<ctype_nid> is the NID of the content 30 type, I<econt_nid> is the NID of the embedded content type and I<mdalgs> is a 31 list of signed data digestAlgorithms. Valid values that can be used by the 32 ASN.1 structure I<it> are ASN1_ITEM_rptr(PKCS7) or ASN1_ITEM_rptr(CMS_ContentInfo). 33 The library context I<libctx> and the property query I<propq> are used when 34 retrieving algorithms from providers. 35 36 =head1 NOTES 37 38 The higher level functions L<SMIME_write_CMS(3)> and 39 L<SMIME_write_PKCS7(3)> should be used instead of SMIME_write_ASN1(). 40 41 The following flags can be passed in the B<flags> parameter. 42 43 If B<CMS_DETACHED> is set then cleartext signing will be used, this option only 44 makes sense for SignedData where B<CMS_DETACHED> is also set when the sign() 45 method is called. 46 47 If the B<CMS_TEXT> flag is set MIME headers for type B<text/plain> are added to 48 the content, this only makes sense if B<CMS_DETACHED> is also set. 49 50 If the B<CMS_STREAM> flag is set streaming is performed. This flag should only 51 be set if B<CMS_STREAM> was also set in the previous call to a CMS_ContentInfo 52 or PKCS7 creation function. 53 54 If cleartext signing is being used and B<CMS_STREAM> not set then the data must 55 be read twice: once to compute the signature in sign method and once to output 56 the S/MIME message. 57 58 If streaming is performed the content is output in BER format using indefinite 59 length constructed encoding except in the case of signed data with detached 60 content where the content is absent and DER format is used. 61 62 =head1 RETURN VALUES 63 64 SMIME_write_ASN1_ex() and SMIME_write_ASN1() return 1 for success or 65 0 for failure. 66 67 =head1 SEE ALSO 68 69 L<ERR_get_error(3)>, 70 L<SMIME_write_CMS(3)>, 71 L<SMIME_write_PKCS7(3)> 72 73 =head1 COPYRIGHT 74 75 Copyright 2020 The OpenSSL Project Authors. All Rights Reserved. 76 77 Licensed under the Apache License 2.0 (the "License"). You may not use 78 this file except in compliance with the License. You can obtain a copy 79 in the file LICENSE in the source distribution or at 80 L<https://www.openssl.org/source/license.html>. 81 82 =cut 83