1109998Smarkm=pod
2109998Smarkm
3109998Smarkm=head1 NAME
4109998Smarkm
5109998SmarkmSMIME_write_PKCS7 - convert PKCS#7 structure to S/MIME format.
6109998Smarkm
7109998Smarkm=head1 SYNOPSIS
8109998Smarkm
9215697Ssimon #include <openssl/pkcs7.h>
10109998Smarkm
11215697Ssimon int SMIME_write_PKCS7(BIO *out, PKCS7 *p7, BIO *data, int flags);
12215697Ssimon
13109998Smarkm=head1 DESCRIPTION
14109998Smarkm
15109998SmarkmSMIME_write_PKCS7() adds the appropriate MIME headers to a PKCS#7
16109998Smarkmstructure to produce an S/MIME message.
17109998Smarkm
18238405SjkimB<out> is the BIO to write the data to. B<p7> is the appropriate B<PKCS7>
19238405Sjkimstructure. If streaming is enabled then the content must be supplied in the
20238405SjkimB<data> argument. B<flags> is an optional set of flags.
21109998Smarkm
22109998Smarkm=head1 NOTES
23109998Smarkm
24109998SmarkmThe following flags can be passed in the B<flags> parameter.
25109998Smarkm
26109998SmarkmIf B<PKCS7_DETACHED> is set then cleartext signing will be used,
27109998Smarkmthis option only makes sense for signedData where B<PKCS7_DETACHED>
28109998Smarkmis also set when PKCS7_sign() is also called.
29109998Smarkm
30109998SmarkmIf the B<PKCS7_TEXT> flag is set MIME headers for type B<text/plain>
31109998Smarkmare added to the content, this only makes sense if B<PKCS7_DETACHED>
32109998Smarkmis also set.
33109998Smarkm
34238405SjkimIf the B<PKCS7_STREAM> flag is set streaming is performed. This flag should
35238405Sjkimonly be set if B<PKCS7_STREAM> was also set in the previous call to
36238405SjkimPKCS7_sign() or B<PKCS7_encrypt()>.
37109998Smarkm
38238405SjkimIf cleartext signing is being used and B<PKCS7_STREAM> not set then
39160814Ssimonthe data must be read twice: once to compute the signature in PKCS7_sign()
40160814Ssimonand once to output the S/MIME message.
41160814Ssimon
42238405SjkimIf streaming is performed the content is output in BER format using indefinite
43238405Sjkimlength constructuted encoding except in the case of signed data with detached
44238405Sjkimcontent where the content is absent and DER format is used.
45238405Sjkim
46109998Smarkm=head1 BUGS
47109998Smarkm
48109998SmarkmSMIME_write_PKCS7() always base64 encodes PKCS#7 structures, there
49109998Smarkmshould be an option to disable this.
50109998Smarkm
51109998Smarkm=head1 RETURN VALUES
52109998Smarkm
53109998SmarkmSMIME_write_PKCS7() returns 1 for success or 0 for failure.
54109998Smarkm
55109998Smarkm=head1 SEE ALSO
56109998Smarkm
57109998SmarkmL<ERR_get_error(3)|ERR_get_error(3)>, L<PKCS7_sign(3)|PKCS7_sign(3)>,
58109998SmarkmL<PKCS7_verify(3)|PKCS7_verify(3)>, L<PKCS7_encrypt(3)|PKCS7_encrypt(3)>
59109998SmarkmL<PKCS7_decrypt(3)|PKCS7_decrypt(3)>
60109998Smarkm
61109998Smarkm=head1 HISTORY
62109998Smarkm
63109998SmarkmSMIME_write_PKCS7() was added to OpenSSL 0.9.5
64109998Smarkm
65109998Smarkm=cut
66