xref: /openbsd-src/lib/libcrypto/man/PKCS7_decrypt.3 (revision aa997e528a848ca5596493c2a801bdd6fb26ae61)
1.\"	$OpenBSD: PKCS7_decrypt.3,v 1.7 2018/03/22 16:06:33 schwarze Exp $
2.\"	OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2002, 2006 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: March 22 2018 $
52.Dt PKCS7_DECRYPT 3
53.Os
54.Sh NAME
55.Nm PKCS7_decrypt
56.Nd decrypt content from a PKCS#7 envelopedData structure
57.Sh SYNOPSIS
58.In openssl/pkcs7.h
59.Ft int
60.Fo PKCS7_decrypt
61.Fa "PKCS7 *p7"
62.Fa "EVP_PKEY *pkey"
63.Fa "X509 *cert"
64.Fa "BIO *data"
65.Fa "int flags"
66.Fc
67.Sh DESCRIPTION
68.Fn PKCS7_decrypt
69extracts and decrypts the content from a PKCS#7 envelopedData structure.
70.Fa pkey
71is the private key of the recipient,
72.Fa cert
73is the recipient's certificate,
74.Fa data
75is a
76.Vt BIO
77to write the content to and
78.Fa flags
79is an optional set of flags.
80.Pp
81.Xr OpenSSL_add_all_algorithms 3
82(or equivalent) should be called before using this function or errors
83about unknown algorithms will occur.
84.Pp
85Although the recipient's certificate is not needed to decrypt the data,
86it is needed to locate the appropriate recipients
87in the PKCS#7 structure.
88.Pp
89If the
90.Dv PKCS7_TEXT
91.Fa flag
92is set, MIME headers for type
93.Sy text/plain
94are deleted from the content.
95If the content is not of type
96.Sy text/plain ,
97an error is returned.
98.Sh RETURN VALUES
99.Fn PKCS7_decrypt
100returns 1 for success or 0 for failure.
101.Pp
102The error can be obtained from
103.Xr ERR_get_error 3 .
104.Sh SEE ALSO
105.Xr ERR_get_error 3 ,
106.Xr PKCS7_encrypt 3 ,
107.Xr PKCS7_new 3
108.Sh HISTORY
109.Fn PKCS7_decrypt
110first appeared in OpenSSL 0.9.5 and has been available since
111.Ox 2.7 .
112.Sh BUGS
113.Fn PKCS7_decrypt
114must be passed the correct recipient key and certificate.
115It would be better if it could look up the correct key and certificate
116from a database.
117.Pp
118The lack of single pass processing and need to hold all data in memory
119as mentioned in
120.Xr PKCS7_sign 3
121also applies to
122.Fn PKCS7_decrypt .
123