[crypto] Use verbs in key exchange method names

Almost all cryptographic algorithm method names are currently verbs
(e.g. pubkey_sign(), cipher_encrypt(), digest_update(), etc).

Rename the two key exchange methods to also use verbs, for the sake of
consistency and to better match the TLS usage of "key_share".

Signed-off-by: Michael Brown <mcb30@ipxe.org>
diff --git a/src/crypto/ffdhe.c b/src/crypto/ffdhe.c
index f2b682d..7756ffb 100644
--- a/src/crypto/ffdhe.c
+++ b/src/crypto/ffdhe.c
@@ -255,21 +255,21 @@
 }
 
 /**
- * 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 @@
  * @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 7fa18ca..5a21cac 100644
--- a/src/crypto/weierstrass.c
+++ b/src/crypto/weierstrass.c
@@ -1028,14 +1028,14 @@
 }
 
 /**
- * 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 @@
 }
 
 /**
- * Calculate shared secret
+ * Agree shared secret
  *
  * @v exchange		Key exchange algorithm
  * @v private		Private key
@@ -1059,9 +1059,9 @@
  * @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 5eb74b6..c52f0f1 100644
--- a/src/crypto/x25519.c
+++ b/src/crypto/x25519.c
@@ -831,21 +831,21 @@
 }
 
 /**
- * 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 @@
  * @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 @@
 	.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 e512ae0..9b25edb 100644
--- a/src/include/ipxe/crypto.h
+++ b/src/include/ipxe/crypto.h
@@ -185,16 +185,16 @@
 	/** 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 @@
 	 * @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 @@
 }
 
 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 b3a11cc..aa76b6b 100644
--- a/src/include/ipxe/ffdhe.h
+++ b/src/include/ipxe/ffdhe.h
@@ -33,11 +33,11 @@
 	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 @@
 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 @@
 		.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 4095b4a..ef4da32 100644
--- a/src/include/ipxe/weierstrass.h
+++ b/src/include/ipxe/weierstrass.h
@@ -164,11 +164,11 @@
 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 @@
 		.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 bd4b14b..b5aa8a4 100644
--- a/src/net/tls.c
+++ b/src/net/tls.c
@@ -1762,7 +1762,7 @@
 			  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 @@
 		}
 
 		/* 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 3655373..d3b1e93 100644
--- a/src/tests/exchange_test.c
+++ b/src/tests/exchange_test.c
@@ -67,7 +67,7 @@
 	/* 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 @@
 	/* 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 );