1e71b7053SJung-uk Kim=pod 2e71b7053SJung-uk Kim 3e71b7053SJung-uk Kim=head1 NAME 4e71b7053SJung-uk Kim 5cfc39718SJung-uk KimPKCS7_sign_add_signer, 6cfc39718SJung-uk KimPKCS7_add_certificate, PKCS7_add_crl - add information to PKCS7 structure 7e71b7053SJung-uk Kim 8e71b7053SJung-uk Kim=head1 SYNOPSIS 9e71b7053SJung-uk Kim 10e71b7053SJung-uk Kim #include <openssl/pkcs7.h> 11e71b7053SJung-uk Kim 12e71b7053SJung-uk Kim PKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7, X509 *signcert, 13e71b7053SJung-uk Kim EVP_PKEY *pkey, const EVP_MD *md, int flags); 14cfc39718SJung-uk Kim int PKCS7_add_certificate(PKCS7 *p7, X509 *cert); 15cfc39718SJung-uk Kim int PKCS7_add_crl(PKCS7 *p7, X509_CRL *crl); 16e71b7053SJung-uk Kim 17e71b7053SJung-uk Kim=head1 DESCRIPTION 18e71b7053SJung-uk Kim 19cfc39718SJung-uk KimPKCS7_sign_add_signer() adds a signer with certificate I<signcert> and private 20cfc39718SJung-uk Kimkey I<pkey> using message digest I<md> to a PKCS7 signed data structure I<p7>. 21e71b7053SJung-uk Kim 22cfc39718SJung-uk KimThe B<PKCS7> structure should be obtained from an initial call to PKCS7_sign() 23cfc39718SJung-uk Kimwith the flag B<PKCS7_PARTIAL> set or in the case or re-signing a valid PKCS#7 24e71b7053SJung-uk Kimsigned data structure. 25e71b7053SJung-uk Kim 26cfc39718SJung-uk KimIf the I<md> parameter is NULL then the default digest for the public 27e71b7053SJung-uk Kimkey algorithm will be used. 28e71b7053SJung-uk Kim 29cfc39718SJung-uk KimUnless the B<PKCS7_REUSE_DIGEST> flag is set the returned B<PKCS7> structure 30e71b7053SJung-uk Kimis not complete and must be finalized either by streaming (if applicable) or 31e71b7053SJung-uk Kima call to PKCS7_final(). 32e71b7053SJung-uk Kim 33e71b7053SJung-uk Kim 34e71b7053SJung-uk Kim=head1 NOTES 35e71b7053SJung-uk Kim 36e71b7053SJung-uk KimThe main purpose of this function is to provide finer control over a PKCS#7 37e71b7053SJung-uk Kimsigned data structure where the simpler PKCS7_sign() function defaults are 38e71b7053SJung-uk Kimnot appropriate. For example if multiple signers or non default digest 39e71b7053SJung-uk Kimalgorithms are needed. 40e71b7053SJung-uk Kim 41cfc39718SJung-uk KimAny of the following flags (ored together) can be passed in the I<flags> 42e71b7053SJung-uk Kimparameter. 43e71b7053SJung-uk Kim 44e71b7053SJung-uk KimIf B<PKCS7_REUSE_DIGEST> is set then an attempt is made to copy the content 45cfc39718SJung-uk Kimdigest value from the B<PKCS7> structure: to add a signer to an existing structure. 46e71b7053SJung-uk KimAn error occurs if a matching digest value cannot be found to copy. The 47cfc39718SJung-uk Kimreturned B<PKCS7> structure will be valid and finalized when this flag is set. 48e71b7053SJung-uk Kim 49e71b7053SJung-uk KimIf B<PKCS7_PARTIAL> is set in addition to B<PKCS7_REUSE_DIGEST> then the 50e71b7053SJung-uk KimB<PKCS7_SIGNER_INO> structure will not be finalized so additional attributes 51e71b7053SJung-uk Kimcan be added. In this case an explicit call to PKCS7_SIGNER_INFO_sign() is 52e71b7053SJung-uk Kimneeded to finalize it. 53e71b7053SJung-uk Kim 54e71b7053SJung-uk KimIf B<PKCS7_NOCERTS> is set the signer's certificate will not be included in the 55cfc39718SJung-uk KimB<PKCS7> structure, the signer's certificate must still be supplied in the 56cfc39718SJung-uk KimI<signcert> parameter though. This can reduce the size of the signature if the 57e71b7053SJung-uk Kimsigners certificate can be obtained by other means: for example a previously 58e71b7053SJung-uk Kimsigned message. 59e71b7053SJung-uk Kim 60e71b7053SJung-uk KimThe signedData structure includes several PKCS#7 authenticatedAttributes 61e71b7053SJung-uk Kimincluding the signing time, the PKCS#7 content type and the supported list of 62e71b7053SJung-uk Kimciphers in an SMIMECapabilities attribute. If B<PKCS7_NOATTR> is set then no 63e71b7053SJung-uk KimauthenticatedAttributes will be used. If B<PKCS7_NOSMIMECAP> is set then just 64e71b7053SJung-uk Kimthe SMIMECapabilities are omitted. 65e71b7053SJung-uk Kim 66e71b7053SJung-uk KimIf present the SMIMECapabilities attribute indicates support for the following 67e71b7053SJung-uk Kimalgorithms: triple DES, 128 bit RC2, 64 bit RC2, DES and 40 bit RC2. If any of 68e71b7053SJung-uk Kimthese algorithms is disabled then it will not be included. 69e71b7053SJung-uk Kim 70cfc39718SJung-uk KimPKCS7_sign_add_signers() returns an internal pointer to the B<PKCS7_SIGNER_INFO> 71cfc39718SJung-uk Kimstructure just added, which can be used to set additional attributes 72e71b7053SJung-uk Kimbefore it is finalized. 73e71b7053SJung-uk Kim 74cfc39718SJung-uk KimPKCS7_add_certificate() adds to the B<PKCS7> structure I<p7> the certificate 75cfc39718SJung-uk KimI<cert>, which may be an end-entity (signer) certificate 76cfc39718SJung-uk Kimor a CA certificate useful for chain building. 77cfc39718SJung-uk KimThis is done internally by L<PKCS7_sign_ex(3)> and similar signing functions. 78cfc39718SJung-uk KimIt may have to be used before calling L<PKCS7_verify(3)> 79cfc39718SJung-uk Kimin order to provide any missing certificate(s) needed for verification. 80cfc39718SJung-uk Kim 81cfc39718SJung-uk KimPKCS7_add_crl() adds the CRL I<crl> to the B<PKCS7> structure I<p7>. 82cfc39718SJung-uk KimThis may be called to provide certificate status information 83cfc39718SJung-uk Kimto be included when signing or to use when verifying the B<PKCS7> structure. 84cfc39718SJung-uk Kim 85e71b7053SJung-uk Kim=head1 RETURN VALUES 86e71b7053SJung-uk Kim 87cfc39718SJung-uk KimPKCS7_sign_add_signers() returns an internal pointer to the B<PKCS7_SIGNER_INFO> 88e71b7053SJung-uk Kimstructure just added or NULL if an error occurs. 89e71b7053SJung-uk Kim 90cfc39718SJung-uk KimPKCS7_add_certificate() and PKCS7_add_crl() return 1 on success, 0 on error. 91cfc39718SJung-uk Kim 92e71b7053SJung-uk Kim=head1 SEE ALSO 93e71b7053SJung-uk Kim 94cfc39718SJung-uk KimL<ERR_get_error(3)>, L<PKCS7_sign_ex(3)>, 95cfc39718SJung-uk KimL<PKCS7_final(3)>, L<PKCS7_verify(3)> 96e71b7053SJung-uk Kim 97e71b7053SJung-uk Kim=head1 HISTORY 98e71b7053SJung-uk Kim 996935a639SJung-uk KimThe PPKCS7_sign_add_signer() function was added in OpenSSL 1.0.0. 100e71b7053SJung-uk Kim 101e71b7053SJung-uk Kim=head1 COPYRIGHT 102e71b7053SJung-uk Kim 103*e7be843bSPierre ProncheryCopyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. 104e71b7053SJung-uk Kim 105b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 106e71b7053SJung-uk Kimthis file except in compliance with the License. You can obtain a copy 107e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at 108e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>. 109e71b7053SJung-uk Kim 110e71b7053SJung-uk Kim=cut 111