EVP_DigestVerifyInit.pod 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. =pod
  2. =head1 NAME
  3. EVP_DigestVerifyInit, EVP_DigestVerifyUpdate, EVP_DigestVerifyFinal,
  4. EVP_DigestVerify - EVP signature verification functions
  5. =head1 SYNOPSIS
  6. #include <openssl/evp.h>
  7. int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
  8. const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey);
  9. int EVP_DigestVerifyUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt);
  10. int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig,
  11. size_t siglen);
  12. int EVP_DigestVerify(EVP_MD_CTX *ctx, const unsigned char *sigret,
  13. size_t siglen, const unsigned char *tbs, size_t tbslen);
  14. =head1 DESCRIPTION
  15. The EVP signature routines are a high level interface to digital signatures.
  16. EVP_DigestVerifyInit() sets up verification context B<ctx> to use digest
  17. B<type> from ENGINE B<e> and public key B<pkey>. B<ctx> must be created
  18. with EVP_MD_CTX_new() before calling this function. If B<pctx> is not NULL the
  19. EVP_PKEY_CTX of the verification operation will be written to B<*pctx>: this
  20. can be used to set alternative verification options.
  21. EVP_DigestVerifyUpdate() hashes B<cnt> bytes of data at B<d> into the
  22. verification context B<ctx>. This function can be called several times on the
  23. same B<ctx> to include additional data. This function is currently implemented
  24. using a macro.
  25. EVP_DigestVerifyFinal() verifies the data in B<ctx> against the signature in
  26. B<sig> of length B<siglen>.
  27. EVP_DigestVerify() verifies B<tbslen> bytes at B<tbs> against the signature
  28. in B<sig> of length B<siglen>.
  29. =head1 RETURN VALUES
  30. EVP_DigestVerifyInit() and EVP_DigestVerifyUpdate() return 1 for success and 0
  31. for failure.
  32. EVP_DigestVerifyFinal() and EVP_DigestVerify() return 1 for success; any other
  33. value indicates failure. A return value of zero indicates that the signature
  34. did not verify successfully (that is, B<tbs> did not match the original data or
  35. the signature had an invalid form), while other values indicate a more serious
  36. error (and sometimes also indicate an invalid signature form).
  37. The error codes can be obtained from L<ERR_get_error(3)>.
  38. =head1 NOTES
  39. The B<EVP> interface to digital signatures should almost always be used in
  40. preference to the low level interfaces. This is because the code then becomes
  41. transparent to the algorithm used and much more flexible.
  42. EVP_DigestVerify() is a one shot operation which verifies a single block of
  43. data in one function. For algorithms that support streaming it is equivalent
  44. to calling EVP_DigestVerifyUpdate() and EVP_DigestVerifyFinal(). For
  45. algorithms which do not support streaming (e.g. PureEdDSA) it is the only way
  46. to verify data.
  47. In previous versions of OpenSSL there was a link between message digest types
  48. and public key algorithms. This meant that "clone" digests such as EVP_dss1()
  49. needed to be used to sign using SHA1 and DSA. This is no longer necessary and
  50. the use of clone digest is now discouraged.
  51. For some key types and parameters the random number generator must be seeded
  52. or the operation will fail.
  53. The call to EVP_DigestVerifyFinal() internally finalizes a copy of the digest
  54. context. This means that EVP_VerifyUpdate() and EVP_VerifyFinal() can
  55. be called later to digest and verify additional data.
  56. Since only a copy of the digest context is ever finalized the context must
  57. be cleaned up after use by calling EVP_MD_CTX_free() or a memory leak
  58. will occur.
  59. =head1 SEE ALSO
  60. L<EVP_DigestSignInit(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<dgst(1)>
  65. =head1 HISTORY
  66. EVP_DigestVerifyInit(), EVP_DigestVerifyUpdate() and EVP_DigestVerifyFinal()
  67. were first added to OpenSSL 1.0.0.
  68. =head1 COPYRIGHT
  69. Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.
  70. Licensed under the OpenSSL license (the "License"). You may not use
  71. this file except in compliance with the License. You can obtain a copy
  72. in the file LICENSE in the source distribution or at
  73. L<https://www.openssl.org/source/license.html>.
  74. =cut