8314045: ArithmeticException in GaloisCounterMode

Co-authored-by: Ioana Nedelcu <ioannanedelcu@google.com>
Reviewed-by: ascarpino
This commit is contained in:
Liam Miller-Cushon 2023-08-14 15:51:18 +00:00
parent 911d1dbbf7
commit f41c267f85
2 changed files with 65 additions and 0 deletions

View file

@ -1572,6 +1572,13 @@ abstract class GaloisCounterMode extends CipherSpi {
len += buffer.remaining();
}
// Check that input data is long enough to fit the expected tag.
if (len < 0) {
throw new AEADBadTagException("Input data too short to " +
"contain an expected tag length of " + tagLenBytes +
"bytes");
}
checkDataLength(len);
// Verify dst is large enough