ecdsa_vrf.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #include <openssl/ec.h>
  10. #include "ec_lcl.h"
  11. #include <openssl/err.h>
  12. /*-
  13. * returns
  14. * 1: correct signature
  15. * 0: incorrect signature
  16. * -1: error
  17. */
  18. int ECDSA_do_verify(const unsigned char *dgst, int dgst_len,
  19. const ECDSA_SIG *sig, EC_KEY *eckey)
  20. {
  21. if (eckey->meth->verify_sig != NULL)
  22. return eckey->meth->verify_sig(dgst, dgst_len, sig, eckey);
  23. ECerr(EC_F_ECDSA_DO_VERIFY, EC_R_OPERATION_NOT_SUPPORTED);
  24. return 0;
  25. }
  26. /*-
  27. * returns
  28. * 1: correct signature
  29. * 0: incorrect signature
  30. * -1: error
  31. */
  32. int ECDSA_verify(int type, const unsigned char *dgst, int dgst_len,
  33. const unsigned char *sigbuf, int sig_len, EC_KEY *eckey)
  34. {
  35. if (eckey->meth->verify != NULL)
  36. return eckey->meth->verify(type, dgst, dgst_len, sigbuf, sig_len,
  37. eckey);
  38. ECerr(EC_F_ECDSA_VERIFY, EC_R_OPERATION_NOT_SUPPORTED);
  39. return 0;
  40. }