OpenBSD manual page server

Manual Page Search Parameters

SMIME_WRITE_ASN1(3) Library Functions Manual SMIME_WRITE_ASN1(3)

SMIME_write_ASN1generate an S/MIME message

#include <openssl/asn1.h>

int
SMIME_write_ASN1(BIO *out_bio, ASN1_VALUE *val_in, BIO *in_bio, int flags, int ctype_nid, int econt_nid, STACK_OF(X509_ALGOR) *micalg, const ASN1_ITEM *it);

() generates an S/MIME message on out_bio by writing MIME 1.0 headers followed by a BER- and base64-encoded serialization of val_in, which can be of the type CMS_ContentInfo or PKCS7 and has to match the it argument.

The flags can be the logical OR of zero or more of the following bits:

Skip the calls to PKCS7_dataInit(3) and PKCS7_dataFinal(3). This flag has no effect unless SMIME_DETACHED is also set. It is normally used if out_bio is already set up to calculate and finalize the digest when written through.
If specified, this flag is passed through to SMIME_crlf_copy(3).
End MIME header lines with pairs of carriage return and newline characters. By default, no carriage return characters are written and header lines are ended with newline characters only.
Use cleartext signing. Generate a "multipart/signed" S/MIME message using the micalg argument and ignoring the ctype_nid and econt_nid arguments. The content is read from in_bio. If in_bio is a NULL pointer, this flag is ignored.

If this flag is ignored or not specified, the smime-type is chosen according to ctype_nid instead:

"enveloped-data"
"signed-receipt" if econt_nid is NID_id_smime_ct_receipt
"signed-data" if micalg is not empty
"certs-only" if micalg is empty
"compressed-data"
In Content-Type headers, use "application/x-pkcs7-mime" or "application/x-pkcs7-signature". By default, "application/pkcs7-mime" or "application/pkcs7-signature" are used instead.
Perform streaming by reading the content from in_bio. This only works if SMIME_DETACHED is not specified.
SMIME_TEXT
Prepend the line "Content-Type: text/plain" to the content. This only makes sense if SMIME_DETACHED is also set. It is ignored if the flag SMIME_BINARY is also set.

SMIME_write_ASN1() is intended to return 1 on success or 0 on failure.

ASN1_item_i2d_bio(3), BIO_f_base64(3), BIO_new(3), SMIME_crlf_copy(3), SMIME_write_CMS(3), SMIME_write_PKCS7(3), X509_ALGOR_new(3)

SMIME_write_ASN1() first appeared in OpenSSL 1.0.0 and has been available since OpenBSD 4.9.

SMIME_write_ASN1() ignores most errors and is likely to return 1 even after producing corrupt or incomplete output.

May 1, 2023 OpenBSD-current