CMS_add1_signer.pod 4.2 KB

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