ec.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright 2018 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. /* Internal EC functions for other submodules: not for application use */
  10. #ifndef OSSL_CRYPTO_EC_H
  11. # define OSSL_CRYPTO_EC_H
  12. # include <openssl/opensslconf.h>
  13. # ifndef OPENSSL_NO_EC
  14. # include <openssl/ec.h>
  15. /*-
  16. * Computes the multiplicative inverse of x in the range
  17. * [1,EC_GROUP::order), where EC_GROUP::order is the cardinality of the
  18. * subgroup generated by the generator G:
  19. *
  20. * res := x^(-1) (mod EC_GROUP::order).
  21. *
  22. * This function expects the following two conditions to hold:
  23. * - the EC_GROUP order is prime, and
  24. * - x is included in the range [1, EC_GROUP::order).
  25. *
  26. * This function returns 1 on success, 0 on error.
  27. *
  28. * If the EC_GROUP order is even, this function explicitly returns 0 as
  29. * an error.
  30. * In case any of the two conditions stated above is not satisfied,
  31. * the correctness of its output is not guaranteed, even if the return
  32. * value could still be 1 (as primality testing and a conditional modular
  33. * reduction round on the input can be omitted by the underlying
  34. * implementations for better SCA properties on regular input values).
  35. */
  36. __owur int ec_group_do_inverse_ord(const EC_GROUP *group, BIGNUM *res,
  37. const BIGNUM *x, BN_CTX *ctx);
  38. /*-
  39. * ECDH Key Derivation Function as defined in ANSI X9.63
  40. */
  41. int ecdh_KDF_X9_63(unsigned char *out, size_t outlen,
  42. const unsigned char *Z, size_t Zlen,
  43. const unsigned char *sinfo, size_t sinfolen,
  44. const EVP_MD *md);
  45. # endif /* OPENSSL_NO_EC */
  46. #endif