[tls] Allow for NIST elliptic curve point formats

The elliptic curve point representation for the x25519 curve includes
only the X value, since the curve is designed such that the Montgomery
ladder does not need to ever know or calculate a Y value.  There is no
curve point format byte: the public key data is simply the X value.
The pre-master secret is also simply the X value of the shared secret
curve point.

The point representation for the NIST curves includes both X and Y
values, and a single curve point format byte that must indicate that
the format is uncompressed.  The pre-master secret for the NIST curves
does not include both X and Y values: only the X value is used.

Extend the definition of an elliptic curve to allow the point size to
be specified separately from the key size, and extend the definition
of a TLS named curve to include an optional curve point format byte
and a pre-master secret length.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-01-21 15:29:05 +00:00
parent df7ec31766
commit c9291bc5c7
5 changed files with 40 additions and 11 deletions

View File

@@ -184,7 +184,9 @@ struct pubkey_algorithm {
struct elliptic_curve {
/** Curve name */
const char *name;
/** Key size */
/** Point (and public key) size */
size_t pointsize;
/** Scalar (and private key) size */
size_t keysize;
/** Multiply scalar by curve point
*

View File

@@ -218,12 +218,19 @@ struct tls_cipher_suite {
/** TLS named curved type */
#define TLS_NAMED_CURVE_TYPE 3
/** TLS uncompressed curve point format */
#define TLS_POINT_FORMAT_UNCOMPRESSED 4
/** A TLS named curve */
struct tls_named_curve {
/** Elliptic curve */
struct elliptic_curve *curve;
/** Numeric code (in network-endian order) */
uint16_t code;
/** Curve point format byte (if any) */
uint8_t format;
/** Pre-master secret length */
uint8_t pre_master_secret_len;
};
/** TLS named curve table */