From 009889577b1b116a79b770039d10ba77fe2c750a Mon Sep 17 00:00:00 2001 From: gefeili Date: Wed, 8 Jan 2025 13:23:07 +1030 Subject: [PATCH] Fix the bug in CipherTest.checkAEADParemeter --- core/src/test/java/org/bouncycastle/crypto/test/CipherTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/test/java/org/bouncycastle/crypto/test/CipherTest.java b/core/src/test/java/org/bouncycastle/crypto/test/CipherTest.java index f16480e9b8..48e30052fe 100644 --- a/core/src/test/java/org/bouncycastle/crypto/test/CipherTest.java +++ b/core/src/test/java/org/bouncycastle/crypto/test/CipherTest.java @@ -275,7 +275,7 @@ static void checkAEADParemeter(SimpleTest test, int keySize, int ivSize, final i } int len = cipher.processBytes(plaintext, 0, plaintext.length, ciphertext1, 0); len += cipher.doFinal(ciphertext1, len); - int aadSplit = random.nextInt(99); + int aadSplit = random.nextInt(aad.length); cipher.init(true, new AEADParameters(new KeyParameter(key), macSize * 8, iv, Arrays.copyOf(aad, aadSplit))); cipher.processAADBytes(aad, aadSplit, aad.length - aadSplit); byte[] ciphertext2 = new byte[cipher.getOutputSize(plaintext.length)];