1PKCS7_ENCRYPT(3ossl)                OpenSSL               PKCS7_ENCRYPT(3ossl)
2
3
4

NAME

6       PKCS7_encrypt_ex, PKCS7_encrypt - create a PKCS#7 envelopedData
7       structure
8

SYNOPSIS

10        #include <openssl/pkcs7.h>
11
12        PKCS7 *PKCS7_encrypt_ex(STACK_OF(X509) *certs, BIO *in,
13                                const EVP_CIPHER *cipher, int flags,
14                                OSSL_LIB_CTX *libctx, const char *propq);
15        PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher,
16                             int flags);
17

DESCRIPTION

19       PKCS7_encrypt_ex() creates and returns a PKCS#7 envelopedData
20       structure.  certs is a list of recipient certificates. in is the
21       content to be encrypted. cipher is the symmetric cipher to use. flags
22       is an optional set of flags. The library context libctx and the
23       property query propq are used when retrieving algorithms from
24       providers.
25
26       Only RSA keys are supported in PKCS#7 and envelopedData so the
27       recipient certificates supplied to this function must all contain RSA
28       public keys, though they do not have to be signed using the RSA
29       algorithm.
30
31       EVP_des_ede3_cbc() (triple DES) is the algorithm of choice for S/MIME
32       use because most clients will support it.
33
34       Some old "export grade" clients may only support weak encryption using
35       40 or 64 bit RC2. These can be used by passing EVP_rc2_40_cbc() and
36       EVP_rc2_64_cbc() respectively.
37
38       The algorithm passed in the cipher parameter must support ASN1 encoding
39       of its parameters.
40
41       Many browsers implement a "sign and encrypt" option which is simply an
42       S/MIME envelopedData containing an S/MIME signed message. This can be
43       readily produced by storing the S/MIME signed message in a memory BIO
44       and passing it to PKCS7_encrypt().
45
46       The following flags can be passed in the flags parameter.
47
48       If the PKCS7_TEXT flag is set MIME headers for type text/plain are
49       prepended to the data.
50
51       Normally the supplied content is translated into MIME canonical format
52       (as required by the S/MIME specifications) if PKCS7_BINARY is set no
53       translation occurs. This option should be used if the supplied data is
54       in binary format otherwise the translation will corrupt it. If
55       PKCS7_BINARY is set then PKCS7_TEXT is ignored.
56
57       If the PKCS7_STREAM flag is set a partial PKCS7 structure is output
58       suitable for streaming I/O: no data is read from the BIO in.
59
60       If the flag PKCS7_STREAM is set the returned PKCS7 structure is not
61       complete and outputting its contents via a function that does not
62       properly finalize the PKCS7 structure will give unpredictable results.
63
64       Several functions including SMIME_write_PKCS7(),
65       i2d_PKCS7_bio_stream(), PEM_write_bio_PKCS7_stream() finalize the
66       structure. Alternatively finalization can be performed by obtaining the
67       streaming ASN1 BIO directly using BIO_new_PKCS7().
68
69       PKCS7_encrypt() is similar to PKCS7_encrypt_ex() but uses default
70       values of NULL for the library context libctx and the property query
71       propq.
72

RETURN VALUES

74       PKCS7_encrypt_ex() and PKCS7_encrypt() return either a PKCS7 structure
75       or NULL if an error occurred. The error can be obtained from
76       ERR_get_error(3).
77

SEE ALSO

79       ERR_get_error(3), PKCS7_decrypt(3)
80

HISTORY

82       The function PKCS7_encrypt_ex() was added in OpenSSL 3.0.
83
84       The PKCS7_STREAM flag was added in OpenSSL 1.0.0.
85
87       Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
88
89       Licensed under the Apache License 2.0 (the "License").  You may not use
90       this file except in compliance with the License.  You can obtain a copy
91       in the file LICENSE in the source distribution or at
92       <https://www.openssl.org/source/license.html>.
93
94
95
963.0.5                             2022-11-01              PKCS7_ENCRYPT(3ossl)
Impressum