key-exchange: Rename function that verifies pubkey lengths

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.
This commit is contained in:
Tobias Brunner
2026-07-24 08:47:37 +02:00
parent 1fbb14884c
commit 80f8f5e9d4
15 changed files with 18 additions and 18 deletions
+1 -1
View 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;
}
+1 -1
View 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;
+3 -3
View 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
@@ -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;
}
@@ -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;
}
@@ -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;
}
+1 -1
View 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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}
+1 -1
View 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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}