EVP_VerifyInit.pod 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. =pod
  2. =head1 NAME
  3. EVP_VerifyInit_ex,
  4. EVP_VerifyInit, EVP_VerifyUpdate, EVP_VerifyFinal_ex, EVP_VerifyFinal
  5. - EVP signature verification functions
  6. =head1 SYNOPSIS
  7. #include <openssl/evp.h>
  8. int EVP_VerifyInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
  9. int EVP_VerifyUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
  10. int EVP_VerifyFinal_ex(EVP_MD_CTX *ctx, const unsigned char *sigbuf,
  11. unsigned int siglen, EVP_PKEY *pkey,
  12. OSSL_LIB_CTX *libctx, const char *propq);
  13. int EVP_VerifyFinal(EVP_MD_CTX *ctx, unsigned char *sigbuf, unsigned int siglen,
  14. EVP_PKEY *pkey);
  15. int EVP_VerifyInit(EVP_MD_CTX *ctx, const EVP_MD *type);
  16. =head1 DESCRIPTION
  17. The EVP signature verification routines are a high-level interface to digital
  18. signatures.
  19. EVP_VerifyInit_ex() sets up verification context I<ctx> to use digest
  20. I<type> from ENGINE I<impl>. I<ctx> must be created by calling
  21. EVP_MD_CTX_new() before calling this function.
  22. EVP_VerifyUpdate() hashes I<cnt> bytes of data at I<d> into the
  23. verification context I<ctx>. This function can be called several times on the
  24. same I<ctx> to include additional data.
  25. EVP_VerifyFinal_ex() verifies the data in I<ctx> using the public key
  26. I<pkey> and I<siglen> bytes in I<sigbuf>.
  27. The library context I<libctx> and property query I<propq> are used when creating
  28. a context to use with the key I<pkey>.
  29. EVP_VerifyFinal() is similar to EVP_VerifyFinal_ex() but uses default
  30. values of NULL for the library context I<libctx> and the property query I<propq>.
  31. EVP_VerifyInit() initializes verification context I<ctx> to use the default
  32. implementation of digest I<type>.
  33. =head1 RETURN VALUES
  34. EVP_VerifyInit_ex() and EVP_VerifyUpdate() return 1 for success and 0 for
  35. failure.
  36. EVP_VerifyFinal_ex() and EVP_VerifyFinal() return 1 for a correct
  37. signature, 0 for failure and a negative value if some other error occurred.
  38. The error codes can be obtained by L<ERR_get_error(3)>.
  39. =head1 NOTES
  40. The B<EVP> interface to digital signatures should almost always be used in
  41. preference to the low-level interfaces. This is because the code then becomes
  42. transparent to the algorithm used and much more flexible.
  43. The call to EVP_VerifyFinal() internally finalizes a copy of the digest context.
  44. This means that calls to EVP_VerifyUpdate() and EVP_VerifyFinal() can be called
  45. later to digest and verify additional data. Applications may disable this
  46. behavior by setting the EVP_MD_CTX_FLAG_FINALISE context flag via
  47. L<EVP_MD_CTX_set_flags(3)>.
  48. Since only a copy of the digest context is ever finalized the context must
  49. be cleaned up after use by calling EVP_MD_CTX_free() or a memory leak
  50. will occur.
  51. Note that not all providers support continuation, in case the selected
  52. provider does not allow to duplicate contexts EVP_VerifyFinal() will
  53. finalize the digest context and attempting to process additional data via
  54. EVP_VerifyUpdate() will result in an error.
  55. =head1 BUGS
  56. Older versions of this documentation wrongly stated that calls to
  57. EVP_VerifyUpdate() could not be made after calling EVP_VerifyFinal().
  58. Since the public key is passed in the call to EVP_SignFinal() any error
  59. relating to the private key (for example an unsuitable key and digest
  60. combination) will not be indicated until after potentially large amounts of
  61. data have been passed through EVP_SignUpdate().
  62. It is not possible to change the signing parameters using these function.
  63. The previous two bugs are fixed in the newer EVP_DigestVerify*() function.
  64. =head1 SEE ALSO
  65. L<evp(7)>,
  66. L<EVP_SignInit(3)>,
  67. L<EVP_DigestInit(3)>,
  68. L<evp(7)>, L<HMAC(3)>, L<MD2(3)>,
  69. L<MD5(3)>, L<MDC2(3)>, L<RIPEMD160(3)>,
  70. L<SHA1(3)>, L<openssl-dgst(1)>
  71. =head1 HISTORY
  72. The function EVP_VerifyFinal_ex() was added in OpenSSL 3.0.
  73. =head1 COPYRIGHT
  74. Copyright 2000-2023 The OpenSSL Project Authors. All Rights Reserved.
  75. Licensed under the Apache License 2.0 (the "License"). You may not use
  76. this file except in compliance with the License. You can obtain a copy
  77. in the file LICENSE in the source distribution or at
  78. L<https://www.openssl.org/source/license.html>.
  79. =cut