Throw an exception if CipherOutputStream's cipher does.

The upstream CipherOutputStream just suppresses outputting further
bytes when it gets an exception from the underlying cipher during
doFinal(), which means an invalid authentication tag will be silently
ignored.  Instead, have it throw an exception in that case.

This could theoretically impact app compatibility, but it's unlikely
because this only impacts the case where an AEAD cipher is being
used and the tags don't actually verify, which should only happen in
the case that someone has tampered with the ciphertext.  We also
consider it acceptable to break anyone relying on the behavior that
invalid ciphertexts are silently accepted, since that's inappropriate
behavior in the case of malicious tampering.

Bug: 36636576
Test: cts -m CtsLibcoreTestCases
Change-Id: Ic087015ca3bef8683f23b86ee34b4ecd391e3bdb
2 files changed