]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
key-exchange: Rename function that verifies pubkey lengths
authorTobias Brunner <tobias@strongswan.org>
Wed, 1 Jul 2026 08:33:13 +0000 (10:33 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 24 Jul 2026 06:47:37 +0000 (08:47 +0200)
The previous name confused LLMs as they assume it is intended to actually
cryptographically verify the public key.  The new name more clearly
describes what it actually does.

15 files changed:
src/charon-tkm/src/tkm/tkm_key_exchange.c
src/libstrongswan/crypto/key_exchange.c
src/libstrongswan/crypto/key_exchange.h
src/libstrongswan/plugins/botan/botan_diffie_hellman.c
src/libstrongswan/plugins/botan/botan_ec_diffie_hellman.c
src/libstrongswan/plugins/botan/botan_x25519.c
src/libstrongswan/plugins/gcrypt/gcrypt_dh.c
src/libstrongswan/plugins/gmp/gmp_diffie_hellman.c
src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c
src/libstrongswan/plugins/openssl/openssl_ec_diffie_hellman.c
src/libstrongswan/plugins/openssl/openssl_x_diffie_hellman.c
src/libstrongswan/plugins/pkcs11/pkcs11_dh.c
src/libstrongswan/plugins/wolfssl/wolfssl_diffie_hellman.c
src/libstrongswan/plugins/wolfssl/wolfssl_ec_diffie_hellman.c
src/libstrongswan/plugins/wolfssl/wolfssl_x_diffie_hellman.c

index d454ca4edd5b01fcd80c7ed6d93d2eafb43fd33a..304af4592ae3df3deeccd8f06e48e015dad3fbfe 100644 (file)
@@ -88,7 +88,7 @@ METHOD(key_exchange_t, set_public_key, bool,
        blob_id_type pubvalue_id;
        bool ret = FALSE;
 
-       if (!key_exchange_verify_pubkey(this->method, value))
+       if (!key_exchange_check_pubkey_len(this->method, value))
        {
                return FALSE;
        }
index 1abcb85dd7c6b00462e5e0d5b596a0974c5bf42d..471b6cbda0071372e417486f3c954eb731902626 100644 (file)
@@ -634,7 +634,7 @@ bool key_exchange_is_kem(key_exchange_method_t ke)
 /*
  * Described in header
  */
-bool key_exchange_verify_pubkey(key_exchange_method_t ke, chunk_t value)
+bool key_exchange_check_pubkey_len(key_exchange_method_t ke, chunk_t value)
 {
        diffie_hellman_params_t *params;
        bool valid = FALSE;
index bf369c9d03b558f3dbace1ded219969f0b2e8e04..cd99a24eec8e7b7a8523a7a8ed4b7653ef3360bc 100644 (file)
@@ -247,13 +247,13 @@ bool key_exchange_is_ecdh(key_exchange_method_t ke);
 bool key_exchange_is_kem(key_exchange_method_t ke);
 
 /**
- * Check if a public key is valid for given key exchange method.
+ * Check if a public key's length is valid for the given key exchange method.
  *
  * @param ke                   key exchange method
  * @param value                        public key to check
- * @return                             TRUE if value looks valid
+ * @return                             TRUE if value's length is valid
  */
-bool key_exchange_verify_pubkey(key_exchange_method_t ke, chunk_t value);
+bool key_exchange_check_pubkey_len(key_exchange_method_t ke, chunk_t value);
 
 /**
  * Return the first shared secret plus the concatenated additional shared
index 175fa6333f9ce6326443943724f8759d1980ebfe..2c0fcde3fd08ee2d77732de6466bf99ecaa14301 100644 (file)
@@ -102,7 +102,7 @@ static bool load_private_key(private_botan_diffie_hellman_t *this, chunk_t value
 METHOD(key_exchange_t, set_public_key, bool,
        private_botan_diffie_hellman_t *this, chunk_t value)
 {
-       if (!key_exchange_verify_pubkey(this->group, value))
+       if (!key_exchange_check_pubkey_len(this->group, value))
        {
                return FALSE;
        }
index c7c396f2a718cad95cb2ec03b43f1317fd992d7a..521d08bf08e4b309d882c393252b6479dcad44ef 100644 (file)
@@ -74,7 +74,7 @@ struct private_botan_ec_diffie_hellman_t {
 METHOD(key_exchange_t, set_public_key, bool,
        private_botan_ec_diffie_hellman_t *this, chunk_t value)
 {
-       if (!key_exchange_verify_pubkey(this->group, value))
+       if (!key_exchange_check_pubkey_len(this->group, value))
        {
                return FALSE;
        }
index 18ea7d1a65b637fb9d2e9dbd551c755c1f2319c5..71a6749924a667a43d9f1f65bffaf9963ca4aa59 100644 (file)
@@ -63,7 +63,7 @@ struct private_diffie_hellman_t {
 METHOD(key_exchange_t, set_public_key, bool,
        private_diffie_hellman_t *this, chunk_t value)
 {
-       if (!key_exchange_verify_pubkey(CURVE_25519, value))
+       if (!key_exchange_check_pubkey_len(CURVE_25519, value))
        {
                return FALSE;
        }
index b92433045f4ec6f360e3775f9cfd930be053ad46..75b25e3f1c85688c4a4a321425bcc4ed92f50938 100644 (file)
@@ -80,7 +80,7 @@ METHOD(key_exchange_t, set_public_key, bool,
        gcry_mpi_t p_min_1;
        gcry_error_t err;
 
-       if (!key_exchange_verify_pubkey(this->group, value))
+       if (!key_exchange_check_pubkey_len(this->group, value))
        {
                return FALSE;
        }
index df95f0064c8dda1b040fee0bddda21c6d333becd..dd99eeb781be679e034d3fdec43141f6bb1f4a18 100644 (file)
@@ -89,7 +89,7 @@ METHOD(key_exchange_t, set_public_key, bool,
 {
        mpz_t p_min_1;
 
-       if (!key_exchange_verify_pubkey(this->group, value))
+       if (!key_exchange_check_pubkey_len(this->group, value))
        {
                return FALSE;
        }
index 1f0fbb725171424174ba9506ed23468306c1fd14..67869aa0923bf800d1b9c2b6a505a01ab90b410a 100644 (file)
@@ -154,7 +154,7 @@ METHOD(key_exchange_t, get_shared_secret, bool,
 METHOD(key_exchange_t, set_public_key, bool,
        private_openssl_diffie_hellman_t *this, chunk_t value)
 {
-       if (!key_exchange_verify_pubkey(this->group, value))
+       if (!key_exchange_check_pubkey_len(this->group, value))
        {
                return FALSE;
        }
index 70ce6dde0baeb79a92111cf2292d21e4f12ac4a6..c7ef7e1f52bd91ab5f62112c5ec0ed13e02525e0 100644 (file)
@@ -201,7 +201,7 @@ error:
 METHOD(key_exchange_t, set_public_key, bool,
        private_openssl_ec_diffie_hellman_t *this, chunk_t value)
 {
-       if (!key_exchange_verify_pubkey(this->group, value))
+       if (!key_exchange_check_pubkey_len(this->group, value))
        {
                return FALSE;
        }
index 1a75c043ecfb776c04aa823d83c578e39a134af9..60959ff364b6d57563d51aaf0dbb53943f112c3f 100644 (file)
@@ -76,7 +76,7 @@ static int map_key_type(key_exchange_method_t ke)
 METHOD(key_exchange_t, set_public_key, bool,
        private_key_exchange_t *this, chunk_t value)
 {
-       if (!key_exchange_verify_pubkey(this->ke, value))
+       if (!key_exchange_check_pubkey_len(this->ke, value))
        {
                return FALSE;
        }
index 73a0b6573712f57eae059f25ae2201cebeba5818..fdf3464a53f435793142ff5d75d77add3e30ffa6 100644 (file)
@@ -145,7 +145,7 @@ static bool derive_secret(private_pkcs11_dh_t *this, chunk_t other)
 METHOD(key_exchange_t, set_public_key, bool,
        private_pkcs11_dh_t *this, chunk_t value)
 {
-       if (!key_exchange_verify_pubkey(this->group, value))
+       if (!key_exchange_check_pubkey_len(this->group, value))
        {
                return FALSE;
        }
index 7591196068c38cea62ceeda2779694498d3626d9..f3e5ae8fb43f51a04c480ad8773738ebed8589b4 100644 (file)
@@ -115,7 +115,7 @@ METHOD(key_exchange_t, get_shared_secret, bool,
 METHOD(key_exchange_t, set_public_key, bool,
        private_wolfssl_diffie_hellman_t *this, chunk_t value)
 {
-       if (!key_exchange_verify_pubkey(this->group, value))
+       if (!key_exchange_check_pubkey_len(this->group, value))
        {
                return FALSE;
        }
index 94a92ff0bce59ba187b76d933a61528eb3d6b659..838c7773ec08ebda5abc2e6f2b1c3a0737391681 100644 (file)
@@ -105,7 +105,7 @@ METHOD(key_exchange_t, set_public_key, bool,
 {
        chunk_t uncomp;
 
-       if (!key_exchange_verify_pubkey(this->group, value))
+       if (!key_exchange_check_pubkey_len(this->group, value))
        {
                return FALSE;
        }
index 68ff5bc7d4a3169095092e2267cc49def8884426..904d3c4a33bdc5c732359a27841cf9eb0b730de9 100644 (file)
@@ -117,7 +117,7 @@ METHOD(key_exchange_t, get_shared_secret_25519, bool,
 METHOD(key_exchange_t, set_public_key_25519, bool,
        private_diffie_hellman_t *this, chunk_t value)
 {
-       if (!key_exchange_verify_pubkey(this->group, value))
+       if (!key_exchange_check_pubkey_len(this->group, value))
        {
                return FALSE;
        }
@@ -207,7 +207,7 @@ METHOD(key_exchange_t, get_shared_secret_448, bool,
 METHOD(key_exchange_t, set_public_key_448, bool,
        private_diffie_hellman_t *this, chunk_t value)
 {
-       if (!key_exchange_verify_pubkey(this->group, value))
+       if (!key_exchange_check_pubkey_len(this->group, value))
        {
                return FALSE;
        }