]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man3/PKCS7_encrypt.pod
Deprecate the low level Diffie-Hellman functions.
[thirdparty/openssl.git] / doc / man3 / PKCS7_encrypt.pod
CommitLineData
4e1b50e2
DSH
1=pod
2
3=head1 NAME
4
5PKCS7_encrypt - create a PKCS#7 envelopedData structure
6
7=head1 SYNOPSIS
8
c264592d
UM
9 #include <openssl/pkcs7.h>
10
e9b77246
BB
11 PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher,
12 int flags);
4e1b50e2
DSH
13
14=head1 DESCRIPTION
15
16PKCS7_encrypt() creates and returns a PKCS#7 envelopedData structure. B<certs>
17is a list of recipient certificates. B<in> is the content to be encrypted.
18B<cipher> is the symmetric cipher to use. B<flags> is an optional set of flags.
19
4cfb986f
DSH
20Only RSA keys are supported in PKCS#7 and envelopedData so the recipient
21certificates supplied to this function must all contain RSA public keys, though
22they do not have to be signed using the RSA algorithm.
4e1b50e2 23
4cfb986f
DSH
24EVP_des_ede3_cbc() (triple DES) is the algorithm of choice for S/MIME use
25because most clients will support it.
4e1b50e2 26
4cfb986f
DSH
27Some old "export grade" clients may only support weak encryption using 40 or 64
28bit RC2. These can be used by passing EVP_rc2_40_cbc() and EVP_rc2_64_cbc()
29respectively.
4e1b50e2 30
4cfb986f 31The algorithm passed in the B<cipher> parameter must support ASN1 encoding of
1bc74519 32its parameters.
4e1b50e2 33
4cfb986f 34Many browsers implement a "sign and encrypt" option which is simply an S/MIME
ec8ad2bb
DSH
35envelopedData containing an S/MIME signed message. This can be readily produced
36by storing the S/MIME signed message in a memory BIO and passing it to
37PKCS7_encrypt().
38
4e1b50e2
DSH
39The following flags can be passed in the B<flags> parameter.
40
4cfb986f
DSH
41If the B<PKCS7_TEXT> flag is set MIME headers for type B<text/plain> are
42prepended to the data.
4e1b50e2 43
4cfb986f
DSH
44Normally the supplied content is translated into MIME canonical format (as
45required by the S/MIME specifications) if B<PKCS7_BINARY> is set no translation
46occurs. This option should be used if the supplied data is in binary format
47otherwise the translation will corrupt it. If B<PKCS7_BINARY> is set then
48B<PKCS7_TEXT> is ignored.
4e1b50e2 49
4cfb986f
DSH
50If the B<PKCS7_STREAM> flag is set a partial B<PKCS7> structure is output
51suitable for streaming I/O: no data is read from the BIO B<in>.
4e1b50e2 52
4cfb986f
DSH
53If the flag B<PKCS7_STREAM> is set the returned B<PKCS7> structure is B<not>
54complete and outputting its contents via a function that does not
1bc74519 55properly finalize the B<PKCS7> structure will give unpredictable
4cfb986f 56results.
4e1b50e2 57
9034c56c 58Several functions including SMIME_write_PKCS7(), i2d_PKCS7_bio_stream(),
4cfb986f
DSH
59PEM_write_bio_PKCS7_stream() finalize the structure. Alternatively finalization
60can be performed by obtaining the streaming ASN1 B<BIO> directly using
61BIO_new_PKCS7().
4e1b50e2 62
4cfb986f
DSH
63=head1 RETURN VALUES
64
65PKCS7_encrypt() returns either a PKCS7 structure or NULL if an error occurred.
66The error can be obtained from ERR_get_error(3).
4e1b50e2
DSH
67
68=head1 SEE ALSO
69
9b86974e 70L<ERR_get_error(3)>, L<PKCS7_decrypt(3)>
4e1b50e2
DSH
71
72=head1 HISTORY
73
a528d4f0 74The B<PKCS7_STREAM> flag was added in OpenSSL 1.0.0.
4e1b50e2 75
e2f92610
RS
76=head1 COPYRIGHT
77
78Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
79
4746f25a 80Licensed under the Apache License 2.0 (the "License"). You may not use
e2f92610
RS
81this file except in compliance with the License. You can obtain a copy
82in the file LICENSE in the source distribution or at
83L<https://www.openssl.org/source/license.html>.
84
85=cut