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

NAME

6       CMS_encrypt_ex, CMS_encrypt - create a CMS envelopedData structure
7

SYNOPSIS

9        #include <openssl/cms.h>
10
11        CMS_ContentInfo *CMS_encrypt_ex(STACK_OF(X509) *certs, BIO *in,
12                                        const EVP_CIPHER *cipher, unsigned int flags,
13                                        OSSL_LIB_CTX *libctx, const char *propq);
14        CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *in,
15                                     const EVP_CIPHER *cipher, unsigned int flags);
16

DESCRIPTION

18       CMS_encrypt_ex() creates and returns a CMS EnvelopedData or
19       AuthEnvelopedData structure. certs is a list of recipient certificates.
20       in is the content to be encrypted. cipher is the symmetric cipher to
21       use.  flags is an optional set of flags. The library context libctx and
22       the property query propq are used internally when retrieving algorithms
23       from providers.
24
25       Only certificates carrying RSA, Diffie-Hellman or EC keys are supported
26       by this function.
27
28       EVP_des_ede3_cbc() (triple DES) is the algorithm of choice for S/MIME
29       use because most clients will support it.
30
31       The algorithm passed in the cipher parameter must support ASN1 encoding
32       of its parameters. If the cipher mode is GCM, then an AuthEnvelopedData
33       structure containing MAC is used. Otherwise an EnvelopedData structure
34       is used. Currently the AES variants with GCM mode are the only
35       supported AEAD algorithms.
36
37       Many browsers implement a "sign and encrypt" option which is simply an
38       S/MIME envelopedData containing an S/MIME signed message. This can be
39       readily produced by storing the S/MIME signed message in a memory BIO
40       and passing it to CMS_encrypt().
41
42       The following flags can be passed in the flags parameter.
43
44       If the CMS_TEXT flag is set MIME headers for type text/plain are
45       prepended to the data.
46
47       Normally the supplied content is translated into MIME canonical format
48       (as required by the S/MIME specifications) if CMS_BINARY is set no
49       translation occurs. This option should be used if the supplied data is
50       in binary format otherwise the translation will corrupt it. If
51       CMS_BINARY is set then CMS_TEXT is ignored.
52
53       OpenSSL will by default identify recipient certificates using issuer
54       name and serial number. If CMS_USE_KEYID is set it will use the subject
55       key identifier value instead. An error occurs if all recipient
56       certificates do not have a subject key identifier extension.
57
58       If the CMS_STREAM flag is set a partial CMS_ContentInfo structure is
59       returned suitable for streaming I/O: no data is read from the BIO in.
60
61       If the CMS_PARTIAL flag is set a partial CMS_ContentInfo structure is
62       returned to which additional recipients and attributes can be added
63       before finalization.
64
65       The data being encrypted is included in the CMS_ContentInfo structure,
66       unless CMS_DETACHED is set in which case it is omitted. This is rarely
67       used in practice and is not supported by SMIME_write_CMS().
68
69       If the flag CMS_STREAM is set the returned CMS_ContentInfo structure is
70       not complete and outputting its contents via a function that does not
71       properly finalize the CMS_ContentInfo structure will give unpredictable
72       results.
73
74       Several functions including SMIME_write_CMS(), i2d_CMS_bio_stream(),
75       PEM_write_bio_CMS_stream() finalize the structure. Alternatively
76       finalization can be performed by obtaining the streaming ASN1 BIO
77       directly using BIO_new_CMS().
78
79       The recipients specified in certs use a CMS KeyTransRecipientInfo info
80       structure. KEKRecipientInfo is also supported using the flag
81       CMS_PARTIAL and CMS_add0_recipient_key().
82
83       The parameter certs may be NULL if CMS_PARTIAL is set and recipients
84       added later using CMS_add1_recipient_cert() or
85       CMS_add0_recipient_key().
86
87       CMS_encrypt() is similar to CMS_encrypt_ex() but uses default values of
88       NULL for the library context libctx and the property query propq.
89

RETURN VALUES

91       CMS_encrypt_ex() and CMS_encrypt() return either a CMS_ContentInfo
92       structure or NULL if an error occurred. The error can be obtained from
93       ERR_get_error(3).
94

SEE ALSO

96       ERR_get_error(3), CMS_decrypt(3)
97

HISTORY

99       The function CMS_encrypt_ex() was added in OpenSSL 3.0.
100
101       The CMS_STREAM flag was first supported in OpenSSL 1.0.0.
102
104       Copyright 2008-2020 The OpenSSL Project Authors. All Rights Reserved.
105
106       Licensed under the Apache License 2.0 (the "License").  You may not use
107       this file except in compliance with the License.  You can obtain a copy
108       in the file LICENSE in the source distribution or at
109       <https://www.openssl.org/source/license.html>.
110
111
112
1133.1.1                             2023-08-31                CMS_ENCRYPT(3ossl)
Impressum