1PKCS7_encrypt(3)                    OpenSSL                   PKCS7_encrypt(3)
2
3
4

NAME

6       PKCS7_encrypt - create a PKCS#7 envelopedData structure
7

SYNOPSIS

9        #include <openssl/pkcs7.h>
10
11        PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, int flags);
12

DESCRIPTION

14       PKCS7_encrypt() creates and returns a PKCS#7 envelopedData structure.
15       certs is a list of recipient certificates. in is the content to be
16       encrypted.  cipher is the symmetric cipher to use. flags is an optional
17       set of flags.
18

NOTES

20       Only RSA keys are supported in PKCS#7 and envelopedData so the
21       recipient certificates supplied to this function must all contain RSA
22       public keys, though they do not have to be signed using the RSA
23       algorithm.
24
25       EVP_des_ede3_cbc() (triple DES) is the algorithm of choice for S/MIME
26       use because most clients will support it.
27
28       Some old "export grade" clients may only support weak encryption using
29       40 or 64 bit RC2. These can be used by passing EVP_rc2_40_cbc() and
30       EVP_rc2_64_cbc() respectively.
31
32       The algorithm passed in the cipher parameter must support ASN1 encoding
33       of its parameters.
34
35       Many browsers implement a "sign and encrypt" option which is simply an
36       S/MIME envelopedData containing an S/MIME signed message. This can be
37       readily produced by storing the S/MIME signed message in a memory BIO
38       and passing it to PKCS7_encrypt().
39
40       The following flags can be passed in the flags parameter.
41
42       If the PKCS7_TEXT flag is set MIME headers for type text/plain are
43       prepended to the data.
44
45       Normally the supplied content is translated into MIME canonical format
46       (as required by the S/MIME specifications) if PKCS7_BINARY is set no
47       translation occurs. This option should be used if the supplied data is
48       in binary format otherwise the translation will corrupt it. If
49       PKCS7_BINARY is set then PKCS7_TEXT is ignored.
50
51       If the PKCS7_STREAM flag is set a partial PKCS7 structure is output
52       suitable for streaming I/O: no data is read from the BIO in.
53

NOTES

55       If the flag PKCS7_STREAM is set the returned PKCS7 structure is not
56       complete and outputting its contents via a function that does not
57       properly finalize the PKCS7 structure will give unpredictable results.
58
59       Several functions including SMIME_write_PKCS7(),
60       i2d_PKCS7_bio_stream(), PEM_write_bio_PKCS7_stream() finalize the
61       structure. Alternatively finalization can be performed by obtaining the
62       streaming ASN1 BIO directly using BIO_new_PKCS7().
63

RETURN VALUES

65       PKCS7_encrypt() returns either a PKCS7 structure or NULL if an error
66       occurred.  The error can be obtained from ERR_get_error(3).
67

SEE ALSO

69       ERR_get_error(3), PKCS7_decrypt(3)
70

HISTORY

72       PKCS7_decrypt() was added to OpenSSL 0.9.5 The PKCS7_STREAM flag was
73       first supported in OpenSSL 1.0.0.
74
75
76
771.0.2o                            2020-08-01                  PKCS7_encrypt(3)
Impressum