child-create: Add support for multiple key exchanges

It also changes that payloads are built before installing the CHILD_SA
on the responder, that is, the KE payload is generated before keys are
derived, so that key_exchange_t::get_public_key() is called before
get_shared_secret(), or its internal equivalent, which could be relevant
for KE implementations that want to ensure that the key can't be
accessed again after the key derivation.
This commit is contained in:
Tobias Brunner
2024-08-07 16:20:18 +02:00
parent ca3e6d2d14
commit d7760416d6
7 changed files with 765 additions and 250 deletions
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -81,13 +81,13 @@ struct child_create_t {
void (*use_label)(child_create_t *this, sec_label_t *label);
/**
* Initially propose a specific DH group to override configuration.
* Initially propose a specific KE method to override configuration.
*
* This is used during rekeying to prefer the previously negotiated group.
* This is used during rekeying to prefer the previously negotiated method.
*
* @param dh_group DH group to use
* @param ke_method KE method to use
*/
void (*use_dh_group)(child_create_t *this, key_exchange_method_t dh_group);
void (*use_ke_method)(child_create_t *this, key_exchange_method_t ke_method);
/**
* Get the lower of the two nonces, used for rekey collisions.
+4 -4
View File
@@ -201,16 +201,16 @@ METHOD(task_t, build_i, status_t,
if (!this->child_create)
{
proposal_t *proposal;
uint16_t dh_group;
uint16_t ke_method;
this->child_create = child_create_create(this->ike_sa,
config->get_ref(config), TRUE, NULL, NULL);
proposal = this->child_sa->get_proposal(this->child_sa);
if (proposal->get_algorithm(proposal, KEY_EXCHANGE_METHOD,
&dh_group, NULL))
{ /* reuse the DH group negotiated previously */
this->child_create->use_dh_group(this->child_create, dh_group);
&ke_method, NULL))
{ /* reuse the KE method negotiated previously */
this->child_create->use_ke_method(this->child_create, ke_method);
}
}
reqid = this->child_sa->get_reqid_ref(this->child_sa);