EVP_VerifyInit.pod 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 -1 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.
  46. Since only a copy of the digest context is ever finalized the context must
  47. be cleaned up after use by calling EVP_MD_CTX_free() or a memory leak
  48. will occur.
  49. =head1 BUGS
  50. Older versions of this documentation wrongly stated that calls to
  51. EVP_VerifyUpdate() could not be made after calling EVP_VerifyFinal().
  52. Since the public key is passed in the call to EVP_SignFinal() any error
  53. relating to the private key (for example an unsuitable key and digest
  54. combination) will not be indicated until after potentially large amounts of
  55. data have been passed through EVP_SignUpdate().
  56. It is not possible to change the signing parameters using these function.
  57. The previous two bugs are fixed in the newer EVP_DigestVerify*() function.
  58. =head1 SEE ALSO
  59. L<evp(7)>,
  60. L<EVP_SignInit(3)>,
  61. L<EVP_DigestInit(3)>,
  62. L<evp(7)>, L<HMAC(3)>, L<MD2(3)>,
  63. L<MD5(3)>, L<MDC2(3)>, L<RIPEMD160(3)>,
  64. L<SHA1(3)>, L<openssl-dgst(1)>
  65. head1 HISTORY
  66. The function EVP_VerifyFinal_ex() was added in OpenSSL 3.0.
  67. =head1 COPYRIGHT
  68. Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
  69. Licensed under the Apache License 2.0 (the "License"). You may not use
  70. this file except in compliance with the License. You can obtain a copy
  71. in the file LICENSE in the source distribution or at
  72. L<https://www.openssl.org/source/license.html>.
  73. =cut