Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright (c) 2021 HiSilicon */
0003 
0004 #ifndef _CRYTO_ECC_CURVE_H
0005 #define _CRYTO_ECC_CURVE_H
0006 
0007 #include <linux/types.h>
0008 
0009 /**
0010  * struct ecc_point - elliptic curve point in affine coordinates
0011  *
0012  * @x:      X coordinate in vli form.
0013  * @y:      Y coordinate in vli form.
0014  * @ndigits:    Length of vlis in u64 qwords.
0015  */
0016 struct ecc_point {
0017     u64 *x;
0018     u64 *y;
0019     u8 ndigits;
0020 };
0021 
0022 /**
0023  * struct ecc_curve - definition of elliptic curve
0024  *
0025  * @name:   Short name of the curve.
0026  * @g:      Generator point of the curve.
0027  * @p:      Prime number, if Barrett's reduction is used for this curve
0028  *      pre-calculated value 'mu' is appended to the @p after ndigits.
0029  *      Use of Barrett's reduction is heuristically determined in
0030  *      vli_mmod_fast().
0031  * @n:      Order of the curve group.
0032  * @a:      Curve parameter a.
0033  * @b:      Curve parameter b.
0034  */
0035 struct ecc_curve {
0036     char *name;
0037     struct ecc_point g;
0038     u64 *p;
0039     u64 *n;
0040     u64 *a;
0041     u64 *b;
0042 };
0043 
0044 /**
0045  * ecc_get_curve() - get elliptic curve;
0046  * @curve_id:           Curves IDs:
0047  *                      defined in 'include/crypto/ecdh.h';
0048  *
0049  * Returns curve if get curve succssful, NULL otherwise
0050  */
0051 const struct ecc_curve *ecc_get_curve(unsigned int curve_id);
0052 
0053 /**
0054  * ecc_get_curve25519() - get curve25519 curve;
0055  *
0056  * Returns curve25519
0057  */
0058 const struct ecc_curve *ecc_get_curve25519(void);
0059 
0060 #endif