1CMS_SIGN(3)                         OpenSSL                        CMS_SIGN(3)
2
3
4

NAME

6       CMS_sign - create a CMS SignedData structure
7

SYNOPSIS

9        #include <openssl/cms.h>
10
11        CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
12                                  BIO *data, unsigned int flags);
13

DESCRIPTION

15       CMS_sign() creates and returns a CMS SignedData structure. signcert is
16       the certificate to sign with, pkey is the corresponding private key.
17       certs is an optional additional set of certificates to include in the
18       CMS structure (for example any intermediate CAs in the chain). Any or
19       all of these parameters can be NULL, see NOTES below.
20
21       The data to be signed is read from BIO data.
22
23       flags is an optional set of flags.
24

NOTES

26       Any of the following flags (ored together) can be passed in the flags
27       parameter.
28
29       Many S/MIME clients expect the signed content to include valid MIME
30       headers. If the CMS_TEXT flag is set MIME headers for type text/plain
31       are prepended to the data.
32
33       If CMS_NOCERTS is set the signer's certificate will not be included in
34       the CMS_ContentInfo structure, the signer's certificate must still be
35       supplied in the signcert parameter though. This can reduce the size of
36       the signature if the signers certificate can be obtained by other
37       means: for example a previously signed message.
38
39       The data being signed is included in the CMS_ContentInfo structure,
40       unless CMS_DETACHED is set in which case it is omitted. This is used
41       for CMS_ContentInfo detached signatures which are used in S/MIME
42       plaintext signed messages for example.
43
44       Normally the supplied content is translated into MIME canonical format
45       (as required by the S/MIME specifications) if CMS_BINARY is set no
46       translation occurs. This option should be used if the supplied data is
47       in binary format otherwise the translation will corrupt it.
48
49       The SignedData structure includes several CMS signedAttributes
50       including the signing time, the CMS content type and the supported list
51       of ciphers in an SMIMECapabilities attribute. If CMS_NOATTR is set then
52       no signedAttributes will be used. If CMS_NOSMIMECAP is set then just
53       the SMIMECapabilities are omitted.
54
55       If present the SMIMECapabilities attribute indicates support for the
56       following algorithms in preference order: 256 bit AES, Gost R3411-94,
57       Gost 28147-89, 192 bit AES, 128 bit AES, triple DES, 128 bit RC2, 64
58       bit RC2, DES and 40 bit RC2.  If any of these algorithms is not
59       available then it will not be included: for example the GOST algorithms
60       will not be included if the GOST ENGINE is not loaded.
61
62       OpenSSL will by default identify signing certificates using issuer name
63       and serial number. If CMS_USE_KEYID is set it will use the subject key
64       identifier value instead. An error occurs if the signing certificate
65       does not have a subject key identifier extension.
66
67       If the flags CMS_STREAM is set then the returned CMS_ContentInfo
68       structure is just initialized ready to perform the signing operation.
69       The signing is however not performed and the data to be signed is not
70       read from the data parameter. Signing is deferred until after the data
71       has been written. In this way data can be signed in a single pass.
72
73       If the CMS_PARTIAL flag is set a partial CMS_ContentInfo structure is
74       output to which additional signers and capabilities can be added before
75       finalization.
76
77       If the flag CMS_STREAM is set the returned CMS_ContentInfo structure is
78       not complete and outputting its contents via a function that does not
79       properly finalize the CMS_ContentInfo structure will give unpredictable
80       results.
81
82       Several functions including SMIME_write_CMS(), i2d_CMS_bio_stream(),
83       PEM_write_bio_CMS_stream() finalize the structure. Alternatively
84       finalization can be performed by obtaining the streaming ASN1 BIO
85       directly using BIO_new_CMS().
86
87       If a signer is specified it will use the default digest for the signing
88       algorithm. This is SHA1 for both RSA and DSA keys.
89
90       If signcert and pkey are NULL then a certificates only CMS structure is
91       output.
92
93       The function CMS_sign() is a basic CMS signing function whose output
94       will be suitable for many purposes. For finer control of the output
95       format the certs, signcert and pkey parameters can all be NULL and the
96       CMS_PARTIAL flag set. Then one or more signers can be added using the
97       function CMS_sign_add1_signer(), non default digests can be used and
98       custom attributes added. CMS_final() must then be called to finalize
99       the structure if streaming is not enabled.
100

BUGS

102       Some attributes such as counter signatures are not supported.
103

RETURN VALUES

105       CMS_sign() returns either a valid CMS_ContentInfo structure or NULL if
106       an error occurred. The error can be obtained from ERR_get_error(3).
107

SEE ALSO

109       ERR_get_error(3), CMS_verify(3)
110

HISTORY

112       The CMS_STREAM flag is only supported for detached data in OpenSSL
113       0.9.8, it is supported for embedded data in OpenSSL 1.0.0 and later.
114
116       Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
117
118       Licensed under the OpenSSL license (the "License").  You may not use
119       this file except in compliance with the License.  You can obtain a copy
120       in the file LICENSE in the source distribution or at
121       <https://www.openssl.org/source/license.html>.
122
123
124
1251.1.1l                            2021-09-15                       CMS_SIGN(3)
Impressum