Add a return value to crypter_t.set_key()

This commit is contained in:
Martin Willi
2012-07-16 14:53:38 +02:00
parent 3b96189a2a
commit ce73fc19db
23 changed files with 87 additions and 57 deletions
+6 -3
View File
@@ -205,8 +205,7 @@ METHOD(aead_t, get_key_size, size_t,
METHOD(aead_t, set_key, bool,
private_aead_t *this, chunk_t key)
{
this->crypter->set_key(this->crypter, key);
return TRUE;
return this->crypter->set_key(this->crypter, key);
}
METHOD(aead_t, aead_destroy, void,
@@ -291,7 +290,11 @@ static aead_t *create_aead(proposal_t *proposal, prf_t *prf, chunk_t skeyid_e)
return NULL;
}
DBG4(DBG_IKE, "encryption key Ka %B", &ka);
crypter->set_key(crypter, ka);
if (!crypter->set_key(crypter, ka))
{
chunk_clear(&ka);
return NULL;
}
chunk_clear(&ka);
INIT(this,
+16 -2
View File
@@ -225,7 +225,14 @@ static bool derive_ike_traditional(private_keymat_v2_t *this, u_int16_t enc_alg,
return FALSE;
}
DBG4(DBG_IKE, "Sk_ei secret %B", &key);
crypter_i->set_key(crypter_i, key);
if (!crypter_i->set_key(crypter_i, key))
{
crypter_i->destroy(crypter_i);
crypter_r->destroy(crypter_r);
signer_i->destroy(signer_i);
signer_r->destroy(signer_r);
return FALSE;
}
chunk_clear(&key);
if (!prf_plus->allocate_bytes(prf_plus, key_size, &key))
@@ -237,7 +244,14 @@ static bool derive_ike_traditional(private_keymat_v2_t *this, u_int16_t enc_alg,
return FALSE;
}
DBG4(DBG_IKE, "Sk_er secret %B", &key);
crypter_r->set_key(crypter_r, key);
if (!crypter_r->set_key(crypter_r, key))
{
crypter_i->destroy(crypter_i);
crypter_r->destroy(crypter_r);
signer_i->destroy(signer_i);
signer_r->destroy(signer_r);
return FALSE;
}
chunk_clear(&key);
if (this->initiator)