diff options
-rw-r--r-- | src/libstrongswan/crypto/pkcs7.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/libstrongswan/crypto/pkcs7.c b/src/libstrongswan/crypto/pkcs7.c index c5fa8c02d..33ed7c92d 100644 --- a/src/libstrongswan/crypto/pkcs7.c +++ b/src/libstrongswan/crypto/pkcs7.c @@ -787,12 +787,24 @@ METHOD(pkcs7_t, build_envelopedData, bool, rng_t *rng; rng = lib->crypto->create_rng(lib->crypto, RNG_TRUE); - rng->allocate_bytes(rng, crypter->get_key_size(crypter), &symmetricKey); + if (!rng || !rng->allocate_bytes(rng, crypter->get_key_size(crypter), + &symmetricKey)) + { + DBG1(DBG_LIB, " failed to allocate symmetric encryption key"); + DESTROY_IF(rng); + return FALSE; + } DBG4(DBG_LIB, " symmetric encryption key: %B", &symmetricKey); rng->destroy(rng); rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK); - rng->allocate_bytes(rng, crypter->get_iv_size(crypter), &iv); + if (!rng || !rng->allocate_bytes(rng, crypter->get_iv_size(crypter), + &iv)) + { + DBG1(DBG_LIB, " failed to allocate initialization vector"); + DESTROY_IF(rng); + return FALSE; + } DBG4(DBG_LIB, " initialization vector: %B", &iv); rng->destroy(rng); } |