diff --git a/src/charon-tkm/src/tkm/tkm_key_exchange.c b/src/charon-tkm/src/tkm/tkm_key_exchange.c index d454ca4ed..304af4592 100644 --- a/src/charon-tkm/src/tkm/tkm_key_exchange.c +++ b/src/charon-tkm/src/tkm/tkm_key_exchange.c @@ -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; } diff --git a/src/libstrongswan/crypto/key_exchange.c b/src/libstrongswan/crypto/key_exchange.c index 1abcb85dd..471b6cbda 100644 --- a/src/libstrongswan/crypto/key_exchange.c +++ b/src/libstrongswan/crypto/key_exchange.c @@ -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; diff --git a/src/libstrongswan/crypto/key_exchange.h b/src/libstrongswan/crypto/key_exchange.h index bf369c9d0..cd99a24ee 100644 --- a/src/libstrongswan/crypto/key_exchange.h +++ b/src/libstrongswan/crypto/key_exchange.h @@ -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 diff --git a/src/libstrongswan/plugins/botan/botan_diffie_hellman.c b/src/libstrongswan/plugins/botan/botan_diffie_hellman.c index 175fa6333..2c0fcde3f 100644 --- a/src/libstrongswan/plugins/botan/botan_diffie_hellman.c +++ b/src/libstrongswan/plugins/botan/botan_diffie_hellman.c @@ -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; } diff --git a/src/libstrongswan/plugins/botan/botan_ec_diffie_hellman.c b/src/libstrongswan/plugins/botan/botan_ec_diffie_hellman.c index c7c396f2a..521d08bf0 100644 --- a/src/libstrongswan/plugins/botan/botan_ec_diffie_hellman.c +++ b/src/libstrongswan/plugins/botan/botan_ec_diffie_hellman.c @@ -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; } diff --git a/src/libstrongswan/plugins/botan/botan_x25519.c b/src/libstrongswan/plugins/botan/botan_x25519.c index 18ea7d1a6..71a674992 100644 --- a/src/libstrongswan/plugins/botan/botan_x25519.c +++ b/src/libstrongswan/plugins/botan/botan_x25519.c @@ -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; } diff --git a/src/libstrongswan/plugins/gcrypt/gcrypt_dh.c b/src/libstrongswan/plugins/gcrypt/gcrypt_dh.c index b92433045..75b25e3f1 100644 --- a/src/libstrongswan/plugins/gcrypt/gcrypt_dh.c +++ b/src/libstrongswan/plugins/gcrypt/gcrypt_dh.c @@ -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; } diff --git a/src/libstrongswan/plugins/gmp/gmp_diffie_hellman.c b/src/libstrongswan/plugins/gmp/gmp_diffie_hellman.c index df95f0064..dd99eeb78 100644 --- a/src/libstrongswan/plugins/gmp/gmp_diffie_hellman.c +++ b/src/libstrongswan/plugins/gmp/gmp_diffie_hellman.c @@ -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; } diff --git a/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c b/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c index 1f0fbb725..67869aa09 100644 --- a/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c +++ b/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c @@ -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; } diff --git a/src/libstrongswan/plugins/openssl/openssl_ec_diffie_hellman.c b/src/libstrongswan/plugins/openssl/openssl_ec_diffie_hellman.c index 70ce6dde0..c7ef7e1f5 100644 --- a/src/libstrongswan/plugins/openssl/openssl_ec_diffie_hellman.c +++ b/src/libstrongswan/plugins/openssl/openssl_ec_diffie_hellman.c @@ -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; } diff --git a/src/libstrongswan/plugins/openssl/openssl_x_diffie_hellman.c b/src/libstrongswan/plugins/openssl/openssl_x_diffie_hellman.c index 1a75c043e..60959ff36 100644 --- a/src/libstrongswan/plugins/openssl/openssl_x_diffie_hellman.c +++ b/src/libstrongswan/plugins/openssl/openssl_x_diffie_hellman.c @@ -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; } diff --git a/src/libstrongswan/plugins/pkcs11/pkcs11_dh.c b/src/libstrongswan/plugins/pkcs11/pkcs11_dh.c index 73a0b6573..fdf3464a5 100644 --- a/src/libstrongswan/plugins/pkcs11/pkcs11_dh.c +++ b/src/libstrongswan/plugins/pkcs11/pkcs11_dh.c @@ -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; } diff --git a/src/libstrongswan/plugins/wolfssl/wolfssl_diffie_hellman.c b/src/libstrongswan/plugins/wolfssl/wolfssl_diffie_hellman.c index 759119606..f3e5ae8fb 100644 --- a/src/libstrongswan/plugins/wolfssl/wolfssl_diffie_hellman.c +++ b/src/libstrongswan/plugins/wolfssl/wolfssl_diffie_hellman.c @@ -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; } diff --git a/src/libstrongswan/plugins/wolfssl/wolfssl_ec_diffie_hellman.c b/src/libstrongswan/plugins/wolfssl/wolfssl_ec_diffie_hellman.c index 94a92ff0b..838c7773e 100644 --- a/src/libstrongswan/plugins/wolfssl/wolfssl_ec_diffie_hellman.c +++ b/src/libstrongswan/plugins/wolfssl/wolfssl_ec_diffie_hellman.c @@ -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; } diff --git a/src/libstrongswan/plugins/wolfssl/wolfssl_x_diffie_hellman.c b/src/libstrongswan/plugins/wolfssl/wolfssl_x_diffie_hellman.c index 68ff5bc7d..904d3c4a3 100644 --- a/src/libstrongswan/plugins/wolfssl/wolfssl_x_diffie_hellman.c +++ b/src/libstrongswan/plugins/wolfssl/wolfssl_x_diffie_hellman.c @@ -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; }