Unit tests and a bugfix for IncomingEncryptionLayer.

Throw FormatException rather than RuntimeException if authenticated
decryption fails.
This commit is contained in:
akwizgran
2012-08-29 20:28:50 +01:00
parent 0b0fa76686
commit fbbebb7cfc
2 changed files with 271 additions and 5 deletions

View File

@@ -109,8 +109,8 @@ class IncomingEncryptionLayer implements FrameReader {
int decrypted = frameCipher.doFinal(ciphertext, 0, ciphertextLength,
frame, 0);
if(decrypted != plaintextLength) throw new RuntimeException();
} catch(GeneralSecurityException badCipher) {
throw new RuntimeException(badCipher);
} catch(GeneralSecurityException e) {
throw new FormatException();
}
// Decode and validate the header
finalFrame = FrameEncoder.isFinalFrame(frame);