2
0

ecdsa_sign.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (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. ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey)
  13. {
  14. return ECDSA_do_sign_ex(dgst, dlen, NULL, NULL, eckey);
  15. }
  16. ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dlen,
  17. const BIGNUM *kinv, const BIGNUM *rp,
  18. EC_KEY *eckey)
  19. {
  20. if (eckey->meth->sign_sig != NULL)
  21. return eckey->meth->sign_sig(dgst, dlen, kinv, rp, eckey);
  22. ECerr(EC_F_ECDSA_DO_SIGN_EX, EC_R_OPERATION_NOT_SUPPORTED);
  23. return NULL;
  24. }
  25. int ECDSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char
  26. *sig, unsigned int *siglen, EC_KEY *eckey)
  27. {
  28. return ECDSA_sign_ex(type, dgst, dlen, sig, siglen, NULL, NULL, eckey);
  29. }
  30. int ECDSA_sign_ex(int type, const unsigned char *dgst, int dlen,
  31. unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv,
  32. const BIGNUM *r, EC_KEY *eckey)
  33. {
  34. if (eckey->meth->sign != NULL)
  35. return eckey->meth->sign(type, dgst, dlen, sig, siglen, kinv, r, eckey);
  36. ECerr(EC_F_ECDSA_SIGN_EX, EC_R_OPERATION_NOT_SUPPORTED);
  37. return 0;
  38. }
  39. int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
  40. BIGNUM **rp)
  41. {
  42. if (eckey->meth->sign_setup != NULL)
  43. return eckey->meth->sign_setup(eckey, ctx_in, kinvp, rp);
  44. ECerr(EC_F_ECDSA_SIGN_SETUP, EC_R_OPERATION_NOT_SUPPORTED);
  45. return 0;
  46. }