xref: /freebsd/crypto/openssl/doc/man3/CMS_add1_signer.pod (revision e7be843b4a162e68651d3911f0357ed464915629)
1=pod
2
3=head1 NAME
4
5CMS_add1_signer, CMS_SignerInfo_sign - add a signer to a CMS_ContentInfo signed data structure
6
7=head1 SYNOPSIS
8
9 #include <openssl/cms.h>
10
11 CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms, X509 *signcert,
12                                 EVP_PKEY *pkey, const EVP_MD *md,
13                                 unsigned int flags);
14
15 int CMS_SignerInfo_sign(CMS_SignerInfo *si);
16
17=head1 DESCRIPTION
18
19CMS_add1_signer() adds a signer with certificate B<signcert> and private
20key B<pkey> using message digest B<md> to CMS_ContentInfo SignedData
21structure B<cms>.
22
23The CMS_ContentInfo structure should be obtained from an initial call to
24CMS_sign() with the flag B<CMS_PARTIAL> set or in the case or re-signing a
25valid CMS_ContentInfo SignedData structure.
26
27If the B<md> parameter is B<NULL> then the default digest for the public
28key algorithm will be used.
29
30Unless the B<CMS_REUSE_DIGEST> flag is set the returned CMS_ContentInfo
31structure is not complete and must be finalized either by streaming (if
32applicable) or a call to CMS_final().
33
34The CMS_SignerInfo_sign() function explicitly signs a CMS_SignerInfo
35structure, its main use is when the B<CMS_REUSE_DIGEST> and B<CMS_PARTIAL> flags
36are both set.
37
38=head1 NOTES
39
40The main purpose of CMS_add1_signer() is to provide finer control
41over a CMS signed data structure where the simpler CMS_sign() function defaults
42are not appropriate. For example if multiple signers or non default digest
43algorithms are needed. New attributes can also be added using the returned
44CMS_SignerInfo structure and the CMS attribute utility functions or the
45CMS signed receipt request functions.
46
47Any of the following flags (ored together) can be passed in the B<flags>
48parameter.
49
50If B<CMS_REUSE_DIGEST> is set then an attempt is made to copy the content
51digest value from the CMS_ContentInfo structure: to add a signer to an existing
52structure.  An error occurs if a matching digest value cannot be found to copy.
53The returned CMS_ContentInfo structure will be valid and finalized when this
54flag is set.
55
56If B<CMS_PARTIAL> is set in addition to B<CMS_REUSE_DIGEST> then the
57CMS_SignerInfo structure will not be finalized so additional attributes
58can be added. In this case an explicit call to CMS_SignerInfo_sign() is
59needed to finalize it.
60
61If B<CMS_NOCERTS> is set the signer's certificate will not be included in the
62CMS_ContentInfo structure, the signer's certificate must still be supplied in
63the B<signcert> parameter though. This can reduce the size of the signature if
64the signers certificate can be obtained by other means: for example a
65previously signed message.
66
67The SignedData structure includes several CMS signedAttributes including the
68signing time, the CMS content type and the supported list of ciphers in an
69SMIMECapabilities attribute. If B<CMS_NOATTR> is set then no signedAttributes
70will be used at all. If B<CMS_NOSMIMECAP> is set then the SMIMECapabilities
71will be omitted. If B<CMS_NO_SIGNING_TIME> is set then the signing time will be
72omitted.
73
74OpenSSL will by default identify signing certificates using issuer name
75and serial number. If B<CMS_USE_KEYID> is set it will use the subject key
76identifier value instead. An error occurs if the signing certificate does not
77have a subject key identifier extension.
78
79If present the SMIMECapabilities attribute indicates support for the following
80algorithms in preference order: 256 bit AES, Gost R3411-94, Gost 28147-89, 192
81bit AES, 128 bit AES, triple DES, 128 bit RC2, 64 bit RC2, DES and 40 bit RC2.
82If any of these algorithms is not available then it will not be included: for example the GOST algorithms will not be included if the GOST ENGINE is
83not loaded.
84
85CMS_add1_signer() returns an internal pointer to the CMS_SignerInfo
86structure just added, this can be used to set additional attributes
87before it is finalized.
88
89=head1 RETURN VALUES
90
91CMS_add1_signer() returns an internal pointer to the CMS_SignerInfo
92structure just added or NULL if an error occurs.
93
94CMS_SignerInfo_sign() returns 1 on success, 0 on failure.
95
96=head1 SEE ALSO
97
98L<ERR_get_error(3)>, L<CMS_sign(3)>,
99L<CMS_final(3)>,
100
101=head1 COPYRIGHT
102
103Copyright 2014-2016 The OpenSSL Project Authors. All Rights Reserved.
104
105Licensed under the Apache License 2.0 (the "License").  You may not use
106this file except in compliance with the License.  You can obtain a copy
107in the file LICENSE in the source distribution or at
108L<https://www.openssl.org/source/license.html>.
109
110=cut
111