diff --git a/src/crypto/ffdhe.c b/src/crypto/ffdhe.c index f2b682d42..7756ffbdd 100644 --- a/src/crypto/ffdhe.c +++ b/src/crypto/ffdhe.c @@ -255,21 +255,21 @@ static int ffdhe ( struct ffdhe_group *group, const void *public, } /** - * Calculate public key + * Share public key * * @v exchange Key exchange algorithm * @v private Private key * @v public Public key to fill in */ -void ffdhe_public ( struct exchange_algorithm *exchange, const void *private, - void *public ) { +void ffdhe_share ( struct exchange_algorithm *exchange, const void *private, + void *public ) { struct ffdhe_group *group = exchange->priv; ffdhe ( group, NULL, private, public ); } /** - * Calculate shared secret + * Agree shared secret * * @v exchange Key exchange algorithm * @v private Private key @@ -277,8 +277,8 @@ void ffdhe_public ( struct exchange_algorithm *exchange, const void *private, * @v shared Shared secret to fill in * @ret rc Return status code */ -int ffdhe_shared ( struct exchange_algorithm *exchange, const void *private, - const void *partner, void *shared ) { +int ffdhe_agree ( struct exchange_algorithm *exchange, const void *private, + const void *partner, void *shared ) { struct ffdhe_group *group = exchange->priv; return ffdhe ( group, partner, private, shared ); diff --git a/src/crypto/weierstrass.c b/src/crypto/weierstrass.c index 7fa18ca41..5a21cac4d 100644 --- a/src/crypto/weierstrass.c +++ b/src/crypto/weierstrass.c @@ -1028,14 +1028,14 @@ int weierstrass_add_once ( struct weierstrass_curve *curve, } /** - * Calculate public key + * Share public key * * @v exchange Key exchange algorithm * @v private Private key * @v public Public key to fill in */ -void weierstrass_public ( struct exchange_algorithm *exchange, - const void *private, void *public ) { +void weierstrass_share ( struct exchange_algorithm *exchange, + const void *private, void *public ) { struct weierstrass_curve *curve = exchange->priv; size_t len = curve->len; weierstrass_uncompressed_t ( len ) *uncompressed = public; @@ -1051,7 +1051,7 @@ void weierstrass_public ( struct exchange_algorithm *exchange, } /** - * Calculate shared secret + * Agree shared secret * * @v exchange Key exchange algorithm * @v private Private key @@ -1059,9 +1059,9 @@ void weierstrass_public ( struct exchange_algorithm *exchange, * @v shared Shared secret to fill in * @ret rc Return status code */ -int weierstrass_shared ( struct exchange_algorithm *exchange, - const void *private, const void *partner, - void *shared ) { +int weierstrass_agree ( struct exchange_algorithm *exchange, + const void *private, const void *partner, + void *shared ) { struct weierstrass_curve *curve = exchange->priv; size_t len = curve->len; const weierstrass_uncompressed_t ( len ) *uncompressed = partner; diff --git a/src/crypto/x25519.c b/src/crypto/x25519.c index 5eb74b627..c52f0f1e8 100644 --- a/src/crypto/x25519.c +++ b/src/crypto/x25519.c @@ -831,21 +831,21 @@ void x25519_key ( const struct x25519_value *base, } /** - * Calculate public key + * Share public key * * @v exchange Key exchange algorithm * @v private Private key * @v public Public key to fill in */ -static void x25519_public ( struct exchange_algorithm *exchange __unused, - const void *private, void *public ) { +static void x25519_share ( struct exchange_algorithm *exchange __unused, + const void *private, void *public ) { /* Calculate public key */ x25519_key ( &x25519_generator, private, public ); } /** - * Calculate shared secret + * Agree shared secret * * @v exchange Key exchange algorithm * @v private Private key @@ -853,9 +853,9 @@ static void x25519_public ( struct exchange_algorithm *exchange __unused, * @v shared Shared secret to fill in * @ret rc Return status code */ -static int x25519_shared ( struct exchange_algorithm *exchange __unused, - const void *private, const void *partner, - void *shared ) { +static int x25519_agree ( struct exchange_algorithm *exchange __unused, + const void *private, const void *partner, + void *shared ) { /* Calculate shared secret */ x25519_key ( partner, private, shared ); @@ -873,6 +873,6 @@ struct exchange_algorithm x25519_algorithm = { .privsize = sizeof ( struct x25519_value ), .pubsize = sizeof ( struct x25519_value ), .sharedsize = sizeof ( struct x25519_value ), - .public = x25519_public, - .shared = x25519_shared, + .share = x25519_share, + .agree = x25519_agree, }; diff --git a/src/include/ipxe/crypto.h b/src/include/ipxe/crypto.h index e512ae06c..9b25edba1 100644 --- a/src/include/ipxe/crypto.h +++ b/src/include/ipxe/crypto.h @@ -185,16 +185,16 @@ struct exchange_algorithm { /** Shared secret size */ size_t sharedsize; /** - * Calculate public key + * Share public key * * @v exchange Key exchange algorithm * @v private Private key * @v public Public key to fill in */ - void ( * public ) ( struct exchange_algorithm *exchange, - const void *private, void *public ); + void ( * share ) ( struct exchange_algorithm *exchange, + const void *private, void *public ); /** - * Calculate shared secret + * Agree shared secret * * @v exchange Key exchange algorithm * @v private Private key @@ -202,9 +202,9 @@ struct exchange_algorithm { * @v shared Shared secret to fill in * @ret rc Return status code */ - int ( * shared ) ( struct exchange_algorithm *exchange, - const void *private, const void *partner, - void *shared ); + int ( * agree ) ( struct exchange_algorithm *exchange, + const void *private, const void *partner, + void *shared ); /** Algorithm private data */ void *priv; }; @@ -354,15 +354,15 @@ pubkey_match ( struct pubkey_algorithm *pubkey, } static inline __attribute__ (( always_inline )) void -exchange_public ( struct exchange_algorithm *exchange, const void *private, - void *public ) { - exchange->public ( exchange, private, public ); +exchange_share ( struct exchange_algorithm *exchange, const void *private, + void *public ) { + exchange->share ( exchange, private, public ); } static inline __attribute__ (( always_inline )) int -exchange_shared ( struct exchange_algorithm *exchange, const void *private, - const void *partner, void *shared ) { - return exchange->shared ( exchange, private, partner, shared ); +exchange_agree ( struct exchange_algorithm *exchange, const void *private, + const void *partner, void *shared ) { + return exchange->agree ( exchange, private, partner, shared ); } static inline __attribute__ (( always_inline )) int diff --git a/src/include/ipxe/ffdhe.h b/src/include/ipxe/ffdhe.h index b3a11cc36..aa76b6b8f 100644 --- a/src/include/ipxe/ffdhe.h +++ b/src/include/ipxe/ffdhe.h @@ -33,11 +33,11 @@ struct ffdhe_group { uint32_t lsb32; }; -extern void ffdhe_public ( struct exchange_algorithm *exchange, - const void *private, void *public ); -extern int ffdhe_shared ( struct exchange_algorithm *exchange, - const void *private, const void *partner, - void *shared ); +extern void ffdhe_share ( struct exchange_algorithm *exchange, + const void *private, void *public ); +extern int ffdhe_agree ( struct exchange_algorithm *exchange, + const void *private, const void *partner, + void *shared ); extern int ffdhe_has_params ( struct exchange_algorithm *exchange, const void *modulus, size_t len, const void *generator, size_t generator_len ); @@ -51,7 +51,7 @@ extern int ffdhe_has_params ( struct exchange_algorithm *exchange, static inline __attribute__ (( always_inline )) int is_ffdhe ( struct exchange_algorithm *exchange ) { - return ( exchange->public == ffdhe_public ); + return ( exchange->share == ffdhe_share ); } /** Define a finite field DHE group */ @@ -70,8 +70,8 @@ is_ffdhe ( struct exchange_algorithm *exchange ) { .privsize = ( ( _expbits + 7 ) / 8 ), \ .pubsize = ( _bits / 8 ), \ .sharedsize = ( _bits / 8 ), \ - .public = ffdhe_public, \ - .shared = ffdhe_shared, \ + .share = ffdhe_share, \ + .agree = ffdhe_agree, \ .priv = &_name ## _group, \ } diff --git a/src/include/ipxe/weierstrass.h b/src/include/ipxe/weierstrass.h index 4095b4a77..ef4da3279 100644 --- a/src/include/ipxe/weierstrass.h +++ b/src/include/ipxe/weierstrass.h @@ -164,11 +164,11 @@ extern int weierstrass_multiply ( struct weierstrass_curve *curve, extern int weierstrass_add_once ( struct weierstrass_curve *curve, const void *addend, const void *augend, void *result ); -extern void weierstrass_public ( struct exchange_algorithm *exchange, - const void *private, void *public ); -extern int weierstrass_shared ( struct exchange_algorithm *exchange, - const void *private, const void *partner, - void *shared ); +extern void weierstrass_share ( struct exchange_algorithm *exchange, + const void *private, void *public ); +extern int weierstrass_agree ( struct exchange_algorithm *exchange, + const void *private, const void *partner, + void *shared ); /** Define a Weierstrass curve */ #define WEIERSTRASS_CURVE( _name, _curve, _exchange, _len, _prime, \ @@ -224,8 +224,8 @@ extern int weierstrass_shared ( struct exchange_algorithm *exchange, .privsize = (_len), \ .pubsize = sizeof ( weierstrass_uncompressed_t(_len) ), \ .sharedsize = (_len), \ - .public = weierstrass_public, \ - .shared = weierstrass_shared, \ + .share = weierstrass_share, \ + .agree = weierstrass_agree, \ .priv = &_name ## _weierstrass, \ } diff --git a/src/net/tls.c b/src/net/tls.c index bd4b14b6a..b5aa8a43c 100644 --- a/src/net/tls.c +++ b/src/net/tls.c @@ -1762,7 +1762,7 @@ static int tls_send_client_key_exchange_ecdhe ( struct tls_connection *tls ) { htonl ( sizeof ( key_xchg ) - sizeof ( key_xchg.type_length ) ) ); key_xchg.public_len = sizeof ( key_xchg.public ); - exchange_public ( exchange, private, key_xchg.public ); + exchange_share ( exchange, private, key_xchg.public ); /* Transmit Client Key Exchange record */ if ( ( rc = tls_send_handshake ( tls, &key_xchg, @@ -1771,8 +1771,8 @@ static int tls_send_client_key_exchange_ecdhe ( struct tls_connection *tls ) { } /* Generate pre-master secret */ - if ( ( rc = exchange_shared ( exchange, private, ecdh->public, - pre_master_secret ) ) != 0 ) { + if ( ( rc = exchange_agree ( exchange, private, ecdh->public, + pre_master_secret ) ) != 0 ) { DBGC ( tls, "TLS %p could not exchange keys: %s\n", tls, strerror ( rc ) ); return rc; diff --git a/src/tests/exchange_test.c b/src/tests/exchange_test.c index 3655373f6..d3b1e9306 100644 --- a/src/tests/exchange_test.c +++ b/src/tests/exchange_test.c @@ -67,7 +67,7 @@ void exchange_okx ( struct exchange_test *test, const char *file, /* Verify calculation of public key */ DBGC ( test, "KEX %s private key:\n", exchange->name ); DBGC_HDA ( test, 0, test->private, exchange->privsize ); - exchange_public ( exchange, test->private, actual->public ); + exchange_share ( exchange, test->private, actual->public ); DBGC ( test, "KEX %s public key:\n", exchange->name ); DBGC_HDA ( test, 0, actual->public, exchange->pubsize ); okx ( memcmp ( actual->public, test->public, exchange->pubsize ) == 0, @@ -76,8 +76,8 @@ void exchange_okx ( struct exchange_test *test, const char *file, /* Verify calculation of shared secret */ DBGC ( test, "KEX %s partner key:\n", exchange->name ); DBGC_HDA ( test, 0, test->partner, exchange->pubsize ); - rc = exchange_shared ( exchange, test->private, test->partner, - actual->shared ); + rc = exchange_agree ( exchange, test->private, test->partner, + actual->shared ); if ( test->shared_len ) { /* Verify successful calculation */ okx ( rc == 0, file, line );