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