NAME
SMIME_write_ASN1
—
generate an S/MIME message
SYNOPSIS
#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);
DESCRIPTION
SMIME_write_ASN1
()
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:
PKCS7_REUSE_DIGEST
- 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. SMIME_BINARY
- If specified, this flag is passed through to SMIME_crlf_copy(3).
SMIME_CRLFEOL
- 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.
SMIME_DETACHED
- 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:
NID_pkcs7_enveloped
- "enveloped-data"
NID_pkcs7_signed
- "signed-receipt" if econt_nid is
NID_id_smime_ct_receipt
"signed-data" if micalg is not empty
"certs-only" if micalg is empty NID_id_smime_ct_compressedData
- "compressed-data"
SMIME_OLDMIME
- 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.
SMIME_STREAM
- Perform streaming by passing this flag through to
i2d_ASN1_bio_stream(3) and 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 flagSMIME_BINARY
is also set.
RETURN VALUES
SMIME_write_ASN1
() is intended to return 1
on success or 0 on failure.
SEE ALSO
ASN1_item_i2d_bio(3), BIO_f_base64(3), BIO_new(3), i2d_ASN1_bio_stream(3), SMIME_crlf_copy(3), SMIME_write_CMS(3), SMIME_write_PKCS7(3), X509_ALGOR_new(3)
HISTORY
SMIME_write_ASN1
() first appeared in
OpenSSL 1.0.0 and has been available since OpenBSD
4.9.
BUGS
SMIME_write_ASN1
() ignores most errors and
is likely to return 1 even after producing corrupt or incomplete output.