1 .\" $OpenBSD: PKCS7_sign.3,v 1.7 2017/01/12 16:13:51 jmc Exp $
2 .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
4 .\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5 .\" Copyright (c) 2002, 2003, 2006-2009, 2015 The OpenSSL Project.
6 .\" All rights reserved.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in
17 .\" the documentation and/or other materials provided with the
20 .\" 3. All advertising materials mentioning features or use of this
21 .\" software must display the following acknowledgment:
22 .\" "This product includes software developed by the OpenSSL Project
23 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 .\" endorse or promote products derived from this software without
27 .\" prior written permission. For written permission, please contact
28 .\" openssl-core@openssl.org.
30 .\" 5. Products derived from this software may not be called "OpenSSL"
31 .\" nor may "OpenSSL" appear in their names without prior written
32 .\" permission of the OpenSSL Project.
34 .\" 6. Redistributions of any form whatsoever must retain the following
36 .\" "This product includes software developed by the OpenSSL Project
37 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
52 .Dd $Mdocdate: January 12 2017 $
57 .Nd create a PKCS#7 signedData structure
64 .Fa "STACK_OF(X509) *certs"
70 creates and returns a PKCS#7 signedData structure.
72 is the certificate to sign with,
74 is the corresponding private key.
76 is an optional additional set of certificates to include in the PKCS#7
77 structure (for example any intermediate CAs in the chain).
79 The data to be signed is read from
84 is an optional set of flags.
86 Any of the following flags (OR'ed together) can be passed in the
90 Many S/MIME clients expect the signed content to include valid MIME
94 flag is set, MIME headers for type
96 are prepended to the data.
100 is set, the signer's certificate will not be included in the PKCS7
101 structure, though the signer's certificate must still be supplied in the
104 This can reduce the size of the signature if the signer's certificate can
105 be obtained by other means: for example a previously signed message.
107 The data being signed is included in the
111 is set, in which case it is omitted.
112 This is used for PKCS7 detached signatures which are used in S/MIME
113 plaintext signed messages for example.
115 Normally the supplied content is translated into MIME canonical format
116 (as required by the S/MIME specifications).
119 is set, no translation occurs.
120 This option should be used if the supplied data is in binary format;
121 otherwise, the translation will corrupt it.
123 The signedData structure includes several PKCS#7 authenticatedAttributes
124 including the signing time, the PKCS#7 content type and the supported
125 list of ciphers in an SMIMECapabilities attribute.
128 is set, then no authenticatedAttributes will be used.
131 is set, then just the SMIMECapabilities are omitted.
133 If present, the SMIMECapabilities attribute indicates support for the
134 following algorithms: triple DES, 128-bit RC2, 64-bit RC2, DES
136 If any of these algorithms is disabled then it will not be included.
140 is set, then the returned
142 structure is just initialized ready to perform the signing operation.
143 The signing is however
145 performed and the data to be signed is not read from the
148 Signing is deferred until after the data has been written.
149 In this way data can be signed in a single pass.
153 flag is set, a partial
155 structure is output to which additional signers and capabilities can be
156 added before finalization.
164 complete and outputting its contents via a function that does not
165 properly finalize the
167 structure will give unpredictable results.
169 Several functions, including
170 .Xr SMIME_write_PKCS7 3 ,
171 .Xr i2d_PKCS7_bio_stream 3 ,
173 .Xr PEM_write_bio_PKCS7_stream 3 ,
174 finalize the structure.
175 Alternatively finalization can be performed by obtaining the streaming
181 If a signer is specified, it will use the default digest for the
185 for both RSA and DSA keys.
187 In OpenSSL 1.0.0, the
192 parameters can all be
197 One or more signers can be added using the function
198 .Xr PKCS7_sign_add_signer 3 .
200 must also be called to finalize the structure if streaming is not
202 Alternative signing digests can also be specified using this method.
210 then a certificate-only PKCS#7 structure is output.
212 In versions of OpenSSL before 1.0.0 the
222 returns either a valid
226 if an error occurred.
227 The error can be obtained from
228 .Fn ERR_get_error 3 .
230 .Xr ERR_get_error 3 ,
235 was added to OpenSSL 0.9.5.
241 flags were added in OpenSSL 1.0.0.
243 Some advanced attributes such as counter signatures are not supported.