From c7ceff4a3a3b6b61a02b99db05eef88f7ca4b735 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Wed, 14 Oct 2015 16:39:41 -0400 Subject: Add null pointer check to pbes2_decrypt, fix message in pbes2_encrypt --- src/lib/misc/pbes2/pbes2.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/misc/pbes2/pbes2.cpp b/src/lib/misc/pbes2/pbes2.cpp index 470e33cb0..ec5a10ba8 100644 --- a/src/lib/misc/pbes2/pbes2.cpp +++ b/src/lib/misc/pbes2/pbes2.cpp @@ -82,7 +82,7 @@ pbes2_encrypt(const secure_vector& key_bits, std::unique_ptr enc(get_cipher_mode(cipher, ENCRYPTION)); if(!enc) - throw Decoding_Error("PBE-PKCS5 cannot decrypt no cipher " + cipher); + throw Encoding_Error("PBE-PKCS5 cannot encrypt no cipher " + cipher); std::unique_ptr pbkdf(get_pbkdf("PBKDF2(" + prf + ")")); @@ -157,6 +157,8 @@ pbes2_decrypt(const secure_vector& key_bits, std::unique_ptr pbkdf(get_pbkdf("PBKDF2(" + prf + ")")); std::unique_ptr dec(get_cipher_mode(cipher, DECRYPTION)); + if(!enc) + throw Decoding_Error("PBE-PKCS5 cannot decrypt no cipher " + cipher); if(key_length == 0) key_length = dec->key_spec().maximum_keylength(); -- cgit v1.2.3