Skip to content

Commit 8346470

Browse files
driverktpull[bot]
authored andcommitted
8320743: AEAD ciphers throw undocumented exceptions on overflow
Reviewed-by: ascarpino
1 parent 348877d commit 8346470

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/java.base/share/classes/com/sun/crypto/provider/ChaCha20Cipher.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ protected AlgorithmParameters engineGetParameters() {
245245
params.init((new DerValue(
246246
DerValue.tag_OctetString, nonceData).toByteArray()));
247247
} catch (NoSuchAlgorithmException | IOException exc) {
248-
throw new RuntimeException(exc);
248+
throw new ProviderException(exc);
249249
}
250250
}
251251

@@ -353,7 +353,7 @@ protected void engineInit(int opmode, Key key,
353353
break;
354354
default:
355355
// Should never happen
356-
throw new RuntimeException("ChaCha20 in unsupported mode");
356+
throw new ProviderException("ChaCha20 in unsupported mode");
357357
}
358358
init(opmode, key, newNonce);
359359
}
@@ -426,7 +426,7 @@ protected void engineInit(int opmode, Key key,
426426
}
427427
break;
428428
default:
429-
throw new RuntimeException("Invalid mode: " + mode);
429+
throw new ProviderException("Invalid mode: " + mode);
430430
}
431431

432432
// Continue with initialization
@@ -730,7 +730,7 @@ protected byte[] engineDoFinal(byte[] in, int inOfs, int inLen)
730730
try {
731731
engine.doFinal(in, inOfs, inLen, output, 0);
732732
} catch (ShortBufferException | KeyException exc) {
733-
throw new RuntimeException(exc);
733+
throw new ProviderException(exc);
734734
} finally {
735735
// Reset the cipher's state to post-init values.
736736
resetStartState();
@@ -767,7 +767,7 @@ protected int engineDoFinal(byte[] in, int inOfs, int inLen, byte[] out,
767767
try {
768768
bytesUpdated = engine.doFinal(in, inOfs, inLen, out, outOfs);
769769
} catch (KeyException ke) {
770-
throw new RuntimeException(ke);
770+
throw new ProviderException(ke);
771771
} finally {
772772
// Reset the cipher's state to post-init values.
773773
resetStartState();

src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ protected AlgorithmParameters engineGetParameters() {
241241
params.init(spec);
242242
return params;
243243
} catch (NoSuchAlgorithmException | InvalidParameterSpecException e) {
244-
throw new RuntimeException(e);
244+
throw new ProviderException(e);
245245
}
246246
}
247247

@@ -781,7 +781,7 @@ int implGCMCrypt(ByteBuffer src, ByteBuffer dst) {
781781
int mergeBlock(byte[] buffer, int bufOfs, int bufLen, byte[] in,
782782
int inOfs, int inLen, byte[] block) {
783783
if (bufLen > blockSize) {
784-
throw new RuntimeException("mergeBlock called on an ibuffer " +
784+
throw new ProviderException("mergeBlock called on an ibuffer " +
785785
"too big: " + bufLen + " bytes");
786786
}
787787

0 commit comments

Comments
 (0)