EVP_VerifyInit.3ossl 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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 "EVP_VERIFYINIT 3ossl"
  58. .TH EVP_VERIFYINIT 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. EVP_VerifyInit_ex,
  65. EVP_VerifyInit, EVP_VerifyUpdate, EVP_VerifyFinal_ex, EVP_VerifyFinal
  66. \&\- EVP signature verification functions
  67. .SH SYNOPSIS
  68. .IX Header "SYNOPSIS"
  69. .Vb 1
  70. \& #include <openssl/evp.h>
  71. \&
  72. \& int EVP_VerifyInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
  73. \& int EVP_VerifyUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
  74. \& int EVP_VerifyFinal_ex(EVP_MD_CTX *ctx, const unsigned char *sigbuf,
  75. \& unsigned int siglen, EVP_PKEY *pkey,
  76. \& OSSL_LIB_CTX *libctx, const char *propq);
  77. \& int EVP_VerifyFinal(EVP_MD_CTX *ctx, unsigned char *sigbuf, unsigned int siglen,
  78. \& EVP_PKEY *pkey);
  79. \&
  80. \& int EVP_VerifyInit(EVP_MD_CTX *ctx, const EVP_MD *type);
  81. .Ve
  82. .SH DESCRIPTION
  83. .IX Header "DESCRIPTION"
  84. The EVP signature verification routines are a high-level interface to digital
  85. signatures.
  86. .PP
  87. \&\fBEVP_VerifyInit_ex()\fR sets up verification context \fIctx\fR to use digest
  88. \&\fItype\fR from ENGINE \fIimpl\fR. \fIctx\fR must be created by calling
  89. \&\fBEVP_MD_CTX_new()\fR before calling this function.
  90. .PP
  91. \&\fBEVP_VerifyUpdate()\fR hashes \fIcnt\fR bytes of data at \fId\fR into the
  92. verification context \fIctx\fR. This function can be called several times on the
  93. same \fIctx\fR to include additional data.
  94. .PP
  95. \&\fBEVP_VerifyFinal_ex()\fR verifies the data in \fIctx\fR using the public key
  96. \&\fIpkey\fR and \fIsiglen\fR bytes in \fIsigbuf\fR.
  97. The library context \fIlibctx\fR and property query \fIpropq\fR are used when creating
  98. a context to use with the key \fIpkey\fR.
  99. .PP
  100. \&\fBEVP_VerifyFinal()\fR is similar to \fBEVP_VerifyFinal_ex()\fR but uses default
  101. values of NULL for the library context \fIlibctx\fR and the property query \fIpropq\fR.
  102. .PP
  103. \&\fBEVP_VerifyInit()\fR initializes verification context \fIctx\fR to use the default
  104. implementation of digest \fItype\fR.
  105. .SH "RETURN VALUES"
  106. .IX Header "RETURN VALUES"
  107. \&\fBEVP_VerifyInit_ex()\fR and \fBEVP_VerifyUpdate()\fR return 1 for success and 0 for
  108. failure.
  109. .PP
  110. \&\fBEVP_VerifyFinal_ex()\fR and \fBEVP_VerifyFinal()\fR return 1 for a correct
  111. signature, 0 for failure and a negative value if some other error occurred.
  112. .PP
  113. The error codes can be obtained by \fBERR_get_error\fR\|(3).
  114. .SH NOTES
  115. .IX Header "NOTES"
  116. The \fBEVP\fR interface to digital signatures should almost always be used in
  117. preference to the low-level interfaces. This is because the code then becomes
  118. transparent to the algorithm used and much more flexible.
  119. .PP
  120. The call to \fBEVP_VerifyFinal()\fR internally finalizes a copy of the digest context.
  121. This means that calls to \fBEVP_VerifyUpdate()\fR and \fBEVP_VerifyFinal()\fR can be called
  122. later to digest and verify additional data. Applications may disable this
  123. behavior by setting the EVP_MD_CTX_FLAG_FINALISE context flag via
  124. \&\fBEVP_MD_CTX_set_flags\fR\|(3).
  125. .PP
  126. Since only a copy of the digest context is ever finalized the context must
  127. be cleaned up after use by calling \fBEVP_MD_CTX_free()\fR or a memory leak
  128. will occur.
  129. .PP
  130. Note that not all providers support continuation, in case the selected
  131. provider does not allow to duplicate contexts \fBEVP_VerifyFinal()\fR will
  132. finalize the digest context and attempting to process additional data via
  133. \&\fBEVP_VerifyUpdate()\fR will result in an error.
  134. .SH BUGS
  135. .IX Header "BUGS"
  136. Older versions of this documentation wrongly stated that calls to
  137. \&\fBEVP_VerifyUpdate()\fR could not be made after calling \fBEVP_VerifyFinal()\fR.
  138. .PP
  139. Since the public key is passed in the call to \fBEVP_SignFinal()\fR any error
  140. relating to the private key (for example an unsuitable key and digest
  141. combination) will not be indicated until after potentially large amounts of
  142. data have been passed through \fBEVP_SignUpdate()\fR.
  143. .PP
  144. It is not possible to change the signing parameters using these function.
  145. .PP
  146. The previous two bugs are fixed in the newer EVP_DigestVerify*() function.
  147. .SH "SEE ALSO"
  148. .IX Header "SEE ALSO"
  149. \&\fBevp\fR\|(7),
  150. \&\fBEVP_SignInit\fR\|(3),
  151. \&\fBEVP_DigestInit\fR\|(3),
  152. \&\fBevp\fR\|(7), \fBHMAC\fR\|(3), \fBMD2\fR\|(3),
  153. \&\fBMD5\fR\|(3), \fBMDC2\fR\|(3), \fBRIPEMD160\fR\|(3),
  154. \&\fBSHA1\fR\|(3), \fBopenssl\-dgst\fR\|(1)
  155. .SH HISTORY
  156. .IX Header "HISTORY"
  157. The function \fBEVP_VerifyFinal_ex()\fR was added in OpenSSL 3.0.
  158. .SH COPYRIGHT
  159. .IX Header "COPYRIGHT"
  160. Copyright 2000\-2023 The OpenSSL Project Authors. All Rights Reserved.
  161. .PP
  162. Licensed under the Apache License 2.0 (the "License"). You may not use
  163. this file except in compliance with the License. You can obtain a copy
  164. in the file LICENSE in the source distribution or at
  165. <https://www.openssl.org/source/license.html>.