aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWycheproof Team <noreply@google.com>2023-09-14 10:44:45 -0700
committerCopybara-Service <copybara-worker@google.com>2023-09-14 10:45:20 -0700
commit7f80b0814581404f5423e391381301c541985626 (patch)
treeaa17aece1149b7618cd57406a21c6cde7c098dfc
parent0111beb4c57607dbdf56d5caa8882d5eafb89481 (diff)
downloadwycheproof-7f80b0814581404f5423e391381301c541985626.tar.gz
Explicitly provide an AlgorithmParameterSpec for cipher initialization
Bouncy Castle 1.73 and later no longer allows null IES algorithm parameters: https://github.com/bcgit/bc-java/commit/5f7b6e7588737bcfb8f1dac85c03d761dc39f42c http://sponge2/9c4945bf-871a-4131-ac6e-81353a8599d0 (ok) http://sponge2/d7ab9ab6-c9b6-4939-b967-36a58ffcb269 (failed) NOKEYCHECK=True PiperOrigin-RevId: 565414128
-rw-r--r--java/com/google/security/wycheproof/testcases/DhiesTest.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/java/com/google/security/wycheproof/testcases/DhiesTest.java b/java/com/google/security/wycheproof/testcases/DhiesTest.java
index 7821596..920dd75 100644
--- a/java/com/google/security/wycheproof/testcases/DhiesTest.java
+++ b/java/com/google/security/wycheproof/testcases/DhiesTest.java
@@ -92,8 +92,9 @@ public class DhiesTest {
String paramsHex;
switch (algorithmName.toUpperCase(Locale.ENGLISH)) {
case "DHIES":
- // No algorithm parameters necessary.
- return null;
+ // 128-bit HMAC key.
+ paramsHex = "300702020080010100";
+ break;
case "DHIESWITHAES-CBC":
// 256-bit AES key, 256-bit HMAC key, all zero nonce
paramsHex = "301c02020100301602020100041000000000000000000000000000000000";
@@ -167,7 +168,11 @@ public class DhiesTest {
TestUtil.skipTest(algorithmName + " is not supported");
return; // fallback for legacy test setups where skipTest does not throw an exception.
}
+ try {
dhies.init(Cipher.ENCRYPT_MODE, pub);
+ } catch (IllegalArgumentException e) {
+ TestUtil.skipTest("AlgorithmParameters must be non-null");
+ }
byte[] ciphertext = dhies.doFinal(message);
System.out.println(
algorithmName + " : " + TestUtil.bytesToHex(dhies.getParameters().getEncoded()));
@@ -269,7 +274,11 @@ public class DhiesTest {
continue;
}
byte[] message = new byte[128];
+ try {
dhies.init(Cipher.ENCRYPT_MODE, pub);
+ } catch (IllegalArgumentException e) {
+ TestUtil.skipTest("AlgorithmParameters must be non-null");
+ }
byte[] ciphertext = dhies.doFinal(message);
int blockSize = 16;
for (int i = 0; i < ciphertext.length - 2 * blockSize + 1; i++) {