PKCS7_sign_add_signer.3ossl 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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 "PKCS7_SIGN_ADD_SIGNER 3ossl"
  58. .TH PKCS7_SIGN_ADD_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. PKCS7_sign_add_signer,
  65. PKCS7_add_certificate, PKCS7_add_crl \- add information to PKCS7 structure
  66. .SH SYNOPSIS
  67. .IX Header "SYNOPSIS"
  68. .Vb 1
  69. \& #include <openssl/pkcs7.h>
  70. \&
  71. \& PKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7, X509 *signcert,
  72. \& EVP_PKEY *pkey, const EVP_MD *md, int flags);
  73. \& int PKCS7_add_certificate(PKCS7 *p7, X509 *cert);
  74. \& int PKCS7_add_crl(PKCS7 *p7, X509_CRL *crl);
  75. .Ve
  76. .SH DESCRIPTION
  77. .IX Header "DESCRIPTION"
  78. \&\fBPKCS7_sign_add_signer()\fR adds a signer with certificate \fIsigncert\fR and private
  79. key \fIpkey\fR using message digest \fImd\fR to a PKCS7 signed data structure \fIp7\fR.
  80. .PP
  81. The \fBPKCS7\fR structure should be obtained from an initial call to \fBPKCS7_sign()\fR
  82. with the flag \fBPKCS7_PARTIAL\fR set or in the case or re-signing a valid PKCS#7
  83. signed data structure.
  84. .PP
  85. If the \fImd\fR parameter is NULL then the default digest for the public
  86. key algorithm will be used.
  87. .PP
  88. Unless the \fBPKCS7_REUSE_DIGEST\fR flag is set the returned \fBPKCS7\fR structure
  89. is not complete and must be finalized either by streaming (if applicable) or
  90. a call to \fBPKCS7_final()\fR.
  91. .SH NOTES
  92. .IX Header "NOTES"
  93. The main purpose of this function is to provide finer control over a PKCS#7
  94. signed data structure where the simpler \fBPKCS7_sign()\fR function defaults are
  95. not appropriate. For example if multiple signers or non default digest
  96. algorithms are needed.
  97. .PP
  98. Any of the following flags (ored together) can be passed in the \fIflags\fR
  99. parameter.
  100. .PP
  101. If \fBPKCS7_REUSE_DIGEST\fR is set then an attempt is made to copy the content
  102. digest value from the \fBPKCS7\fR structure: to add a signer to an existing structure.
  103. An error occurs if a matching digest value cannot be found to copy. The
  104. returned \fBPKCS7\fR structure will be valid and finalized when this flag is set.
  105. .PP
  106. If \fBPKCS7_PARTIAL\fR is set in addition to \fBPKCS7_REUSE_DIGEST\fR then the
  107. \&\fBPKCS7_SIGNER_INO\fR structure will not be finalized so additional attributes
  108. can be added. In this case an explicit call to \fBPKCS7_SIGNER_INFO_sign()\fR is
  109. needed to finalize it.
  110. .PP
  111. If \fBPKCS7_NOCERTS\fR is set the signer's certificate will not be included in the
  112. \&\fBPKCS7\fR structure, the signer's certificate must still be supplied in the
  113. \&\fIsigncert\fR parameter though. This can reduce the size of the signature if the
  114. signers certificate can be obtained by other means: for example a previously
  115. signed message.
  116. .PP
  117. The signedData structure includes several PKCS#7 authenticatedAttributes
  118. including the signing time, the PKCS#7 content type and the supported list of
  119. ciphers in an SMIMECapabilities attribute. If \fBPKCS7_NOATTR\fR is set then no
  120. authenticatedAttributes will be used. If \fBPKCS7_NOSMIMECAP\fR is set then just
  121. the SMIMECapabilities are omitted.
  122. .PP
  123. If present the SMIMECapabilities attribute indicates support for the following
  124. algorithms: triple DES, 128 bit RC2, 64 bit RC2, DES and 40 bit RC2. If any of
  125. these algorithms is disabled then it will not be included.
  126. .PP
  127. \&\fBPKCS7_sign_add_signers()\fR returns an internal pointer to the \fBPKCS7_SIGNER_INFO\fR
  128. structure just added, which can be used to set additional attributes
  129. before it is finalized.
  130. .PP
  131. \&\fBPKCS7_add_certificate()\fR adds to the \fBPKCS7\fR structure \fIp7\fR the certificate
  132. \&\fIcert\fR, which may be an end-entity (signer) certificate
  133. or a CA certificate useful for chain building.
  134. This is done internally by \fBPKCS7_sign_ex\fR\|(3) and similar signing functions.
  135. It may have to be used before calling \fBPKCS7_verify\fR\|(3)
  136. in order to provide any missing certificate(s) needed for verification.
  137. .PP
  138. \&\fBPKCS7_add_crl()\fR adds the CRL \fIcrl\fR to the \fBPKCS7\fR structure \fIp7\fR.
  139. This may be called to provide certificate status information
  140. to be included when signing or to use when verifying the \fBPKCS7\fR structure.
  141. .SH "RETURN VALUES"
  142. .IX Header "RETURN VALUES"
  143. \&\fBPKCS7_sign_add_signers()\fR returns an internal pointer to the \fBPKCS7_SIGNER_INFO\fR
  144. structure just added or NULL if an error occurs.
  145. .PP
  146. \&\fBPKCS7_add_certificate()\fR and \fBPKCS7_add_crl()\fR return 1 on success, 0 on error.
  147. .SH "SEE ALSO"
  148. .IX Header "SEE ALSO"
  149. \&\fBERR_get_error\fR\|(3), \fBPKCS7_sign_ex\fR\|(3),
  150. \&\fBPKCS7_final\fR\|(3), \fBPKCS7_verify\fR\|(3)
  151. .SH HISTORY
  152. .IX Header "HISTORY"
  153. The \fBPPKCS7_sign_add_signer()\fR function was added in OpenSSL 1.0.0.
  154. .SH COPYRIGHT
  155. .IX Header "COPYRIGHT"
  156. Copyright 2007\-2016 The OpenSSL Project Authors. All Rights Reserved.
  157. .PP
  158. Licensed under the Apache License 2.0 (the "License"). You may not use
  159. this file except in compliance with the License. You can obtain a copy
  160. in the file LICENSE in the source distribution or at
  161. <https://www.openssl.org/source/license.html>.