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
This commit is contained in:
Daniel Bleichenbacher
2018-07-26 08:20:27 -07:00
committed by quannguyentm
parent d59a68af04
commit 4d6cead1bb
2 changed files with 5 additions and 8 deletions
@@ -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 {
@@ -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<String> exceptions = new HashSet<String>();
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");