PKCS7_sign_add_signer.pod 4.3 KB

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