1.\" $OpenBSD: PKCS7_decrypt.3,v 1.10 2019/06/10 14:58:48 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: June 10 2019 $ 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 81Although the recipient's certificate is not needed to decrypt the data, 82it is needed to locate the appropriate recipients 83in the PKCS#7 structure. 84.Pp 85If the 86.Dv PKCS7_TEXT 87.Fa flag 88is set, MIME headers for type 89.Sy text/plain 90are deleted from the content. 91If the content is not of type 92.Sy text/plain , 93an error is returned. 94.Sh RETURN VALUES 95.Fn PKCS7_decrypt 96returns 1 for success or 0 for failure. 97.Pp 98The error can be obtained from 99.Xr ERR_get_error 3 . 100.Sh SEE ALSO 101.Xr PKCS7_encrypt 3 , 102.Xr PKCS7_new 3 , 103.Xr PKCS7_verify 3 104.Sh HISTORY 105.Fn PKCS7_decrypt 106first appeared in OpenSSL 0.9.5 and has been available since 107.Ox 2.7 . 108.Sh BUGS 109.Fn PKCS7_decrypt 110must be passed the correct recipient key and certificate. 111It would be better if it could look up the correct key and certificate 112from a database. 113.Pp 114The lack of single pass processing and need to hold all data in memory 115as mentioned in 116.Xr PKCS7_sign 3 117also applies to 118.Fn PKCS7_decrypt . 119