ecc_curve.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) 2021 HiSilicon */
  3. #ifndef _CRYTO_ECC_CURVE_H
  4. #define _CRYTO_ECC_CURVE_H
  5. #include <linux/types.h>
  6. /**
  7. * struct ecc_point - elliptic curve point in affine coordinates
  8. *
  9. * @x: X coordinate in vli form.
  10. * @y: Y coordinate in vli form.
  11. * @ndigits: Length of vlis in u64 qwords.
  12. */
  13. struct ecc_point {
  14. u64 *x;
  15. u64 *y;
  16. u8 ndigits;
  17. };
  18. /**
  19. * struct ecc_curve - definition of elliptic curve
  20. *
  21. * @name: Short name of the curve.
  22. * @g: Generator point of the curve.
  23. * @p: Prime number, if Barrett's reduction is used for this curve
  24. * pre-calculated value 'mu' is appended to the @p after ndigits.
  25. * Use of Barrett's reduction is heuristically determined in
  26. * vli_mmod_fast().
  27. * @n: Order of the curve group.
  28. * @a: Curve parameter a.
  29. * @b: Curve parameter b.
  30. */
  31. struct ecc_curve {
  32. char *name;
  33. struct ecc_point g;
  34. u64 *p;
  35. u64 *n;
  36. u64 *a;
  37. u64 *b;
  38. };
  39. /**
  40. * ecc_get_curve() - get elliptic curve;
  41. * @curve_id: Curves IDs:
  42. * defined in 'include/crypto/ecdh.h';
  43. *
  44. * Returns curve if get curve succssful, NULL otherwise
  45. */
  46. const struct ecc_curve *ecc_get_curve(unsigned int curve_id);
  47. /**
  48. * ecc_get_curve25519() - get curve25519 curve;
  49. *
  50. * Returns curve25519
  51. */
  52. const struct ecc_curve *ecc_get_curve25519(void);
  53. #endif