summaryrefslogtreecommitdiffstats
path: root/src/crypto
diff options
context:
space:
mode:
authorMichael Brown2025-12-05 15:47:55 +0100
committerMichael Brown2025-12-05 16:10:22 +0100
commitd3adea83809537d7476430233994723c690ebfce (patch)
tree73ff36af091dd72d527ef98a0fdb557d386a8a94 /src/crypto
parent[crypto] Verify that weierstrass_multiply() result is not point at infinity (diff)
downloadipxe-d3adea83809537d7476430233994723c690ebfce.tar.gz
ipxe-d3adea83809537d7476430233994723c690ebfce.tar.xz
ipxe-d3adea83809537d7476430233994723c690ebfce.zip
[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>
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/p256.c9
-rw-r--r--src/crypto/p384.c11
2 files changed, 18 insertions, 2 deletions
diff --git a/src/crypto/p256.c b/src/crypto/p256.c
index 9b0b542a1..2ba66e72c 100644
--- a/src/crypto/p256.c
+++ b/src/crypto/p256.c
@@ -62,6 +62,13 @@ static const uint8_t p256_base[ P256_LEN * 2 ] = {
0xce, 0xcb, 0xb6, 0x40, 0x68, 0x37, 0xbf, 0x51, 0xf5
};
+/** P-256 group order */
+static const uint8_t p256_order[P256_LEN] = {
+ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xbc, 0xe6, 0xfa, 0xad, 0xa7, 0x17,
+ 0x9e, 0x84, 0xf3, 0xb9, 0xca, 0xc2, 0xfc, 0x63, 0x25, 0x51
+};
+
/** P-256 elliptic curve */
WEIERSTRASS_CURVE ( p256, p256_curve, P256_LEN,
- p256_prime, p256_a, p256_b, p256_base );
+ p256_prime, p256_a, p256_b, p256_base, p256_order );
diff --git a/src/crypto/p384.c b/src/crypto/p384.c
index 887bf161d..a53a9ce9d 100644
--- a/src/crypto/p384.c
+++ b/src/crypto/p384.c
@@ -71,6 +71,15 @@ static const uint8_t p384_base[ P384_LEN * 2 ] = {
0x7a, 0x43, 0x1d, 0x7c, 0x90, 0xea, 0x0e, 0x5f
};
+/** P-384 group order */
+static const uint8_t p384_order[P384_LEN] = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xc7, 0x63, 0x4d, 0x81, 0xf4, 0x37, 0x2d, 0xdf, 0x58,
+ 0x1a, 0x0d, 0xb2, 0x48, 0xb0, 0xa7, 0x7a, 0xec, 0xec, 0x19, 0x6a,
+ 0xcc, 0xc5, 0x29, 0x73
+};
+
/** P-384 elliptic curve */
WEIERSTRASS_CURVE ( p384, p384_curve, P384_LEN,
- p384_prime, p384_a, p384_b, p384_base );
+ p384_prime, p384_a, p384_b, p384_base, p384_order );