CMS_add1_signer.3ossl 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "CMS_ADD1_SIGNER 3ossl"
  58. .TH CMS_ADD1_SIGNER 3ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. CMS_add1_signer, CMS_SignerInfo_sign \- add a signer to a CMS_ContentInfo signed data structure
  65. .SH SYNOPSIS
  66. .IX Header "SYNOPSIS"
  67. .Vb 1
  68. \& #include <openssl/cms.h>
  69. \&
  70. \& CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms, X509 *signcert,
  71. \& EVP_PKEY *pkey, const EVP_MD *md,
  72. \& unsigned int flags);
  73. \&
  74. \& int CMS_SignerInfo_sign(CMS_SignerInfo *si);
  75. .Ve
  76. .SH DESCRIPTION
  77. .IX Header "DESCRIPTION"
  78. \&\fBCMS_add1_signer()\fR adds a signer with certificate \fBsigncert\fR and private
  79. key \fBpkey\fR using message digest \fBmd\fR to CMS_ContentInfo SignedData
  80. structure \fBcms\fR.
  81. .PP
  82. The CMS_ContentInfo structure should be obtained from an initial call to
  83. \&\fBCMS_sign()\fR with the flag \fBCMS_PARTIAL\fR set or in the case or re-signing a
  84. valid CMS_ContentInfo SignedData structure.
  85. .PP
  86. If the \fBmd\fR parameter is \fBNULL\fR then the default digest for the public
  87. key algorithm will be used.
  88. .PP
  89. Unless the \fBCMS_REUSE_DIGEST\fR flag is set the returned CMS_ContentInfo
  90. structure is not complete and must be finalized either by streaming (if
  91. applicable) or a call to \fBCMS_final()\fR.
  92. .PP
  93. The \fBCMS_SignerInfo_sign()\fR function explicitly signs a CMS_SignerInfo
  94. structure, its main use is when the \fBCMS_REUSE_DIGEST\fR and \fBCMS_PARTIAL\fR flags
  95. are both set.
  96. .SH NOTES
  97. .IX Header "NOTES"
  98. The main purpose of \fBCMS_add1_signer()\fR is to provide finer control
  99. over a CMS signed data structure where the simpler \fBCMS_sign()\fR function defaults
  100. are not appropriate. For example if multiple signers or non default digest
  101. algorithms are needed. New attributes can also be added using the returned
  102. CMS_SignerInfo structure and the CMS attribute utility functions or the
  103. CMS signed receipt request functions.
  104. .PP
  105. Any of the following flags (ored together) can be passed in the \fBflags\fR
  106. parameter.
  107. .PP
  108. If \fBCMS_REUSE_DIGEST\fR is set then an attempt is made to copy the content
  109. digest value from the CMS_ContentInfo structure: to add a signer to an existing
  110. structure. An error occurs if a matching digest value cannot be found to copy.
  111. The returned CMS_ContentInfo structure will be valid and finalized when this
  112. flag is set.
  113. .PP
  114. If \fBCMS_PARTIAL\fR is set in addition to \fBCMS_REUSE_DIGEST\fR then the
  115. CMS_SignerInfo structure will not be finalized so additional attributes
  116. can be added. In this case an explicit call to \fBCMS_SignerInfo_sign()\fR is
  117. needed to finalize it.
  118. .PP
  119. If \fBCMS_NOCERTS\fR is set the signer's certificate will not be included in the
  120. CMS_ContentInfo structure, the signer's certificate must still be supplied in
  121. the \fBsigncert\fR parameter though. This can reduce the size of the signature if
  122. the signers certificate can be obtained by other means: for example a
  123. previously signed message.
  124. .PP
  125. The SignedData structure includes several CMS signedAttributes including the
  126. signing time, the CMS content type and the supported list of ciphers in an
  127. SMIMECapabilities attribute. If \fBCMS_NOATTR\fR is set then no signedAttributes
  128. will be used. If \fBCMS_NOSMIMECAP\fR is set then just the SMIMECapabilities are
  129. omitted.
  130. .PP
  131. OpenSSL will by default identify signing certificates using issuer name
  132. and serial number. If \fBCMS_USE_KEYID\fR is set it will use the subject key
  133. identifier value instead. An error occurs if the signing certificate does not
  134. have a subject key identifier extension.
  135. .PP
  136. If present the SMIMECapabilities attribute indicates support for the following
  137. algorithms in preference order: 256 bit AES, Gost R3411\-94, Gost 28147\-89, 192
  138. bit AES, 128 bit AES, triple DES, 128 bit RC2, 64 bit RC2, DES and 40 bit RC2.
  139. 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
  140. not loaded.
  141. .PP
  142. \&\fBCMS_add1_signer()\fR returns an internal pointer to the CMS_SignerInfo
  143. structure just added, this can be used to set additional attributes
  144. before it is finalized.
  145. .SH "RETURN VALUES"
  146. .IX Header "RETURN VALUES"
  147. \&\fBCMS_add1_signer()\fR returns an internal pointer to the CMS_SignerInfo
  148. structure just added or NULL if an error occurs.
  149. .PP
  150. \&\fBCMS_SignerInfo_sign()\fR returns 1 on success, 0 on failure.
  151. .SH "SEE ALSO"
  152. .IX Header "SEE ALSO"
  153. \&\fBERR_get_error\fR\|(3), \fBCMS_sign\fR\|(3),
  154. \&\fBCMS_final\fR\|(3),
  155. .SH COPYRIGHT
  156. .IX Header "COPYRIGHT"
  157. Copyright 2014\-2016 The OpenSSL Project Authors. All Rights Reserved.
  158. .PP
  159. Licensed under the Apache License 2.0 (the "License"). You may not use
  160. this file except in compliance with the License. You can obtain a copy
  161. in the file LICENSE in the source distribution or at
  162. <https://www.openssl.org/source/license.html>.