mirror of
https://github.com/ipxe/ipxe
synced 2026-01-28 11:44:14 +03:00
[crypto] Expose the (prime) group order as an elliptic curve property
ECDSA requires knowledge of the group order of the base point, and is defined only for curves with a prime group order (e.g. the NIST curves). Add the group order as an explicit property of an elliptic curve, and add tests to verify that the order is correct. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -183,6 +183,8 @@ struct elliptic_curve {
|
||||
size_t keysize;
|
||||
/** Generator base point */
|
||||
const void *base;
|
||||
/** Order of the generator (if prime) */
|
||||
const void *order;
|
||||
/** Multiply scalar by curve point
|
||||
*
|
||||
* @v base Base point
|
||||
|
||||
@@ -128,7 +128,8 @@ extern int weierstrass_multiply ( struct weierstrass_curve *curve,
|
||||
void *result );
|
||||
|
||||
/** Define a Weierstrass curve */
|
||||
#define WEIERSTRASS_CURVE( _name, _curve, _len, _prime, _a, _b, _base ) \
|
||||
#define WEIERSTRASS_CURVE( _name, _curve, _len, _prime, _a, _b, _base, \
|
||||
_order ) \
|
||||
static bigint_t ( weierstrass_size(_len) ) \
|
||||
_name ## _cache[WEIERSTRASS_NUM_CACHED]; \
|
||||
static struct weierstrass_curve _name ## _weierstrass = { \
|
||||
@@ -161,6 +162,7 @@ extern int weierstrass_multiply ( struct weierstrass_curve *curve,
|
||||
.pointsize = ( WEIERSTRASS_AXES * (_len) ), \
|
||||
.keysize = (_len), \
|
||||
.base = (_base), \
|
||||
.order = (_order), \
|
||||
.multiply = _name ## _multiply, \
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user