Current Path : /usr/opt/openssl11/share/doc/openssl/html/man3/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //usr/opt/openssl11/share/doc/openssl/html/man3/PKCS7_sign.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>PKCS7_sign</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rev="made" href="mailto:root@hsxx.drive.ne.jp" /> </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>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. <em>signcert</em> is the certificate to sign with, <em>pkey</em> is the corresponding private key. <em>certs</em> is an optional set of extra 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 <em>data</em>.</p> <p><em>flags</em> is an optional set of flags.</p> <p>Any of the following flags (ored together) can be passed in the <em>flags</em></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 <code>text/plain</code> are prepended to the data.</p> <p>If <strong>PKCS7_NOCERTS</strong> is set the signer's certificate and the extra <em>certs</em> will not be included in the PKCS7 structure. The signer's certificate must still be supplied in the <em>signcert</em> parameter though. This can reduce the size of the signatures if the signer's certificates 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 <em>data</em> 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> <p> </p> <hr /> <h1><a name="notes">NOTES</a></h1> <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 <em>certs</em>, <em>signcert</em> and <em>pkey</em> parameters can all be NULL 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 <em>signcert</em> and <em>pkey</em> are NULL then a certificates only PKCS#7 structure is output.</p> <p>In versions of OpenSSL before 1.0.0 the <em>signcert</em> and <em>pkey</em> parameters must not 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 <em>certs</em>, <em>signcert</em>, and <em>pkey</em> parameters to be NULL 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-2022 The OpenSSL Project Authors. All Rights Reserved.</p> <p>Licensed under the OpenSSL license (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>