diff options
author | Jack Lloyd <[email protected]> | 2015-10-14 16:39:41 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2015-10-14 16:39:41 -0400 |
commit | c7ceff4a3a3b6b61a02b99db05eef88f7ca4b735 (patch) | |
tree | 259f6519d142985dcc8c730749d113fec9d75caf /src/lib/misc | |
parent | d4e09c4f8a2235911875044d7cb4f499ab2e467d (diff) |
Add null pointer check to pbes2_decrypt, fix message in pbes2_encrypt
Diffstat (limited to 'src/lib/misc')
-rw-r--r-- | src/lib/misc/pbes2/pbes2.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
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<byte>& key_bits, std::unique_ptr<Cipher_Mode> 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> pbkdf(get_pbkdf("PBKDF2(" + prf + ")")); @@ -157,6 +157,8 @@ pbes2_decrypt(const secure_vector<byte>& key_bits, std::unique_ptr<PBKDF> pbkdf(get_pbkdf("PBKDF2(" + prf + ")")); std::unique_ptr<Cipher_Mode> 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(); |