summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/CMS_sign.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/CMS_sign.3')
-rw-r--r--src/lib/libcrypto/man/CMS_sign.3224
1 files changed, 224 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/CMS_sign.3 b/src/lib/libcrypto/man/CMS_sign.3
new file mode 100644
index 0000000000..54d95f4a5d
--- /dev/null
+++ b/src/lib/libcrypto/man/CMS_sign.3
@@ -0,0 +1,224 @@
1.\" $OpenBSD: CMS_sign.3,v 1.3 2019/08/10 23:41:22 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: August 10 2019 $
52.Dt CMS_SIGN 3
53.Os
54.Sh NAME
55.Nm CMS_sign
56.Nd create a CMS SignedData structure
57.Sh SYNOPSIS
58.In openssl/cms.h
59.Ft CMS_ContentInfo *
60.Fo CMS_sign
61.Fa "X509 *signcert"
62.Fa "EVP_PKEY *pkey"
63.Fa "STACK_OF(X509) *certs"
64.Fa "BIO *data"
65.Fa "unsigned int flags"
66.Fc
67.Sh DESCRIPTION
68.Fn CMS_sign
69creates and returns a CMS SignedData structure.
70.Fa signcert
71is the certificate to sign with,
72.Fa pkey
73is the corresponding private key.
74.Fa certs
75is an optional additional set of certificates to include in the CMS
76structure (for example any intermediate CAs in the chain).
77Any or all of these parameters can be
78.Dv NULL .
79.Pp
80The data to be signed is read from
81.Fa data .
82.Pp
83.Fa flags
84is an optional set of flags.
85.Pp
86Any of the following flags (OR'ed together) can be passed in the
87.Fa flags
88parameter:
89.Bl -tag -width Ds
90.It Dv CMS_TEXT
91Prepend MIME headers for the type text/plain to the data.
92Many S/MIME clients expect the signed content to include valid MIME
93headers.
94.It Dv CMS_NOCERTS
95Do not include the signer's certificate in the
96.Vt CMS_ContentInfo
97structure.
98The signer's certificate must still be supplied in the
99.Fa signcert
100parameter though.
101This can reduce the size of the signature if the signers certificate can
102be obtained by other means: for example a previously signed message.
103.It Dv CMS_DETACHED
104Omit the data being signed from the
105.Vt CMS_ContentInfo
106structure.
107This is used for
108.Vt CMS_ContentInfo
109detached signatures which are used in S/MIME plaintext signed messages
110for example.
111.It Dv CMS_BINARY
112Do not translate the supplied content into MIME canonical format
113even though that is required by the S/MIME specifications.
114This option should be used if the supplied data is in binary format.
115Otherwise the translation will corrupt it.
116.It Dv CMS_NOATTR
117Do not use any signedAttributes.
118By default, the SignedData structure includes several CMS
119signedAttributes including the signing time, the CMS content type,
120and the supported list of ciphers in an SMIMECapabilities attribute.
121.It Dv CMS_NOSMIMECAP
122Omit just the SMIMECapabilities.
123If present, the SMIMECapabilities attribute indicates support for the
124following algorithms in preference order: 256 bit AES, Gost R3411-94,
125Gost 28147-89, 192 bit AES, 128 bit AES, triple DES, 128 bit RC2, 64 bit
126RC2, DES and 40 bit RC2.
127If any of these algorithms is not available, then it will not be
128included: for example the GOST algorithms will not be included if
129the GOST ENGINE is not loaded.
130.It Dv CMS_USE_KEYID
131Use the subject key identifier value to identify signing certificates.
132An error occurs if the signing certificate does not have a subject key
133identifier extension.
134By default, issuer name and serial number are used instead.
135.It Dv CMS_STREAM
136Only initialize the returned
137.Vt CMS_ContentInfo
138structure to prepare it for performing the signing operation.
139The signing is however
140.Em not
141performed and the data to be signed is not read from the
142.Fa data
143parameter.
144Signing is deferred until after the data has been written.
145In this way, data can be signed in a single pass.
146The returned
147.Vt CMS_ContentInfo
148structure is
149.Em not
150complete and outputting its contents via a function that does not
151properly finalize the
152.Vt CMS_ContentInfo
153structure will give unpredictable results.
154Several functions including
155.Xr SMIME_write_CMS 3 ,
156.Xr i2d_CMS_bio_stream 3 ,
157or
158.Xr PEM_write_bio_CMS_stream 3
159finalize the structure.
160Alternatively, finalization can be performed by obtaining the streaming
161ASN1
162.Vt BIO
163directly using
164.Xr BIO_new_CMS 3 .
165.It Dv CMS_PARTIAL
166Output a partial
167.Vt CMS_ContentInfo
168structure to which additional signers and capabilities can be
169added before finalization.
170.El
171.Pp
172If a signer is specified, it will use the default digest for the signing
173algorithm.
174This is SHA1 for both RSA and DSA keys.
175.Pp
176If
177.Fa signcert
178and
179.Fa pkey
180are
181.Dv NULL ,
182then a certificates only CMS structure is output.
183.Pp
184The function
185.Fn CMS_sign
186is a basic CMS signing function whose output will be suitable for many
187purposes.
188For finer control of the output format the
189.Fa certs ,
190.Fa signcert
191and
192.Fa pkey
193parameters can all be
194.Dv NULL
195and the
196.Dv CMS_PARTIAL
197flag set.
198Then one or more signers can be added using the function
199.Xr CMS_sign_add1_signer 3 ,
200non default digests can be used and custom attributes added.
201.Xr CMS_final 3
202must then be called to finalize the structure if streaming is not
203enabled.
204.Sh RETURN VALUES
205.Fn CMS_sign
206returns either a valid
207.Vt CMS_ContentInfo
208structure or
209.Dv NULL
210if an error occurred.
211The error can be obtained from
212.Xr ERR_get_error 3 .
213.Sh SEE ALSO
214.Xr CMS_verify 3
215.Sh HISTORY
216.Fn CMS_sign
217was added to OpenSSL 0.9.8.
218.Pp
219The
220.Dv CMS_STREAM
221flag is only supported for detached data in OpenSSL 0.9.8, it is
222supported for embedded data in OpenSSL 1.0.0 and later.
223.Sh BUGS
224Some attributes such as counter signatures are not supported.