Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Use IV of size 16 bytes in CipherTests #29

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 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 All @@ -200,9 +189,6 @@ private void runTestSingleUpdate(String nameKeySizeAndMode, String padding) thro
decipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key, "AES"), spec, sr);
byte[] output = decipher.doFinal(outFinal, 0, outFinal.length);

if (flakyTests.contains(cipherName)) {
return;
}
assertArrayEquals("Single update cipher test for " + cipherName + " failed", input, output);
}

Expand Down
Loading