Rename diffie_hellman_t to key_exchange_t and change the interface etc.

This makes it more generic so we can use it for QSKE methods.
This commit is contained in:
Tobias Brunner
2022-06-29 10:28:50 +02:00
parent ec95fd9b93
commit 3af7c6db87
130 changed files with 1379 additions and 1384 deletions
+25 -25
View File
@@ -252,18 +252,18 @@ METHOD(proposal_t, get_algorithm, bool,
return found;
}
METHOD(proposal_t, has_dh_group, bool,
private_proposal_t *this, diffie_hellman_group_t group)
METHOD(proposal_t, has_ke_method, bool,
private_proposal_t *this, key_exchange_method_t ke)
{
bool found = FALSE, any = FALSE;
enumerator_t *enumerator;
uint16_t current;
enumerator = create_enumerator(this, DIFFIE_HELLMAN_GROUP);
enumerator = create_enumerator(this, KEY_EXCHANGE_METHOD);
while (enumerator->enumerate(enumerator, &current, NULL))
{
any = TRUE;
if (current == group)
if (current == ke)
{
found = TRUE;
break;
@@ -271,15 +271,15 @@ METHOD(proposal_t, has_dh_group, bool,
}
enumerator->destroy(enumerator);
if (!any && group == MODP_NONE)
if (!any && ke == MODP_NONE)
{
found = TRUE;
}
return found;
}
METHOD(proposal_t, promote_dh_group, bool,
private_proposal_t *this, diffie_hellman_group_t group)
METHOD(proposal_t, promote_ke_method, bool,
private_proposal_t *this, key_exchange_method_t method)
{
enumerator_t *enumerator;
entry_t *entry;
@@ -288,8 +288,8 @@ METHOD(proposal_t, promote_dh_group, bool,
enumerator = array_create_enumerator(this->transforms);
while (enumerator->enumerate(enumerator, &entry))
{
if (entry->type == DIFFIE_HELLMAN_GROUP &&
entry->alg == group)
if (entry->type == KEY_EXCHANGE_METHOD &&
entry->alg == method)
{
array_remove_at(this->transforms, enumerator);
found = TRUE;
@@ -300,8 +300,8 @@ METHOD(proposal_t, promote_dh_group, bool,
if (found)
{
entry_t entry = {
.type = DIFFIE_HELLMAN_GROUP,
.alg = group,
.type = KEY_EXCHANGE_METHOD,
.alg = method,
};
array_insert(this->transforms, ARRAY_HEAD, &entry);
}
@@ -319,7 +319,7 @@ static bool select_algo(private_proposal_t *this, proposal_t *other,
uint16_t alg1, alg2, ks1, ks2;
bool found = FALSE, optional = FALSE;
if (type == DIFFIE_HELLMAN_GROUP)
if (type == KEY_EXCHANGE_METHOD)
{
optional = this->protocol == PROTO_ESP || this->protocol == PROTO_AH;
}
@@ -408,7 +408,7 @@ static bool select_algos(private_proposal_t *this, proposal_t *other,
{
continue;
}
if (type == DIFFIE_HELLMAN_GROUP && (flags & PROPOSAL_SKIP_DH))
if (type == KEY_EXCHANGE_METHOD && (flags & PROPOSAL_SKIP_KE))
{
continue;
}
@@ -601,7 +601,7 @@ METHOD(proposal_t, clone_, proposal_t*,
{
continue;
}
if (entry->type == DIFFIE_HELLMAN_GROUP && (flags & PROPOSAL_SKIP_DH))
if (entry->type == KEY_EXCHANGE_METHOD && (flags & PROPOSAL_SKIP_KE))
{
continue;
}
@@ -696,13 +696,13 @@ static bool check_proposal(private_proposal_t *this)
e = array_create_enumerator(this->transforms);
while (e->enumerate(e, &entry))
{
if (entry->type == DIFFIE_HELLMAN_GROUP && !entry->alg)
if (entry->type == KEY_EXCHANGE_METHOD && !entry->alg)
{
array_remove_at(this->transforms, e);
}
}
e->destroy(e);
if (!get_algorithm(this, DIFFIE_HELLMAN_GROUP, NULL, NULL))
if (!get_algorithm(this, KEY_EXCHANGE_METHOD, NULL, NULL))
{
DBG1(DBG_CFG, "a DH group is mandatory in IKE proposals");
return FALSE;
@@ -943,8 +943,8 @@ proposal_t *proposal_create_v1(protocol_id_t protocol, uint8_t number,
.add_algorithm = _add_algorithm,
.create_enumerator = _create_enumerator,
.get_algorithm = _get_algorithm,
.has_dh_group = _has_dh_group,
.promote_dh_group = _promote_dh_group,
.has_ke_method = _has_ke_method,
.promote_ke_method = _promote_ke_method,
.select = _select_proposal,
.matches = _matches,
.get_protocol = _get_protocol,
@@ -983,7 +983,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
encryption_algorithm_t encryption;
integrity_algorithm_t integrity;
pseudo_random_function_t prf;
diffie_hellman_group_t group;
key_exchange_method_t group;
const char *plugin_name;
if (aead)
@@ -1175,7 +1175,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
enumerator->destroy(enumerator);
/* Round 1 adds ECC and NTRU algorithms with at least 128 bit security strength */
enumerator = lib->crypto->create_dh_enumerator(lib->crypto);
enumerator = lib->crypto->create_ke_enumerator(lib->crypto);
while (enumerator->enumerate(enumerator, &group, &plugin_name))
{
switch (group)
@@ -1192,7 +1192,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
case NTRU_192_BIT:
case NTRU_256_BIT:
case NH_128_BIT:
add_algorithm(this, DIFFIE_HELLMAN_GROUP, group, 0);
add_algorithm(this, KEY_EXCHANGE_METHOD, group, 0);
break;
default:
break;
@@ -1201,7 +1201,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
enumerator->destroy(enumerator);
/* Round 2 adds other algorithms with at least 128 bit security strength */
enumerator = lib->crypto->create_dh_enumerator(lib->crypto);
enumerator = lib->crypto->create_ke_enumerator(lib->crypto);
while (enumerator->enumerate(enumerator, &group, &plugin_name))
{
switch (group)
@@ -1210,7 +1210,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
case MODP_4096_BIT:
case MODP_6144_BIT:
case MODP_8192_BIT:
add_algorithm(this, DIFFIE_HELLMAN_GROUP, group, 0);
add_algorithm(this, KEY_EXCHANGE_METHOD, group, 0);
break;
default:
break;
@@ -1219,7 +1219,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
enumerator->destroy(enumerator);
/* Round 3 adds algorithms with less than 128 bit security strength */
enumerator = lib->crypto->create_dh_enumerator(lib->crypto);
enumerator = lib->crypto->create_ke_enumerator(lib->crypto);
while (enumerator->enumerate(enumerator, &group, &plugin_name))
{
switch (group)
@@ -1244,7 +1244,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
/* rarely used */
break;
case MODP_2048_BIT:
add_algorithm(this, DIFFIE_HELLMAN_GROUP, group, 0);
add_algorithm(this, KEY_EXCHANGE_METHOD, group, 0);
break;
default:
break;