aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/plugins/gmp/gmp_rsa_private_key.c
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2012-06-25 16:09:00 +0200
committerMartin Willi <martin@revosec.ch>2012-07-16 14:53:35 +0200
commit5025135f70e3c6f24dec4143c7de8640627d9026 (patch)
treeab68004375a0ad04a97dba30cc9584216e03847c /src/libstrongswan/plugins/gmp/gmp_rsa_private_key.c
parente93bb353d5b2750b3a89751a83086108e3d7c1ca (diff)
downloadstrongswan-5025135f.tar.bz2
strongswan-5025135f.tar.xz
Check rng return value when generating DH secrets and primes in gmp plugin
Diffstat (limited to 'src/libstrongswan/plugins/gmp/gmp_rsa_private_key.c')
-rw-r--r--src/libstrongswan/plugins/gmp/gmp_rsa_private_key.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libstrongswan/plugins/gmp/gmp_rsa_private_key.c b/src/libstrongswan/plugins/gmp/gmp_rsa_private_key.c
index 1b6c20817..acd9ae2b7 100644
--- a/src/libstrongswan/plugins/gmp/gmp_rsa_private_key.c
+++ b/src/libstrongswan/plugins/gmp/gmp_rsa_private_key.c
@@ -149,7 +149,12 @@ static status_t compute_prime(private_gmp_rsa_private_key_t *this,
mpz_init(*prime);
do
{
- rng->allocate_bytes(rng, prime_size, &random_bytes);
+ if (!rng->allocate_bytes(rng, prime_size, &random_bytes))
+ {
+ DBG1(DBG_LIB, "failed to allocate random prime");
+ rng->destroy(rng);
+ return FAILED;
+ }
/* make sure the two most significant bits are set */
random_bytes.ptr[0] = random_bytes.ptr[0] | 0xC0;