From 4d6cead1bbe72ec5772838371d0c622645294e92 Mon Sep 17 00:00:00 2001 From: Daniel Bleichenbacher Date: Thu, 26 Jul 2018 08:20:27 -0700 Subject: [PATCH] Modifying some tests because of BC version 1.59. google3 switched from version 1.52 to 1.59. Hence some tests no longer fail. - DSA now has a 2048 bit default - Ecies with AES-CBC no longer has a padding oracle. BC fixed more bugs between version 1.52 and 1.59. But most of these bugs were were already fixed internally in google3. PiperOrigin-RevId: 206161567 GitOrigin-RevId: 5cc85701f13635f4bfca70d5f0cd285125b70999 --- .../google/security/wycheproof/testcases/DsaTest.java | 4 ++-- .../google/security/wycheproof/testcases/EciesTest.java | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/java/com/google/security/wycheproof/testcases/DsaTest.java b/java/com/google/security/wycheproof/testcases/DsaTest.java index 3e602c1..46a9393 100644 --- a/java/com/google/security/wycheproof/testcases/DsaTest.java +++ b/java/com/google/security/wycheproof/testcases/DsaTest.java @@ -918,8 +918,8 @@ public class DsaTest { * that 1024 bits are supported. */ @NoPresubmitTest( - providers = {ProviderType.OPENJDK, ProviderType.BOUNCY_CASTLE}, - bugs = {"b/33190860", "b/33190677"} + providers = {ProviderType.OPENJDK}, + bugs = {"b/33190860"} ) @Test public void testDefaultKeySize() throws Exception { diff --git a/java/com/google/security/wycheproof/testcases/EciesTest.java b/java/com/google/security/wycheproof/testcases/EciesTest.java index b22e1d2..a88c979 100644 --- a/java/com/google/security/wycheproof/testcases/EciesTest.java +++ b/java/com/google/security/wycheproof/testcases/EciesTest.java @@ -20,6 +20,7 @@ import static org.junit.Assert.fail; import com.google.security.wycheproof.WycheproofRunner.NoPresubmitTest; import com.google.security.wycheproof.WycheproofRunner.ProviderType; import java.nio.ByteBuffer; +import java.security.AlgorithmParameters; import java.security.GeneralSecurityException; import java.security.KeyPair; import java.security.KeyPairGenerator; @@ -183,13 +184,13 @@ public class EciesTest { ecies.init(Cipher.ENCRYPT_MODE, pub); byte[] ciphertext = ecies.doFinal(message); System.out.println(TestUtil.bytesToHex(ciphertext)); - ecies.init(Cipher.DECRYPT_MODE, priv, ecies.getParameters()); + AlgorithmParameters params = ecies.getParameters(); HashSet exceptions = new HashSet(); for (int byteNr = kemSize; byteNr < ciphertext.length; byteNr++) { for (int bit = 0; bit < 8; bit++) { byte[] corrupt = Arrays.copyOf(ciphertext, ciphertext.length); corrupt[byteNr] ^= (byte) (1 << bit); - ecies.init(Cipher.DECRYPT_MODE, keyPair.getPrivate()); + ecies.init(Cipher.DECRYPT_MODE, priv, params); try { ecies.doFinal(corrupt); fail("Decrypted:" + TestUtil.bytesToHex(corrupt)); @@ -209,10 +210,6 @@ public class EciesTest { testExceptions("ECIES"); } - @NoPresubmitTest( - providers = {ProviderType.BOUNCY_CASTLE}, - bugs = {"b/30424901: won't fix, all BC ECIES modes are banned"} - ) @Test public void testEciesCorruptAesCbc() throws Exception { testExceptions("ECIESWithAES-CBC");