From fb6114ffb91ffa2d119c35d3d1a855254577f930 Mon Sep 17 00:00:00 2001 From: Jack He Date: Tue, 5 May 2020 00:16:03 +0000 Subject: Revert "Remove deprecated BouncyCastle algorithms" Revert "Remove deprecated BouncyCastle algorithms" Revert submission 1299358-remove_bc_algos Reason for revert: broke higkey-userdebug Bug: 155693016 Reverted Changes: I98adb4d2f:Load default KeyFactory instead of BC's implementa... I5256fe1c7:Remove deprecated BouncyCastle algorithms I0437de742:Remove deprecated BouncyCastle algorithms Ie9e0cfa02:Remove deprecated BouncyCastle algorithms Change-Id: I6030fdd2339b62ba51e7322caa3224f18023373e --- .../google/security/wycheproof/BouncyCastleAllTests.java | 6 ++++++ java/com/google/security/wycheproof/BouncyCastleTest.java | 6 ++++++ java/com/google/security/wycheproof/ConscryptTest.java | 7 +------ java/com/google/security/wycheproof/testcases/DsaTest.java | 4 ---- .../google/security/wycheproof/testcases/EcKeyTest.java | 14 -------------- .../com/google/security/wycheproof/testcases/EcdhTest.java | 11 ----------- .../google/security/wycheproof/testcases/EcdsaTest.java | 13 ------------- .../google/security/wycheproof/testcases/RsaKeyTest.java | 11 ----------- .../security/wycheproof/testcases/RsaSignatureTest.java | 11 ----------- 9 files changed, 13 insertions(+), 70 deletions(-) diff --git a/java/com/google/security/wycheproof/BouncyCastleAllTests.java b/java/com/google/security/wycheproof/BouncyCastleAllTests.java index 2ce1290..7bf5792 100644 --- a/java/com/google/security/wycheproof/BouncyCastleAllTests.java +++ b/java/com/google/security/wycheproof/BouncyCastleAllTests.java @@ -37,7 +37,13 @@ import org.junit.runners.Suite.SuiteClasses; DhTest.class, DhiesTest.class, DsaTest.class, + EcKeyTest.class, + EcdhTest.class, + EcdsaTest.class, EciesTest.class, + RsaEncryptionTest.class, + RsaKeyTest.class, + RsaSignatureTest.class, }) @Provider(ProviderType.BOUNCY_CASTLE) public final class BouncyCastleAllTests { diff --git a/java/com/google/security/wycheproof/BouncyCastleTest.java b/java/com/google/security/wycheproof/BouncyCastleTest.java index c5beb94..6fd118c 100644 --- a/java/com/google/security/wycheproof/BouncyCastleTest.java +++ b/java/com/google/security/wycheproof/BouncyCastleTest.java @@ -38,7 +38,13 @@ import org.junit.runners.Suite.SuiteClasses; DhTest.class, DhiesTest.class, DsaTest.class, + EcKeyTest.class, + EcdhTest.class, + EcdsaTest.class, EciesTest.class, + RsaEncryptionTest.class, + RsaKeyTest.class, + RsaSignatureTest.class, }) @Provider(ProviderType.BOUNCY_CASTLE) @Fast diff --git a/java/com/google/security/wycheproof/ConscryptTest.java b/java/com/google/security/wycheproof/ConscryptTest.java index 1cd5cf6..2a87a7b 100644 --- a/java/com/google/security/wycheproof/ConscryptTest.java +++ b/java/com/google/security/wycheproof/ConscryptTest.java @@ -31,21 +31,16 @@ import org.junit.runners.Suite.SuiteClasses; */ @RunWith(WycheproofRunner.class) @SuiteClasses({ - AesEaxTest.class, AesGcmTest.class, BasicTest.class, CipherInputStreamTest.class, CipherOutputStreamTest.class, - DhTest.class, - DhiesTest.class, - DsaTest.class, EcKeyTest.class, EcdhTest.class, EcdsaTest.class, - EciesTest.class, RsaEncryptionTest.class, RsaKeyTest.class, - RsaSignatureTest.class, + RsaSignatureTest.class }) @Provider(ProviderType.CONSCRYPT) @Fast diff --git a/java/com/google/security/wycheproof/testcases/DsaTest.java b/java/com/google/security/wycheproof/testcases/DsaTest.java index 62ddb01..bf7761e 100644 --- a/java/com/google/security/wycheproof/testcases/DsaTest.java +++ b/java/com/google/security/wycheproof/testcases/DsaTest.java @@ -26,7 +26,6 @@ // signature multiple times, since this allows to get more accurate timings. package com.google.security.wycheproof; -import com.google.security.wycheproof.WycheproofRunner.ExcludedTest; import com.google.security.wycheproof.WycheproofRunner.ProviderType; import com.google.security.wycheproof.WycheproofRunner.SlowTest; // Android-removed: Android doesn't support JMX @@ -892,9 +891,6 @@ public class DsaTest extends TestCase { * test until April 2016. */ @SuppressWarnings("InsecureCryptoUsage") - @ExcludedTest( - providers = {ProviderType.BOUNCY_CASTLE}, - comment = "Signature.SHA1WithDSA is removed") public void testDsaBias() throws Exception { // q is close to 2/3 * 2^160. BigInteger q = new BigInteger("974317976835659416858874959372334979171063697271"); diff --git a/java/com/google/security/wycheproof/testcases/EcKeyTest.java b/java/com/google/security/wycheproof/testcases/EcKeyTest.java index a18a8ff..8d3563c 100644 --- a/java/com/google/security/wycheproof/testcases/EcKeyTest.java +++ b/java/com/google/security/wycheproof/testcases/EcKeyTest.java @@ -21,8 +21,6 @@ package com.google.security.wycheproof; -import com.google.security.wycheproof.WycheproofRunner.ExcludedTest; -import com.google.security.wycheproof.WycheproofRunner.ProviderType; import java.math.BigInteger; import java.security.InvalidAlgorithmParameterException; import java.security.KeyFactory; @@ -129,9 +127,6 @@ public class EcKeyTest extends TestCase { + "8c0b49bbb85c3303ddb1553c3b761c2caacca71606ba9ebac8", }; - @ExcludedTest( - providers = {ProviderType.BOUNCY_CASTLE}, - comment = "KeyFactory.EC is removed") public void testEncodedPublicKey() throws Exception { KeyFactory kf = KeyFactory.getInstance("EC"); for (String encodedHex : EC_INVALID_PUBLIC_KEYS) { @@ -147,9 +142,6 @@ public class EcKeyTest extends TestCase { } } - @ExcludedTest( - providers = {ProviderType.BOUNCY_CASTLE}, - comment = "KeyPairGenerator.EC is removed") public void testEncodedPrivateKey() throws Exception { KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC"); keyGen.initialize(EcUtil.getNistP256Params()); @@ -193,9 +185,6 @@ public class EcKeyTest extends TestCase { // TODO(bleichen): use RandomUtil } - @ExcludedTest( - providers = {ProviderType.BOUNCY_CASTLE}, - comment = "KeyPairGenerator.EC is removed") public void testKeyGenerationAll() throws Exception { testKeyGeneration(EcUtil.getNistP224Params(), true); testKeyGeneration(EcUtil.getNistP256Params(), true); @@ -213,9 +202,6 @@ public class EcKeyTest extends TestCase { * Nist recommends a minimal security strength of 112 bits for the time until 2030. * To achieve this security strength EC keys of at least 224 bits are required. */ - @ExcludedTest( - providers = {ProviderType.BOUNCY_CASTLE}, - comment = "KeyPairGenerator.EC is removed") public void testDefaultKeyGeneration() throws Exception { KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC"); KeyPair keyPair = keyGen.generateKeyPair(); diff --git a/java/com/google/security/wycheproof/testcases/EcdhTest.java b/java/com/google/security/wycheproof/testcases/EcdhTest.java index c1a8b82..00be916 100644 --- a/java/com/google/security/wycheproof/testcases/EcdhTest.java +++ b/java/com/google/security/wycheproof/testcases/EcdhTest.java @@ -16,8 +16,6 @@ package com.google.security.wycheproof; -import com.google.security.wycheproof.WycheproofRunner.ExcludedTest; -import com.google.security.wycheproof.WycheproofRunner.ProviderType; import java.math.BigInteger; import java.security.GeneralSecurityException; import java.security.InvalidKeyException; @@ -829,9 +827,6 @@ public class EcdhTest extends TestCase { }; /** Checks that key agreement using ECDH works. */ - @ExcludedTest( - providers = {ProviderType.BOUNCY_CASTLE}, - comment = "KeyPairGenerator.EC is removed") public void testBasic() throws Exception { KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC"); ECGenParameterSpec ecSpec = new ECGenParameterSpec("secp256r1"); @@ -850,9 +845,6 @@ public class EcdhTest extends TestCase { assertEquals(TestUtil.bytesToHex(kAB), TestUtil.bytesToHex(kBA)); } - @ExcludedTest( - providers = {ProviderType.BOUNCY_CASTLE}, - comment = "KeyAgreement.ECDH is removed") public void testVectors() throws Exception { KeyAgreement ka = KeyAgreement.getInstance("ECDH"); for (EcdhTestVector t : ECDH_TEST_VECTORS) { @@ -867,9 +859,6 @@ public class EcdhTest extends TestCase { } } - @ExcludedTest( - providers = {ProviderType.BOUNCY_CASTLE}, - comment = "KeyFactory.EC is removed") public void testDecode() throws Exception { KeyFactory kf = KeyFactory.getInstance("EC"); ECPublicKey key1 = (ECPublicKey) kf.generatePublic(EC_VALID_PUBLIC_KEY.getSpec()); diff --git a/java/com/google/security/wycheproof/testcases/EcdsaTest.java b/java/com/google/security/wycheproof/testcases/EcdsaTest.java index 0d65286..c279aaf 100644 --- a/java/com/google/security/wycheproof/testcases/EcdsaTest.java +++ b/java/com/google/security/wycheproof/testcases/EcdsaTest.java @@ -16,7 +16,6 @@ package com.google.security.wycheproof; -import com.google.security.wycheproof.WycheproofRunner.ExcludedTest; import com.google.security.wycheproof.WycheproofRunner.ProviderType; import com.google.security.wycheproof.WycheproofRunner.SlowTest; // Android-removed: Android doesn't support JMX @@ -641,18 +640,12 @@ public class EcdsaTest extends TestCase { assertEquals(0, errors); } - @ExcludedTest( - providers = {ProviderType.BOUNCY_CASTLE}, - comment = "Signature.SHA256WithECDSA is removed") public void testValidSignatures() throws Exception { testVectors( VALID_SIGNATURES, publicKey1(), "Hello", "SHA256WithECDSA", "Valid ECDSA signature", true, true); } - @ExcludedTest( - providers = {ProviderType.BOUNCY_CASTLE}, - comment = "Signature.SHA256WithECDSA is removed") public void testModifiedSignatures() throws Exception { testVectors( MODIFIED_SIGNATURES, @@ -664,9 +657,6 @@ public class EcdsaTest extends TestCase { true); } - @ExcludedTest( - providers = {ProviderType.BOUNCY_CASTLE}, - comment = "Signature.SHA256WithECDSA is removed") public void testInvalidSignatures() throws Exception { testVectors( INVALID_SIGNATURES, @@ -682,9 +672,6 @@ public class EcdsaTest extends TestCase { * This test checks the basic functionality of ECDSA. It can also be used to generate simple test * vectors. */ - @ExcludedTest( - providers = {ProviderType.BOUNCY_CASTLE}, - comment = "KeyPairGenerator.EC is removed") public void testBasic() throws Exception { String algorithm = "SHA256WithECDSA"; String hashAlgorithm = "SHA-256"; diff --git a/java/com/google/security/wycheproof/testcases/RsaKeyTest.java b/java/com/google/security/wycheproof/testcases/RsaKeyTest.java index bfe5249..b761dae 100644 --- a/java/com/google/security/wycheproof/testcases/RsaKeyTest.java +++ b/java/com/google/security/wycheproof/testcases/RsaKeyTest.java @@ -16,8 +16,6 @@ package com.google.security.wycheproof; -import com.google.security.wycheproof.WycheproofRunner.ExcludedTest; -import com.google.security.wycheproof.WycheproofRunner.ProviderType; import java.math.BigInteger; import java.security.KeyFactory; import java.security.KeyPair; @@ -1456,9 +1454,6 @@ public class RsaKeyTest extends TestCase { checkKeyPair(keypair, keySizeInBits); } - @ExcludedTest( - providers = {ProviderType.BOUNCY_CASTLE}, - comment = "KeyPairGenerator.RSA is removed") public void testKeyGeneration() throws Exception { testKeyGenerationSize(1024); testKeyGenerationSize(2048); @@ -1471,9 +1466,6 @@ public class RsaKeyTest extends TestCase { * Such a failure does not need to be a bug, since several encoding for the same key are * possible. */ - @ExcludedTest( - providers = {ProviderType.BOUNCY_CASTLE}, - comment = "KeyFactory.RSA is removed") public void testEncodeDecodePublic() throws Exception { KeyFactory kf = KeyFactory.getInstance("RSA"); byte[] encoded = TestUtil.hexToBytes(ENCODED_PUBLIC_KEY); @@ -1491,9 +1483,6 @@ public class RsaKeyTest extends TestCase { * This test has mostly "defense in depth" characteristic, since applications should * never accept unauthenticated public keys. */ - @ExcludedTest( - providers = {ProviderType.BOUNCY_CASTLE}, - comment = "KeyFactory.RSA is removed") public void testModifiedPublicKeyDecoding() throws Exception { KeyFactory kf = KeyFactory.getInstance("RSA"); int cnt = 0; diff --git a/java/com/google/security/wycheproof/testcases/RsaSignatureTest.java b/java/com/google/security/wycheproof/testcases/RsaSignatureTest.java index f9e97ba..3d214fe 100644 --- a/java/com/google/security/wycheproof/testcases/RsaSignatureTest.java +++ b/java/com/google/security/wycheproof/testcases/RsaSignatureTest.java @@ -16,8 +16,6 @@ package com.google.security.wycheproof; -import com.google.security.wycheproof.WycheproofRunner.ExcludedTest; -import com.google.security.wycheproof.WycheproofRunner.ProviderType; import java.math.BigInteger; import java.security.KeyFactory; import java.security.KeyPair; @@ -1076,9 +1074,6 @@ public class RsaSignatureTest extends TestCase { + "0000", }; - @ExcludedTest( - providers = {ProviderType.BOUNCY_CASTLE}, - comment = "KeyPairGenerator.RSA is removed") public void testBasic() throws Exception { String algorithm = "SHA256WithRSA"; String hashAlgorithm = "SHA-256"; @@ -1160,9 +1155,6 @@ public class RsaSignatureTest extends TestCase { } /** SunJCE threw an OutOfMemoryError with one of the signatures. */ - @ExcludedTest( - providers = {ProviderType.BOUNCY_CASTLE}, - comment = "KeyFactory.RSA is removed") public void testVectorsAll() throws Exception { testVectors(RSA_KEY1, ALGORITHM_KEY1, SIGNATURES_KEY1); } @@ -1195,9 +1187,6 @@ public class RsaSignatureTest extends TestCase { * https://groups.google.com/a/chromium.org/forum/#!topic/chromium-reviews/Jo5S7HtEABI claims that * 7% of the responses in the Online Certificate Status Protocol (OCSP) miss the NULL parameter */ - @ExcludedTest( - providers = {ProviderType.BOUNCY_CASTLE}, - comment = "KeyFactory.RSA is removed") public void testLegacySignatures() throws Exception { RSAPublicKeySpec key = RSA_KEY1; String algorithm = ALGORITHM_KEY1; -- cgit v1.2.3