encoding: Allow ke_payload_create_from_diffie_hellman() to fail
This commit is contained in:
@@ -694,7 +694,13 @@ METHOD(phase1_t, add_nonce_ke, bool,
|
||||
nonce_gen_t *nonceg;
|
||||
chunk_t nonce;
|
||||
|
||||
ke_payload = ke_payload_create_from_diffie_hellman(PLV1_KEY_EXCHANGE, this->dh);
|
||||
ke_payload = ke_payload_create_from_diffie_hellman(PLV1_KEY_EXCHANGE,
|
||||
this->dh);
|
||||
if (!ke_payload)
|
||||
{
|
||||
DBG1(DBG_IKE, "creating KE payload failed");
|
||||
return FALSE;
|
||||
}
|
||||
message->add_payload(message, &ke_payload->payload_interface);
|
||||
|
||||
nonceg = this->keymat->keymat.create_nonce_gen(&this->keymat->keymat);
|
||||
|
||||
@@ -465,12 +465,19 @@ static bool get_nonce(private_quick_mode_t *this, chunk_t *nonce,
|
||||
/**
|
||||
* Add KE payload to message
|
||||
*/
|
||||
static void add_ke(private_quick_mode_t *this, message_t *message)
|
||||
static bool add_ke(private_quick_mode_t *this, message_t *message)
|
||||
{
|
||||
ke_payload_t *ke_payload;
|
||||
|
||||
ke_payload = ke_payload_create_from_diffie_hellman(PLV1_KEY_EXCHANGE, this->dh);
|
||||
ke_payload = ke_payload_create_from_diffie_hellman(PLV1_KEY_EXCHANGE,
|
||||
this->dh);
|
||||
if (!ke_payload)
|
||||
{
|
||||
DBG1(DBG_IKE, "creating KE payload failed");
|
||||
return FALSE;
|
||||
}
|
||||
message->add_payload(message, &ke_payload->payload_interface);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -880,7 +887,10 @@ METHOD(task_t, build_i, status_t,
|
||||
}
|
||||
if (group != MODP_NONE)
|
||||
{
|
||||
add_ke(this, message);
|
||||
if (!add_ke(this, message))
|
||||
{
|
||||
return FAILED;
|
||||
}
|
||||
}
|
||||
if (!this->tsi)
|
||||
{
|
||||
@@ -1218,7 +1228,10 @@ METHOD(task_t, build_r, status_t,
|
||||
}
|
||||
if (this->dh)
|
||||
{
|
||||
add_ke(this, message);
|
||||
if (!add_ke(this, message))
|
||||
{
|
||||
return FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
add_ts(this, message);
|
||||
|
||||
Reference in New Issue
Block a user