157 lines
7.2 KiB
HTML
Executable File
157 lines
7.2 KiB
HTML
Executable File
<?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_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>
|
|
<li><a href="#notes">NOTES</a></li>
|
|
<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>CMS_sign - create a CMS SignedData structure</p>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="synopsis">SYNOPSIS</a></h1>
|
|
<pre>
|
|
#include <openssl/cms.h></pre>
|
|
<pre>
|
|
CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
|
|
BIO *data, unsigned int flags);</pre>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="description">DESCRIPTION</a></h1>
|
|
<p><code>CMS_sign()</code> creates and returns a CMS 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 CMS
|
|
structure (for example any intermediate CAs in the chain). Any or all of
|
|
these parameters can be <strong>NULL</strong>, see <strong>NOTES</strong> below.</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>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="notes">NOTES</a></h1>
|
|
<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>CMS_TEXT</strong> flag is set MIME headers for type <strong>text/plain</strong> are prepended
|
|
to the data.</p>
|
|
<p>If <strong>CMS_NOCERTS</strong> is set the signer's certificate will not be included in the
|
|
CMS_ContentInfo 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 CMS_ContentInfo structure, unless
|
|
<strong>CMS_DETACHED</strong> is set in which case it is omitted. This is used for
|
|
CMS_ContentInfo 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>CMS_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 CMS signedAttributes including the
|
|
signing time, the CMS content type and the supported list of ciphers in an
|
|
SMIMECapabilities attribute. If <strong>CMS_NOATTR</strong> is set then no signedAttributes
|
|
will be used. If <strong>CMS_NOSMIMECAP</strong> is set then just the SMIMECapabilities are
|
|
omitted.</p>
|
|
<p>If present the SMIMECapabilities attribute indicates support for the following
|
|
algorithms in preference order: 256 bit AES, Gost R3411-94, Gost 28147-89, 192
|
|
bit AES, 128 bit AES, triple DES, 128 bit RC2, 64 bit RC2, DES and 40 bit RC2.
|
|
If any of these algorithms is not available then it will not be included: for example the GOST algorithms will not be included if the GOST ENGINE is
|
|
not loaded.</p>
|
|
<p>OpenSSL will by default identify signing certificates using issuer name
|
|
and serial number. If <strong>CMS_USE_KEYID</strong> is set it will use the subject key
|
|
identifier value instead. An error occurs if the signing certificate does not
|
|
have a subject key identifier extension.</p>
|
|
<p>If the flags <strong>CMS_STREAM</strong> is set then the returned <strong>CMS_ContentInfo</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>CMS_PARTIAL</strong> flag is set a partial <strong>CMS_ContentInfo</strong> structure is
|
|
output to which additional signers and capabilities can be added before
|
|
finalization.</p>
|
|
<p>If the flag <strong>CMS_STREAM</strong> is set the returned <strong>CMS_ContentInfo</strong> structure is
|
|
<strong>not</strong> complete and outputting its contents via a function that does not
|
|
properly finalize the <strong>CMS_ContentInfo</strong> structure will give unpredictable
|
|
results.</p>
|
|
<p>Several functions including <code>SMIME_write_CMS()</code>, i2d_CMS_bio_stream(),
|
|
<code>PEM_write_bio_CMS_stream()</code> finalize the structure. Alternatively finalization
|
|
can be performed by obtaining the streaming ASN1 <strong>BIO</strong> directly using
|
|
<code>BIO_new_CMS()</code>.</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>If <strong>signcert</strong> and <strong>pkey</strong> are NULL then a certificates only CMS structure is
|
|
output.</p>
|
|
<p>The function <code>CMS_sign()</code> is a basic CMS signing function whose output will be
|
|
suitable for many purposes. For finer control of the output format the
|
|
<strong>certs</strong>, <strong>signcert</strong> and <strong>pkey</strong> parameters can all be <strong>NULL</strong> and the
|
|
<strong>CMS_PARTIAL</strong> flag set. Then one or more signers can be added using the
|
|
function CMS_sign_add1_signer(), non default digests can be used and custom
|
|
attributes added. <code>CMS_final()</code> must then be called to finalize the
|
|
structure if streaming is not enabled.</p>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="bugs">BUGS</a></h1>
|
|
<p>Some attributes such as counter signatures are not supported.</p>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="return_values">RETURN VALUES</a></h1>
|
|
<p><code>CMS_sign()</code> returns either a valid CMS_ContentInfo 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>CMS_verify(3)</em></p>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="history">HISTORY</a></h1>
|
|
<p>The <strong>CMS_STREAM</strong> flag is only supported for detached data in OpenSSL 0.9.8,
|
|
it is supported for embedded data in OpenSSL 1.0.0 and later.</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>
|