diff options
author | Tobias Brunner <tobias@strongswan.org> | 2012-06-25 16:10:46 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2012-07-16 14:53:36 +0200 |
commit | 1f5291b1ce86cd86fb23136e713949aead9154b7 (patch) | |
tree | a87ea8214f69819ec03cfcc8467f1fb87e783c6d /src/libstrongswan | |
parent | 5025135f70e3c6f24dec4143c7de8640627d9026 (diff) | |
download | strongswan-1f5291b1ce86cd86fb23136e713949aead9154b7.tar.bz2 strongswan-1f5291b1ce86cd86fb23136e713949aead9154b7.tar.xz |
Check rng return value when generating DH secret in gcrypt plugin
Diffstat (limited to 'src/libstrongswan')
-rw-r--r-- | src/libstrongswan/plugins/gcrypt/gcrypt_dh.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libstrongswan/plugins/gcrypt/gcrypt_dh.c b/src/libstrongswan/plugins/gcrypt/gcrypt_dh.c index 6c4665da2..0efd3ba16 100644 --- a/src/libstrongswan/plugins/gcrypt/gcrypt_dh.c +++ b/src/libstrongswan/plugins/gcrypt/gcrypt_dh.c @@ -208,9 +208,8 @@ gcrypt_dh_t *create_generic(diffie_hellman_group_t group, size_t exp_len, } rng = lib->crypto->create_rng(lib->crypto, RNG_STRONG); - if (rng) + if (rng && rng->allocate_bytes(rng, exp_len, &random)) { /* prefer external randomizer */ - rng->allocate_bytes(rng, exp_len, &random); rng->destroy(rng); err = gcry_mpi_scan(&this->xa, GCRYMPI_FMT_USG, random.ptr, random.len, NULL); @@ -226,6 +225,7 @@ gcrypt_dh_t *create_generic(diffie_hellman_group_t group, size_t exp_len, } else { /* fallback to gcrypt internal randomizer, shouldn't ever happen */ + DESTROY_IF(rng); this->xa = gcry_mpi_new(exp_len * 8); gcry_mpi_randomize(this->xa, exp_len * 8, GCRY_STRONG_RANDOM); } |