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, const EVP_CIPHER *cipher, unsigned int flags);
12

DESCRIPTION

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

NOTES

20       Only certificates carrying RSA keys are supported so the recipient
21       certificates supplied to this function must all contain RSA public
22       keys, though they do not have to be signed using the RSA algorithm.
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       CMS_decrypt() was added to OpenSSL 0.9.8 The CMS_STREAM flag was first
90       supported in OpenSSL 1.0.0.
91
92
93
941.0.2o                            2018-03-27                    CMS_encrypt(3)
Impressum