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

NAME

6       CMS_encrypt - create a CMS envelopedData structure
7

SYNOPSIS

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

DESCRIPTION

15       CMS_encrypt() creates and returns a CMS EnvelopedData structure. certs
16       is a list of recipient certificates. in is the content to be encrypted.
17       cipher is the symmetric cipher to use. flags is an optional set of
18       flags.
19

NOTES

21       Only certificates carrying RSA, Diffie-Hellman or EC keys are supported
22       by this function.
23
24       EVP_des_ede3_cbc() (triple DES) is the algorithm of choice for S/MIME
25       use because most clients will support it.
26
27       The algorithm passed in the cipher parameter must support ASN1 encoding
28       of its parameters.
29
30       Many browsers implement a "sign and encrypt" option which is simply an
31       S/MIME envelopedData containing an S/MIME signed message. This can be
32       readily produced by storing the S/MIME signed message in a memory BIO
33       and passing it to CMS_encrypt().
34
35       The following flags can be passed in the flags parameter.
36
37       If the CMS_TEXT flag is set MIME headers for type text/plain are
38       prepended to the data.
39
40       Normally the supplied content is translated into MIME canonical format
41       (as required by the S/MIME specifications) if CMS_BINARY is set no
42       translation occurs. This option should be used if the supplied data is
43       in binary format otherwise the translation will corrupt it. If
44       CMS_BINARY is set then CMS_TEXT is ignored.
45
46       OpenSSL will by default identify recipient certificates using issuer
47       name and serial number. If CMS_USE_KEYID is set it will use the subject
48       key identifier value instead. An error occurs if all recipient
49       certificates do not have a subject key identifier extension.
50
51       If the CMS_STREAM flag is set a partial CMS_ContentInfo structure is
52       returned suitable for streaming I/O: no data is read from the BIO in.
53
54       If the CMS_PARTIAL flag is set a partial CMS_ContentInfo structure is
55       returned to which additional recipients and attributes can be added
56       before finalization.
57
58       The data being encrypted is included in the CMS_ContentInfo structure,
59       unless CMS_DETACHED is set in which case it is omitted. This is rarely
60       used in practice and is not supported by SMIME_write_CMS().
61

NOTES

63       If the flag CMS_STREAM is set the returned CMS_ContentInfo structure is
64       not complete and outputting its contents via a function that does not
65       properly finalize the CMS_ContentInfo structure will give unpredictable
66       results.
67
68       Several functions including SMIME_write_CMS(), i2d_CMS_bio_stream(),
69       PEM_write_bio_CMS_stream() finalize the structure. Alternatively
70       finalization can be performed by obtaining the streaming ASN1 BIO
71       directly using BIO_new_CMS().
72
73       The recipients specified in certs use a CMS KeyTransRecipientInfo info
74       structure. KEKRecipientInfo is also supported using the flag
75       CMS_PARTIAL and CMS_add0_recipient_key().
76
77       The parameter certs may be NULL if CMS_PARTIAL is set and recipients
78       added later using CMS_add1_recipient_cert() or
79       CMS_add0_recipient_key().
80

RETURN VALUES

82       CMS_encrypt() returns either a CMS_ContentInfo structure or NULL if an
83       error occurred. The error can be obtained from ERR_get_error(3).
84

SEE ALSO

86       ERR_get_error(3), CMS_decrypt(3)
87

HISTORY

89       The CMS_STREAM flag was first supported in OpenSSL 1.0.0.
90
92       Copyright 2008-2018 The OpenSSL Project Authors. All Rights Reserved.
93
94       Licensed under the OpenSSL license (the "License").  You may not use
95       this file except in compliance with the License.  You can obtain a copy
96       in the file LICENSE in the source distribution or at
97       <https://www.openssl.org/source/license.html>.
98
99
100
1011.1.1g                            2020-04-23                    CMS_ENCRYPT(3)
Impressum