From 2f099e24f514429c5c4d7d1502e32add5ad50ac6 Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Fri, 13 Mar 2009 13:04:19 -0700 Subject: [PATCH] auto import from //branches/cupcake_rel/...@138607 --- .../tests/java/security/Identity2Test.java | 28 +- .../tests/java/security/KeyStore2Test.java | 2 - .../security/tests/java/security/ProviderTest.java | 59 ++-- .../security/tests/java/security/SecurityTest.java | 35 -- .../java/security/UnresolvedPermissionTest.java | 11 +- .../java/security/PermissionCollectionTest.java | 5 +- .../javax/security/cert/X509CertificateTest.java | 93 +++--- .../tests/java/security/SecureClassLoaderTest.java | 62 ++-- .../security/cert/CertificateFactory1Test.java | 1 - .../java/tests/security/cert/CertificateTest.java | 124 ++------ .../tests/security/cert/PKIXParametersTest.java | 10 +- .../java/tests/security/cert/TrustAnchorTest.java | 3 - .../tests/security/cert/X509CertSelectorTest.java | 351 +++++++-------------- .../tests/security/cert/X509Certificate2Test.java | 12 +- .../java/tests/security/interfaces/AllTests.java | 3 - .../interfaces/DSAKeyPairGeneratorTest.java | 1 - .../java/tests/security/interfaces/DSAKeyTest.java | 3 +- .../tests/security/interfaces/DSAParamsTest.java | 1 - .../security/interfaces/DSAPrivateKeyTest.java | 9 +- .../security/interfaces/DSAPublicKeyTest.java | 11 +- .../java/tests/security/interfaces/ECKeyTest.java | 67 ---- .../security/interfaces/ECPrivateKeyTest.java | 53 ---- .../tests/security/interfaces/ECPublicKeyTest.java | 62 ---- .../java/tests/security/interfaces/RSAKeyTest.java | 3 +- .../security/interfaces/RSAPrivateCrtKeyTest.java | 3 +- .../security/interfaces/RSAPrivateKeyTest.java | 3 +- .../security/interfaces/RSAPublicKeyTest.java | 3 +- .../test/java/tests/security/interfaces/Util.java | 6 - .../security/permissions/JavaNetSocketTest.java | 45 ++- .../security/AlgorithmParameterGeneratorTest.java | 7 +- .../targets/security/AlgorithmParametersTest.java | 7 +- .../test/java/tests/targets/security/AllTests.java | 5 + .../test/java/tests/targets/security/DHTest.java | 5 +- .../tests/targets/security/KeyFactoryTest.java | 7 +- .../targets/security/KeyPairGeneratorTest.java | 6 +- .../java/tests/targets/security/KeyStoreTest.java | 12 +- .../tests/targets/security/KeyStoreTestPKCS12.java | 20 -- .../tests/targets/security/MessageDigestTest.java | 64 +++- .../tests/targets/security/SecureRandomTest.java | 7 +- .../java/tests/targets/security/SignatureTest.java | 7 +- .../security/SignatureTestSHA224withRSA.java | 11 + .../targets/security/cert/CertPathBuilderTest.java | 7 +- .../security/UnresolvedPermissionTest.golden.ser | Bin 0 -> 1040 bytes .../{ => tests/resources}/hyts_badpem.cer | 0 .../resources}/java/security/cert/CertPath.PkiPath | Bin .../support/src/test/java/targets/Signatures.java | 15 +- 46 files changed, 450 insertions(+), 799 deletions(-) delete mode 100644 libcore/security/src/test/java/tests/security/interfaces/ECKeyTest.java delete mode 100644 libcore/security/src/test/java/tests/security/interfaces/ECPrivateKeyTest.java delete mode 100644 libcore/security/src/test/java/tests/security/interfaces/ECPublicKeyTest.java create mode 100644 libcore/security/src/test/java/tests/targets/security/SignatureTestSHA224withRSA.java create mode 100755 libcore/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.golden.ser rename libcore/security/src/test/resources/{ => tests/resources}/hyts_badpem.cer (100%) rename libcore/security/src/test/resources/{ => tests/resources}/java/security/cert/CertPath.PkiPath (100%) diff --git a/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/Identity2Test.java b/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/Identity2Test.java index 1c3e5d639..55e2fd261 100644 --- a/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/Identity2Test.java +++ b/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/Identity2Test.java @@ -32,7 +32,7 @@ import java.security.cert.X509Certificate; import org.apache.harmony.security.tests.java.security.IdentityScope2Test.IdentityScopeSubclass; -import dalvik.annotation.KnownFailure; +import dalvik.annotation.AndroidOnly; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; @@ -382,7 +382,8 @@ public class Identity2Test extends junit.framework.TestCase { args = {java.security.Certificate.class} ) }) - @KnownFailure("Test 3 disabled because the exception is never thrown.") + @AndroidOnly("Spec says: Removing unknown certificates throw an exception. " + + "The RI ignores unknown certificates.") public void test_removeCertificateLjava_security_Certificate() throws Exception { IdentitySubclass sub = new IdentitySubclass("test", new IdentityScopeSubclass()); @@ -393,21 +394,26 @@ public class Identity2Test extends junit.framework.TestCase { CertificateImpl certImpl = new CertificateImpl(cert[0]); sub.addCertificate(certImpl); - sub.removeCertificate(null); - assertEquals("Test 1: Certificate should not have been removed.", + try { + sub.removeCertificate(null); + fail("Test 1: KeyManagementException expected."); + } catch (KeyManagementException e) { + // Expected. + } + assertEquals("Test 2: Certificate should not have been removed.", 1, sub.certificates().length); sub.removeCertificate(certImpl); - assertEquals("Test 2: Certificate has not been removed.", + assertEquals("Test 3: Certificate has not been removed.", 0, sub.certificates().length); // Removing the same certificate a second time should fail. -// try { -// sub.removeCertificate(certImpl); -// fail("Test 3: KeyManagementException expected."); -// } catch (KeyManagementException e) { -// // Expected. -// } + try { + sub.removeCertificate(certImpl); + fail("Test 4: KeyManagementException expected."); + } catch (KeyManagementException e) { + // Expected. + } } diff --git a/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStore2Test.java b/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStore2Test.java index 92ad60f4e..817de3554 100644 --- a/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStore2Test.java +++ b/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStore2Test.java @@ -18,7 +18,6 @@ package org.apache.harmony.security.tests.java.security; import dalvik.annotation.AndroidOnly; -import dalvik.annotation.KnownFailure; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; @@ -562,7 +561,6 @@ public class KeyStore2Test extends junit.framework.TestCase { method = "load", args = {java.io.InputStream.class, char[].class} ) - @KnownFailure("null parameter for password is not checked and results in a NullPointerException") public void test_loadLjava_io_InputStream$C() throws Exception { // Test for method void java.security.KeyStore.load(java.io.InputStream, // char []) diff --git a/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/ProviderTest.java b/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/ProviderTest.java index fafd6e3f4..197ce79e2 100644 --- a/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/ProviderTest.java +++ b/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/ProviderTest.java @@ -111,20 +111,14 @@ public class ProviderTest extends TestCase { args = {} ) @KnownFailure("AccessController/AccessControlContext grants Permissions by default") - public final void testClear_SecurityException() { + public final void testClear_SecurityManager() { TestSecurityManager sm = new TestSecurityManager("clearProviderProperties.MyProvider"); - try { - System.setSecurityManager(sm); - p.clear(); - fail("expected SecurityException"); - } catch (SecurityException e) { - // ok - assertTrue("Provider.clear must call checkPermission with " - + "SecurityPermission clearProviderProperties.NAME", - sm.called); - } finally { - System.setSecurityManager(null); - } + System.setSecurityManager(sm); + p.clear(); + assertTrue("Provider.clear must call checkPermission with " + + "SecurityPermission clearProviderProperties.NAME", + sm.called); + System.setSecurityManager(null); } /* @@ -382,21 +376,15 @@ public class ProviderTest extends TestCase { args = {java.lang.Object.class, java.lang.Object.class} ) @KnownFailure("AccessController/AccessControlContext grants Permissions by default") - public final void testPutObjectObject_SecurityException() { + public final void testPutObjectObject_SecurityManager() { TestSecurityManager sm = new TestSecurityManager("putProviderProperty.MyProvider"); Provider p = new MyProvider(); - try { - System.setSecurityManager(sm); - p.put(new Object(), new Object()); - fail("expected SecurityPermission"); - } catch (SecurityException e) { - // ok - assertTrue("Provider put must call checkPermission " - + "SecurityPermission putProviderProperty.Name", sm.called); - } finally { - System.setSecurityManager(null); - } + System.setSecurityManager(sm); + p.put(new Object(), new Object()); + assertTrue("Provider put must call checkPermission " + + "SecurityPermission putProviderProperty.Name", sm.called); + System.setSecurityManager(null); } /* @@ -438,21 +426,15 @@ public class ProviderTest extends TestCase { args = {java.lang.Object.class} ) @KnownFailure("AccessController/AccessControlContext grants Permissions by default") - public final void testRemoveObject_SecurityException() { + public final void testRemoveObject_SecurityManager() { TestSecurityManager sm = new TestSecurityManager( "removeProviderProperty.MyProvider"); - try { - System.setSecurityManager(sm); - p.remove(new Object()); - fail("expected SecurityException"); - } catch (SecurityException e) { - // ok - assertTrue("Provider.remove must check permission " - + "SecurityPermission removeProviderProperty.NAME", - sm.called); - } finally { - System.setSecurityManager(null); - } + System.setSecurityManager(sm); + p.remove(new Object()); + assertTrue("Provider.remove must check permission " + + "SecurityPermission removeProviderProperty.NAME", + sm.called); + System.setSecurityManager(null); } @TestTargetNew( @@ -801,7 +783,6 @@ public class ProviderTest extends TestCase { if (permission instanceof SecurityPermission) { if (permissionName.equals(permission.getName())) { called = true; - super.checkPermission(permission); } } } diff --git a/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/SecurityTest.java b/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/SecurityTest.java index 0a015415f..d2edfd0b2 100644 --- a/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/SecurityTest.java +++ b/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/SecurityTest.java @@ -22,7 +22,6 @@ package org.apache.harmony.security.tests.java.security; -import dalvik.annotation.BrokenTest; import dalvik.annotation.KnownFailure; import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; @@ -30,18 +29,13 @@ import dalvik.annotation.TestTargets; import dalvik.annotation.TestLevel; import java.security.InvalidParameterException; -import java.security.KeyFactory; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; import java.security.Provider; import java.security.Security; -import java.security.Signature; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Set; -import org.apache.harmony.security.tests.support.TestKeyPair; import junit.framework.TestCase; @@ -51,35 +45,6 @@ import junit.framework.TestCase; */ public class SecurityTest extends TestCase { - @TestTargetNew( - level = TestLevel.ADDITIONAL, - notes = "Methods from java.security.Security class are not tested", - method = "!", - args = {} - ) - @BrokenTest("empty test") - public final void testMixed() { - - TestKeyPair tkp = null; - try { - tkp = new TestKeyPair("DSA"); - } catch (NoSuchAlgorithmException e1) { - e1.printStackTrace(); - return; - } - - try { - MessageDigest.getInstance("SHA-1"); - KeyFactory.getInstance("DSA"); - Signature ss = Signature.getInstance("DSA"); - ss.initSign(tkp.getPrivate()); - Signature.getInstance("aaaaaaaaaaaa"); - } catch (Exception e) { - // ignore - } - - } - /** * @tests java.security.Security#insertProviderAt(Provider, int) */ diff --git a/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.java b/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.java index 3453e1087..ce02e9dd9 100644 --- a/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.java +++ b/libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.java @@ -19,7 +19,6 @@ package org.apache.harmony.security.tests.java.security; import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargets; import dalvik.annotation.TestLevel; import java.io.Serializable; @@ -138,11 +137,11 @@ public class UnresolvedPermissionTest extends TestCase { @TestTargetNew( level = TestLevel.COMPLETE, - notes = "missing serialization golden file", + notes = "", method = "!SerializationGolden", args = {} ) - public void _testSerialization_Compatibility() throws Exception { + public void testSerialization_Compatibility() throws Exception { UnresolvedPermission up = new UnresolvedPermission( "java.security.SecurityPermission", "a.b.c", "actions", null); assertEquals("java.security.SecurityPermission", up.getUnresolvedType()); @@ -156,8 +155,10 @@ public class UnresolvedPermissionTest extends TestCase { assertEquals("java.security.SecurityPermission", deserializedUp .getUnresolvedType()); assertEquals("a.b.c", deserializedUp.getUnresolvedName()); - assertEquals("actions", deserializedUp.getUnresolvedActions()); - assertNull(deserializedUp.getUnresolvedCerts()); + assertEquals("action", deserializedUp.getUnresolvedActions()); + Certificate[] certs = deserializedUp.getUnresolvedCerts(); + assertNotNull(certs); + assertEquals(1, certs.length); } }); } diff --git a/libcore/security/src/test/java/tests/api/java/security/PermissionCollectionTest.java b/libcore/security/src/test/java/tests/api/java/security/PermissionCollectionTest.java index 4d367ef8b..c63fe503d 100644 --- a/libcore/security/src/test/java/tests/api/java/security/PermissionCollectionTest.java +++ b/libcore/security/src/test/java/tests/api/java/security/PermissionCollectionTest.java @@ -19,7 +19,6 @@ package tests.api.java.security; import dalvik.annotation.BrokenTest; import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetNew; @@ -66,8 +65,8 @@ public class PermissionCollectionTest extends junit.framework.TestCase { method = "implies", args = {java.security.Permission.class} ) - @BrokenTest("Method implies is not called in this test") - public void _test_impliesLjava_security_Permission() throws Exception{ + @BrokenTest("Android doesn't support protection domains. NPE at first Line") + public void test_impliesLjava_security_Permission() throws Exception{ // Look for the tests classpath URL classURL = this.getClass().getProtectionDomain().getCodeSource() diff --git a/libcore/security/src/test/java/tests/api/javax/security/cert/X509CertificateTest.java b/libcore/security/src/test/java/tests/api/javax/security/cert/X509CertificateTest.java index dac06332c..ba8998d28 100644 --- a/libcore/security/src/test/java/tests/api/javax/security/cert/X509CertificateTest.java +++ b/libcore/security/src/test/java/tests/api/javax/security/cert/X509CertificateTest.java @@ -22,7 +22,7 @@ package tests.api.javax.security.cert; -import dalvik.annotation.KnownFailure; +import dalvik.annotation.BrokenTest; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; @@ -170,26 +170,9 @@ public class X509CertificateTest extends TestCase { method = "X509Certificate", args = {} ) - public void testConstructor() throws CertificateEncodingException { - //Direct constructor + public void testConstructor() { + //Direct constructor, check if it throws an exception X509Certificate cert = new MyCertificate(); - assertNotNull(cert); - assertNull("Principal should be null", cert.getIssuerDN()); - assertEquals("Wrong end date", new Date(), cert.getNotAfter()); - assertEquals("Wrong start date", new Date(), cert.getNotBefore()); - assertNull("Public key should be null", cert.getPublicKey()); - assertEquals("Serial number should be 0", BigInteger.valueOf(0), cert.getSerialNumber()); - assertEquals("Wrong algorithm name", "algName", cert.getSigAlgName()); - assertEquals("Wrong algorithm OID", "algOID", cert.getSigAlgOID()); - assertNull("Signature algorithm parameters should be null", cert.getSigAlgParams()); - assertNull("Subject should be null", cert.getSubjectDN()); - assertEquals("Version should be 0", 0, cert.getVersion()); - - try { - X509Certificate.getInstance(new byte[]{(byte) 1 }); - } catch (CertificateException e) { - //ok - } } /** @@ -264,6 +247,12 @@ public class X509CertificateTest extends TestCase { assertNotNull(c); assertTrue(Arrays.equals(c.getEncoded(),cert.getEncoded() )); } + + try { + X509Certificate.getInstance(new byte[]{(byte) 1 }); + } catch (CertificateException e) { + //ok + } // Regression for HARMONY-756 try { @@ -583,27 +572,27 @@ public class X509CertificateTest extends TestCase { @Override public Date getNotAfter() { - return new Date(); + return null; } @Override public Date getNotBefore() { - return new Date(); + return null; } @Override public BigInteger getSerialNumber() { - return BigInteger.valueOf(0); + return null; } @Override public String getSigAlgName() { - return "algName"; + return null; } @Override public String getSigAlgOID() { - return "algOID"; + return null; } @Override @@ -623,8 +612,7 @@ public class X509CertificateTest extends TestCase { @Override public byte[] getEncoded() throws CertificateEncodingException { - return new byte[] { (byte) 1, (byte) 2, - (byte) 3, (byte) 4, (byte) 5 }; + return null; } @Override @@ -634,7 +622,7 @@ public class X509CertificateTest extends TestCase { @Override public String toString() { - return "certificate"; + return null; } @Override @@ -770,7 +758,6 @@ public class X509CertificateTest extends TestCase { method = "verify", args = {java.security.PublicKey.class} ) - @KnownFailure("there is an error with the self signed certificate") public void testVerifyPublicKey() throws InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException, CertificateException { @@ -816,37 +803,31 @@ public class X509CertificateTest extends TestCase { // ok } - MyModifiablePublicKey changedAlgo = new MyModifiablePublicKey(k); - changedAlgo.setAlgorithm("MD5withBla"); - - try { - javaxCert.verify(changedAlgo); - fail("Exception expected"); - } catch (SignatureException e) { - // ok - } - + // following test doesn't work because the algorithm is derived from + // somewhere else. + + // MyModifiablePublicKey changedAlgo = new MyModifiablePublicKey(k); + // changedAlgo.setAlgorithm("MD5withBla"); + + // try { + // javaxCert.verify(changedAlgo); + // fail("Exception expected"); + // } catch (SignatureException e) { + // // ok + // } - /* + // Security.removeProvider(mySSProvider.getName()); - Security.removeProvider(mySSProvider.getName()); + // try { + // javaxSSCert.verify(javaxSSCert.getPublicKey()); + // } catch (NoSuchProviderException e) { + // // ok + // } - try { - javaxSSCert.verify(javaxSSCert.getPublicKey()); - } catch (NoSuchProviderException e) { - // ok - } - - Security.addProvider(mySSProvider); - - //Test NoSuchAlgorithmException - - + // Security.addProvider(mySSProvider); // must always evaluate true for self signed - javaxSSCert.verify(javaxSSCert.getPublicKey()); - - */ + // javaxSSCert.verify(javaxSSCert.getPublicKey()); } /** @@ -866,7 +847,7 @@ public class X509CertificateTest extends TestCase { method = "verify", args = {java.security.PublicKey.class, java.lang.String.class} ) - @KnownFailure("there is an error with the self signed certificate") + @BrokenTest("there is an error with the self signed certificate") public void testVerifyPublicKeyString() throws InvalidKeyException, java.security.cert.CertificateException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException, IOException, diff --git a/libcore/security/src/test/java/tests/java/security/SecureClassLoaderTest.java b/libcore/security/src/test/java/tests/java/security/SecureClassLoaderTest.java index 7a6353c1b..1dfaae605 100644 --- a/libcore/security/src/test/java/tests/java/security/SecureClassLoaderTest.java +++ b/libcore/security/src/test/java/tests/java/security/SecureClassLoaderTest.java @@ -22,6 +22,7 @@ package tests.java.security; +import dalvik.annotation.KnownFailure; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; @@ -247,6 +248,7 @@ public class SecureClassLoaderTest extends TestCase { method = "SecureClassLoader", args = {java.lang.ClassLoader.class} ) + @KnownFailure("Android doesn't allow null parent.") public void testSecureClassLoaderClassLoader() throws Exception { URL[] urls = new URL[] { new URL("http://localhost") }; URLClassLoader ucl = URLClassLoader.newInstance(urls); @@ -307,36 +309,36 @@ public class SecureClassLoaderTest extends TestCase { ldr.getPerms(cs); } - /** - * Tests defineClass(String, byte[], int, int, CodeSource) - */ - @TestTargetNew( - level = TestLevel.NOT_FEASIBLE, - notes = "ClassFormatError, IndexOutOfBoundsException, SecurityException checking missed", - method = "defineClass", - args = {java.lang.String.class, byte[].class, int.class, int.class, java.security.CodeSource.class} - ) - public void _testDefineClassStringbyteArrayintintCodeSource() { - MyClassLoader ldr = new MyClassLoader(); - Class klass = ldr.define(null, klassData, 0, klassData.length, null); - assertEquals(klass.getName(), klassName); - } - - /** - * Tests defineClass(String, ByteBuffer, CodeSource) - */ - @TestTargetNew( - level = TestLevel.NOT_FEASIBLE, - notes = "ClassFormatError, SecurityException checking missed", - method = "defineClass", - args = {java.lang.String.class, java.nio.ByteBuffer.class, java.security.CodeSource.class} - ) - public void _testDefineClassStringByteBufferCodeSource() { - MyClassLoader ldr = new MyClassLoader(); - ByteBuffer bbuf = ByteBuffer.wrap(klassData); - Class klass = ldr.define(null, bbuf, null); - assertEquals(klass.getName(), klassName); - } +// /** +// * Tests defineClass(String, byte[], int, int, CodeSource) +// */ +// @TestTargetNew( +// level = TestLevel.NOT_FEASIBLE, +// notes = "ClassFormatError, IndexOutOfBoundsException, SecurityException checking missed", +// method = "defineClass", +// args = {java.lang.String.class, byte[].class, int.class, int.class, java.security.CodeSource.class} +// ) +// public void _testDefineClassStringbyteArrayintintCodeSource() { +// MyClassLoader ldr = new MyClassLoader(); +// Class klass = ldr.define(null, klassData, 0, klassData.length, null); +// assertEquals(klass.getName(), klassName); +// } +// +// /** +// * Tests defineClass(String, ByteBuffer, CodeSource) +// */ +// @TestTargetNew( +// level = TestLevel.NOT_FEASIBLE, +// notes = "ClassFormatError, SecurityException checking missed", +// method = "defineClass", +// args = {java.lang.String.class, java.nio.ByteBuffer.class, java.security.CodeSource.class} +// ) +// public void _testDefineClassStringByteBufferCodeSource() { +// MyClassLoader ldr = new MyClassLoader(); +// ByteBuffer bbuf = ByteBuffer.wrap(klassData); +// Class klass = ldr.define(null, bbuf, null); +// assertEquals(klass.getName(), klassName); +// } class MyClassLoader extends SecureClassLoader { diff --git a/libcore/security/src/test/java/tests/security/cert/CertificateFactory1Test.java b/libcore/security/src/test/java/tests/security/cert/CertificateFactory1Test.java index b64e501e0..42677eb83 100644 --- a/libcore/security/src/test/java/tests/security/cert/CertificateFactory1Test.java +++ b/libcore/security/src/test/java/tests/security/cert/CertificateFactory1Test.java @@ -530,7 +530,6 @@ public class CertificateFactory1Test extends TestCase { args = {java.io.InputStream.class} ) }) - // Test passed on RI public void testCertificateFactory11() throws IOException { if (!X509Support) { fail(NotSupportMsg); diff --git a/libcore/security/src/test/java/tests/security/cert/CertificateTest.java b/libcore/security/src/test/java/tests/security/cert/CertificateTest.java index c56c0c0b8..2d0f7e838 100644 --- a/libcore/security/src/test/java/tests/security/cert/CertificateTest.java +++ b/libcore/security/src/test/java/tests/security/cert/CertificateTest.java @@ -25,7 +25,6 @@ package tests.security.cert; import dalvik.annotation.AndroidOnly; -import dalvik.annotation.BrokenTest; import dalvik.annotation.KnownFailure; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetNew; @@ -35,7 +34,9 @@ import dalvik.annotation.TestTargets; import junit.framework.TestCase; import java.io.ByteArrayInputStream; +import java.io.IOException; import java.io.ObjectStreamException; +import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; @@ -43,12 +44,10 @@ import java.security.Provider; import java.security.PublicKey; import java.security.Security; import java.security.SignatureException; -import java.security.cert.CertPath; import java.security.cert.Certificate; import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; import java.util.Arrays; import org.apache.harmony.security.tests.support.cert.MyCertificate; @@ -56,9 +55,6 @@ import org.apache.harmony.security.tests.support.cert.MyFailingCertificate; import org.apache.harmony.security.tests.support.cert.TestUtils; import org.apache.harmony.testframework.serialization.SerializationTest; -//import tests.api.javax.security.cert.X509CertificateTest.MyModifiablePublicKey; - - /** * Tests for Certificate fields and methods * @@ -259,7 +255,7 @@ public class CertificateTest extends TestCase { assertTrue(Arrays.equals(TestUtils.rootCert.getBytes(),cert.getEncoded())); - byte[] b = rootCert.getBytes(); + byte[] b = TestUtils.rootCert.getBytes(); b[4] = (byte) 200; @@ -381,72 +377,6 @@ public class CertificateTest extends TestCase { } } - /** - * Certificate: - Data: - Version: 3 (0x2) - Serial Number: 0 (0x0) - Signature Algorithm: sha1WithRSAEncryption - Issuer: C=AN, ST=Android, O=Android, OU=Android, CN=Android/emailAddress=android - Validity - Not Before: Dec 9 16:35:30 2008 GMT - Not After : Dec 9 16:35:30 2011 GMT - Subject: C=AN, ST=Android, O=Android, OU=Android, CN=Android/emailAddress=android - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - RSA Public Key: (1024 bit) - Modulus (1024 bit): - 00:c5:fb:5e:68:37:82:1d:58:ed:cb:31:8c:08:7f: - 51:31:4c:68:40:8c:4d:07:a1:0e:18:36:02:6b:89: - 92:c1:cf:88:1e:cf:00:22:00:8c:37:e8:6a:76:94: - 71:53:81:78:e1:48:94:fa:16:61:93:eb:a0:ee:62: - 9d:6a:d2:2c:b8:77:9d:c9:36:d5:d9:1c:eb:26:3c: - 43:66:4d:7b:1c:1d:c7:a1:37:66:e2:84:54:d3:ed: - 21:dd:01:1c:ec:9b:0c:1e:35:e9:37:15:9d:2b:78: - a8:3b:11:3a:ee:c2:de:55:44:4c:bd:40:8d:e5:52: - b0:fc:53:33:73:4a:e5:d0:df - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Subject Key Identifier: - 4B:E3:22:14:AD:0A:14:46:B7:52:31:8B:AB:9E:5A:62:F3:98:37:80 - X509v3 Authority Key Identifier: - keyid:4B:E3:22:14:AD:0A:14:46:B7:52:31:8B:AB:9E:5A:62:F3:98:37:80 - DirName:/C=AN/ST=Android/O=Android/OU=Android/CN=Android/emailAddress=android - serial:00 - - X509v3 Basic Constraints: - CA:TRUE - Signature Algorithm: sha1WithRSAEncryption - 72:4f:12:8a:4e:61:b2:9a:ba:58:17:0b:55:96:f5:66:1c:a8: - ba:d1:0f:8b:9b:2d:ab:a8:00:ac:7f:99:7d:f6:0f:d7:85:eb: - 75:4b:e5:42:37:71:46:b1:4a:b0:1b:17:e4:f9:7c:9f:bd:20: - 75:35:9f:27:8e:07:95:e8:34:bd:ab:e4:10:5f:a3:7b:4c:56: - 69:d4:d0:f1:e9:74:15:2d:7f:77:f0:38:77:eb:8a:99:f3:a9: - 88:f0:63:58:07:b9:5a:61:f8:ff:11:e7:06:a1:d1:f8:85:fb: - 99:1c:f5:cb:77:86:36:cd:43:37:99:09:c2:9a:d8:f2:28:05: - 06:0c - - */ - public static final String rootCert = "-----BEGIN CERTIFICATE-----\n" + - "MIIDGzCCAoSgAwIBAgIBADANBgkqhkiG9w0BAQUFADBtMQswCQYDVQQGEwJBTjEQ\n" + - "MA4GA1UECBMHQW5kcm9pZDEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5k\n" + - "cm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEWMBQGCSqGSIb3DQEJARYHYW5kcm9pZDAe\n" + - "Fw0wODEyMDkxNjM1MzBaFw0xMTEyMDkxNjM1MzBaMG0xCzAJBgNVBAYTAkFOMRAw\n" + - "DgYDVQQIEwdBbmRyb2lkMRAwDgYDVQQKEwdBbmRyb2lkMRAwDgYDVQQLEwdBbmRy\n" + - "b2lkMRAwDgYDVQQDEwdBbmRyb2lkMRYwFAYJKoZIhvcNAQkBFgdhbmRyb2lkMIGf\n" + - "MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDF+15oN4IdWO3LMYwIf1ExTGhAjE0H\n" + - "oQ4YNgJriZLBz4gezwAiAIw36Gp2lHFTgXjhSJT6FmGT66DuYp1q0iy4d53JNtXZ\n" + - "HOsmPENmTXscHcehN2bihFTT7SHdARzsmwweNek3FZ0reKg7ETruwt5VREy9QI3l\n" + - "UrD8UzNzSuXQ3wIDAQABo4HKMIHHMB0GA1UdDgQWBBRL4yIUrQoURrdSMYurnlpi\n" + - "85g3gDCBlwYDVR0jBIGPMIGMgBRL4yIUrQoURrdSMYurnlpi85g3gKFxpG8wbTEL\n" + - "MAkGA1UEBhMCQU4xEDAOBgNVBAgTB0FuZHJvaWQxEDAOBgNVBAoTB0FuZHJvaWQx\n" + - "EDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWQxFjAUBgkqhkiG9w0B\n" + - "CQEWB2FuZHJvaWSCAQAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQBy\n" + - "TxKKTmGymrpYFwtVlvVmHKi60Q+Lmy2rqACsf5l99g/Xhet1S+VCN3FGsUqwGxfk\n" + - "+XyfvSB1NZ8njgeV6DS9q+QQX6N7TFZp1NDx6XQVLX938Dh364qZ86mI8GNYB7la\n" + - "Yfj/EecGodH4hfuZHPXLd4Y2zUM3mQnCmtjyKAUGDA==\n" + - "-----END CERTIFICATE-----"; - public class MyModifiablePublicKey implements PublicKey { private PublicKey key; @@ -540,9 +470,6 @@ public class MyModifiablePublicKey implements PublicKey { ) @AndroidOnly("Gets security providers with specific signature algorithm: " + "Security.getProviders(\"Signature.sha1WithRSAEncryption\")") - @KnownFailure("ClassCastException is thrown by " + - "Certificate.verify(PublicKey pk) method instead of " + - "InvalidKeyException.") public final void testVerifyPublicKeyString2() throws InvalidKeyException, CertificateException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException { @@ -558,15 +485,21 @@ public class MyModifiablePublicKey implements PublicKey { // ok } - Security.removeProvider(wrongProvider.getName()); - - try { - cert.verify(cert.getPublicKey(), wrongProvider.getName()); - } catch (NoSuchAlgorithmException e) { - // ok - } + // This test has side effects affecting all other tests running later + // on in the same vm instance. Maybe a better way would be to first add + // a new provider, test if it works, then remove it and test if the + // exception is thrown. + // + // Security.removeProvider(wrongProvider.getName()); + // + // try { + // cert.verify(cert.getPublicKey(), wrongProvider.getName()); + // } catch (NoSuchAlgorithmException e) { + // // ok + // } + // + // Security.insertProviderAt(wrongProvider, oldPosition); - Security.addProvider(wrongProvider); /* PublicKey k = cert.getPublicKey(); MyModifiablePublicKey tamperedKey = new MyModifiablePublicKey(k); @@ -594,22 +527,20 @@ public class MyModifiablePublicKey implements PublicKey { * @throws NoSuchAlgorithmException * @throws NoSuchProviderException * @throws SignatureException + * @throws IOException + * @throws InvalidAlgorithmParameterException */ @TestTargetNew( level = TestLevel.SUFFICIENT, - notes = "Test fails: ClassCastException when InvalidKeyException is expected." + - "", + notes = "Can't test exception for cases where the algorithm is unknown", method = "verify", args = {java.security.PublicKey.class} ) @AndroidOnly("Gets security providers with specific signature algorithm: " + "Security.getProviders(\"Signature.sha1WithRSAEncryption\")") - @KnownFailure("ClassCastException is thrown by " + - "Certificate.verify(PublicKey pk) method instead of " + - "InvalidKeyException. ") public final void testVerifyPublicKey2() throws InvalidKeyException, CertificateException, NoSuchAlgorithmException, - NoSuchProviderException, SignatureException { + NoSuchProviderException, SignatureException, InvalidAlgorithmParameterException, IOException { Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding); c1.verify(null); @@ -634,18 +565,7 @@ public class MyModifiablePublicKey implements PublicKey { fail("Exception expected"); } catch (Exception e) { // ok - } - - MyModifiablePublicKey changedAlgo = new MyModifiablePublicKey(k); - changedAlgo.setAlgorithm("MD5withBla"); - - try { - cert.verify(changedAlgo); - fail("Exception expected"); - } catch (SignatureException e) { - // ok - } - + } } /** diff --git a/libcore/security/src/test/java/tests/security/cert/PKIXParametersTest.java b/libcore/security/src/test/java/tests/security/cert/PKIXParametersTest.java index efe46ed6c..394e08edb 100644 --- a/libcore/security/src/test/java/tests/security/cert/PKIXParametersTest.java +++ b/libcore/security/src/test/java/tests/security/cert/PKIXParametersTest.java @@ -22,7 +22,7 @@ package tests.security.cert; -import dalvik.annotation.KnownFailure; +import dalvik.annotation.AndroidOnly; import dalvik.annotation.TestTargets; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetNew; @@ -1413,9 +1413,8 @@ public class PKIXParametersTest extends TestCase { method = "setDate", args = {java.util.Date.class} ) - @KnownFailure("p.setDate(null) does not reset to current"+ - " time. RI fails at last assertion (time reset to 2007). Our" + - " fails at assertNotNull(p.getDate)") + @AndroidOnly("On the RI p.setDate(null) does not reset the date to null " + + "as specified.") public final void test_setDateLjava_util_Date() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); assertNotNull("could not create test TrustAnchor set", taSet); @@ -1443,8 +1442,7 @@ public class PKIXParametersTest extends TestCase { p = new PKIXParameters(taSet); p.setDate(new Date(555L)); p.setDate(null); // reset 'date' back to current time - assertNotNull(p.getDate()); - //assertEquals(Calendar.getInstance().getTime(), p.getDate()); + assertNull(p.getDate()); } /** diff --git a/libcore/security/src/test/java/tests/security/cert/TrustAnchorTest.java b/libcore/security/src/test/java/tests/security/cert/TrustAnchorTest.java index 308a9f030..93d596f5d 100644 --- a/libcore/security/src/test/java/tests/security/cert/TrustAnchorTest.java +++ b/libcore/security/src/test/java/tests/security/cert/TrustAnchorTest.java @@ -22,7 +22,6 @@ package tests.security.cert; -import dalvik.annotation.KnownFailure; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; @@ -645,8 +644,6 @@ public class TrustAnchorTest extends TestCase { method = "toString", args = {} ) - @KnownFailure("java.lang.RuntimeException is thrown during " + - "TrustAnchor.toString() method.") public final void testToString() throws Exception { PublicKey pk = new TestKeyPair(keyAlg).getPublic(); TrustAnchor ta1 = new TrustAnchor(validCaNameRfc2253, pk, diff --git a/libcore/security/src/test/java/tests/security/cert/X509CertSelectorTest.java b/libcore/security/src/test/java/tests/security/cert/X509CertSelectorTest.java index 1bbc35f99..3199ffa39 100644 --- a/libcore/security/src/test/java/tests/security/cert/X509CertSelectorTest.java +++ b/libcore/security/src/test/java/tests/security/cert/X509CertSelectorTest.java @@ -17,9 +17,6 @@ package tests.security.cert; -import dalvik.annotation.BrokenTest; - -import dalvik.annotation.KnownFailure; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargetClass; @@ -39,18 +36,15 @@ import java.security.SignatureException; import java.security.cert.CertPath; import java.security.cert.CertPathBuilder; import java.security.cert.CertPathBuilderException; -import java.security.cert.CertStore; import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateException; import java.security.cert.CertificateExpiredException; import java.security.cert.CertificateFactory; import java.security.cert.CertificateNotYetValidException; import java.security.cert.CertificateParsingException; -import java.security.cert.CollectionCertStoreParameters; import java.security.cert.PKIXBuilderParameters; import java.security.cert.PKIXCertPathBuilderResult; import java.security.cert.TrustAnchor; -import java.security.cert.X509CRL; import java.security.cert.X509CertSelector; import java.security.cert.X509Certificate; import java.util.ArrayList; @@ -67,7 +61,6 @@ import java.util.Set; import javax.security.auth.x500.X500Principal; -import org.apache.harmony.security.provider.cert.X509CertImpl; import org.apache.harmony.security.tests.support.cert.MyCRL; import org.apache.harmony.security.tests.support.cert.TestUtils; import org.apache.harmony.security.tests.support.TestKeyPair; @@ -81,8 +74,6 @@ import org.apache.harmony.security.x501.Name; import org.apache.harmony.security.x509.CertificatePolicies; import org.apache.harmony.security.x509.GeneralName; import org.apache.harmony.security.x509.GeneralNames; -import org.apache.harmony.security.x509.GeneralSubtree; -import org.apache.harmony.security.x509.GeneralSubtrees; import org.apache.harmony.security.x509.NameConstraints; import org.apache.harmony.security.x509.ORAddress; import org.apache.harmony.security.x509.OtherName; @@ -94,6 +85,47 @@ import org.apache.harmony.security.x509.PrivateKeyUsagePeriod; */ @TestTargetClass(X509CertSelector.class) public class X509CertSelectorTest extends TestCase { + + byte[][] constraintBytes = new byte[][] { + { + 48, 34, -96, 15, 48, 13, -127, 8, 56, 50, 50, 46, 78, + 97, 109, 101, -128, 1, 0, -95, 15, 48, 13, -127, 8, 56, + 50, 50, 46, 78, 97, 109, 101, -128, 1, 0}, + { + 48, 42, -96, 19, 48, 17, -127, 12, 114, 102, 99, 64, + 56, 50, 50, 46, 78, 97, 109, 101, -128, 1, 0, -95, 19, + 48, 17, -127, 12, 114, 102, 99, 64, 56, 50, 50, 46, 78, + 97, 109, 101, -128, 1, 0}, + { + 48, 34, -96, 15, 48, 13, -126, 8, 78, 97, 109, 101, 46, + 111, 114, 103, -128, 1, 0, -95, 15, 48, 13, -126, 8, + 78, 97, 109, 101, 46, 111, 114, 103, -128, 1, 0}, + { + 48, 42, -96, 19, 48, 17, -126, 12, 100, 78, 83, 46, 78, + 97, 109, 101, 46, 111, 114, 103, -128, 1, 0, -95, 19, + 48, 17, -126, 12, 100, 78, 83, 46, 78, 97, 109, 101, + 46, 111, 114, 103, -128, 1, 0}, + { + 48, 54, -96, 25, 48, 23, -122, 18, 104, 116, 116, 112, + 58, 47, 47, 82, 101, 115, 111, 117, 114, 99, 101, 46, + 73, 100, -128, 1, 0, -95, 25, 48, 23, -122, 18, 104, + 116, 116, 112, 58, 47, 47, 82, 101, 115, 111, 117, 114, + 99, 101, 46, 73, 100, -128, 1, 0}, + { + 48, 70, -96, 33, 48, 31, -122, 26, 104, 116, 116, 112, + 58, 47, 47, 117, 110, 105, 102, 111, 114, 109, 46, 82, + 101, 115, 111, 117, 114, 99, 101, 46, 73, 100, -128, 1, + 0, -95, 33, 48, 31, -122, 26, 104, 116, 116, 112, 58, + 47, 47, 117, 110, 105, 102, 111, 114, 109, 46, 82, 101, + 115, 111, 117, 114, 99, 101, 46, 73, 100, -128, 1, 0}, + { + 48, 26, -96, 11, 48, 9, -121, 4, 1, 1, 1, 1, -128, 1, + 0, -95, 11, 48, 9, -121, 4, 1, 1, 1, 1, -128, 1, 0}, + { + 48, 50, -96, 23, 48, 21, -121, 16, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, -128, 1, 0, -95, 23, 48, 21, + -121, 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, -128, 1, 0}}; /** * @tests java.security.cert.X509CertSelector#addSubjectAlternativeName(int, byte[]) @@ -543,29 +575,38 @@ public class X509CertSelectorTest extends TestCase { args = {} ) public void test_getNameConstraints() throws IOException { - GeneralName[] name_constraints = new GeneralName[] { - new GeneralName(1, "822.Name"), - new GeneralName(1, "rfc@822.Name"), - new GeneralName(2, "Name.org"), - new GeneralName(2, "dNS.Name.org"), - - new GeneralName(6, "http://Resource.Id"), - new GeneralName(6, "http://uniform.Resource.Id"), - new GeneralName(7, "1.1.1.1"), - new GeneralName(new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 }), }; +// Used to generate following byte array +// GeneralName[] name_constraints = new GeneralName[] { +// new GeneralName(1, "822.Name"), +// new GeneralName(1, "rfc@822.Name"), +// new GeneralName(2, "Name.org"), +// new GeneralName(2, "dNS.Name.org"), +// +// new GeneralName(6, "http://Resource.Id"), +// new GeneralName(6, "http://uniform.Resource.Id"), +// new GeneralName(7, "1.1.1.1"), +// +// new GeneralName(new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1 }), }; +// +// constraintBytes = new byte[name_constraints.length][]; +// +// for (int i = 0; i < name_constraints.length; i++) { +// GeneralSubtree subtree = new GeneralSubtree(name_constraints[i]); +// GeneralSubtrees subtrees = new GeneralSubtrees(); +// subtrees.addSubtree(subtree); +// NameConstraints constraints = new NameConstraints(subtrees, +// subtrees); +// constraintBytes[i] = constraints.getEncoded(); +// } +// System.out.println("XXX"+Arrays.deepToString(constraintBytes)+"XXX"); X509CertSelector selector = new X509CertSelector(); - for (int i = 0; i < name_constraints.length; i++) { - GeneralSubtree subtree = new GeneralSubtree(name_constraints[i]); - GeneralSubtrees subtrees = new GeneralSubtrees(); - subtrees.addSubtree(subtree); - NameConstraints constraints = new NameConstraints(subtrees, - subtrees); - selector.setNameConstraints(constraints.getEncoded()); - assertTrue(Arrays.equals(constraints.getEncoded(), selector + for (int i = 0; i < constraintBytes.length; i++) { + selector.setNameConstraints(constraintBytes[i]); + assertTrue(Arrays.equals(constraintBytes[i], selector .getNameConstraints())); } } @@ -1354,29 +1395,31 @@ public class X509CertSelectorTest extends TestCase { args = {byte[].class} ) public void test_setNameConstraintsLB$() throws IOException { - GeneralName[] name_constraints = new GeneralName[] { - new GeneralName(1, "822.Name"), - new GeneralName(1, "rfc@822.Name"), - new GeneralName(2, "Name.org"), - new GeneralName(2, "dNS.Name.org"), - - new GeneralName(6, "http://Resource.Id"), - new GeneralName(6, "http://uniform.Resource.Id"), - new GeneralName(7, "1.1.1.1"), - - new GeneralName(new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 }), }; - +// GeneralName[] name_constraints = new GeneralName[] { +// new GeneralName(1, "822.Name"), +// new GeneralName(1, "rfc@822.Name"), +// new GeneralName(2, "Name.org"), +// new GeneralName(2, "dNS.Name.org"), +// +// new GeneralName(6, "http://Resource.Id"), +// new GeneralName(6, "http://uniform.Resource.Id"), +// new GeneralName(7, "1.1.1.1"), +// +// new GeneralName(new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1 }), }; +// +// for (int i = 0; i < name_constraints.length; i++) { +// GeneralSubtree subtree = new GeneralSubtree(name_constraints[i]); +// GeneralSubtrees subtrees = new GeneralSubtrees(); +// subtrees.addSubtree(subtree); +// NameConstraints constraints = new NameConstraints(subtrees, +// subtrees); +// } X509CertSelector selector = new X509CertSelector(); - for (int i = 0; i < name_constraints.length; i++) { - GeneralSubtree subtree = new GeneralSubtree(name_constraints[i]); - GeneralSubtrees subtrees = new GeneralSubtrees(); - subtrees.addSubtree(subtree); - NameConstraints constraints = new NameConstraints(subtrees, - subtrees); - selector.setNameConstraints(constraints.getEncoded()); - assertTrue(Arrays.equals(constraints.getEncoded(), selector + for (int i = 0; i < constraintBytes.length; i++) { + selector.setNameConstraints(constraintBytes[i]); + assertTrue(Arrays.equals(constraintBytes[i], selector .getNameConstraints())); } } @@ -2348,183 +2391,12 @@ public class X509CertSelectorTest extends TestCase { private CertPathBuilder builder; - /** - * Certificate: - Data: - Version: 3 (0x2) - Serial Number: 0 (0x0) - Signature Algorithm: sha1WithRSAEncryption - Issuer: C=AN, ST=Android, O=Android, OU=Android, CN=Android/emailAddress=android - Validity - Not Before: Dec 9 16:35:30 2008 GMT - Not After : Dec 9 16:35:30 2011 GMT - Subject: C=AN, ST=Android, O=Android, OU=Android, CN=Android/emailAddress=android - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - RSA Public Key: (1024 bit) - Modulus (1024 bit): - 00:c5:fb:5e:68:37:82:1d:58:ed:cb:31:8c:08:7f: - 51:31:4c:68:40:8c:4d:07:a1:0e:18:36:02:6b:89: - 92:c1:cf:88:1e:cf:00:22:00:8c:37:e8:6a:76:94: - 71:53:81:78:e1:48:94:fa:16:61:93:eb:a0:ee:62: - 9d:6a:d2:2c:b8:77:9d:c9:36:d5:d9:1c:eb:26:3c: - 43:66:4d:7b:1c:1d:c7:a1:37:66:e2:84:54:d3:ed: - 21:dd:01:1c:ec:9b:0c:1e:35:e9:37:15:9d:2b:78: - a8:3b:11:3a:ee:c2:de:55:44:4c:bd:40:8d:e5:52: - b0:fc:53:33:73:4a:e5:d0:df - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Subject Key Identifier: - 4B:E3:22:14:AD:0A:14:46:B7:52:31:8B:AB:9E:5A:62:F3:98:37:80 - X509v3 Authority Key Identifier: - keyid:4B:E3:22:14:AD:0A:14:46:B7:52:31:8B:AB:9E:5A:62:F3:98:37:80 - DirName:/C=AN/ST=Android/O=Android/OU=Android/CN=Android/emailAddress=android - serial:00 - - X509v3 Basic Constraints: - CA:TRUE - Signature Algorithm: sha1WithRSAEncryption - 72:4f:12:8a:4e:61:b2:9a:ba:58:17:0b:55:96:f5:66:1c:a8: - ba:d1:0f:8b:9b:2d:ab:a8:00:ac:7f:99:7d:f6:0f:d7:85:eb: - 75:4b:e5:42:37:71:46:b1:4a:b0:1b:17:e4:f9:7c:9f:bd:20: - 75:35:9f:27:8e:07:95:e8:34:bd:ab:e4:10:5f:a3:7b:4c:56: - 69:d4:d0:f1:e9:74:15:2d:7f:77:f0:38:77:eb:8a:99:f3:a9: - 88:f0:63:58:07:b9:5a:61:f8:ff:11:e7:06:a1:d1:f8:85:fb: - 99:1c:f5:cb:77:86:36:cd:43:37:99:09:c2:9a:d8:f2:28:05: - 06:0c - - */ - public static final String rootCert = "-----BEGIN CERTIFICATE-----\n" + - "MIIDGzCCAoSgAwIBAgIBADANBgkqhkiG9w0BAQUFADBtMQswCQYDVQQGEwJBTjEQ\n" + - "MA4GA1UECBMHQW5kcm9pZDEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5k\n" + - "cm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEWMBQGCSqGSIb3DQEJARYHYW5kcm9pZDAe\n" + - "Fw0wODEyMDkxNjM1MzBaFw0xMTEyMDkxNjM1MzBaMG0xCzAJBgNVBAYTAkFOMRAw\n" + - "DgYDVQQIEwdBbmRyb2lkMRAwDgYDVQQKEwdBbmRyb2lkMRAwDgYDVQQLEwdBbmRy\n" + - "b2lkMRAwDgYDVQQDEwdBbmRyb2lkMRYwFAYJKoZIhvcNAQkBFgdhbmRyb2lkMIGf\n" + - "MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDF+15oN4IdWO3LMYwIf1ExTGhAjE0H\n" + - "oQ4YNgJriZLBz4gezwAiAIw36Gp2lHFTgXjhSJT6FmGT66DuYp1q0iy4d53JNtXZ\n" + - "HOsmPENmTXscHcehN2bihFTT7SHdARzsmwweNek3FZ0reKg7ETruwt5VREy9QI3l\n" + - "UrD8UzNzSuXQ3wIDAQABo4HKMIHHMB0GA1UdDgQWBBRL4yIUrQoURrdSMYurnlpi\n" + - "85g3gDCBlwYDVR0jBIGPMIGMgBRL4yIUrQoURrdSMYurnlpi85g3gKFxpG8wbTEL\n" + - "MAkGA1UEBhMCQU4xEDAOBgNVBAgTB0FuZHJvaWQxEDAOBgNVBAoTB0FuZHJvaWQx\n" + - "EDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWQxFjAUBgkqhkiG9w0B\n" + - "CQEWB2FuZHJvaWSCAQAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQBy\n" + - "TxKKTmGymrpYFwtVlvVmHKi60Q+Lmy2rqACsf5l99g/Xhet1S+VCN3FGsUqwGxfk\n" + - "+XyfvSB1NZ8njgeV6DS9q+QQX6N7TFZp1NDx6XQVLX938Dh364qZ86mI8GNYB7la\n" + - "Yfj/EecGodH4hfuZHPXLd4Y2zUM3mQnCmtjyKAUGDA==\n" + - "-----END CERTIFICATE-----"; - - public static final String rootPrivateKey = - "-----BEGIN RSA PRIVATE KEY-----\n" + - "Proc-Type: 4,ENCRYPTED\n" + - "DEK-Info: DES-EDE3-CBC,D9682F66FDA316E5\n" + - "\n" + - "8lGaQPlUZ/iHhdldB//xfNUrZ3RAkBthzKg+n9HBJsjztXXAZ40NGYZmgvpgnfmr\n" + - "7ZJxHxYHFc3GAmBBk9v+/dA8E5yWJa71roffWMQUuFNfGzHhGTOxvNC04W7yAajs\n" + - "CPuyI+xnAAo73F7NVTiqX3NVgu4bB8RVxJyToMe4M289oh93YvxWQ4buVTf0ErJ8\n" + - "Yc8+0ugpfXjGfRhL36qj6B1CcV7NMdXAVExrGlTf0TWT9wVbiROk4XaoaFuWh17h\n" + - "11NEDjsKQ8T4M9kRdC+tKfST8sLik1Pq6jRLIKeX8GQd7tV1IWVZ3KcQBJwu9zLq\n" + - "Hi0GTSF7IWCdwXjDyniMQiSbkmHNP+OnVyhaqew5Ooh0uOEQq/KWFewXg7B3VMr0\n" + - "l6U8sBX9ODGeW0wVdNopvl17udCkV0xm3S+MRZDnZiTlAXwKx/a/gyf5R5XYp3S0\n" + - "0eqrfy2o6Ax4hRkwcNJ2KMeLQNIiYYWKABQj5/i4TYZV6npCIXOnQEkXa9DmqyUE\n" + - "qB7eFj5FcXeqQ8ERmsLveWArsLDn2NNPdv5EaKIs2lrvwoKYeYF7hrKNpifq+QqS\n" + - "u1kN+KHjibcF42EAUozNVmkHsW8VqlywAs4MsMwxU0D57cVGWycuSedraKhc0D6j\n" + - "a4pQOWWY3ZMLoAA1ZmHG9cjDPqcJt0rqk5AhSBRmGVUccfkP7dk9KyJQizro87LI\n" + - "u7zWwMIqTfmlhyfAP0AWjrt/bMN9heGByVA55xkyCdSEVaC5gsIfmGpNy4u+wbZ9\n" + - "rSWVuTfAbjW0n0FW+CDS1LgdjXNkeAP2Uvc1QgVRCPdA23WniLFFJQ==\n" + - "-----END RSA PRIVATE KEY-----"; - - /** - * Certificate: - Data: - Version: 3 (0x2) - Serial Number: 1 (0x1) - Signature Algorithm: sha1WithRSAEncryption - Issuer: C=AN, ST=Android, O=Android, OU=Android, CN=Android/emailAddress=android - Validity - Not Before: Dec 9 16:40:35 2008 GMT - Not After : Dec 9 16:40:35 2009 GMT - Subject: C=AN, ST=Android, L=Android, O=Android, OU=Android, CN=Android Certificate/emailAddress=android - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - RSA Public Key: (1024 bit) - Modulus (1024 bit): - 00:b8:e3:de:c7:a9:40:47:2c:2a:6f:f5:2a:f4:cd: - f2:2d:40:fa:15:3f:1c:37:66:73:a5:67:4d:5b:a0: - b6:b1:dd:dc:bf:01:c7:e2:c1:48:1a:8f:1c:ce:ec: - b0:a2:55:29:9a:1b:3a:6e:cc:7b:d7:65:ae:0b:05: - 34:03:8a:af:db:f0:dc:01:80:92:03:b4:13:e5:d6: - fd:79:66:7f:c3:1a:62:d5:5e:3d:c0:19:a4:42:15: - 47:19:e6:f0:c8:b7:e2:7b:82:a2:c7:3d:df:ac:8c: - d5:bc:39:b8:e5:93:ac:3f:af:30:b7:cc:00:a8:00: - f3:38:23:b0:97:0e:92:b1:1b - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Basic Constraints: - CA:FALSE - Netscape Comment: - OpenSSL Generated Certificate - X509v3 Subject Key Identifier: - 88:4D:EC:16:26:A7:76:F5:26:43:BC:34:99:DF:D5:EA:7B:F8:5F:DE - X509v3 Authority Key Identifier: - keyid:4B:E3:22:14:AD:0A:14:46:B7:52:31:8B:AB:9E:5A:62:F3:98:37:80 - - Signature Algorithm: sha1WithRSAEncryption - 55:73:95:e6:4c:40:fc:fd:52:8a:5f:83:15:49:73:ca:f3:d8: - 5f:bb:d6:f5:2e:90:e6:7f:c3:7d:4d:27:d3:45:c6:53:9b:aa: - e3:32:99:40:b3:a9:d3:14:7d:d5:e6:a7:70:95:30:6e:dc:8c: - 7b:48:e1:98:d1:65:7a:eb:bf:b0:5c:cd:c2:eb:31:5e:b6:e9: - df:56:95:bc:eb:79:74:27:5b:6d:c8:55:63:09:d3:f9:e2:40: - ba:b4:a2:c7:2c:cb:b1:3a:c2:d8:0c:21:31:ee:68:7e:97:ce: - 98:22:2e:c6:cf:f0:1a:11:04:ca:9a:06:de:98:48:85:ac:6c: - 6f:98 - */ - public static final String endCert = - "-----BEGIN CERTIFICATE-----\n" + - "MIIC6jCCAlOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBtMQswCQYDVQQGEwJBTjEQ\n" + - "MA4GA1UECBMHQW5kcm9pZDEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5k\n" + - "cm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEWMBQGCSqGSIb3DQEJARYHYW5kcm9pZDAe\n" + - "Fw0wODEyMDkxNjQwMzVaFw0wOTEyMDkxNjQwMzVaMIGLMQswCQYDVQQGEwJBTjEQ\n" + - "MA4GA1UECBMHQW5kcm9pZDEQMA4GA1UEBxMHQW5kcm9pZDEQMA4GA1UEChMHQW5k\n" + - "cm9pZDEQMA4GA1UECxMHQW5kcm9pZDEcMBoGA1UEAxMTQW5kcm9pZCBDZXJ0aWZp\n" + - "Y2F0ZTEWMBQGCSqGSIb3DQEJARYHYW5kcm9pZDCBnzANBgkqhkiG9w0BAQEFAAOB\n" + - "jQAwgYkCgYEAuOPex6lARywqb/Uq9M3yLUD6FT8cN2ZzpWdNW6C2sd3cvwHH4sFI\n" + - "Go8czuywolUpmhs6bsx712WuCwU0A4qv2/DcAYCSA7QT5db9eWZ/wxpi1V49wBmk\n" + - "QhVHGebwyLfie4Kixz3frIzVvDm45ZOsP68wt8wAqADzOCOwlw6SsRsCAwEAAaN7\n" + - "MHkwCQYDVR0TBAIwADAsBglghkgBhvhCAQ0EHxYdT3BlblNTTCBHZW5lcmF0ZWQg\n" + - "Q2VydGlmaWNhdGUwHQYDVR0OBBYEFIhN7BYmp3b1JkO8NJnf1ep7+F/eMB8GA1Ud\n" + - "IwQYMBaAFEvjIhStChRGt1Ixi6ueWmLzmDeAMA0GCSqGSIb3DQEBBQUAA4GBAFVz\n" + - "leZMQPz9UopfgxVJc8rz2F+71vUukOZ/w31NJ9NFxlObquMymUCzqdMUfdXmp3CV\n" + - "MG7cjHtI4ZjRZXrrv7BczcLrMV626d9WlbzreXQnW23IVWMJ0/niQLq0oscsy7E6\n" + - "wtgMITHuaH6XzpgiLsbP8BoRBMqaBt6YSIWsbG+Y\n" + - "-----END CERTIFICATE-----"; - - public static final String endPrivateKey = - "-----BEGIN RSA PRIVATE KEY-----\n" + - "Proc-Type: 4,ENCRYPTED\n" + - "DEK-Info: DES-EDE3-CBC,E20AAB000D1D90B1\n" + - "\n" + - "cWrCb6eHuwb6/gnbX12Va47qSpFW0j99Lq2eEj0fqLdlwA6+KvD3/U+Nj4ldaAQ4\n" + - "rYryQv0MJu/kT9z/mJbBI4NwunX/9vXttyuh8s07sv8AqdHCylYR9miz61Q0LkLR\n" + - "9H9D8NWMgMnuVhlj+NUXlkF+Jfriu5xkIqeYDhN8c3/AMawQoNdW/pWmgz0BfFIP\n" + - "DUxszfXHx5mfSMoRdC2YZGlFdsONSO7s14Ayz8+pKD0PzSARXtTEJ5+mELCnhFsw\n" + - "R7zYYwD+9WjL702bjYQxwRS5Sk1Z/VAxLFfjdtlUFSi6VLGIG+jUnM1RF91KtJY1\n" + - "bJOQrlHw9/wyH75y9sXUrVpil4qH9shILHgu4A0VaL7IpIFjWS9vPY7SvwqRlbk7\n" + - "QPhxoIpiNzjzjEa7PG6nSqy8mRzJP0OLWzRUoMWJn6ntf+oj7CzaaIgFrrwRGOCQ\n" + - "BYibTTMZ/paxKDvZ9Lcl8a6uRvi2II2/F63bPcTcILsKDsBdQp93Evanw1QKXdGi\n" + - "jb4b0Y1LYZM0jl7z2TSBZ27HyHKp4jMQP9q9mujEKInjzSB+gsRGfP6++OilrR2U\n" + - "Y7kN2o/ufnPHltel0pUWOHr45IyK8zowgXWtKVl9U+VRwr2thGbdqkRGk55KjJK4\n" + - "Q+OfwvIKHgvn/4cN/BGIA/52eyY//bTFk6ePGY2vlQK4mvB7MeSxtxoCGxdCYQru\n" + - "wI28rOHyQ1cdx141yxlKVSIcxBVZHm8sfh9PHeKMKuaOgc8kfx+Qh8IghFHyJ+yg\n" + - "PboNF9/PiM/glaaBzY2OKTYQKY6LiTetZiI6RdLE7Y+SFwG7Wwo5dg==\n" + - "-----END RSA PRIVATE KEY-----"; - private void setupEnvironment() throws Exception { // create certificates and CRLs CertificateFactory cf = CertificateFactory.getInstance("X.509"); - ByteArrayInputStream bi = new ByteArrayInputStream(rootCert.getBytes()); + ByteArrayInputStream bi = new ByteArrayInputStream(TestUtils.rootCert.getBytes()); rootCertificate = (X509Certificate) cf.generateCertificate(bi); - bi = new ByteArrayInputStream(endCert.getBytes()); + bi = new ByteArrayInputStream(TestUtils.endCert.getBytes()); endCertificate = (X509Certificate) cf.generateCertificate(bi); BigInteger revokedSerialNumber = BigInteger.valueOf(1); @@ -2579,11 +2451,16 @@ public class X509CertSelectorTest extends TestCase { public void test_addPathToNameLintLbyte_array2() throws Exception { TestUtils.initCertPathSSCertChain(); setupEnvironment(); - GeneralName name = new GeneralName(1, "822.Name"); - assertNotNull(name.getEncoded()); - byte[] b = new byte[name.getEncoded().length]; - b = name.getEncoded(); - b[name.getEncoded().length-3] = (byte) 200; + byte[] bytes, bytesName; + // GeneralName name = new GeneralName(1, "822.Name"); + // bytes = name.getEncoded(); + // bytesName = name.getEncodedName(); + bytes = new byte[] {-127, 8, 56, 50, 50, 46, 78, 97, 109, 101}; + bytesName = new byte[] {-127, 8, 56, 50, 50, 46, 78, 97, 109, 101}; + assertNotNull(bytes); + byte[] b = new byte[bytes.length]; + b = bytes; + b[bytes.length-3] = (byte) 200; try { theCertSelector.addPathToName(1, b); @@ -2593,7 +2470,7 @@ public class X509CertSelectorTest extends TestCase { theCertSelector.setPathToNames(null); - theCertSelector.addPathToName(1, name.getEncodedName()); + theCertSelector.addPathToName(1, bytesName); assertNotNull(theCertSelector.getPathToNames()); CertPath p = buildCertPath(); assertNull(p); @@ -2619,12 +2496,16 @@ public class X509CertSelectorTest extends TestCase { ) public void test_addPathToNameLintLjava_lang_String2() throws Exception { setupEnvironment(); - - GeneralName name = new GeneralName(1, "822.Name"); - assertNotNull(name.getEncoded()); - byte[] b = new byte[name.getEncoded().length]; - b = name.getEncoded(); - b[name.getEncoded().length-3] = (byte) 200; + byte[] bytes, bytesName; + // GeneralName name = new GeneralName(1, "822.Name"); + // bytes = name.getEncoded(); + // bytesName = name.getEncodedName(); + bytes = new byte[] {-127, 8, 56, 50, 50, 46, 78, 97, 109, 101}; + bytesName = new byte[] {22, 8, 56, 50, 50, 46, 78, 97, 109, 101}; + assertNotNull(bytes); + byte[] b = new byte[bytes.length]; + b = bytes; + b[bytes.length-3] = (byte) 200; try { theCertSelector.addPathToName(1, new String(b)); @@ -2634,7 +2515,7 @@ public class X509CertSelectorTest extends TestCase { theCertSelector.setPathToNames(null); - theCertSelector.addPathToName(1, new String(name.getEncodedName())); + theCertSelector.addPathToName(1, new String(bytesName)); assertNotNull(theCertSelector.getPathToNames()); CertPath p = buildCertPath(); diff --git a/libcore/security/src/test/java/tests/security/cert/X509Certificate2Test.java b/libcore/security/src/test/java/tests/security/cert/X509Certificate2Test.java index 48230d98f..f60ca80f4 100644 --- a/libcore/security/src/test/java/tests/security/cert/X509Certificate2Test.java +++ b/libcore/security/src/test/java/tests/security/cert/X509Certificate2Test.java @@ -17,8 +17,6 @@ package tests.security.cert; -import dalvik.annotation.AndroidOnly; -import dalvik.annotation.KnownFailure; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; @@ -55,8 +53,6 @@ public class X509Certificate2Test extends junit.framework.TestCase { method = "toString", args = {} ) - @KnownFailure("java.lang.RuntimeException is thrown during " + - "X509Certificate.toString() method.") public void test_toString() throws Exception { // Regression for HARMONY-3384 @@ -502,8 +498,6 @@ public class X509Certificate2Test extends junit.framework.TestCase { method = "getSubjectAlternativeNames", args = {} ) - @AndroidOnly("getSubjectAlternativeNames method is not supported, " + - "it returns null for X509Certificate.") public void testGetSubjectAlternativeNames() throws CertificateParsingException { @@ -511,7 +505,7 @@ public class X509Certificate2Test extends junit.framework.TestCase { Collection> coll = cert.getSubjectAlternativeNames(); //getSubjectAlternativeNames method is not supported - assertNull(coll); + assertNotNull(coll); try { coll.clear(); @@ -540,8 +534,6 @@ public class X509Certificate2Test extends junit.framework.TestCase { method = "getIssuerAlternativeNames", args = {} ) - @AndroidOnly("getIssuerAlternativeNames method is not supported, " + - "it returns null for X509Certificate.") public void testGetIssuerAlternativeNames() throws CertificateParsingException { @@ -549,7 +541,7 @@ public class X509Certificate2Test extends junit.framework.TestCase { Collection> coll = cert.getIssuerAlternativeNames(); // getIssuerAlternativeNames returns null. - assertNull(coll); + assertNotNull(coll); try { coll.clear(); diff --git a/libcore/security/src/test/java/tests/security/interfaces/AllTests.java b/libcore/security/src/test/java/tests/security/interfaces/AllTests.java index 884dadf8a..e665119d1 100644 --- a/libcore/security/src/test/java/tests/security/interfaces/AllTests.java +++ b/libcore/security/src/test/java/tests/security/interfaces/AllTests.java @@ -39,9 +39,6 @@ public class AllTests { suite.addTestSuite(RSAMultiPrimePrivateCrtKeyTest.class); suite.addTestSuite(DSAPrivateKeyTest.class); suite.addTestSuite(DSAPublicKeyTest.class); - suite.addTestSuite(ECKeyTest.class); - suite.addTestSuite(ECPrivateKeyTest.class); - suite.addTestSuite(ECPublicKeyTest.class); suite.addTestSuite(RSAKeyTest.class); suite.addTestSuite(RSAPrivateCrtKeyTest.class); suite.addTestSuite(RSAPrivateKeyTest.class); diff --git a/libcore/security/src/test/java/tests/security/interfaces/DSAKeyPairGeneratorTest.java b/libcore/security/src/test/java/tests/security/interfaces/DSAKeyPairGeneratorTest.java index 8c257d91d..0de893dbe 100644 --- a/libcore/security/src/test/java/tests/security/interfaces/DSAKeyPairGeneratorTest.java +++ b/libcore/security/src/test/java/tests/security/interfaces/DSAKeyPairGeneratorTest.java @@ -16,7 +16,6 @@ package tests.security.interfaces; -import dalvik.annotation.TestTargets; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargetClass; diff --git a/libcore/security/src/test/java/tests/security/interfaces/DSAKeyTest.java b/libcore/security/src/test/java/tests/security/interfaces/DSAKeyTest.java index cb43b088c..2a65b64a2 100644 --- a/libcore/security/src/test/java/tests/security/interfaces/DSAKeyTest.java +++ b/libcore/security/src/test/java/tests/security/interfaces/DSAKeyTest.java @@ -15,7 +15,6 @@ */ package tests.security.interfaces; -import dalvik.annotation.TestTargets; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargetClass; @@ -46,7 +45,7 @@ public class DSAKeyTest extends TestCase { public void test_getParams() throws Exception { DSAParams param = new DSAParameterSpec(Util.P, Util.Q, Util.G); - KeyPairGenerator gen = KeyPairGenerator.getInstance("DSA", Util.prov); + KeyPairGenerator gen = KeyPairGenerator.getInstance("DSA"); gen.initialize((DSAParameterSpec) param); DSAKey key = null; diff --git a/libcore/security/src/test/java/tests/security/interfaces/DSAParamsTest.java b/libcore/security/src/test/java/tests/security/interfaces/DSAParamsTest.java index f01462e44..4a19512d6 100644 --- a/libcore/security/src/test/java/tests/security/interfaces/DSAParamsTest.java +++ b/libcore/security/src/test/java/tests/security/interfaces/DSAParamsTest.java @@ -14,7 +14,6 @@ * limitations under the License. */ package tests.security.interfaces; -import dalvik.annotation.TestTargets; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargetClass; diff --git a/libcore/security/src/test/java/tests/security/interfaces/DSAPrivateKeyTest.java b/libcore/security/src/test/java/tests/security/interfaces/DSAPrivateKeyTest.java index 504f8d71b..ee099152f 100644 --- a/libcore/security/src/test/java/tests/security/interfaces/DSAPrivateKeyTest.java +++ b/libcore/security/src/test/java/tests/security/interfaces/DSAPrivateKeyTest.java @@ -17,7 +17,7 @@ package tests.security.interfaces; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargetClass; -import dalvik.annotation.KnownFailure; +import dalvik.annotation.BrokenTest; import junit.framework.TestCase; @@ -39,12 +39,11 @@ public class DSAPrivateKeyTest extends TestCase { method = "getX", args = {} ) - @SuppressWarnings("serial") - @KnownFailure("Incorrect value was returned for method " + + @BrokenTest("Incorrect value was returned for method " + "java.security.interfaces.DSAPrivateKey.getX(). "+ - "This test is passed for RI.") + "This test does not pass on the RI.") public void test_getX() throws Exception { - KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA", Util.prov); + KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA"); keyGen.initialize(new DSAParameterSpec(Util.P, Util.Q, Util.G), new SecureRandom(new MySecureRandomSpi(), null) { }); diff --git a/libcore/security/src/test/java/tests/security/interfaces/DSAPublicKeyTest.java b/libcore/security/src/test/java/tests/security/interfaces/DSAPublicKeyTest.java index 2341447ae..42f2966ef 100644 --- a/libcore/security/src/test/java/tests/security/interfaces/DSAPublicKeyTest.java +++ b/libcore/security/src/test/java/tests/security/interfaces/DSAPublicKeyTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ package tests.security.interfaces; -import dalvik.annotation.KnownFailure; +import dalvik.annotation.BrokenTest; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargetClass; @@ -45,10 +45,9 @@ public class DSAPublicKeyTest extends TestCase { method = "getY", args = {} ) - @SuppressWarnings("serial") - @KnownFailure("Incorrect value was returned for method " + + @BrokenTest("Incorrect value was returned for method " + "java.security.interfaces.DSAPublicKey.getY(). "+ - "This test is passed for RI.") + "This test does not pass on the RI.") public void test_getY() throws Exception { KeyPairGenerator keyGen = null; KeyPair keys = null; @@ -56,7 +55,7 @@ public class DSAPublicKeyTest extends TestCase { DSAPublicKey publ = null; // Case 1: check with predefined p, q, g, x - keyGen = KeyPairGenerator.getInstance("DSA", Util.prov); + keyGen = KeyPairGenerator.getInstance("DSA"); keyGen.initialize(new DSAParameterSpec(Util.P, Util.Q, Util.G), new SecureRandom(new MySecureRandomSpi(), null) { }); @@ -68,7 +67,7 @@ public class DSAPublicKeyTest extends TestCase { // Case 2: check with random p, q, g, x. It takes some time (up to // minute) - keyGen = KeyPairGenerator.getInstance("DSA", Util.prov); + keyGen = KeyPairGenerator.getInstance("DSA"); keys = keyGen.generateKeyPair(); priv = (DSAPrivateKey) keys.getPrivate(); publ = (DSAPublicKey) keys.getPublic(); diff --git a/libcore/security/src/test/java/tests/security/interfaces/ECKeyTest.java b/libcore/security/src/test/java/tests/security/interfaces/ECKeyTest.java deleted file mode 100644 index cee4a6f25..000000000 --- a/libcore/security/src/test/java/tests/security/interfaces/ECKeyTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package tests.security.interfaces; -import dalvik.annotation.AndroidOnly; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import junit.framework.TestCase; - -import java.security.KeyPairGenerator; -import java.security.interfaces.ECKey; -import java.security.spec.ECParameterSpec; - -@TestTargetClass(ECKey.class) -public class ECKeyTest extends TestCase { - - /** - * @tests java.security.interfaces.ECKey - * #getParams() - * test covers following use cases - * Case 1: check private key - * Case 2: check public key - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getParams", - args = {} - ) - @AndroidOnly("EC is not supported for android. " + - "EC is not define in RI.") - public void test_getParams() throws Exception { - KeyPairGenerator gen = KeyPairGenerator.getInstance("EC", Util.prov); - gen.initialize(Util.ecParam); - ECKey key = null; - - // Case 1: check private key - key = (ECKey) gen.generateKeyPair().getPrivate(); - assertECParameterSpecEquals(Util.ecParam, key.getParams()); - - // Case 2: check public key - key = (ECKey) gen.generateKeyPair().getPublic(); - assertECParameterSpecEquals(Util.ecParam, key.getParams()); - } - - private void assertECParameterSpecEquals(ECParameterSpec expected, ECParameterSpec actual) { - assertEquals("cofactors don't match", expected.getCofactor(), actual.getCofactor()); - assertEquals("curves don't match", expected.getCurve(), actual.getCurve()); - assertEquals("generator don't match", expected.getGenerator(), actual.getGenerator()); - assertEquals("order don't match", expected.getOrder(), actual.getOrder()); - - } -} diff --git a/libcore/security/src/test/java/tests/security/interfaces/ECPrivateKeyTest.java b/libcore/security/src/test/java/tests/security/interfaces/ECPrivateKeyTest.java deleted file mode 100644 index 79acdb7f7..000000000 --- a/libcore/security/src/test/java/tests/security/interfaces/ECPrivateKeyTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package tests.security.interfaces; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.AndroidOnly; - -import junit.framework.TestCase; - -import java.security.KeyPairGenerator; -import java.security.SecureRandom; -import java.security.interfaces.ECPrivateKey; - -@TestTargetClass(ECPrivateKey.class) -public class ECPrivateKeyTest extends TestCase { - - /** - * @tests java.security.interfaces.ECPrivateKey - * #getS() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getS", - args = {} - ) - @SuppressWarnings("serial") - @AndroidOnly("EC is not supported for android. " + - "EC is not define in RI.") - public void test_getS() throws Exception { - KeyPairGenerator gen = KeyPairGenerator.getInstance("EC", Util.prov); - gen.initialize(Util.ecParam, new SecureRandom(new MySecureRandomSpi(), - null) { - }); - ECPrivateKey key = (ECPrivateKey) gen.generateKeyPair().getPrivate(); - assertEquals("Invalid S", Util.RND_RET, key.getS()); - } - -} diff --git a/libcore/security/src/test/java/tests/security/interfaces/ECPublicKeyTest.java b/libcore/security/src/test/java/tests/security/interfaces/ECPublicKeyTest.java deleted file mode 100644 index 0c497ec65..000000000 --- a/libcore/security/src/test/java/tests/security/interfaces/ECPublicKeyTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package tests.security.interfaces; -import dalvik.annotation.AndroidOnly; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import junit.framework.TestCase; - -import java.math.BigInteger; -import java.security.KeyPairGenerator; -import java.security.SecureRandom; -import java.security.interfaces.ECPublicKey; -import java.security.spec.ECPoint; - -@TestTargetClass(ECPublicKey.class) -public class ECPublicKeyTest extends TestCase { - - /** - * @tests java.security.interfaces.ECPublicKey - * #getW() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getW", - args = {} - ) - @SuppressWarnings("serial") - @AndroidOnly("EC is not supported for android. " + - "EC is not define in RI.") - public void test_getW() throws Exception { - KeyPairGenerator gen = KeyPairGenerator.getInstance("EC", Util.prov); - gen.initialize(Util.ecParam, new SecureRandom(new MySecureRandomSpi(), - null) { - }); - ECPublicKey key = (ECPublicKey) gen.generateKeyPair().getPublic(); - assertECPointEquals(new ECPoint(BigInteger.valueOf(4), - BigInteger.valueOf(15)), key.getW()); - } - - private void assertECPointEquals(ECPoint expected, ECPoint actual) { - assertEquals("X coordiates are different", expected.getAffineX(), - actual.getAffineX()); - assertEquals("Y coordiates are different", expected.getAffineY(), - actual.getAffineY()); - } -} diff --git a/libcore/security/src/test/java/tests/security/interfaces/RSAKeyTest.java b/libcore/security/src/test/java/tests/security/interfaces/RSAKeyTest.java index 87804b0a8..dad13db23 100644 --- a/libcore/security/src/test/java/tests/security/interfaces/RSAKeyTest.java +++ b/libcore/security/src/test/java/tests/security/interfaces/RSAKeyTest.java @@ -14,7 +14,6 @@ * limitations under the License. */ package tests.security.interfaces; -import dalvik.annotation.TestTargets; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargetClass; @@ -44,7 +43,7 @@ public class RSAKeyTest extends TestCase { args = {} ) public void test_getModulus() throws Exception { - KeyFactory gen = KeyFactory.getInstance("RSA", Util.prov); + KeyFactory gen = KeyFactory.getInstance("RSA"); final BigInteger n = BigInteger.valueOf(3233); final BigInteger d = BigInteger.valueOf(2753); final BigInteger e = BigInteger.valueOf(17); diff --git a/libcore/security/src/test/java/tests/security/interfaces/RSAPrivateCrtKeyTest.java b/libcore/security/src/test/java/tests/security/interfaces/RSAPrivateCrtKeyTest.java index 7549852ea..fb7972189 100644 --- a/libcore/security/src/test/java/tests/security/interfaces/RSAPrivateCrtKeyTest.java +++ b/libcore/security/src/test/java/tests/security/interfaces/RSAPrivateCrtKeyTest.java @@ -14,7 +14,6 @@ * limitations under the License. */ package tests.security.interfaces; -import dalvik.annotation.TestTargets; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargetClass; @@ -31,7 +30,7 @@ public class RSAPrivateCrtKeyTest extends TestCase { protected void setUp() throws Exception { super.setUp(); - KeyFactory gen = KeyFactory.getInstance("RSA", Util.prov); + KeyFactory gen = KeyFactory.getInstance("RSA"); key = (RSAPrivateCrtKey) gen.generatePrivate(Util.rsaCrtParam); } diff --git a/libcore/security/src/test/java/tests/security/interfaces/RSAPrivateKeyTest.java b/libcore/security/src/test/java/tests/security/interfaces/RSAPrivateKeyTest.java index e911be74f..4e7d61602 100644 --- a/libcore/security/src/test/java/tests/security/interfaces/RSAPrivateKeyTest.java +++ b/libcore/security/src/test/java/tests/security/interfaces/RSAPrivateKeyTest.java @@ -14,7 +14,6 @@ * limitations under the License. */ package tests.security.interfaces; -import dalvik.annotation.TestTargets; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargetClass; @@ -40,7 +39,7 @@ public class RSAPrivateKeyTest extends TestCase { args = {} ) public void test_getPrivateExponent() throws Exception { - KeyFactory gen = KeyFactory.getInstance("RSA", Util.prov); + KeyFactory gen = KeyFactory.getInstance("RSA"); final BigInteger n = BigInteger.valueOf(3233); final BigInteger d = BigInteger.valueOf(2753); RSAPrivateKey key = (RSAPrivateKey) gen.generatePrivate(new RSAPrivateKeySpec( diff --git a/libcore/security/src/test/java/tests/security/interfaces/RSAPublicKeyTest.java b/libcore/security/src/test/java/tests/security/interfaces/RSAPublicKeyTest.java index c7018a6bd..83fbeb2cd 100644 --- a/libcore/security/src/test/java/tests/security/interfaces/RSAPublicKeyTest.java +++ b/libcore/security/src/test/java/tests/security/interfaces/RSAPublicKeyTest.java @@ -14,7 +14,6 @@ * limitations under the License. */ package tests.security.interfaces; -import dalvik.annotation.TestTargets; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargetClass; @@ -40,7 +39,7 @@ public class RSAPublicKeyTest extends TestCase { args = {} ) public void test_getPublicExponent() throws Exception { - KeyFactory gen = KeyFactory.getInstance("RSA", Util.prov); + KeyFactory gen = KeyFactory.getInstance("RSA"); final BigInteger n = BigInteger.valueOf(3233); final BigInteger e = BigInteger.valueOf(17); RSAPublicKey key = (RSAPublicKey) gen.generatePublic(new RSAPublicKeySpec( diff --git a/libcore/security/src/test/java/tests/security/interfaces/Util.java b/libcore/security/src/test/java/tests/security/interfaces/Util.java index c1f3bb7d4..61143a0a4 100644 --- a/libcore/security/src/test/java/tests/security/interfaces/Util.java +++ b/libcore/security/src/test/java/tests/security/interfaces/Util.java @@ -15,7 +15,6 @@ */ package tests.security.interfaces; import java.math.BigInteger; -import java.security.Provider; import java.security.SecureRandomSpi; import java.security.spec.ECFieldFp; import java.security.spec.ECParameterSpec; @@ -29,11 +28,6 @@ import java.security.spec.RSAPrivateCrtKeySpec; class Util { /** - * BouncyCastle provider - */ - static final Provider prov = new org.bouncycastle.jce.provider.BouncyCastleProvider(); - - /** * Valid P for DSA tests */ static final BigInteger P = new BigInteger( diff --git a/libcore/security/src/test/java/tests/security/permissions/JavaNetSocketTest.java b/libcore/security/src/test/java/tests/security/permissions/JavaNetSocketTest.java index 314feb8b7..393306402 100644 --- a/libcore/security/src/test/java/tests/security/permissions/JavaNetSocketTest.java +++ b/libcore/security/src/test/java/tests/security/permissions/JavaNetSocketTest.java @@ -27,6 +27,7 @@ import junit.framework.TestCase; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; +import java.net.UnknownHostException; import java.security.Permission; /* * This class tests the security permissions which are documented in @@ -88,7 +89,6 @@ public class JavaNetSocketTest extends TestCase { args = {java.net.InetAddress.class, int.class, java.net.InetAddress.class, int.class} ) }) - @KnownFailure("ToT fixed") public void test_ctor() throws IOException { class TestSecurityManager extends SecurityManager { boolean called = false; @@ -154,4 +154,47 @@ public class JavaNetSocketTest extends TestCase { assertEquals("Argument of checkConnect is not correct", hostAddress, s.host); assertEquals("Argument of checkConnect is not correct", port, s.port); } + + @TestTargetNew( + level = TestLevel.PARTIAL, + notes = "", + method = "Socket", + args = {java.net.InetAddress.class, int.class, java.net.InetAddress.class, int.class} + ) + @KnownFailure("throws SocketException with message: the socket level is invalid. Works on the RI") + public void test_ctor2() throws IOException { + class TestSecurityManager extends SecurityManager { + boolean called = false; + String host = null; + int port = -1; + void reset(){ + called = false; + host = null; + port = -1; + } + @Override + public void checkConnect(String host, int port) { + this.called = true; + this.port = port; + this.host = host; + } + @Override + public void checkPermission(Permission permission) { + + } + } + + String host = "www.google.ch"; + int port = 80; + String hostAddress = InetAddress.getByName(host).getHostAddress(); + + TestSecurityManager s = new TestSecurityManager(); + System.setSecurityManager(s); + + s.reset(); + new Socket(InetAddress.getByName(host), port, InetAddress.getLocalHost(), 0); + assertTrue("java.net.ServerSocket ctor must call checkConnect on security permissions", s.called); + assertEquals("Argument of checkConnect is not correct", hostAddress, s.host); + assertEquals("Argument of checkConnect is not correct", port, s.port); + } } diff --git a/libcore/security/src/test/java/tests/targets/security/AlgorithmParameterGeneratorTest.java b/libcore/security/src/test/java/tests/targets/security/AlgorithmParameterGeneratorTest.java index 0c362fa5a..7c7643052 100644 --- a/libcore/security/src/test/java/tests/targets/security/AlgorithmParameterGeneratorTest.java +++ b/libcore/security/src/test/java/tests/targets/security/AlgorithmParameterGeneratorTest.java @@ -1,7 +1,6 @@ package tests.targets.security; import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargets; @@ -11,7 +10,6 @@ import java.security.AlgorithmParameterGenerator; import java.security.AlgorithmParameters; import java.security.NoSuchAlgorithmException; -@TestTargetClass(targets.AlgorithmParameterGenerators.Internal.class) public abstract class AlgorithmParameterGeneratorTest extends TestCase { private final String algorithmName; @@ -32,6 +30,11 @@ public abstract class AlgorithmParameterGeneratorTest extends TestCase { level=TestLevel.ADDITIONAL, method="init", args={int.class} + ), + @TestTargetNew( + level=TestLevel.COMPLETE, + method="method", + args={} ) }) public void testAlgorithmParameterGenerator() { diff --git a/libcore/security/src/test/java/tests/targets/security/AlgorithmParametersTest.java b/libcore/security/src/test/java/tests/targets/security/AlgorithmParametersTest.java index 3b45d4043..49ac2de49 100644 --- a/libcore/security/src/test/java/tests/targets/security/AlgorithmParametersTest.java +++ b/libcore/security/src/test/java/tests/targets/security/AlgorithmParametersTest.java @@ -1,7 +1,6 @@ package tests.targets.security; import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargets; @@ -12,7 +11,6 @@ import java.security.NoSuchAlgorithmException; import java.security.spec.AlgorithmParameterSpec; import java.security.spec.InvalidParameterSpecException; -@TestTargetClass(targets.AlgorithmParameters.Internal.class) public class AlgorithmParametersTest extends TestCase { private final String algorithmName; @@ -40,6 +38,11 @@ public class AlgorithmParametersTest extends TestCase { level=TestLevel.ADDITIONAL, method="init", args={byte[].class} + ), + @TestTargetNew( + level=TestLevel.COMPLETE, + method="method", + args={} ) }) public void testAlgorithmParameters() { diff --git a/libcore/security/src/test/java/tests/targets/security/AllTests.java b/libcore/security/src/test/java/tests/targets/security/AllTests.java index 4235b7127..c4d85b5dd 100644 --- a/libcore/security/src/test/java/tests/targets/security/AllTests.java +++ b/libcore/security/src/test/java/tests/targets/security/AllTests.java @@ -35,6 +35,7 @@ public class AllTests { suite.addTestSuite(MessageDigestTestMD5.class); suite.addTestSuite(MessageDigestTestSHA1.class); + suite.addTestSuite(MessageDigestTestSHA224.class); suite.addTestSuite(MessageDigestTestSHA256.class); suite.addTestSuite(MessageDigestTestSHA384.class); suite.addTestSuite(MessageDigestTestSHA512.class); @@ -49,8 +50,10 @@ public class AllTests { suite.addTestSuite(SignatureTestMD2withRSA.class); suite.addTestSuite(SignatureTestMD5withRSA.class); + suite.addTestSuite(SignatureTestNONEwithDSA.class); suite.addTestSuite(SignatureTestSHA1withDSA.class); suite.addTestSuite(SignatureTestSHA1withRSA.class); + suite.addTestSuite(SignatureTestSHA224withRSA.class); suite.addTestSuite(SignatureTestSHA256withRSA.class); suite.addTestSuite(SignatureTestSHA384withRSA.class); suite.addTestSuite(SignatureTestSHA512withRSA.class); @@ -67,6 +70,8 @@ public class AllTests { suite.addTestSuite(AlgorithmParametersTestDH.class); suite.addTestSuite(KeyStoreTestPKCS12.class); + + suite.addTestSuite(SecureRandomTestSHA1PRNG.class); // $JUnit-END$ return suite; diff --git a/libcore/security/src/test/java/tests/targets/security/DHTest.java b/libcore/security/src/test/java/tests/targets/security/DHTest.java index 9ccc61659..16b6d626b 100644 --- a/libcore/security/src/test/java/tests/targets/security/DHTest.java +++ b/libcore/security/src/test/java/tests/targets/security/DHTest.java @@ -22,10 +22,9 @@ public class DHTest extends TestCase { @TestTargetNew( level = TestLevel.ADDITIONAL, - method = "!", + method = "method", args = {} ) - @BrokenTest("please cleanup test and annotations") public void testDHGen() throws Exception { KeyPairGenerator gen = null; @@ -33,8 +32,6 @@ public class DHTest extends TestCase { gen = KeyPairGenerator.getInstance("DH"); } catch (NoSuchAlgorithmException e) { fail(e.getMessage()); -// } catch (NoSuchProviderException e) { -// fail(e.getMessage()); } AlgorithmParameterGenerator algorithmparametergenerator = AlgorithmParameterGenerator.getInstance("DH"); diff --git a/libcore/security/src/test/java/tests/targets/security/KeyFactoryTest.java b/libcore/security/src/test/java/tests/targets/security/KeyFactoryTest.java index 9b5008aff..ddfef9fed 100644 --- a/libcore/security/src/test/java/tests/targets/security/KeyFactoryTest.java +++ b/libcore/security/src/test/java/tests/targets/security/KeyFactoryTest.java @@ -1,7 +1,6 @@ package tests.targets.security; import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargets; @@ -15,7 +14,6 @@ import java.security.PrivateKey; import java.security.PublicKey; import java.security.spec.InvalidKeySpecException; import java.security.spec.KeySpec; -@TestTargetClass(targets.KeyFactories.Internal.class) public abstract class KeyFactoryTest extends TestCase { @@ -65,6 +63,11 @@ public abstract class KeyFactoryTestj#$%1rT;c z5rYJ(JqXh`9(!o75gu5_1l9uAUQtlOpn$3;80tub-Vz2jh;vF9SQGV<^pZg~vs5uK zFdHy1FfcN(M(CLuSOU3<22ISe22D)2nOGcy-)9?ev$1Qnd7QIgVP<78C^6(V;ACSC zWnmL$3JNvkG2jAmIE0z~g8dCe41_>Dc42P6{IdMw%%ses;%q}c10IklmoTemUP)?> zp{Ri{h|ev|;}Ybf0CT9Jlz{|Dm|0jbEGID~GdHtH!8boAza%@q%s@_@*TBTU(g=u6 z%}gz$fLt>JQ$uqocYs{g#JIztiBSg@Jd8k&JX2#M!{7SgM%hv!&7k{UbM)RkdHzjs zdyvh07ly-f_6^$t)iPaU9h3rpN80vA{Mvu?>n?+Dr)P)eTyL~)kTuEwl$NkPduG7W zCG+RMV5t^RI^@55<@JBtk4gWq4u5`Z#WGQTmfy|aE+3UU%w!rO93?i<=v(RMb=ry7 zwcdYHVwRkH(Sz|glPJUVgn)igW$rVZChcrm^ty%nLxjv%kkh_DT+n)Lw(Y&sdsfGo z?FiplIc5FsUskW0eun#S+p;&M2S$eX?Ya`_|E!Q*ps`_#r&yu#3m*+J;qB)+je1Tj zduSt8)g4mPtMOp*Iyvpl%StEaEw1POrD&S;@pn=cql)#JB_H>#2%ONlqWS*AsHgMU zCUvL9HB^VHrZDJ#;Eo=e0|t@X}+2} z0{PdI8=H9L81s+0CZylsG*h$IU_DoO^Q=3A_xvpPm2d4PF3?|oFKV{Nr%ke{v2{yq zHBk~Zvp$1?4wFcx$ae1Q;RVNDTX3XxUUXc)i)T+QlZeB1T_1U!sXrV0`Cq-sobaby I#iXYK02(ZFbpQYW literal 0 HcmV?d00001 diff --git a/libcore/security/src/test/resources/hyts_badpem.cer b/libcore/security/src/test/resources/tests/resources/hyts_badpem.cer similarity index 100% rename from libcore/security/src/test/resources/hyts_badpem.cer rename to libcore/security/src/test/resources/tests/resources/hyts_badpem.cer diff --git a/libcore/security/src/test/resources/java/security/cert/CertPath.PkiPath b/libcore/security/src/test/resources/tests/resources/java/security/cert/CertPath.PkiPath similarity index 100% rename from libcore/security/src/test/resources/java/security/cert/CertPath.PkiPath rename to libcore/security/src/test/resources/tests/resources/java/security/cert/CertPath.PkiPath diff --git a/libcore/support/src/test/java/targets/Signatures.java b/libcore/support/src/test/java/targets/Signatures.java index 3296df667..0d69d9b89 100644 --- a/libcore/support/src/test/java/targets/Signatures.java +++ b/libcore/support/src/test/java/targets/Signatures.java @@ -23,12 +23,17 @@ public interface Signatures { } @VirtualTestTarget + static abstract class SHA384withRSA extends Internal { + protected abstract void method(); + } + + @VirtualTestTarget static abstract class SHA256withRSA extends Internal { protected abstract void method(); } @VirtualTestTarget - static abstract class NONEwithDSA extends Internal { + static abstract class SHA224withRSA extends Internal { protected abstract void method(); } @@ -38,22 +43,22 @@ public interface Signatures { } @VirtualTestTarget - static abstract class SHA384withRSA extends Internal { + static abstract class MD5withRSA extends Internal { protected abstract void method(); } @VirtualTestTarget - static abstract class SHA1withDSA extends Internal { + static abstract class MD2withRSA extends Internal { protected abstract void method(); } @VirtualTestTarget - static abstract class MD5withRSA extends Internal { + static abstract class SHA1withDSA extends Internal { protected abstract void method(); } @VirtualTestTarget - static abstract class MD2withRSA extends Internal { + static abstract class NONEwithDSA extends Internal { protected abstract void method(); } } -- 2.11.0