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, BIO *data, unsigned int flags);
12

DESCRIPTION

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

NOTES

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

BUGS

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

RETURN VALUES

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

SEE ALSO

108       ERR_get_error(3), CMS_verify(3)
109

HISTORY

111       CMS_sign() was added to OpenSSL 0.9.8
112
113       The CMS_STREAM flag is only supported for detached data in OpenSSL
114       0.9.8, it is supported for embedded data in OpenSSL 1.0.0 and later.
115
116
117
1181.0.2o                            2020-08-01                       CMS_sign(3)
Impressum