change key derivation order to fullfill RFC
This commit is contained in:
+26
-11
@@ -295,14 +295,12 @@ static status_t install(private_child_sa_t *this, proposal_t *proposal, prf_plus
|
|||||||
static status_t add(private_child_sa_t *this, proposal_t *proposal, prf_plus_t *prf_plus)
|
static status_t add(private_child_sa_t *this, proposal_t *proposal, prf_plus_t *prf_plus)
|
||||||
{
|
{
|
||||||
linked_list_t *list;
|
linked_list_t *list;
|
||||||
|
u_int32_t outbound_spi, inbound_spi;
|
||||||
|
|
||||||
/* install others (initiators) SAs*/
|
/* backup outbound spi, as alloc overwrites it */
|
||||||
if (install(this, proposal, prf_plus, FALSE) != SUCCESS)
|
outbound_spi = proposal->get_spi(proposal);
|
||||||
{
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get SPIs for our SAs */
|
/* get SPIs inbound SAs */
|
||||||
list = linked_list_create();
|
list = linked_list_create();
|
||||||
list->insert_last(list, proposal);
|
list->insert_last(list, proposal);
|
||||||
if (alloc(this, list) != SUCCESS)
|
if (alloc(this, list) != SUCCESS)
|
||||||
@@ -311,25 +309,42 @@ static status_t add(private_child_sa_t *this, proposal_t *proposal, prf_plus_t *
|
|||||||
return FAILED;
|
return FAILED;
|
||||||
}
|
}
|
||||||
list->destroy(list);
|
list->destroy(list);
|
||||||
|
inbound_spi = proposal->get_spi(proposal);
|
||||||
|
|
||||||
/* install our (responders) SAs */
|
/* install inbound SAs */
|
||||||
if (install(this, proposal, prf_plus, TRUE) != SUCCESS)
|
if (install(this, proposal, prf_plus, TRUE) != SUCCESS)
|
||||||
{
|
{
|
||||||
return FAILED;
|
return FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* install outbound SAs, restore spi*/
|
||||||
|
proposal->set_spi(proposal, outbound_spi);
|
||||||
|
if (install(this, proposal, prf_plus, FALSE) != SUCCESS)
|
||||||
|
{
|
||||||
|
return FAILED;
|
||||||
|
}
|
||||||
|
proposal->set_spi(proposal, inbound_spi);
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static status_t update(private_child_sa_t *this, proposal_t *proposal, prf_plus_t *prf_plus)
|
static status_t update(private_child_sa_t *this, proposal_t *proposal, prf_plus_t *prf_plus)
|
||||||
{
|
{
|
||||||
/* install our (initator) SAs */
|
u_int32_t inbound_spi;
|
||||||
if (install(this, proposal, prf_plus, TRUE) != SUCCESS)
|
|
||||||
|
/* backup received spi, as install() overwrites it */
|
||||||
|
inbound_spi = proposal->get_spi(proposal);
|
||||||
|
|
||||||
|
/* install outbound SAs */
|
||||||
|
if (install(this, proposal, prf_plus, FALSE) != SUCCESS)
|
||||||
{
|
{
|
||||||
return FAILED;
|
return FAILED;
|
||||||
}
|
}
|
||||||
/* install his (responder) SAs */
|
|
||||||
if (install(this, proposal, prf_plus, FALSE) != SUCCESS)
|
/* restore spi */
|
||||||
|
proposal->set_spi(proposal, inbound_spi);
|
||||||
|
/* install inbound SAs */
|
||||||
|
if (install(this, proposal, prf_plus, TRUE) != SUCCESS)
|
||||||
{
|
{
|
||||||
return FAILED;
|
return FAILED;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user