mirror of
https://github.com/ipxe/ipxe
synced 2026-05-08 15:02:55 +03:00
[crypto] Expose the base point as an explicit elliptic curve property
Add the generator base point as an explicit property of an elliptic curve, and remove the ability to pass a NULL to elliptic_multiply() to imply the use of the generator base point. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
+1
-1
@@ -55,7 +55,7 @@ int ecdhe_key ( struct elliptic_curve *curve, const void *partner,
|
||||
}
|
||||
|
||||
/* Construct public key */
|
||||
if ( ( rc = elliptic_multiply ( curve, NULL, private,
|
||||
if ( ( rc = elliptic_multiply ( curve, curve->base, private,
|
||||
public ) ) != 0 ) {
|
||||
DBGC ( curve, "CURVE %s could not generate public key: %s\n",
|
||||
curve->name, strerror ( rc ) );
|
||||
|
||||
@@ -762,7 +762,7 @@ static int weierstrass_verify_raw ( const struct weierstrass_curve *curve,
|
||||
* Multiply curve point by scalar
|
||||
*
|
||||
* @v curve Weierstrass curve
|
||||
* @v base Base point (or NULL to use generator)
|
||||
* @v base Base point
|
||||
* @v scalar Scalar multiple
|
||||
* @v result Result point to fill in
|
||||
* @ret rc Return status code
|
||||
@@ -806,10 +806,6 @@ int weierstrass_multiply ( struct weierstrass_curve *curve, const void *base,
|
||||
if ( ! prime2->element[0] )
|
||||
weierstrass_init ( curve );
|
||||
|
||||
/* Use generator if applicable */
|
||||
if ( ! base )
|
||||
base = curve->base;
|
||||
|
||||
/* Convert input to projective coordinates in Montgomery form */
|
||||
DBGC ( curve, "WEIERSTRASS %s base (", curve->name );
|
||||
for ( i = 0, offset = 0 ; i < WEIERSTRASS_AXES ; i++, offset += len ) {
|
||||
|
||||
+2
-5
@@ -822,7 +822,7 @@ int x25519_key ( const struct x25519_value *base,
|
||||
/**
|
||||
* Multiply scalar by curve point
|
||||
*
|
||||
* @v base Base point (or NULL to use generator)
|
||||
* @v base Base point
|
||||
* @v scalar Scalar multiple
|
||||
* @v result Result point to fill in
|
||||
* @ret rc Return status code
|
||||
@@ -830,10 +830,6 @@ int x25519_key ( const struct x25519_value *base,
|
||||
static int x25519_curve_multiply ( const void *base, const void *scalar,
|
||||
void *result ) {
|
||||
|
||||
/* Use base point if applicable */
|
||||
if ( ! base )
|
||||
base = &x25519_generator;
|
||||
|
||||
return x25519_key ( base, scalar, result );
|
||||
}
|
||||
|
||||
@@ -842,5 +838,6 @@ struct elliptic_curve x25519_curve = {
|
||||
.name = "x25519",
|
||||
.pointsize = sizeof ( struct x25519_value ),
|
||||
.keysize = sizeof ( struct x25519_value ),
|
||||
.base = x25519_generator.raw,
|
||||
.multiply = x25519_curve_multiply,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user