aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/plugins/openssl/openssl_rng.c
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2012-06-25 13:22:54 +0200
committerMartin Willi <martin@revosec.ch>2012-07-16 14:53:34 +0200
commit39e807728e275037fcc145015a6f3fa54c62221c (patch)
tree532ebc86d55c1e780afd32895f4bc7a0d3b3bbc1 /src/libstrongswan/plugins/openssl/openssl_rng.c
parent605985d122cd854ea7c1b85ce3ec107752c9f103 (diff)
downloadstrongswan-39e807728e275037fcc145015a6f3fa54c62221c.tar.bz2
strongswan-39e807728e275037fcc145015a6f3fa54c62221c.tar.xz
RNGs' get_bytes and allocate_bytes return boolean
Diffstat (limited to 'src/libstrongswan/plugins/openssl/openssl_rng.c')
-rw-r--r--src/libstrongswan/plugins/openssl/openssl_rng.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/libstrongswan/plugins/openssl/openssl_rng.c b/src/libstrongswan/plugins/openssl/openssl_rng.c
index abb462279..c83244f60 100644
--- a/src/libstrongswan/plugins/openssl/openssl_rng.c
+++ b/src/libstrongswan/plugins/openssl/openssl_rng.c
@@ -44,10 +44,10 @@ struct private_openssl_rng_t {
rng_quality_t quality;
};
-METHOD(rng_t, get_bytes, void,
+METHOD(rng_t, get_bytes, bool,
private_openssl_rng_t *this, size_t bytes, u_int8_t *buffer)
{
- u_int32_t ret=0;
+ u_int32_t ret;
if (this->quality == RNG_STRONG)
{
@@ -57,18 +57,19 @@ METHOD(rng_t, get_bytes, void,
{
ret = RAND_pseudo_bytes((char*)buffer, bytes);
}
-
- if (ret == 0)
- {
- DBG1(DBG_LIB, "getting randomness from openssl failed.");
- }
+ return ret != 0;
}
-METHOD(rng_t, allocate_bytes, void,
+METHOD(rng_t, allocate_bytes, bool,
private_openssl_rng_t *this, size_t bytes, chunk_t *chunk)
{
*chunk = chunk_alloc(bytes);
- get_bytes(this, chunk->len, chunk->ptr);
+ if (!get_bytes(this, chunk->len, chunk->ptr))
+ {
+ chunk_free(chunk);
+ return FALSE;
+ }
+ return TRUE;
}
METHOD(rng_t, destroy, void,