From: Yehuda Sadeh Date: Tue, 14 Dec 2010 18:51:08 +0000 (-0800) Subject: crypto: catch cryptopp decrypt/encrypt exceptions X-Git-Tag: v0.24~22 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b989087ddf8775588ddbb6234d099398a2e18072;p=ceph.git crypto: catch cryptopp decrypt/encrypt exceptions --- diff --git a/src/auth/Crypto.cc b/src/auth/Crypto.cc index 467e086b3c9d..b03e2083ba2c 100644 --- a/src/auth/Crypto.cc +++ b/src/auth/Crypto.cc @@ -154,7 +154,12 @@ int CryptoAES::encrypt(bufferptr& secret, const bufferlist& in, bufferlist& out) stfEncryptor.Put(in_buf, it->length()); } - stfEncryptor.MessageEnd(); + try { + stfEncryptor.MessageEnd(); + } catch (CryptoPP::Exception& e) { + dout(0) << "encryptor.MessageEnd::Exception: " << e.GetWhat() << dendl; + return false; + } out.append((const char *)ciphertext.c_str(), ciphertext.length()); return true; @@ -178,7 +183,12 @@ int CryptoAES::decrypt(bufferptr& secret, const bufferlist& in, bufferlist& out) stfDecryptor.Put(in_buf, it->length()); } - stfDecryptor.MessageEnd(); + try { + stfDecryptor.MessageEnd(); + } catch (CryptoPP::Exception& e) { + dout(0) << "decryptor.MessageEnd::Exception: " << e.GetWhat() << dendl; + return -EINVAL; + } out.append((const char *)decryptedtext.c_str(), decryptedtext.length()); return decryptedtext.length();