- state ike_sa_init_responded implemented (has some memleaks)
This commit is contained in:
@@ -152,7 +152,7 @@ static void load_default_config (private_configuration_manager_t *this)
|
||||
init_config_t *init_config1, *init_config2, *init_config3;
|
||||
ike_proposal_t proposals[2];
|
||||
child_proposal_t child_proposals[1];
|
||||
sa_config_t *sa_config1, *sa_config2;
|
||||
sa_config_t *sa_config1, *sa_config2, *sa_config3;
|
||||
traffic_selector_t *ts;
|
||||
|
||||
init_config1 = init_config_create("152.96.193.131","152.96.193.131",IKEV2_UDP_PORT,IKEV2_UDP_PORT);
|
||||
@@ -195,6 +195,13 @@ static void load_default_config (private_configuration_manager_t *this)
|
||||
|
||||
sa_config2->add_traffic_selector_initiator(sa_config2,ts);
|
||||
sa_config2->add_traffic_selector_responder(sa_config2,ts);
|
||||
|
||||
sa_config3 = sa_config_create(ID_IPV4_ADDR, "127.0.0.1",
|
||||
ID_IPV4_ADDR, "127.0.0.1",
|
||||
SHARED_KEY_MESSAGE_INTEGRITY_CODE);
|
||||
|
||||
sa_config3->add_traffic_selector_initiator(sa_config3,ts);
|
||||
sa_config3->add_traffic_selector_responder(sa_config3,ts);
|
||||
|
||||
ts->destroy(ts);
|
||||
|
||||
@@ -210,6 +217,7 @@ static void load_default_config (private_configuration_manager_t *this)
|
||||
child_proposals[0].esp.encryption_algorithm = ENCR_AES_CBC;
|
||||
child_proposals[0].esp.encryption_algorithm_key_size = 16;
|
||||
child_proposals[0].esp.integrity_algorithm = AUTH_UNDEFINED;
|
||||
child_proposals[0].esp.extended_sequence_numbers = NO_EXT_SEQ_NUMBERS;
|
||||
child_proposals[0].esp.spi[0] = 2;
|
||||
child_proposals[0].esp.spi[1] = 2;
|
||||
child_proposals[0].esp.spi[2] = 2;
|
||||
@@ -217,10 +225,11 @@ static void load_default_config (private_configuration_manager_t *this)
|
||||
|
||||
sa_config1->add_proposal(sa_config1, &child_proposals[0]);
|
||||
sa_config2->add_proposal(sa_config2, &child_proposals[0]);
|
||||
sa_config3->add_proposal(sa_config3, &child_proposals[0]);
|
||||
|
||||
this->add_new_configuration(this,"pinflb31",init_config1,sa_config2);
|
||||
this->add_new_configuration(this,"pinflb30",init_config2,sa_config1);
|
||||
this->add_new_configuration(this,"localhost",init_config3,sa_config1);
|
||||
this->add_new_configuration(this,"localhost",init_config3,sa_config3);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -260,31 +260,74 @@ static child_proposal_t *select_proposal(private_sa_config_t *this, u_int8_t ah_
|
||||
*/
|
||||
static bool proposal_equals(private_sa_config_t *this, child_proposal_t *first, child_proposal_t *second)
|
||||
{
|
||||
/*
|
||||
* Proto ? Mandatory ? Optional
|
||||
* -----------------------------------
|
||||
* ESP ? ENCR ? INTEG, D-H, ESN
|
||||
* AH ? INTEG ? D-H, ESN
|
||||
*/
|
||||
|
||||
/* equality defaults to false, so return is FALSE if ah and esp not set */
|
||||
bool equal = FALSE;
|
||||
|
||||
/* check ah, if set */
|
||||
if (first->ah.is_set && second->ah.is_set)
|
||||
{
|
||||
if ((first->ah.integrity_algorithm != second->ah.integrity_algorithm) ||
|
||||
(first->ah.integrity_algorithm_key_size != second->ah.integrity_algorithm_key_size) ||
|
||||
(first->ah.diffie_hellman_group != second->ah.diffie_hellman_group) ||
|
||||
(first->ah.extended_sequence_numbers != second->ah.extended_sequence_numbers))
|
||||
/* integrity alg is mandatory, with key size */
|
||||
if ((first->ah.integrity_algorithm == second->ah.integrity_algorithm) &&
|
||||
(first->ah.integrity_algorithm_key_size == second->ah.integrity_algorithm_key_size))
|
||||
{
|
||||
return FALSE;
|
||||
/* dh group is optional, but must be NOT_SET when not set */
|
||||
if (first->ah.diffie_hellman_group != second->ah.diffie_hellman_group)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
/* sequence numbers is optional, but must be NOT_SET when not set */
|
||||
if (first->ah.extended_sequence_numbers != second->ah.extended_sequence_numbers)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
/* all checked, ah seems ok */
|
||||
equal = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
equal = TRUE;
|
||||
}
|
||||
/* check esp, if set */
|
||||
if (first->esp.is_set && second->esp.is_set)
|
||||
{
|
||||
if ((first->esp.encryption_algorithm != second->esp.encryption_algorithm) ||
|
||||
(first->esp.encryption_algorithm_key_size != second->esp.encryption_algorithm_key_size) ||
|
||||
(first->esp.integrity_algorithm != second->esp.integrity_algorithm) ||
|
||||
(first->esp.integrity_algorithm_key_size != second->esp.integrity_algorithm_key_size) ||
|
||||
(first->esp.diffie_hellman_group != second->esp.diffie_hellman_group) ||
|
||||
(first->esp.extended_sequence_numbers != second->esp.extended_sequence_numbers))
|
||||
/* encryption alg is mandatory, with key size */
|
||||
if ((first->esp.encryption_algorithm == second->esp.encryption_algorithm) &&
|
||||
(first->esp.encryption_algorithm_key_size == second->esp.encryption_algorithm_key_size))
|
||||
{
|
||||
return FALSE;
|
||||
/* int alg is optional, check key only when not NOT_SET */
|
||||
if (first->esp.integrity_algorithm != second->esp.integrity_algorithm)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if ((first->esp.integrity_algorithm != AUTH_UNDEFINED) &&
|
||||
(first->esp.integrity_algorithm_key_size != second->esp.integrity_algorithm_key_size))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
/* dh group is optional, but must be NOT_SET when not set */
|
||||
if (first->esp.diffie_hellman_group != second->esp.diffie_hellman_group)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (first->esp.extended_sequence_numbers != second->esp.extended_sequence_numbers)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
/* all checked, esp seems ok */
|
||||
equal = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
equal = TRUE;
|
||||
}
|
||||
return equal;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user