diff options
author | Tobias Brunner <tobias@strongswan.org> | 2012-06-25 16:09:00 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2012-07-16 14:53:35 +0200 |
commit | 5025135f70e3c6f24dec4143c7de8640627d9026 (patch) | |
tree | ab68004375a0ad04a97dba30cc9584216e03847c /src/libstrongswan/plugins/gmp/gmp_rsa_private_key.c | |
parent | e93bb353d5b2750b3a89751a83086108e3d7c1ca (diff) | |
download | strongswan-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.c | 7 |
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; |