proposal: Generalize KE methods

This commit is contained in:
Tobias Brunner
2022-06-29 10:28:50 +02:00
parent b7c167f972
commit 3bebf5bf8d
6 changed files with 111 additions and 41 deletions
+2 -2
View File
@@ -797,13 +797,13 @@ static linked_list_t *get_proposals(private_quick_mode_t *this,
{
if (group != KE_NONE)
{
if (!proposal->has_ke_method(proposal, group))
if (!proposal->has_transform(proposal, KEY_EXCHANGE_METHOD, group))
{
list->remove_at(list, enumerator);
proposal->destroy(proposal);
continue;
}
proposal->promote_ke_method(proposal, group);
proposal->promote_transform(proposal, KEY_EXCHANGE_METHOD, group);
}
proposal->set_spi(proposal, this->spi_i);
}
+4 -2
View File
@@ -328,7 +328,8 @@ static bool update_and_check_proposals(private_child_create_t *this)
if (this->dh_group != KE_NONE)
{ /* proposals that don't contain the selected group are
* moved to the back */
if (!proposal->promote_ke_method(proposal, this->dh_group))
if (!proposal->promote_transform(proposal, KEY_EXCHANGE_METHOD,
this->dh_group))
{
this->proposals->remove_at(this->proposals, enumerator);
other_dh_groups->insert_last(other_dh_groups, proposal);
@@ -554,7 +555,8 @@ static status_t select_and_install(private_child_create_t *this,
}
this->child_sa->set_proposal(this->child_sa, this->proposal);
if (!this->proposal->has_ke_method(this->proposal, this->dh_group))
if (!this->proposal->has_transform(this->proposal, KEY_EXCHANGE_METHOD,
this->dh_group))
{
uint16_t group;
+8 -4
View File
@@ -333,7 +333,8 @@ static bool build_payloads(private_ike_init_t *this, message_t *message)
proposal->set_spi(proposal, id->get_initiator_spi(id));
}
/* move the selected DH group to the front of the proposal */
if (!proposal->promote_ke_method(proposal, this->dh_group))
if (!proposal->promote_transform(proposal, KEY_EXCHANGE_METHOD,
this->dh_group))
{ /* the proposal does not include the group, move to the back */
proposal_list->remove_at(proposal_list, enumerator);
other_dh_groups->insert_last(other_dh_groups, proposal);
@@ -617,7 +618,8 @@ static void process_payloads(private_ike_init_t *this, message_t *message)
}
if (ke_payload && this->proposal &&
this->proposal->has_ke_method(this->proposal, this->dh_group))
this->proposal->has_transform(this->proposal, KEY_EXCHANGE_METHOD,
this->dh_group))
{
if (!this->initiator)
{
@@ -829,7 +831,8 @@ METHOD(task_t, build_r, status_t,
}
if (this->dh == NULL ||
!this->proposal->has_ke_method(this->proposal, this->dh_group))
!this->proposal->has_transform(this->proposal, KEY_EXCHANGE_METHOD,
this->dh_group))
{
uint16_t group;
@@ -1064,7 +1067,8 @@ METHOD(task_t, process_i, status_t,
}
if (this->dh == NULL ||
!this->proposal->has_ke_method(this->proposal, this->dh_group))
!this->proposal->has_transform(this->proposal, KEY_EXCHANGE_METHOD,
this->dh_group))
{
DBG1(DBG_IKE, "peer DH group selection invalid");
return FAILED;