118 lines
4.7 KiB
HTML
118 lines
4.7 KiB
HTML
|
<?xml version="1.0" ?>
|
||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
|
<head>
|
||
|
<title>CMS_decrypt</title>
|
||
|
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||
|
<link rev="made" href="mailto:root@localhost" />
|
||
|
</head>
|
||
|
|
||
|
<body style="background-color: white">
|
||
|
|
||
|
|
||
|
<!-- INDEX BEGIN -->
|
||
|
<div name="index">
|
||
|
<p><a name="__index__"></a></p>
|
||
|
|
||
|
<ul>
|
||
|
|
||
|
<li><a href="#name">NAME</a></li>
|
||
|
<li><a href="#synopsis">SYNOPSIS</a></li>
|
||
|
<li><a href="#description">DESCRIPTION</a></li>
|
||
|
<li><a href="#notes">NOTES</a></li>
|
||
|
<li><a href="#return_values">RETURN VALUES</a></li>
|
||
|
<li><a href="#bugs">BUGS</a></li>
|
||
|
<li><a href="#see_also">SEE ALSO</a></li>
|
||
|
<li><a href="#copyright">COPYRIGHT</a></li>
|
||
|
</ul>
|
||
|
|
||
|
<hr name="index" />
|
||
|
</div>
|
||
|
<!-- INDEX END -->
|
||
|
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="name">NAME</a></h1>
|
||
|
<p>CMS_decrypt - decrypt content from a CMS envelopedData structure</p>
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="synopsis">SYNOPSIS</a></h1>
|
||
|
<pre>
|
||
|
#include <openssl/cms.h></pre>
|
||
|
<pre>
|
||
|
int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert,
|
||
|
BIO *dcont, BIO *out, unsigned int flags);</pre>
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="description">DESCRIPTION</a></h1>
|
||
|
<p><code>CMS_decrypt()</code> extracts and decrypts the content from a CMS EnvelopedData
|
||
|
structure. <strong>pkey</strong> is the private key of the recipient, <strong>cert</strong> is the
|
||
|
recipient's certificate, <strong>out</strong> is a BIO to write the content to and
|
||
|
<strong>flags</strong> is an optional set of flags.</p>
|
||
|
<p>The <strong>dcont</strong> parameter is used in the rare case where the encrypted content
|
||
|
is detached. It will normally be set to NULL.</p>
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="notes">NOTES</a></h1>
|
||
|
<p>Although the recipients certificate is not needed to decrypt the data it is
|
||
|
needed to locate the appropriate (of possible several) recipients in the CMS
|
||
|
structure.</p>
|
||
|
<p>If <strong>cert</strong> is set to NULL all possible recipients are tried. This case however
|
||
|
is problematic. To thwart the MMA attack (Bleichenbacher's attack on
|
||
|
PKCS #1 v1.5 RSA padding) all recipients are tried whether they succeed or
|
||
|
not. If no recipient succeeds then a random symmetric key is used to decrypt
|
||
|
the content: this will typically output garbage and may (but is not guaranteed
|
||
|
to) ultimately return a padding error only. If <code>CMS_decrypt()</code> just returned an
|
||
|
error when all recipient encrypted keys failed to decrypt an attacker could
|
||
|
use this in a timing attack. If the special flag <strong>CMS_DEBUG_DECRYPT</strong> is set
|
||
|
then the above behaviour is modified and an error <strong>is</strong> returned if no
|
||
|
recipient encrypted key can be decrypted <strong>without</strong> generating a random
|
||
|
content encryption key. Applications should use this flag with
|
||
|
<strong>extreme caution</strong> especially in automated gateways as it can leave them
|
||
|
open to attack.</p>
|
||
|
<p>It is possible to determine the correct recipient key by other means (for
|
||
|
example looking them up in a database) and setting them in the CMS structure
|
||
|
in advance using the CMS utility functions such as CMS_set1_pkey(). In this
|
||
|
case both <strong>cert</strong> and <strong>pkey</strong> should be set to NULL.</p>
|
||
|
<p>To process KEKRecipientInfo types CMS_set1_key() or CMS_RecipientInfo_set0_key()
|
||
|
and <code>CMS_RecipientInfo_decrypt()</code> should be called before <code>CMS_decrypt()</code> and
|
||
|
<strong>cert</strong> and <strong>pkey</strong> set to NULL.</p>
|
||
|
<p>The following flags can be passed in the <strong>flags</strong> parameter.</p>
|
||
|
<p>If the <strong>CMS_TEXT</strong> flag is set MIME headers for type <strong>text/plain</strong> are deleted
|
||
|
from the content. If the content is not of type <strong>text/plain</strong> then an error is
|
||
|
returned.</p>
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="return_values">RETURN VALUES</a></h1>
|
||
|
<p><code>CMS_decrypt()</code> returns either 1 for success or 0 for failure.
|
||
|
The error can be obtained from <code>ERR_get_error(3)</code></p>
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="bugs">BUGS</a></h1>
|
||
|
<p>The lack of single pass processing and the need to hold all data in memory as
|
||
|
mentioned in <code>CMS_verify()</code> also applies to <code>CMS_decrypt()</code>.</p>
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="see_also">SEE ALSO</a></h1>
|
||
|
<p><em>ERR_get_error(3)</em>, <em>CMS_encrypt(3)</em></p>
|
||
|
<p>
|
||
|
</p>
|
||
|
<hr />
|
||
|
<h1><a name="copyright">COPYRIGHT</a></h1>
|
||
|
<p>Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.</p>
|
||
|
<p>Licensed under the Apache License 2.0 (the "License"). You may not use
|
||
|
this file except in compliance with the License. You can obtain a copy
|
||
|
in the file LICENSE in the source distribution or at
|
||
|
<a href="https://www.openssl.org/source/license.html">https://www.openssl.org/source/license.html</a>.</p>
|
||
|
|
||
|
</body>
|
||
|
|
||
|
</html>
|