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, BIO *dcont, BIO *out, unsigned int flags);
12

DESCRIPTION

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

NOTES

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

RETURN VALUES

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

BUGS

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

SEE ALSO

68       ERR_get_error(3), CMS_encrypt(3)
69

HISTORY

71       CMS_decrypt() was added to OpenSSL 0.9.8
72
73
74
751.0.2o                            2018-03-27                    CMS_decrypt(3)
Impressum