summaryrefslogtreecommitdiffstats
path: root/src/crypto
diff options
context:
space:
mode:
authorMichael Brown2025-12-05 14:00:12 +0100
committerMichael Brown2025-12-05 14:09:07 +0100
commite50e30a7f8eafea0a1975c555a6fdcab35d8243a (patch)
tree84f7a60bf679a129c5cc1b287e6bb1810684eb57 /src/crypto
parent[http] Abort connections after a long period of inactivity (diff)
downloadipxe-e50e30a7f8eafea0a1975c555a6fdcab35d8243a.tar.gz
ipxe-e50e30a7f8eafea0a1975c555a6fdcab35d8243a.tar.xz
ipxe-e50e30a7f8eafea0a1975c555a6fdcab35d8243a.zip
[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>
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/ecdhe.c2
-rw-r--r--src/crypto/weierstrass.c6
-rw-r--r--src/crypto/x25519.c7
3 files changed, 4 insertions, 11 deletions
diff --git a/src/crypto/ecdhe.c b/src/crypto/ecdhe.c
index 5481b02eb..592c8ca1a 100644
--- a/src/crypto/ecdhe.c
+++ b/src/crypto/ecdhe.c
@@ -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 ) );
diff --git a/src/crypto/weierstrass.c b/src/crypto/weierstrass.c
index c149c7b21..4974e5252 100644
--- a/src/crypto/weierstrass.c
+++ b/src/crypto/weierstrass.c
@@ -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 ) {
diff --git a/src/crypto/x25519.c b/src/crypto/x25519.c
index 41bc5fc5e..00a791877 100644
--- a/src/crypto/x25519.c
+++ b/src/crypto/x25519.c
@@ -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,
};