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

NAME

6       CMS_decrypt, CMS_decrypt_set1_pkey_and_peer, CMS_decrypt_set1_pkey -
7       decrypt content from a CMS envelopedData structure
8

SYNOPSIS

10        #include <openssl/cms.h>
11
12        int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert,
13                        BIO *dcont, BIO *out, unsigned int flags);
14        int CMS_decrypt_set1_pkey_and_peer(CMS_ContentInfo *cms,
15                        EVP_PKEY *pk, X509 *cert, X509 *peer);
16        int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert);
17

DESCRIPTION

19       CMS_decrypt() extracts and decrypts the content from a CMS
20       EnvelopedData or AuthEnvelopedData structure. pkey is the private key
21       of the recipient, cert is the recipient's certificate, out is a BIO to
22       write the content to and flags is an optional set of flags.
23
24       The dcont parameter is used in the rare case where the encrypted
25       content is detached. It will normally be set to NULL.
26
27       CMS_decrypt_set1_pkey_and_peer() associates the private key pkey, the
28       corresponding certificate cert and the originator certificate peer with
29       the CMS_ContentInfo structure cms.
30
31       CMS_decrypt_set1_pkey() associates the private key pkey, corresponding
32       certificate cert with the CMS_ContentInfo structure cms.
33

NOTES

35       Although the recipients certificate is not needed to decrypt the data
36       it is needed to locate the appropriate (of possible several) recipients
37       in the CMS structure.
38
39       If cert is set to NULL all possible recipients are tried. This case
40       however is problematic. To thwart the MMA attack (Bleichenbacher's
41       attack on PKCS #1 v1.5 RSA padding) all recipients are tried whether
42       they succeed or not. If no recipient succeeds then a random symmetric
43       key is used to decrypt the content: this will typically output garbage
44       and may (but is not guaranteed to) ultimately return a padding error
45       only. If CMS_decrypt() just returned an error when all recipient
46       encrypted keys failed to decrypt an attacker could use this in a timing
47       attack. If the special flag CMS_DEBUG_DECRYPT is set then the above
48       behaviour is modified and an error is returned if no recipient
49       encrypted key can be decrypted without generating a random content
50       encryption key. Applications should use this flag with extreme caution
51       especially in automated gateways as it can leave them open to attack.
52
53       It is possible to determine the correct recipient key by other means
54       (for example looking them up in a database) and setting them in the CMS
55       structure in advance using the CMS utility functions such as
56       CMS_set1_pkey(). In this case both cert and pkey should be set to NULL.
57
58       To process KEKRecipientInfo types CMS_set1_key() or
59       CMS_RecipientInfo_set0_key() and CMS_RecipientInfo_decrypt() should be
60       called before CMS_decrypt() and cert and pkey set to NULL.
61
62       The following flags can be passed in the flags parameter.
63
64       If the CMS_TEXT flag is set MIME headers for type text/plain are
65       deleted from the content. If the content is not of type text/plain then
66       an error is returned.
67

RETURN VALUES

69       CMS_decrypt() returns either 1 for success or 0 for failure.  The error
70       can be obtained from ERR_get_error(3)
71

BUGS

73       The lack of single pass processing and the need to hold all data in
74       memory as mentioned in CMS_verify() also applies to CMS_decrypt().
75

SEE ALSO

77       ERR_get_error(3), CMS_encrypt(3)
78

HISTORY

80       CMS_decrypt_set1_pkey_and_peer was added in OpenSSL 3.0.
81
83       Copyright 2008-2020 The OpenSSL Project Authors. All Rights Reserved.
84
85       Licensed under the Apache License 2.0 (the "License").  You may not use
86       this file except in compliance with the License.  You can obtain a copy
87       in the file LICENSE in the source distribution or at
88       <https://www.openssl.org/source/license.html>.
89
90
91
923.0.5                             2022-07-05                CMS_DECRYPT(3ossl)
Impressum