return selected;
}
-METHOD(ike_cfg_t, get_dh_group, diffie_hellman_group_t,
- private_ike_cfg_t *this)
+METHOD(ike_cfg_t, get_algorithm, uint16_t,
+ private_ike_cfg_t *this, transform_type_t type)
{
enumerator_t *enumerator;
proposal_t *proposal;
- uint16_t dh_group = MODP_NONE;
+ uint16_t alg = 0;
enumerator = this->proposals->create_enumerator(this->proposals);
while (enumerator->enumerate(enumerator, &proposal))
{
- if (proposal->get_algorithm(proposal, DIFFIE_HELLMAN_GROUP, &dh_group, NULL))
+ if (proposal->get_algorithm(proposal, type, &alg, NULL))
{
break;
}
}
enumerator->destroy(enumerator);
- return dh_group;
+ return alg;
}
METHOD(ike_cfg_t, equals, bool,
.get_proposals = _get_proposals,
.select_proposal = _select_proposal,
.has_proposal = _has_proposal,
- .get_dh_group = _get_dh_group,
+ .get_algorithm = _get_algorithm,
.equals = _equals,
.get_ref = _get_ref,
.destroy = _destroy,
childless_t (*childless)(ike_cfg_t *this);
/**
- * Get the DH group to use for IKE_SA setup.
+ * Get the first algorithm of a certain transform type that's contained in
+ * any of the configured proposals.
*
- * @return dh group to use for initialization
+ * For instance, use with DIFFIE_HELLMAN_GROUP to get the DH group to use
+ * for the IKE_SA initiation.
+ *
+ * @param type transform type to look for
+ * @return algorithm identifier (0 for none)
*/
- diffie_hellman_group_t (*get_dh_group)(ike_cfg_t *this);
+ uint16_t (*get_algorithm)(ike_cfg_t *this, transform_type_t type);
/**
* Check if two IKE configs are equal.
message->add_payload(message, &sa_payload->payload_interface);
- group = this->ike_cfg->get_dh_group(this->ike_cfg);
- if (group == MODP_NONE)
+ group = this->ike_cfg->get_algorithm(this->ike_cfg,
+ DIFFIE_HELLMAN_GROUP);
+ if (!group)
{
DBG1(DBG_IKE, "DH group selection failed");
return FAILED;
}
else
{ /* this shouldn't happen, but let's be safe */
- this->dh_group = ike_cfg->get_dh_group(ike_cfg);
+ this->dh_group = ike_cfg->get_algorithm(ike_cfg,
+ DIFFIE_HELLMAN_GROUP);
}
}
else
{
- this->dh_group = ike_cfg->get_dh_group(ike_cfg);
+ this->dh_group = ike_cfg->get_algorithm(ike_cfg,
+ DIFFIE_HELLMAN_GROUP);
}
this->dh = this->keymat->keymat.create_dh(&this->keymat->keymat,
this->dh_group);