2020-03-02 16:50:34 +00:00
|
|
|
<?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>PKCS7_sign</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>
|
2020-03-02 17:19:21 +00:00
|
|
|
<li><a href="#notes">NOTES</a></li>
|
|
|
|
<li><a href="#notes">NOTES</a></li>
|
2020-03-02 16:50:34 +00:00
|
|
|
<li><a href="#bugs">BUGS</a></li>
|
|
|
|
<li><a href="#return_values">RETURN VALUES</a></li>
|
|
|
|
<li><a href="#see_also">SEE ALSO</a></li>
|
|
|
|
<li><a href="#history">HISTORY</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>PKCS7_sign - create a PKCS#7 signedData structure</p>
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="synopsis">SYNOPSIS</a></h1>
|
|
|
|
<pre>
|
|
|
|
#include <openssl/pkcs7.h></pre>
|
|
|
|
<pre>
|
|
|
|
PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
|
|
|
|
BIO *data, int flags);</pre>
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="description">DESCRIPTION</a></h1>
|
|
|
|
<p>PKCS7_sign() creates and returns a PKCS#7 signedData structure. <strong>signcert</strong> is
|
|
|
|
the certificate to sign with, <strong>pkey</strong> is the corresponding private key.
|
|
|
|
<strong>certs</strong> is an optional additional set of certificates to include in the PKCS#7
|
|
|
|
structure (for example any intermediate CAs in the chain).</p>
|
|
|
|
<p>The data to be signed is read from BIO <strong>data</strong>.</p>
|
|
|
|
<p><strong>flags</strong> is an optional set of flags.</p>
|
2020-03-02 17:19:21 +00:00
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="notes">NOTES</a></h1>
|
2020-03-02 16:50:34 +00:00
|
|
|
<p>Any of the following flags (ored together) can be passed in the <strong>flags</strong>
|
|
|
|
parameter.</p>
|
|
|
|
<p>Many S/MIME clients expect the signed content to include valid MIME headers. If
|
|
|
|
the <strong>PKCS7_TEXT</strong> flag is set MIME headers for type <strong>text/plain</strong> are prepended
|
|
|
|
to the data.</p>
|
|
|
|
<p>If <strong>PKCS7_NOCERTS</strong> is set the signer's certificate will not be included in the
|
|
|
|
PKCS7 structure, the signer's certificate must still be supplied in the
|
|
|
|
<strong>signcert</strong> parameter though. This can reduce the size of the signature if the
|
|
|
|
signers certificate can be obtained by other means: for example a previously
|
|
|
|
signed message.</p>
|
|
|
|
<p>The data being signed is included in the PKCS7 structure, unless
|
|
|
|
<strong>PKCS7_DETACHED</strong> is set in which case it is omitted. This is used for PKCS7
|
|
|
|
detached signatures which are used in S/MIME plaintext signed messages for
|
|
|
|
example.</p>
|
|
|
|
<p>Normally the supplied content is translated into MIME canonical format (as
|
|
|
|
required by the S/MIME specifications) if <strong>PKCS7_BINARY</strong> is set no translation
|
|
|
|
occurs. This option should be used if the supplied data is in binary format
|
|
|
|
otherwise the translation will corrupt it.</p>
|
|
|
|
<p>The signedData structure includes several PKCS#7 authenticatedAttributes
|
|
|
|
including the signing time, the PKCS#7 content type and the supported list of
|
|
|
|
ciphers in an SMIMECapabilities attribute. If <strong>PKCS7_NOATTR</strong> is set then no
|
|
|
|
authenticatedAttributes will be used. If <strong>PKCS7_NOSMIMECAP</strong> is set then just
|
|
|
|
the SMIMECapabilities are omitted.</p>
|
|
|
|
<p>If present the SMIMECapabilities attribute indicates support for the following
|
|
|
|
algorithms: triple DES, 128 bit RC2, 64 bit RC2, DES and 40 bit RC2. If any of
|
|
|
|
these algorithms is disabled then it will not be included.</p>
|
|
|
|
<p>If the flags <strong>PKCS7_STREAM</strong> is set then the returned <strong>PKCS7</strong> structure is
|
|
|
|
just initialized ready to perform the signing operation. The signing is however
|
|
|
|
<strong>not</strong> performed and the data to be signed is not read from the <strong>data</strong>
|
|
|
|
parameter. Signing is deferred until after the data has been written. In this
|
|
|
|
way data can be signed in a single pass.</p>
|
|
|
|
<p>If the <strong>PKCS7_PARTIAL</strong> flag is set a partial <strong>PKCS7</strong> structure is output to
|
|
|
|
which additional signers and capabilities can be added before finalization.</p>
|
2020-03-02 17:19:21 +00:00
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="notes">NOTES</a></h1>
|
2020-03-02 16:50:34 +00:00
|
|
|
<p>If the flag <strong>PKCS7_STREAM</strong> is set the returned <strong>PKCS7</strong> structure is <strong>not</strong>
|
|
|
|
complete and outputting its contents via a function that does not properly
|
|
|
|
finalize the <strong>PKCS7</strong> structure will give unpredictable results.</p>
|
|
|
|
<p>Several functions including SMIME_write_PKCS7(), i2d_PKCS7_bio_stream(),
|
|
|
|
PEM_write_bio_PKCS7_stream() finalize the structure. Alternatively finalization
|
|
|
|
can be performed by obtaining the streaming ASN1 <strong>BIO</strong> directly using
|
|
|
|
BIO_new_PKCS7().</p>
|
|
|
|
<p>If a signer is specified it will use the default digest for the signing
|
|
|
|
algorithm. This is <strong>SHA1</strong> for both RSA and DSA keys.</p>
|
|
|
|
<p>The <strong>certs</strong>, <strong>signcert</strong> and <strong>pkey</strong> parameters can all be
|
|
|
|
<strong>NULL</strong> if the <strong>PKCS7_PARTIAL</strong> flag is set. One or more signers can be added
|
|
|
|
using the function PKCS7_sign_add_signer(). PKCS7_final() must also be
|
|
|
|
called to finalize the structure if streaming is not enabled. Alternative
|
|
|
|
signing digests can also be specified using this method.</p>
|
|
|
|
<p>If <strong>signcert</strong> and <strong>pkey</strong> are NULL then a certificates only
|
|
|
|
PKCS#7 structure is output.</p>
|
|
|
|
<p>In versions of OpenSSL before 1.0.0 the <strong>signcert</strong> and <strong>pkey</strong> parameters must
|
|
|
|
<strong>NOT</strong> be NULL.</p>
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="bugs">BUGS</a></h1>
|
|
|
|
<p>Some advanced attributes such as counter signatures are not supported.</p>
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="return_values">RETURN VALUES</a></h1>
|
|
|
|
<p>PKCS7_sign() returns either a valid PKCS7 structure or NULL if an error
|
|
|
|
occurred. The error can be obtained from <code>ERR_get_error(3)</code>.</p>
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="see_also">SEE ALSO</a></h1>
|
|
|
|
<p><em>ERR_get_error(3)</em>, <em>PKCS7_verify(3)</em></p>
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="history">HISTORY</a></h1>
|
|
|
|
<p>The <strong>PKCS7_PARTIAL</strong> flag, and the ability for <strong>certs</strong>, <strong>signcert</strong>,
|
|
|
|
and <strong>pkey</strong> parameters to be <strong>NULL</strong> were added in OpenSSL 1.0.0.</p>
|
|
|
|
<p>The <strong>PKCS7_STREAM</strong> flag was added in OpenSSL 1.0.0.</p>
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="copyright">COPYRIGHT</a></h1>
|
|
|
|
<p>Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.</p>
|
2020-03-02 17:19:21 +00:00
|
|
|
<p>Licensed under the OpenSSL license (the "License"). You may not use
|
2020-03-02 16:50:34 +00:00
|
|
|
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>
|