summaryrefslogtreecommitdiff
path: root/src/libstrongswan/plugins/pkcs11/pkcs11_rng.c
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2013-01-02 14:18:20 +0100
committerYves-Alexis Perez <corsac@debian.org>2013-01-02 14:18:20 +0100
commitc1343b3278cdf99533b7902744d15969f9d6fdc1 (patch)
treed5ed3dc5677a59260ec41cd39bb284d3e94c91b3 /src/libstrongswan/plugins/pkcs11/pkcs11_rng.c
parentb34738ed08c2227300d554b139e2495ca5da97d6 (diff)
downloadvyos-strongswan-c1343b3278cdf99533b7902744d15969f9d6fdc1.tar.gz
vyos-strongswan-c1343b3278cdf99533b7902744d15969f9d6fdc1.zip
Imported Upstream version 5.0.1
Diffstat (limited to 'src/libstrongswan/plugins/pkcs11/pkcs11_rng.c')
-rw-r--r--src/libstrongswan/plugins/pkcs11/pkcs11_rng.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/libstrongswan/plugins/pkcs11/pkcs11_rng.c b/src/libstrongswan/plugins/pkcs11/pkcs11_rng.c
index 45cf0b7c2..20e4b6f76 100644
--- a/src/libstrongswan/plugins/pkcs11/pkcs11_rng.c
+++ b/src/libstrongswan/plugins/pkcs11/pkcs11_rng.c
@@ -43,7 +43,7 @@ struct private_pkcs11_rng_t {
};
-METHOD(rng_t, get_bytes, void,
+METHOD(rng_t, get_bytes, bool,
private_pkcs11_rng_t *this, size_t bytes, u_int8_t *buffer)
{
CK_RV rv;
@@ -51,15 +51,21 @@ METHOD(rng_t, get_bytes, void,
if (rv != CKR_OK)
{
DBG1(DBG_CFG, "C_GenerateRandom() failed: %N", ck_rv_names, rv);
- abort();
+ return FALSE;
}
+ return TRUE;
}
-METHOD(rng_t, allocate_bytes, void,
+METHOD(rng_t, allocate_bytes, bool,
private_pkcs11_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_clear(chunk);
+ return FALSE;
+ }
+ return TRUE;
}
METHOD(rng_t, destroy, void,