summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/CMS_decrypt.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/CMS_decrypt.3')
-rw-r--r--src/lib/libcrypto/man/CMS_decrypt.3169
1 files changed, 169 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/CMS_decrypt.3 b/src/lib/libcrypto/man/CMS_decrypt.3
new file mode 100644
index 0000000000..de37b357a1
--- /dev/null
+++ b/src/lib/libcrypto/man/CMS_decrypt.3
@@ -0,0 +1,169 @@
1.\" $OpenBSD: CMS_decrypt.3,v 1.3 2019/08/10 23:41:22 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2008, 2014 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: August 10 2019 $
52.Dt CMS_DECRYPT 3
53.Os
54.Sh NAME
55.Nm CMS_decrypt
56.Nd decrypt content from a CMS envelopedData structure
57.Sh SYNOPSIS
58.In openssl/cms.h
59.Ft int
60.Fo CMS_decrypt
61.Fa "CMS_ContentInfo *cms"
62.Fa "EVP_PKEY *pkey"
63.Fa "X509 *cert"
64.Fa "BIO *dcont"
65.Fa "BIO *out"
66.Fa "unsigned int flags"
67.Fc
68.Sh DESCRIPTION
69.Fn CMS_decrypt
70extracts and decrypts the content from a CMS EnvelopedData structure.
71.Fa pkey
72is the private key of the recipient,
73.Fa cert
74is the recipient's certificate,
75.Fa out
76is a
77.Vt BIO
78to write the content to and
79.Fa flags
80is an optional set of flags.
81.Pp
82The
83.Fa dcont
84parameter is used in the rare case where the encrypted content is
85detached.
86It will normally be set to
87.Dv NULL .
88.Pp
89Although the recipients certificate is not needed to decrypt the data it
90is needed to locate the appropriate (of possible several) recipients in
91the CMS structure.
92.Pp
93If
94.Fa cert
95is set to
96.Dv NULL ,
97all possible recipients are tried.
98This case however is problematic.
99To thwart the MMA attack (Bleichenbacher's attack on PKCS #1 v1.5 RSA
100padding) all recipients are tried whether they succeed or not.
101If no recipient succeeds then a random symmetric key is used to decrypt
102the content: this will typically output garbage and may (but is not
103guaranteed to) ultimately return a padding error only.
104If
105.Fn CMS_decrypt
106just returned an error when all recipient encrypted keys failed to
107decrypt an attacker could use this in a timing attack.
108If the special flag
109.Dv CMS_DEBUG_DECRYPT
110is set, then the above behaviour is modified and an error
111.Em is
112returned if no recipient encrypted key can be decrypted
113.Em without
114generating a random content encryption key.
115Applications should use this flag with extreme caution
116especially in automated gateways as it can leave them open to attack.
117.Pp
118It is possible to determine the correct recipient key by other means
119(for example looking them up in a database) and setting them in the CMS
120structure in advance using the CMS utility functions such as
121.Xr CMS_set1_pkey 3 .
122In this case both
123.Fa cert
124and
125.Fa pkey
126should be set to
127.Dv NULL .
128.Pp
129To process KEKRecipientInfo types,
130.Xr CMS_set1_key 3
131or
132.Xr CMS_RecipientInfo_set0_key 3
133and
134.Xr CMS_RecipientInfo_decrypt 3
135should be called before
136.Fn CMS_decrypt
137and
138.Fa cert
139and
140.Fa pkey
141set to
142.Dv NULL .
143.Pp
144The following flags can be passed in the
145.Fa flags
146parameter:
147.Pp
148If the
149.Dv CMS_TEXT
150flag is set, MIME headers for type text/plain
151are deleted from the content.
152If the content is not of type text/plain,
153then an error is returned.
154.Sh RETURN VALUES
155.Fn CMS_decrypt
156returns either 1 for success or 0 for failure.
157The error can be obtained from
158.Xr ERR_get_error 3 .
159.Sh SEE ALSO
160.Xr CMS_encrypt 3
161.Sh HISTORY
162.Fn CMS_decrypt
163was added to OpenSSL 0.9.8.
164.Sh BUGS
165The lack of single pass processing and the need to hold all data in
166memory as mentioned in
167.Xr CMS_verify 3
168also applies to
169.Fn CMS_decrypt .