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