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

NAME

6       CMS_decrypt - decrypt content from a CMS envelopedData structure
7

SYNOPSIS

9        #include <openssl/cms.h>
10
11        int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert,
12                        BIO *dcont, BIO *out, unsigned int flags);
13

DESCRIPTION

15       CMS_decrypt() extracts and decrypts the content from a CMS
16       EnvelopedData structure. pkey is the private key of the recipient, cert
17       is the recipient's certificate, out is a BIO to write the content to
18       and flags is an optional set of flags.
19
20       The dcont parameter is used in the rare case where the encrypted
21       content is detached. It will normally be set to NULL.
22

NOTES

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

RETURN VALUES

58       CMS_decrypt() returns either 1 for success or 0 for failure.  The error
59       can be obtained from ERR_get_error(3)
60

BUGS

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

SEE ALSO

66       ERR_get_error(3), CMS_encrypt(3)
67
69       Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
70
71       Licensed under the OpenSSL license (the "License").  You may not use
72       this file except in compliance with the License.  You can obtain a copy
73       in the file LICENSE in the source distribution or at
74       <https://www.openssl.org/source/license.html>.
75
76
77
781.1.1                             2018-09-11                    CMS_DECRYPT(3)
Impressum