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