1=pod 2 3=head1 NAME 4 5PKCS7_sign_add_signer, 6PKCS7_add_certificate, PKCS7_add_crl - add information to PKCS7 structure 7 8=head1 SYNOPSIS 9 10 #include <openssl/pkcs7.h> 11 12 PKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7, X509 *signcert, 13 EVP_PKEY *pkey, const EVP_MD *md, int flags); 14 int PKCS7_add_certificate(PKCS7 *p7, X509 *cert); 15 int PKCS7_add_crl(PKCS7 *p7, X509_CRL *crl); 16 17=head1 DESCRIPTION 18 19PKCS7_sign_add_signer() adds a signer with certificate I<signcert> and private 20key I<pkey> using message digest I<md> to a PKCS7 signed data structure I<p7>. 21 22The B<PKCS7> structure should be obtained from an initial call to PKCS7_sign() 23with the flag B<PKCS7_PARTIAL> set or in the case or re-signing a valid PKCS#7 24signed data structure. 25 26If the I<md> parameter is NULL then the default digest for the public 27key algorithm will be used. 28 29Unless the B<PKCS7_REUSE_DIGEST> flag is set the returned B<PKCS7> structure 30is not complete and must be finalized either by streaming (if applicable) or 31a call to PKCS7_final(). 32 33 34=head1 NOTES 35 36The main purpose of this function is to provide finer control over a PKCS#7 37signed data structure where the simpler PKCS7_sign() function defaults are 38not appropriate. For example if multiple signers or non default digest 39algorithms are needed. 40 41Any of the following flags (ored together) can be passed in the I<flags> 42parameter. 43 44If B<PKCS7_REUSE_DIGEST> is set then an attempt is made to copy the content 45digest value from the B<PKCS7> structure: to add a signer to an existing structure. 46An error occurs if a matching digest value cannot be found to copy. The 47returned B<PKCS7> structure will be valid and finalized when this flag is set. 48 49If B<PKCS7_PARTIAL> is set in addition to B<PKCS7_REUSE_DIGEST> then the 50B<PKCS7_SIGNER_INO> structure will not be finalized so additional attributes 51can be added. In this case an explicit call to PKCS7_SIGNER_INFO_sign() is 52needed to finalize it. 53 54If B<PKCS7_NOCERTS> is set the signer's certificate will not be included in the 55B<PKCS7> structure, the signer's certificate must still be supplied in the 56I<signcert> parameter though. This can reduce the size of the signature if the 57signers certificate can be obtained by other means: for example a previously 58signed message. 59 60The signedData structure includes several PKCS#7 authenticatedAttributes 61including the signing time, the PKCS#7 content type and the supported list of 62ciphers in an SMIMECapabilities attribute. If B<PKCS7_NOATTR> is set then no 63authenticatedAttributes will be used. If B<PKCS7_NOSMIMECAP> is set then just 64the SMIMECapabilities are omitted. 65 66If present the SMIMECapabilities attribute indicates support for the following 67algorithms: triple DES, 128 bit RC2, 64 bit RC2, DES and 40 bit RC2. If any of 68these algorithms is disabled then it will not be included. 69 70PKCS7_sign_add_signers() returns an internal pointer to the B<PKCS7_SIGNER_INFO> 71structure just added, which can be used to set additional attributes 72before it is finalized. 73 74PKCS7_add_certificate() adds to the B<PKCS7> structure I<p7> the certificate 75I<cert>, which may be an end-entity (signer) certificate 76or a CA certificate useful for chain building. 77This is done internally by L<PKCS7_sign_ex(3)> and similar signing functions. 78It may have to be used before calling L<PKCS7_verify(3)> 79in order to provide any missing certificate(s) needed for verification. 80 81PKCS7_add_crl() adds the CRL I<crl> to the B<PKCS7> structure I<p7>. 82This may be called to provide certificate status information 83to be included when signing or to use when verifying the B<PKCS7> structure. 84 85=head1 RETURN VALUES 86 87PKCS7_sign_add_signers() returns an internal pointer to the B<PKCS7_SIGNER_INFO> 88structure just added or NULL if an error occurs. 89 90PKCS7_add_certificate() and PKCS7_add_crl() return 1 on success, 0 on error. 91 92=head1 SEE ALSO 93 94L<ERR_get_error(3)>, L<PKCS7_sign_ex(3)>, 95L<PKCS7_final(3)>, L<PKCS7_verify(3)> 96 97=head1 HISTORY 98 99The PPKCS7_sign_add_signer() function was added in OpenSSL 1.0.0. 100 101=head1 COPYRIGHT 102 103Copyright 2007-2022 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