Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / include / crypto / ecc_curve.h
blob7d90c5e822667d931e00264107a185ad2c77ced8
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2021 HiSilicon */
4 #ifndef _CRYTO_ECC_CURVE_H
5 #define _CRYTO_ECC_CURVE_H
7 #include <linux/types.h>
9 /**
10 * struct ecc_point - elliptic curve point in affine coordinates
12 * @x: X coordinate in vli form.
13 * @y: Y coordinate in vli form.
14 * @ndigits: Length of vlis in u64 qwords.
16 struct ecc_point {
17 u64 *x;
18 u64 *y;
19 u8 ndigits;
22 /**
23 * struct ecc_curve - definition of elliptic curve
25 * @name: Short name of the curve.
26 * @nbits: The number of bits of a curve.
27 * @g: Generator point of the curve.
28 * @p: Prime number, if Barrett's reduction is used for this curve
29 * pre-calculated value 'mu' is appended to the @p after ndigits.
30 * Use of Barrett's reduction is heuristically determined in
31 * vli_mmod_fast().
32 * @n: Order of the curve group.
33 * @a: Curve parameter a.
34 * @b: Curve parameter b.
36 struct ecc_curve {
37 char *name;
38 u32 nbits;
39 struct ecc_point g;
40 u64 *p;
41 u64 *n;
42 u64 *a;
43 u64 *b;
46 /**
47 * ecc_get_curve() - get elliptic curve;
48 * @curve_id: Curves IDs:
49 * defined in 'include/crypto/ecdh.h';
51 * Returns curve if get curve succssful, NULL otherwise
53 const struct ecc_curve *ecc_get_curve(unsigned int curve_id);
55 /**
56 * ecc_get_curve25519() - get curve25519 curve;
58 * Returns curve25519
60 const struct ecc_curve *ecc_get_curve25519(void);
62 #endif