Check rng return value when generating secrets and IVs in libtls

This commit is contained in:
Tobias Brunner
2012-07-16 14:53:37 +02:00
committed by Martin Willi
parent e59f983160
commit 126eb2af59
3 changed files with 20 additions and 16 deletions
+4 -4
View File
@@ -243,14 +243,14 @@ METHOD(tls_protection_t, build, status_t,
}
else
{ /* TLSv1.1 uses random IVs, prepended to record */
if (!this->rng)
iv.len = this->crypter_out->get_iv_size(this->crypter_out);
if (!this->rng ||
!this->rng->allocate_bytes(this->rng, iv.len, &iv))
{
DBG1(DBG_TLS, "no RNG supported to generate TLS IV");
DBG1(DBG_TLS, "failed to generate TLS IV");
free(data->ptr);
return FAILED;
}
iv.len = this->crypter_out->get_iv_size(this->crypter_out);
this->rng->allocate_bytes(this->rng, iv.len, &iv);
}
*data = chunk_cat("mmcc", *data, mac, padding,