Skip to content

Commit

Permalink
tests: Use IV of size 16 bytes in CipherTests
Browse files Browse the repository at this point in the history
We only have AES in the list of FIPS-approved Ciphers.
AES needs an initialization vector of size 16-bytes. This
"might" have been the reason for the intermittent failures
seen in CipherTests.
  • Loading branch information
pushkarnk committed Aug 13, 2024
1 parent 229daeb commit 7be09df
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions src/test/java/CipherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@
import static org.junit.Assert.assertArrayEquals;

public class CipherTest {
List<String> flakyTests = List.of(
"AES192/GCM/ISO10126_2",
"AES128/GCM/PKCS7",
"AES256/CTR/NONE",
"AES128/CBC/NONE",
"AES128/CBC/PKCS5",
"AES128/CTR/PKCS5",
"AES128/CFB1/X9_23"
);

String [] paddings = {
"NONE",
Expand Down Expand Up @@ -130,7 +121,7 @@ private void runTestMultipleUpdates(String nameKeySizeAndMode, String padding) t

sr.nextBytes(key);

byte[] iv = new byte[8];
byte[] iv = new byte[16];
sr.nextBytes(iv);

byte[] input = new byte[16];
Expand Down Expand Up @@ -159,8 +150,6 @@ private void runTestMultipleUpdates(String nameKeySizeAndMode, String padding) t
decipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key, "AES"), spec, sr);
byte[] output = decipher.doFinal(fullEnc, 0, encLen);

if (flakyTests.contains(cipherName))
return;
assertArrayEquals("Multi-update cipher test for " + cipherName + " failed", fullInput, output);
}

Expand All @@ -183,7 +172,7 @@ private void runTestSingleUpdate(String nameKeySizeAndMode, String padding) thro

sr.nextBytes(key);

byte[] iv = new byte[8];
byte[] iv = new byte[16];
sr.nextBytes(iv);

AlgorithmParameterSpec spec = new IvParameterSpec(iv);
Expand Down

0 comments on commit 7be09df

Please sign in to comment.