Merge "Ensure the SignatureImpl overrides all methods"
diff --git a/dalvik/src/main/java/dalvik/annotation/AndroidOnly.java b/dalvik/src/main/java/dalvik/annotation/AndroidOnly.java
deleted file mode 100644
index da3c1c5..0000000
--- a/dalvik/src/main/java/dalvik/annotation/AndroidOnly.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2008 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 dalvik.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Marks a test-case as Android-only, that is, it should not be executed on
- * other systems.
- *
- * @hide
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ ElementType.METHOD, ElementType.TYPE })
-public @interface AndroidOnly {
-
- /**
- * Plain text reason for adding this annotation.
- */
- String value();
-
-}
diff --git a/dalvik/src/main/java/dalvik/annotation/BrokenTest.java b/dalvik/src/main/java/dalvik/annotation/BrokenTest.java
deleted file mode 100644
index 16788d0..0000000
--- a/dalvik/src/main/java/dalvik/annotation/BrokenTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2008 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 dalvik.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Marks a test case as broken. This means the test case should be fixed.
- *
- * @hide
- *
- * @deprecated - use expectations/brokentests.txt instead
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ ElementType.METHOD })
-public @interface BrokenTest {
-
- /**
- * Plain text reason for adding this annotation.
- */
- String value();
-
-}
diff --git a/dalvik/src/main/java/dalvik/annotation/SideEffect.java b/dalvik/src/main/java/dalvik/annotation/SideEffect.java
deleted file mode 100644
index 2d691e3..0000000
--- a/dalvik/src/main/java/dalvik/annotation/SideEffect.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2008 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 dalvik.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Marks a test-case as either having a side-effect that other tests might
- * notice or suffering from such a side effect. Such tests should be run in an
- * isolated manner.
- *
- * @hide
- *
- * @deprecated - use expectations/brokentests.txt instead
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ ElementType.METHOD, ElementType.TYPE })
-public @interface SideEffect {
-
- /**
- * Plain text reason for adding this annotation.
- */
- String value();
-
-}
diff --git a/dalvik/src/main/java/dalvik/annotation/TestLevel.java b/dalvik/src/main/java/dalvik/annotation/TestLevel.java
deleted file mode 100644
index f62ea2f..0000000
--- a/dalvik/src/main/java/dalvik/annotation/TestLevel.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2008 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 dalvik.annotation;
-
-/**
- * Defines an enumeration of possible states a test case can be in.
- *
- * @hide
- */
-public enum TestLevel {
-
- /**
- * Indicates that a test method completely tests its target API method.
- */
- COMPLETE,
-
- /**
- * Indicates that a test method partially tests its target API method and
- * that together with all other {@code PARTIAL_COMPLETE} tests for the same
- * method it is sufficient.
- */
- PARTIAL_COMPLETE,
-
- /**
- * Just for compatibility purposes, will be removed later.
- */
- PARTIAL_OK,
-
- /**
- * Indicates that a test method partially tests its target API method. It
- * needs a second review phase to find out if the sum of all partial tests
- * is sufficient for completely testing the target API method. If yes, the
- * level has to be changed to {@code PARTIAL_COMPLETE}.
- */
- PARTIAL,
-
- /**
- * Indicates that a test method is known to not completely test an API
- * method but the missing test steps are too complex and costly to
- * implement. This level is positioned somewhere between {@code PARTIAL}
- * and {@code COMPLETE}.
- */
- SUFFICIENT,
-
- /**
- * Indicates that a test method provides additional testing for an API
- * method for which there already exists one {@code COMPLETE} or a set of
- * {@code PARTIAL_COMPLETE} tests. This level may also be used for test
- * methods that test a concept which can not be directly attributed to
- * the specification of an API method or class.
- */
- ADDITIONAL,
-
- /**
- * Indicates that there is nothing to test in an API method, for example if
- * the specification states that a method does nothing.
- */
- NOT_NECESSARY,
-
- /**
- * Indicates that it is very hard or impossible to test an API method.
- */
- NOT_FEASIBLE,
-
- /**
- * Indicates that the tests is either insufficient or wrong. Something needs
- * to be done about it.
- */
- TODO,
-
-}
diff --git a/dalvik/src/main/java/dalvik/annotation/TestTargetClass.java b/dalvik/src/main/java/dalvik/annotation/TestTargetClass.java
index 1e16d0c..89116ba 100644
--- a/dalvik/src/main/java/dalvik/annotation/TestTargetClass.java
+++ b/dalvik/src/main/java/dalvik/annotation/TestTargetClass.java
@@ -38,10 +38,4 @@
* Specifies the class being tested.
*/
Class<?> value();
-
- /**
- * Option to specify untested methods for the class.
- * @hide
- */
- TestTargetNew[] untestedMethods() default {};
}
diff --git a/dalvik/src/main/java/dalvik/annotation/TestTargetNew.java b/dalvik/src/main/java/dalvik/annotation/TestTargetNew.java
deleted file mode 100644
index 80aebee..0000000
--- a/dalvik/src/main/java/dalvik/annotation/TestTargetNew.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2008 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 dalvik.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Defines an annotation used be used within the TestInfo annotation. It
- * specifies a single method target for the test (but can be used multiple
- * times).
- * @hide
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ ElementType.ANNOTATION_TYPE, ElementType.METHOD })
-public @interface TestTargetNew {
-
- /**
- * Specifies the name of the API method that is being tested. This field
- * may be left empty if the test target is a concept implemented in a
- * class rather than a concrete API method.
- */
- String method() default "";
-
- /**
- * Specifies the signature of the API method that is being tested, in terms
- * of Java classes.
- */
- Class<?>[] args() default {};
-
- /**
- * Specifies the class to which the tested method belongs. If this value is
- * not provided, the class identified in @TestTargetClass is used by the
- * test progress doclet.
- */
- Class<?> clazz() default void.class;
-
- /**
- * Specifies the level of coverage the tested API method has.
- */
- TestLevel level();
-
- /**
- * Specifies noteworthy plain-text information about the test, for example
- * if something is NOT covered by the test method.
- */
- String notes() default "";
-}
diff --git a/dalvik/src/main/java/dalvik/annotation/TestTargets.java b/dalvik/src/main/java/dalvik/annotation/TestTargets.java
deleted file mode 100644
index 207572c..0000000
--- a/dalvik/src/main/java/dalvik/annotation/TestTargets.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2008 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 dalvik.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Defines an annotation for test classes that allows to link them to the class
- * that is being tested. The current assumption is that the test are somewhat
- * organized according to the API classes they test. Might be too strict for
- * some cases.
- * @hide
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ ElementType.METHOD })
-public @interface TestTargets {
-
- /**
- * Specifies the API methods that are tested by the annotated test method.
- */
- TestTargetNew[] value();
-}
diff --git a/dalvik/src/main/java/dalvik/annotation/ToBeFixed.java b/dalvik/src/main/java/dalvik/annotation/ToBeFixed.java
deleted file mode 100644
index 751a038..0000000
--- a/dalvik/src/main/java/dalvik/annotation/ToBeFixed.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2008 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 dalvik.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Defines an annotation for test methods that indicate the test method
- * need to be fixed in future.
- * {@hide pending API Council approval}
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ ElementType.METHOD })
-public @interface ToBeFixed {
-
- /**
- * Specifies the related bug number on CTS bug tracking system.
- */
- String bug() default "";
-
- /**
- * Specifies why this method need to be fixed. If we think it's a bug, explain
- * the expectation and the actual result.
- */
- String explanation() default "";
-}
diff --git a/expectations/knownfailures.txt b/expectations/knownfailures.txt
index f5a13c6..e903cbb 100644
--- a/expectations/knownfailures.txt
+++ b/expectations/knownfailures.txt
@@ -1526,5 +1526,14 @@
"com.android.org.conscrypt.NativeCryptoTest#test_SSL_renegotiate",
"com.android.org.conscrypt.NativeCryptoTest#test_SSL_do_handshake_clientCertificateRequested_throws_after_renegotiate"
]
+},
+{
+ description: "Failures in OldSHA1PRNGSecureRandomTest",
+ result: EXEC_FAILED,
+ names: [
+ "org.apache.harmony.tests.javax.security.OldSHA1PRNGSecureRandomTest#testNextBytesbyteArray02",
+ "org.apache.harmony.tests.javax.security.OldSHA1PRNGSecureRandomTest#testNextBytesbyteArray04",
+ "org.apache.harmony.tests.javax.security.OldSHA1PRNGSecureRandomTest#testSetSeedbyteArray03"
+ ]
}
]
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/Process2Test.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/Process2Test.java
index 649488c..7294bdd 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/Process2Test.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/Process2Test.java
@@ -17,8 +17,6 @@
package org.apache.harmony.tests.java.lang;
-import dalvik.annotation.AndroidOnly;
-
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
@@ -35,7 +33,6 @@
* java.lang.Process#getOutputStream()
* Tests if these methods return buffered streams.
*/
- @AndroidOnly("dalvikvm specific")
public void test_streams()
throws IOException, InterruptedException {
Process p = javaProcessBuilder().start();
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/reflect/GenericSignatureFormatErrorTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/reflect/GenericSignatureFormatErrorTest.java
index 0cad681..20b9ab0 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/reflect/GenericSignatureFormatErrorTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/reflect/GenericSignatureFormatErrorTest.java
@@ -1,6 +1,5 @@
package org.apache.harmony.tests.java.lang.reflect;
-import dalvik.annotation.AndroidOnly;
import dalvik.system.DexFile;
import junit.framework.TestCase;
@@ -31,8 +30,6 @@
}
- @AndroidOnly("Uses Android specific class dalvik.system.DexFile " +
- "for loading classes.")
// SideEffect: strange issue (exception: 'could not open dex file',
// dalvikvm: 'waitpid failed' log msg - only occurs when @SideEffect is removed
// and this test is run via running tests.luni.AllTestsLang TestSuite
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/EnumMapTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/EnumMapTest.java
index 676e373..b201468 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/EnumMapTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/EnumMapTest.java
@@ -16,8 +16,6 @@
package org.apache.harmony.tests.java.util;
-import dalvik.annotation.AndroidOnly;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumMap;
@@ -333,7 +331,7 @@
/**
* java.util.EnumMap#entrySet()
*/
- @AndroidOnly("Map.Entry is indirectly modified on RI when Iterator.next() is invoked")
+ // AndroidOnly("Map.Entry is indirectly modified on RI when Iterator.next() is invoked")
@SuppressWarnings({ "unchecked", "boxing" })
public void test_entrySet() {
EnumMap enumSizeMap = new EnumMap(Size.class);
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/jar/JarEntryTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/jar/JarEntryTest.java
index a48bd60..3f4ed3b 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/jar/JarEntryTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/jar/JarEntryTest.java
@@ -26,6 +26,7 @@
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
import junit.framework.TestCase;
+import libcore.io.Streams;
import tests.support.resource.Support_Resources;
public class JarEntryTest extends TestCase {
@@ -80,9 +81,6 @@
}
}
- /**
- * java.util.jar.JarEntry#JarEntry(java.util.zip.ZipEntry)
- */
public void test_ConstructorLjava_util_zip_ZipEntry() {
assertNotNull("Jar file is null", jarFile);
zipEntry = jarFile.getEntry(entryName);
@@ -116,38 +114,46 @@
attrJar.close();
}
- /**
- * java.util.jar.JarEntry#getCertificates()
- */
- public void test_getCertificates() throws Exception {
+ // http://b/1864326
+ public void testCertificatesAndCodesigners() throws Exception {
zipEntry = jarFile.getEntry(entryName2);
jarEntry = new JarEntry(zipEntry);
assertNull(jarEntry.getCertificates());
- // Regression Test for HARMONY-3424
+ // Regression Test for HARMONY-3424, b/1864326
String jarFileName = "TestCodeSigners.jar";
Support_Resources.copyFile(resources, null, jarFileName);
File file = new File(resources, jarFileName);
JarFile jarFile = new JarFile(file);
JarEntry jarEntry1 = jarFile.getJarEntry("Test.class");
JarEntry jarEntry2 = jarFile.getJarEntry("Test.class");
- InputStream in = jarFile.getInputStream(jarEntry1);
- byte[] buffer = new byte[1024];
- while (in.available() > 0) {
- assertNull("getCertificates() should be null until the entry is read",
- jarEntry1.getCertificates());
+
+ try (InputStream in = jarFile.getInputStream(jarEntry1)) {
+ // Code signers and certs must be {@code null} until the entry is completely
+ // read.
+ assertNull(jarEntry1.getCertificates());
assertNull(jarEntry2.getCertificates());
- in.read(buffer);
+ assertNull(jarEntry1.getCodeSigners());
+ assertNull(jarEntry2.getCodeSigners());
+
+ // Read a few bytes from the stream.
+ in.read(new byte[64]);
+ assertNull(jarEntry1.getCertificates());
+ assertNull(jarEntry2.getCertificates());
+ assertNull(jarEntry1.getCodeSigners());
+ assertNull(jarEntry2.getCodeSigners());
+
+ // Read the rest of the stream.
+ Streams.skipByReading(in, Long.MAX_VALUE);
+
+ assertEquals(-1, in.read());
+ assertNotNull(jarEntry1.getCodeSigners());
+ assertNotNull(jarEntry2.getCodeSigners());
+ assertNotNull(jarEntry1.getCertificates());
+ assertNotNull(jarEntry2.getCertificates());
}
- assertEquals("the file is fully read", -1, in.read());
- assertNotNull(jarEntry1.getCertificates());
- assertNotNull(jarEntry2.getCertificates());
- in.close();
}
- /**
- * java.util.jar.JarEntry#getCodeSigners()
- */
public void test_getCodeSigners() throws IOException {
String jarFileName = "TestCodeSigners.jar";
Support_Resources.copyFile(resources, null, jarFileName);
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/HandshakeCompletedEventTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/HandshakeCompletedEventTest.java
index ec2f4f31..bb2265f 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/HandshakeCompletedEventTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/HandshakeCompletedEventTest.java
@@ -17,7 +17,6 @@
package org.apache.harmony.tests.javax.net.ssl;
-import dalvik.annotation.AndroidOnly;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -334,7 +333,6 @@
* because our self-signed test certificates are not valid.)
*/
- @AndroidOnly("Uses bks key store. Change useBKS to false to run on the RI")
public void testClientAuth() throws Exception {
boolean useBKS = true;
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLSocketTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLSocketTest.java
index 11e3142..861f4a8 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLSocketTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLSocketTest.java
@@ -15,7 +15,6 @@
*/
package org.apache.harmony.tests.javax.net.ssl;
-import dalvik.annotation.AndroidOnly;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -223,7 +222,7 @@
/**
* javax.net.ssl.SSLSocket#addHandshakeCompletedListener(HandshakeCompletedListener listener)
*/
- @AndroidOnly("RI doesn't throw the specified IAE")
+ // AndroidOnly("RI doesn't throw the specified IAE")
public void test_addHandshakeCompletedListener() throws IOException {
SSLSocket ssl = getSSLSocket();
HandshakeCompletedListener ls = new HandshakeCL();
diff --git a/luni/src/test/java/org/apache/harmony/security/tests/provider/crypto/SHA1PRNG_SecureRandomTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/security/OldSHA1PRNGSecureRandomTest.java
similarity index 87%
rename from luni/src/test/java/org/apache/harmony/security/tests/provider/crypto/SHA1PRNG_SecureRandomTest.java
rename to harmony-tests/src/test/java/org/apache/harmony/tests/javax/security/OldSHA1PRNGSecureRandomTest.java
index 0db5ee1..b213b47 100644
--- a/luni/src/test/java/org/apache/harmony/security/tests/provider/crypto/SHA1PRNG_SecureRandomTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/security/OldSHA1PRNGSecureRandomTest.java
@@ -15,10 +15,8 @@
* limitations under the License.
*/
-package org.apache.harmony.security.tests.provider.crypto;
+package org.apache.harmony.tests.javax.security;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
@@ -29,7 +27,7 @@
* Tests against methods in SecureRandom class object using
* SHA1PRNG_SecureRandomImpl.
*/
-public class SHA1PRNG_SecureRandomTest extends TestCase {
+public class OldSHA1PRNGSecureRandomTest extends TestCase {
private static final int LENGTH = 20; // constant defining loop limit
@@ -37,8 +35,6 @@
private static final String algorithm = "SHA1PRNG"; // algorithm's name
- private static final String provider = "Crypto"; // provider's name
-
private static SecureRandom sr; // fields used by tests
private static SecureRandom sr2; //
@@ -48,8 +44,8 @@
*/
protected void setUp() throws Exception {
super.setUp();
- sr = SecureRandom.getInstance(algorithm, provider);
- sr2 = SecureRandom.getInstance(algorithm, provider);
+ sr = SecureRandom.getInstance(algorithm);
+ sr2 = SecureRandom.getInstance(algorithm);
}
/**
@@ -189,8 +185,8 @@
byte[] myBytes2;
for (int i = 1; i < LENGTH / 2; i += INCR) {
- sr1 = SecureRandom.getInstance(algorithm, provider);
- sr2 = SecureRandom.getInstance(algorithm, provider);
+ sr1 = SecureRandom.getInstance(algorithm);
+ sr2 = SecureRandom.getInstance(algorithm);
boolean flag = true;
@@ -245,8 +241,8 @@
// case 1:
for (int i = 1; i < LENGTH / 2; i += INCR) {
- sr1 = SecureRandom.getInstance(algorithm, provider);
- sr2 = SecureRandom.getInstance(algorithm, provider);
+ sr1 = SecureRandom.getInstance(algorithm);
+ sr2 = SecureRandom.getInstance(algorithm);
sr1.nextBytes(new byte[0]);
sr2.nextBytes(new byte[0]);
@@ -286,8 +282,8 @@
byte[][] bytes1 = new byte[2][n];
byte[][] bytes2 = new byte[2][n];
- sr1 = SecureRandom.getInstance(algorithm, provider);
- sr2 = SecureRandom.getInstance(algorithm, provider);
+ sr1 = SecureRandom.getInstance(algorithm);
+ sr2 = SecureRandom.getInstance(algorithm);
sr1.setSeed(myBytes);
sr2.setSeed(myBytes);
@@ -402,31 +398,4 @@
assertFalse("sequences are equal i=" + i, b);
}
}
-
- public void testSeedIsFullLength() throws Exception {
- Class<?> srClass = Class.forName(
- "org.apache.harmony.security.provider.crypto.SHA1PRNG_SecureRandomImpl");
- Field seedField = srClass.getDeclaredField("seed");
- seedField.setAccessible(true);
-
- Method nextBytesMethod = srClass.getDeclaredMethod("engineNextBytes", byte[].class);
- nextBytesMethod.setAccessible(true);
-
- byte[] bytes = new byte[1];
-
- // Iterate 8 times to make sure the probability of a false positive is
- // extremely rare.
- for (int i = 0; i < 8; i++) {
- Object sr = srClass.newInstance();
- nextBytesMethod.invoke(sr, bytes);
- int[] seed = (int[]) seedField.get(sr);
-
- // If the first integer is not zero, it is fixed.
- if (seed[0] != 0) {
- return; // Success
- }
- }
-
- fail("Fallback SHA1PRNG_SecureRandomImpl should not clobber seed internally");
- }
}
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/javax/xml/parsers/SAXParserFactoryTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/xml/parsers/SAXParserFactoryTest.java
index 614b9d8..4e1ffdf 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/javax/xml/parsers/SAXParserFactoryTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/xml/parsers/SAXParserFactoryTest.java
@@ -35,7 +35,6 @@
import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.helpers.DefaultHandler;
-import dalvik.annotation.AndroidOnly;
import dalvik.annotation.KnownFailure;
public class SAXParserFactoryTest extends TestCase {
@@ -65,7 +64,7 @@
super.tearDown();
}
- @AndroidOnly("Android SAX implementation is non-validating")
+ // AndroidOnly("Android SAX implementation is non-validating")
public void test_Constructor() {
MySAXParserFactory mpf = new MySAXParserFactory();
assertTrue(mpf instanceof SAXParserFactory);
diff --git a/libart/src/main/java/java/lang/Class.java b/libart/src/main/java/java/lang/Class.java
index 5736efb..60052b8 100644
--- a/libart/src/main/java/java/lang/Class.java
+++ b/libart/src/main/java/java/lang/Class.java
@@ -583,7 +583,7 @@
* {@code (Class[]) null} is equivalent to the empty array.
* @return the method described by {@code name} and {@code parameterTypes}.
* @throws NoSuchMethodException
- * if the requested constructor cannot be found.
+ * if the requested method cannot be found.
* @throws NullPointerException
* if {@code name} is {@code null}.
* @see #getMethod(String, Class[])
diff --git a/luni/src/main/java/android/system/OsConstants.java b/luni/src/main/java/android/system/OsConstants.java
index b3ad5b6..f0d77de 100644
--- a/luni/src/main/java/android/system/OsConstants.java
+++ b/luni/src/main/java/android/system/OsConstants.java
@@ -350,6 +350,7 @@
public static final int O_RDONLY = placeholder();
public static final int O_RDWR = placeholder();
public static final int O_SYNC = placeholder();
+ /** @hide */ public static final int O_DSYNC = placeholder();
public static final int O_TRUNC = placeholder();
public static final int O_WRONLY = placeholder();
public static final int POLLERR = placeholder();
diff --git a/luni/src/main/java/java/io/RandomAccessFile.java b/luni/src/main/java/java/io/RandomAccessFile.java
index 0e4fa4f..42c30c4 100644
--- a/luni/src/main/java/java/io/RandomAccessFile.java
+++ b/luni/src/main/java/java/io/RandomAccessFile.java
@@ -44,8 +44,6 @@
*/
private FileDescriptor fd;
- private boolean syncMetadata = false;
-
// The unique file channel associated with this FileInputStream (lazily
// initialized).
private FileChannel channel;
@@ -104,11 +102,11 @@
} else if (mode.equals("rw") || mode.equals("rws") || mode.equals("rwd")) {
flags = O_RDWR | O_CREAT;
if (mode.equals("rws")) {
- // Sync file and metadata with every write
- syncMetadata = true;
- } else if (mode.equals("rwd")) {
- // Sync file, but not necessarily metadata
+ // Sync data and metadata with every write
flags |= O_SYNC;
+ } else if (mode.equals("rwd")) {
+ // Sync data, but not necessarily metadata
+ flags |= O_DSYNC;
}
} else {
throw new IllegalArgumentException("Invalid mode: " + mode);
@@ -116,14 +114,6 @@
this.mode = flags;
this.fd = IoBridge.open(file.getPath(), flags);
- // if we are in "rws" mode, attempt to sync file+metadata
- if (syncMetadata) {
- try {
- fd.sync();
- } catch (IOException e) {
- // Ignored
- }
- }
guard.open("close");
}
@@ -635,10 +625,6 @@
seek(newLength);
}
- // if we are in "rws" mode, attempt to sync file+metadata
- if (syncMetadata) {
- fd.sync();
- }
}
/**
@@ -689,10 +675,6 @@
*/
public void write(byte[] buffer, int byteOffset, int byteCount) throws IOException {
IoBridge.write(fd, buffer, byteOffset, byteCount);
- // if we are in "rws" mode, attempt to sync file+metadata
- if (syncMetadata) {
- fd.sync();
- }
}
/**
diff --git a/luni/src/main/java/java/security/SecureRandom.java b/luni/src/main/java/java/security/SecureRandom.java
index 7a03801..8fbcc39 100644
--- a/luni/src/main/java/java/security/SecureRandom.java
+++ b/luni/src/main/java/java/security/SecureRandom.java
@@ -23,7 +23,6 @@
import libcore.io.SizeOf;
import org.apache.harmony.security.fortress.Engine;
import org.apache.harmony.security.fortress.Services;
-import org.apache.harmony.security.provider.crypto.SHA1PRNG_SecureRandomImpl;
/**
* This class generates cryptographically secure pseudo-random numbers.
@@ -86,12 +85,8 @@
*/
public SecureRandom() {
super(0);
- Provider.Service service = Services.getSecureRandomService();
- if (service == null) {
- this.provider = null;
- this.secureRandomSpi = new SHA1PRNG_SecureRandomImpl();
- this.algorithm = "SHA1PRNG";
- } else {
+ final Provider.Service service = Services.getSecureRandomService();
+ if (service != null) {
try {
this.provider = service.getProvider();
this.secureRandomSpi = (SecureRandomSpi)service.newInstance(null);
@@ -99,6 +94,8 @@
} catch (Exception e) {
throw new RuntimeException(e);
}
+ } else {
+ throw new AssertionError("Services.getSecureRandomService() == null");
}
}
diff --git a/luni/src/main/java/java/security/Security.java b/luni/src/main/java/java/security/Security.java
index aeb189f..723b0eb 100644
--- a/luni/src/main/java/java/security/Security.java
+++ b/luni/src/main/java/java/security/Security.java
@@ -90,8 +90,7 @@
private static void registerDefaultProviders() {
secprops.put("security.provider.1", "com.android.org.conscrypt.OpenSSLProvider");
secprops.put("security.provider.2", "com.android.org.bouncycastle.jce.provider.BouncyCastleProvider");
- secprops.put("security.provider.3", "org.apache.harmony.security.provider.crypto.CryptoProvider");
- secprops.put("security.provider.4", "com.android.org.conscrypt.JSSEProvider");
+ secprops.put("security.provider.3", "com.android.org.conscrypt.JSSEProvider");
}
/**
diff --git a/luni/src/main/java/java/security/security.properties b/luni/src/main/java/java/security/security.properties
index a06283b..289efa9 100644
--- a/luni/src/main/java/java/security/security.properties
+++ b/luni/src/main/java/java/security/security.properties
@@ -22,9 +22,8 @@
security.provider.1=com.android.org.conscrypt.OpenSSLProvider
# Android's stripped down BouncyCastle provider
security.provider.2=com.android.org.bouncycastle.jce.provider.BouncyCastleProvider
-# Remaining Harmony providers
-security.provider.3=org.apache.harmony.security.provider.crypto.CryptoProvider
-security.provider.4=com.android.org.conscrypt.JSSEProvider
+# Android's provider of OpenSSL backed implementations
+security.provider.3=com.android.org.conscrypt.JSSEProvider
diff --git a/luni/src/main/java/java/text/Normalizer.java b/luni/src/main/java/java/text/Normalizer.java
index 2e6647e..5355014 100644
--- a/luni/src/main/java/java/text/Normalizer.java
+++ b/luni/src/main/java/java/text/Normalizer.java
@@ -16,8 +16,6 @@
package java.text;
-import libcore.icu.NativeNormalizer;
-
/**
* Provides normalization functions according to
* <a href="http://www.unicode.org/unicode/reports/tr15/tr15-23.html">Unicode Standard Annex #15:
@@ -36,22 +34,32 @@
/**
* Normalization Form D - Canonical Decomposition.
*/
- NFD,
+ NFD(com.ibm.icu.text.Normalizer.NFD),
/**
* Normalization Form C - Canonical Decomposition, followed by Canonical Composition.
*/
- NFC,
+ NFC(com.ibm.icu.text.Normalizer.NFC),
/**
* Normalization Form KD - Compatibility Decomposition.
*/
- NFKD,
+ NFKD(com.ibm.icu.text.Normalizer.NFKD),
/**
* Normalization Form KC - Compatibility Decomposition, followed by Canonical Composition.
*/
- NFKC;
+ NFKC(com.ibm.icu.text.Normalizer.NFKC);
+
+ private final com.ibm.icu.text.Normalizer.Mode icuForm;
+
+ Form(com.ibm.icu.text.Normalizer.Mode icuForm) {
+ this.icuForm = icuForm;
+ }
+
+ com.ibm.icu.text.Normalizer.Mode getIcuForm() {
+ return icuForm;
+ }
}
/**
@@ -63,7 +71,7 @@
* @return true if normalized according to <code>form</code>
*/
public static boolean isNormalized(CharSequence src, Form form) {
- return NativeNormalizer.isNormalized(src, form);
+ return com.ibm.icu.text.Normalizer.isNormalized(src.toString(), form.getIcuForm(), 0);
}
/**
@@ -75,7 +83,7 @@
* @return string normalized according to <code>form</code>
*/
public static String normalize(CharSequence src, Form form) {
- return NativeNormalizer.normalize(src, form);
+ return com.ibm.icu.text.Normalizer.normalize(src.toString(), form.getIcuForm());
}
private Normalizer() {}
diff --git a/luni/src/main/java/libcore/icu/NativeNormalizer.java b/luni/src/main/java/libcore/icu/NativeNormalizer.java
deleted file mode 100644
index a5d8da2..0000000
--- a/luni/src/main/java/libcore/icu/NativeNormalizer.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2010 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 libcore.icu;
-
-import java.text.Normalizer.Form;
-
-public final class NativeNormalizer {
- public static boolean isNormalized(CharSequence src, Form form) {
- return isNormalizedImpl(src.toString(), toUNormalizationMode(form));
- }
-
- public static String normalize(CharSequence src, Form form) {
- return normalizeImpl(src.toString(), toUNormalizationMode(form));
- }
-
- private static int toUNormalizationMode(Form form) {
- // Translates Java enum constants to ICU int constants.
- // See UNormalizationMode in "unicode/unorm.h". Stable API since ICU 2.0.
- switch (form) {
- case NFC: return 4;
- case NFD: return 2;
- case NFKC: return 5;
- case NFKD: return 3;
- }
- throw new AssertionError("unknown Normalizer.Form " + form);
- }
-
- private static native String normalizeImpl(String src, int form);
-
- private static native boolean isNormalizedImpl(String src, int form);
-
- private NativeNormalizer() {}
-}
diff --git a/luni/src/main/java/libcore/icu/NativePluralRules.java b/luni/src/main/java/libcore/icu/NativePluralRules.java
deleted file mode 100644
index f9fe74b..0000000
--- a/luni/src/main/java/libcore/icu/NativePluralRules.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2010 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 libcore.icu;
-
-import java.util.Locale;
-
-/**
- * Provides access to ICU's
- * <a href="http://icu-project.org/apiref/icu4c/classPluralRules.html">PluralRules</a> class.
- * This is not necessary for Java API, but is used by frameworks/base's resources system to
- * ease localization of strings to languages with complex grammatical rules regarding number.
- */
-public final class NativePluralRules {
- public static final int ZERO = 0;
- public static final int ONE = 1;
- public static final int TWO = 2;
- public static final int FEW = 3;
- public static final int MANY = 4;
- public static final int OTHER = 5;
-
- private final long address;
-
- private NativePluralRules(long address) {
- this.address = address;
- }
-
- @Override protected void finalize() throws Throwable {
- try {
- finalizeImpl(address);
- } finally {
- super.finalize();
- }
- }
-
- public static NativePluralRules forLocale(Locale locale) {
- return new NativePluralRules(forLocaleImpl(locale.toString()));
- }
-
- /**
- * Returns the constant defined in this class corresponding
- * to the first rule that matches the given value.
- */
- public int quantityForInt(int value) {
- // Pre-L compatibility. http://b/18429565.
- if (value < 0) {
- return OTHER;
- }
- return quantityForIntImpl(address, value);
- }
-
- private static native void finalizeImpl(long address);
- private static native long forLocaleImpl(String localeName);
- private static native int quantityForIntImpl(long address, int value);
-}
diff --git a/luni/src/main/java/org/apache/harmony/security/PrivateKeyImpl.java b/luni/src/main/java/org/apache/harmony/security/PrivateKeyImpl.java
deleted file mode 100644
index 47aceb3..0000000
--- a/luni/src/main/java/org/apache/harmony/security/PrivateKeyImpl.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.harmony.security;
-
-import java.security.PrivateKey;
-
-/**
- * PrivateKeyImpl
- */
-public class PrivateKeyImpl implements PrivateKey {
-
- /*
- * @serial
- */
- private static final long serialVersionUID = 7776497482533790279L;
-
- private String algorithm;
-
- private byte[] encoding;
-
- public PrivateKeyImpl(String algorithm) {
- this.algorithm = algorithm;
- }
-
- public String getAlgorithm() {
- return algorithm;
- }
-
- public String getFormat() {
- return "PKCS#8";
- }
-
- public byte[] getEncoded() {
-
- byte[] toReturn = new byte[encoding.length];
- System.arraycopy(encoding, 0, toReturn, 0, encoding.length);
-
- return toReturn;
- }
-
- public void setAlgorithm(String algorithm) {
- this.algorithm = algorithm;
- }
-
- public void setEncoding(byte[] encoding) {
- this.encoding = new byte[encoding.length];
- System.arraycopy(encoding, 0, this.encoding, 0, encoding.length);
- }
-
-}
diff --git a/luni/src/main/java/org/apache/harmony/security/PublicKeyImpl.java b/luni/src/main/java/org/apache/harmony/security/PublicKeyImpl.java
deleted file mode 100644
index dccc72d..0000000
--- a/luni/src/main/java/org/apache/harmony/security/PublicKeyImpl.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.harmony.security;
-
-import java.security.PublicKey;
-
-
-/**
- * PublicKeyImpl
- */
-public class PublicKeyImpl implements PublicKey {
-
- /**
- * @serial
- */
- private static final long serialVersionUID = 7179022516819534075L;
-
-
- private byte[] encoding;
-
- private String algorithm;
-
-
- public PublicKeyImpl(String algorithm) {
- this.algorithm = algorithm;
- }
-
-
- public String getAlgorithm() {
- return algorithm;
- }
-
-
- public String getFormat() {
- return "X.509";
- }
-
-
- public byte[] getEncoded() {
- byte[] result = new byte[encoding.length];
- System.arraycopy(encoding, 0, result, 0, encoding.length);
- return result;
- }
-
-
- public void setAlgorithm(String algorithm) {
- this.algorithm = algorithm;
- }
-
-
- public void setEncoding(byte[] encoding) {
- this.encoding = new byte[encoding.length];
- System.arraycopy(encoding, 0, this.encoding, 0, encoding.length);
- }
-}
-
diff --git a/luni/src/main/java/org/apache/harmony/security/pkcs10/CertificationRequest.java b/luni/src/main/java/org/apache/harmony/security/pkcs10/CertificationRequest.java
deleted file mode 100644
index 3d36d37..0000000
--- a/luni/src/main/java/org/apache/harmony/security/pkcs10/CertificationRequest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.harmony.security.pkcs10;
-
-import org.apache.harmony.security.asn1.ASN1BitString;
-import org.apache.harmony.security.asn1.ASN1Sequence;
-import org.apache.harmony.security.asn1.ASN1Type;
-import org.apache.harmony.security.asn1.BerInputStream;
-import org.apache.harmony.security.asn1.BitString;
-import org.apache.harmony.security.x509.AlgorithmIdentifier;
-
-/**
- * The class implements the ASN.1 DER encoding and decoding of the PKCS#10
- * Certificate Signing Request (CSR). Its ASN notation is as follows:
- *
- * CertificationRequest ::= SEQUENCE {
- * certificationRequestInfo CertificationRequestInfo,
- * signatureAlgorithm SignatureAlgorithmIdentifier,
- * signature Signature
- * }
- *
- * SignatureAlgorithmIdentifier ::= AlgorithmIdentifier
- *
- * Signature ::= BIT STRING
- */
-public final class CertificationRequest {
-
- /** the value of certificationRequestInfo field of the structure */
- private CertificationRequestInfo info;
-
- /** the value of signatureAlgorithm field of the structure */
- private AlgorithmIdentifier algId;
-
- /** the value of signature field of the structure */
- private byte[] signature;
-
- /** the ASN.1 encoded form of CertificationRequest */
- private byte[] encoding;
-
- public CertificationRequest(CertificationRequestInfo info,
- AlgorithmIdentifier algId, byte[] signature) {
- this.info = info;
- this.algId = algId;
- this.signature = signature.clone();
- }
-
- private CertificationRequest(CertificationRequestInfo info,
- AlgorithmIdentifier algId, byte[] signature, byte[] encoding) {
- this(info, algId, signature);
- this.encoding = encoding;
- }
-
- public CertificationRequestInfo getInfo() {
- return info;
- }
-
- public byte[] getSignature() {
- byte[] result = new byte[signature.length];
- System.arraycopy(signature, 0, result, 0, signature.length);
- return result;
- }
-
- /**
- * Returns ASN.1 encoded form of this CertificationRequest value.
- * @return a byte array containing ASN.1 encode form.
- */
- public byte[] getEncoded() {
- if (encoding == null) {
- encoding = CertificationRequest.ASN1.encode(this);
- }
- return encoding;
- }
-
- public static final ASN1Sequence ASN1 = new ASN1Sequence(new ASN1Type[] {
- CertificationRequestInfo.ASN1, // info
- AlgorithmIdentifier.ASN1, // signatureAlgorithm
- ASN1BitString.getInstance() }) // signature
- {
-
- public Object getDecodedObject(BerInputStream in) {
- Object[] values = (Object[]) in.content;
- return new CertificationRequest(
- (CertificationRequestInfo) values[0],
- (AlgorithmIdentifier) values[1],
- ((BitString) values[2]).bytes,
- in.getEncoded());
- }
-
- protected void getValues(Object object, Object[] values) {
- CertificationRequest certReq = (CertificationRequest) object;
- values[0] = certReq.info;
- values[1] = certReq.algId;
- values[2] = new BitString(certReq.signature, 0);
- }
- };
-}
-
diff --git a/luni/src/main/java/org/apache/harmony/security/pkcs10/CertificationRequestInfo.java b/luni/src/main/java/org/apache/harmony/security/pkcs10/CertificationRequestInfo.java
deleted file mode 100644
index d13f952..0000000
--- a/luni/src/main/java/org/apache/harmony/security/pkcs10/CertificationRequestInfo.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.harmony.security.pkcs10;
-
-import java.util.List;
-import javax.security.auth.x500.X500Principal;
-import org.apache.harmony.security.asn1.ASN1Implicit;
-import org.apache.harmony.security.asn1.ASN1Integer;
-import org.apache.harmony.security.asn1.ASN1Sequence;
-import org.apache.harmony.security.asn1.ASN1SetOf;
-import org.apache.harmony.security.asn1.ASN1Type;
-import org.apache.harmony.security.asn1.BerInputStream;
-import org.apache.harmony.security.x501.AttributeTypeAndValue;
-import org.apache.harmony.security.x501.Name;
-import org.apache.harmony.security.x509.SubjectPublicKeyInfo;
-
-/**
- * CertificationRequestInfo ::= SEQUENCE {
- * version Version,
- * subject Name,
- * subjectPublicKeyInfo SubjectPublicKeyInfo,
- * attributes [0] IMPLICIT Attributes }
- *
- * Version ::= INTEGER
- *
- * Attributes ::= SET OF Attribute
- */
-public final class CertificationRequestInfo {
- private final int version;
-
- /** the value of subject field of the structure */
- private final Name subject;
-
- /** the value of subjectPublicKeyInfo field of the structure */
- private final SubjectPublicKeyInfo subjectPublicKeyInfo;
-
- /** the value of attributes field of the structure */
- private final List<?> attributes;
-
- /** the ASN.1 encoded form of CertificationRequestInfo */
- private byte[] encoding;
-
- private CertificationRequestInfo(int version, Name subject,
- SubjectPublicKeyInfo subjectPublicKeyInfo, List<?> attributes, byte [] encoding) {
- this.version = version;
- this.subject = subject;
- this.subjectPublicKeyInfo = subjectPublicKeyInfo;
- this.attributes = attributes;
- this.encoding = encoding;
- }
-
- public Name getSubject() {
- return subject;
- }
-
- public int getVersion() {
- return version;
- }
-
- /**
- * Returns ASN.1 encoded form of this CertificationRequestInfo.
- * @return a byte array containing ASN.1 encode form.
- */
- public byte[] getEncoded() {
- if (encoding == null) {
- encoding = ASN1.encode(this);
- }
- return encoding;
- }
-
- @Override public String toString() {
- StringBuilder res = new StringBuilder();
- res.append("-- CertificationRequestInfo:");
- res.append("\n version: ");
- res.append(version);
- res.append("\n subject: ");
- res.append(subject.getName(X500Principal.CANONICAL));
- res.append("\n subjectPublicKeyInfo: ");
- res.append("\n\t algorithm: ");
- res.append(subjectPublicKeyInfo.getAlgorithmIdentifier().getAlgorithm());
- res.append("\n\t public key: ").append(subjectPublicKeyInfo.getPublicKey());
- res.append("\n attributes: ");
- if (attributes != null) {
- res.append(attributes.toString());
- } else {
- res.append("none");
- }
- res.append("\n-- CertificationRequestInfo End\n");
- return res.toString();
- }
-
- public static final ASN1Sequence ASN1 = new ASN1Sequence(new ASN1Type[] {
- ASN1Integer.getInstance(), // version
- Name.ASN1, // subject
- SubjectPublicKeyInfo.ASN1, // subjectPublicKeyInfo
- new ASN1Implicit(0, new ASN1SetOf(
- AttributeTypeAndValue.ASN1)) // attributes
- }) {
-
- @Override protected Object getDecodedObject(BerInputStream in) {
- Object[] values = (Object[]) in.content;
- return new CertificationRequestInfo(
- ASN1Integer.toIntValue(values[0]),
- (Name) values[1],
- (SubjectPublicKeyInfo) values[2],
- (List<?>) values[3],
- in.getEncoded());
- }
-
- @Override protected void getValues(Object object, Object[] values) {
- CertificationRequestInfo certReqInfo = (CertificationRequestInfo) object;
- values[0] = ASN1Integer.fromIntValue(certReqInfo.version);
- values[1] = certReqInfo.subject;
- values[2] = certReqInfo.subjectPublicKeyInfo;
- values[3] = certReqInfo.attributes;
- }
- };
-}
-
diff --git a/luni/src/main/java/org/apache/harmony/security/pkcs8/PrivateKeyInfo.java b/luni/src/main/java/org/apache/harmony/security/pkcs8/PrivateKeyInfo.java
deleted file mode 100644
index 400bf86..0000000
--- a/luni/src/main/java/org/apache/harmony/security/pkcs8/PrivateKeyInfo.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.harmony.security.pkcs8;
-
-import java.util.List;
-import org.apache.harmony.security.asn1.ASN1Implicit;
-import org.apache.harmony.security.asn1.ASN1Integer;
-import org.apache.harmony.security.asn1.ASN1OctetString;
-import org.apache.harmony.security.asn1.ASN1Sequence;
-import org.apache.harmony.security.asn1.ASN1SetOf;
-import org.apache.harmony.security.asn1.ASN1Type;
-import org.apache.harmony.security.asn1.BerInputStream;
-import org.apache.harmony.security.x501.AttributeTypeAndValue;
-import org.apache.harmony.security.x509.AlgorithmIdentifier;
-
-/**
- * The class implements the ASN.1 DER encoding and decoding of the PKCS#8
- * PrivateKeyInfo having the following ASN.1 notation:
- *
- * PrivateKeyInfo ::= SEQUENCE {
- * version Version,
- * privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,
- * privateKey PrivateKey,
- * attributes [0] IMPLICIT Attributes OPTIONAL }
- *
- * Version ::= INTEGER
- *
- * PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier
- *
- * PrivateKey ::= OCTET STRING
- *
- * Attributes ::= SET OF Attribute
- */
-public final class PrivateKeyInfo {
- private final int version;
- private final AlgorithmIdentifier privateKeyAlgorithm;
- private final byte[] privateKey;
- private final List<?> attributes;
- private byte[] encoding;
-
- public PrivateKeyInfo(int version, AlgorithmIdentifier privateKeyAlgorithm,
- byte[] privateKey, List attributes) {
- this.version = version;
- this.privateKeyAlgorithm = privateKeyAlgorithm;
- this.privateKey = privateKey;
- this.attributes = attributes;
- }
-
- private PrivateKeyInfo(int version,
- AlgorithmIdentifier privateKeyAlgorithm, byte[] privateKey,
- List attributes, byte[] encoding) {
- this(version, privateKeyAlgorithm, privateKey, attributes);
- this.encoding = encoding;
- }
-
- public int getVersion() {
- return version;
- }
-
- public AlgorithmIdentifier getAlgorithmIdentifier() {
- return privateKeyAlgorithm;
- }
-
- public List getAttributes() {
- return attributes;
- }
-
- /**
- * Returns the OCTET STRING.
- */
- public byte[] getPrivateKey() {
- return privateKey;
- }
-
- /**
- * Returns ASN.1 encoded form of this PrivateKeyInfo.
- */
- public byte[] getEncoded() {
- if (encoding == null) {
- encoding = ASN1.encode(this);
- }
- return encoding;
- }
-
- public static final ASN1Sequence ASN1 = new ASN1Sequence(new ASN1Type[] {
-
- ASN1Integer.getInstance(), // version
- AlgorithmIdentifier.ASN1, // AlgorithmIdentifier
- ASN1OctetString.getInstance(), // privateKey
-
- new ASN1Implicit(0, new ASN1SetOf(AttributeTypeAndValue.ASN1)) // attributes
- }) {
-
- {
- setOptional(3); // attributes are OPTIONAL
- }
-
- protected Object getDecodedObject(BerInputStream in) {
- Object[] values = (Object[]) in.content;
- return new PrivateKeyInfo(ASN1Integer.toIntValue(values[0]),
- (AlgorithmIdentifier) values[1], (byte[]) values[2],
- (List) values[3], in.getEncoded());
- }
-
- protected void getValues(Object object, Object[] values) {
- PrivateKeyInfo privateKeyInfo = (PrivateKeyInfo) object;
- values[0] = ASN1Integer.fromIntValue(privateKeyInfo.version);
- values[1] = privateKeyInfo.privateKeyAlgorithm;
- values[2] = privateKeyInfo.privateKey;
- values[3] = privateKeyInfo.attributes;
- }
- };
-}
diff --git a/luni/src/main/java/org/apache/harmony/security/provider/crypto/CryptoProvider.java b/luni/src/main/java/org/apache/harmony/security/provider/crypto/CryptoProvider.java
deleted file mode 100644
index ad5ac7d..0000000
--- a/luni/src/main/java/org/apache/harmony/security/provider/crypto/CryptoProvider.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.harmony.security.provider.crypto;
-
-import java.security.Provider;
-
-/**
- * Implementation of Provider for SecureRandom. The implementation supports the
- * "SHA1PRNG" algorithm described in JavaTM Cryptography Architecture, API
- * Specification & Reference
- */
-
-public final class CryptoProvider extends Provider {
-
- private static final long serialVersionUID = 7991202868423459598L;
-
- /**
- * Creates a Provider and puts parameters
- */
- public CryptoProvider() {
- super("Crypto", 1.0, "HARMONY (SHA1 digest; SecureRandom; SHA1withDSA signature)");
-
- put("SecureRandom.SHA1PRNG",
- "org.apache.harmony.security.provider.crypto.SHA1PRNG_SecureRandomImpl");
- put("SecureRandom.SHA1PRNG ImplementedIn", "Software");
- }
-}
diff --git a/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1Constants.java b/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1Constants.java
deleted file mode 100644
index fc6a847..0000000
--- a/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1Constants.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-/**
-* @author Yuri A. Kropachev
-* @version $Revision$
-*/
-
-
-package org.apache.harmony.security.provider.crypto;
-
-
-/**
- * This interface contains : <BR>
- * - a set of constant values, H0-H4, defined in "SECURE HASH STANDARD", FIPS PUB 180-2 ;<BR>
- * - implementation constant values to use in classes using SHA-1 algorithm. <BR>
- */
-public final class SHA1Constants {
- private SHA1Constants() {
- }
-
- /**
- * constant defined in "SECURE HASH STANDARD"
- */
- public static final int H0 = 0x67452301;
-
-
- /**
- * constant defined in "SECURE HASH STANDARD"
- */
- public static final int H1 = 0xEFCDAB89;
-
-
- /**
- * constant defined in "SECURE HASH STANDARD"
- */
- public static final int H2 = 0x98BADCFE;
-
-
- /**
- * constant defined in "SECURE HASH STANDARD"
- */
- public static final int H3 = 0x10325476;
-
-
- /**
- * constant defined in "SECURE HASH STANDARD"
- */
- public static final int H4 = 0xC3D2E1F0;
-
-
- /**
- * offset in buffer to store number of bytes in 0-15 word frame
- */
- public static final int BYTES_OFFSET = 81;
-
-
- /**
- * offset in buffer to store current hash value
- */
- public static final int HASH_OFFSET = 82;
-
-
- /**
- * # of bytes in H0-H4 words; <BR>
- * in this implementation # is set to 20 (in general # varies from 1 to 20)
- */
- public static final int DIGEST_LENGTH = 20;
-}
diff --git a/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1Impl.java b/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1Impl.java
deleted file mode 100644
index 57b9005..0000000
--- a/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1Impl.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-/**
-* @author Yuri A. Kropachev
-* @version $Revision$
-*/
-
-
-package org.apache.harmony.security.provider.crypto;
-
-import static org.apache.harmony.security.provider.crypto.SHA1Constants.*;
-
-/**
- * This class contains methods providing SHA-1 functionality to use in classes. <BR>
- * The methods support the algorithm described in "SECURE HASH STANDARD", FIPS PUB 180-2, <BR>
- * "http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf" <BR>
- * <BR>
- * The class contains two package level access methods, -
- * "void updateHash(int[], byte[], int, int)" and "void computeHash(int[])", -
- * performing the following operations. <BR>
- * <BR>
- * The "updateHash(..)" method appends new bytes to existing ones
- * within limit of a frame of 64 bytes (16 words).
- * Once a length of accumulated bytes reaches the limit
- * the "computeHash(int[])" method is invoked on the frame to compute updated hash,
- * and the number of bytes in the frame is set to 0.
- * Thus, after appending all bytes, the frame contain only those bytes
- * that were not used in computing final hash value yet. <BR>
- * <BR>
- * The "computeHash(..)" method generates a 160 bit hash value using
- * a 512 bit message stored in first 16 words of int[] array argument and
- * current hash value stored in five words, beginning HASH_OFFSET, of the array argument.
- * Computation is done according to SHA-1 algorithm. <BR>
- * <BR>
- * The resulting hash value replaces the previous hash value in the array;
- * original bits of the message are not preserved.
- */
-public class SHA1Impl {
-
-
- /**
- * The method generates a 160 bit hash value using
- * a 512 bit message stored in first 16 words of int[] array argument and
- * current hash value stored in five words, beginning OFFSET+1, of the array argument.
- * Computation is done according to SHA-1 algorithm.
- *
- * The resulting hash value replaces the previous hash value in the array;
- * original bits of the message are not preserved.
- *
- * No checks on argument supplied, that is,
- * a calling method is responsible for such checks.
- * In case of incorrect array passed to the method
- * either NPE or IndexOutOfBoundException gets thrown by JVM.
- *
- * @params
- * arrW - integer array; arrW.length >= (BYTES_OFFSET+6); <BR>
- * only first (BYTES_OFFSET+6) words are used
- */
- static void computeHash(int[] arrW) {
-
- int a = arrW[HASH_OFFSET ];
- int b = arrW[HASH_OFFSET +1];
- int c = arrW[HASH_OFFSET +2];
- int d = arrW[HASH_OFFSET +3];
- int e = arrW[HASH_OFFSET +4];
-
- int temp;
-
- // In this implementation the "d. For t = 0 to 79 do" loop
- // is split into four loops. The following constants:
- // K = 5A827999 0 <= t <= 19
- // K = 6ED9EBA1 20 <= t <= 39
- // K = 8F1BBCDC 40 <= t <= 59
- // K = CA62C1D6 60 <= t <= 79
- // are hex literals in the loops.
-
- for ( int t = 16; t < 80 ; t++ ) {
-
- temp = arrW[t-3] ^ arrW[t-8] ^ arrW[t-14] ^ arrW[t-16];
- arrW[t] = ( temp<<1 ) | ( temp>>>31 );
- }
-
- for ( int t = 0 ; t < 20 ; t++ ) {
-
- temp = ( ( a<<5 ) | ( a>>>27 ) ) +
- ( ( b & c) | ((~b) & d) ) +
- ( e + arrW[t] + 0x5A827999 ) ;
- e = d;
- d = c;
- c = ( b<<30 ) | ( b>>>2 ) ;
- b = a;
- a = temp;
- }
- for ( int t = 20 ; t < 40 ; t++ ) {
-
- temp = ((( a<<5 ) | ( a>>>27 ))) + (b ^ c ^ d) + (e + arrW[t] + 0x6ED9EBA1) ;
- e = d;
- d = c;
- c = ( b<<30 ) | ( b>>>2 ) ;
- b = a;
- a = temp;
- }
- for ( int t = 40 ; t < 60 ; t++ ) {
-
- temp = (( a<<5 ) | ( a>>>27 )) + ((b & c) | (b & d) | (c & d)) +
- (e + arrW[t] + 0x8F1BBCDC) ;
- e = d;
- d = c;
- c = ( b<<30 ) | ( b>>>2 ) ;
- b = a;
- a = temp;
- }
- for ( int t = 60 ; t < 80 ; t++ ) {
-
- temp = ((( a<<5 ) | ( a>>>27 ))) + (b ^ c ^ d) + (e + arrW[t] + 0xCA62C1D6) ;
- e = d;
- d = c;
- c = ( b<<30 ) | ( b>>>2 ) ;
- b = a;
- a = temp;
- }
-
- arrW[HASH_OFFSET ] += a;
- arrW[HASH_OFFSET +1] += b;
- arrW[HASH_OFFSET +2] += c;
- arrW[HASH_OFFSET +3] += d;
- arrW[HASH_OFFSET +4] += e;
- }
-
- /**
- * The method appends new bytes to existing ones
- * within limit of a frame of 64 bytes (16 words).
- *
- * Once a length of accumulated bytes reaches the limit
- * the "computeHash(int[])" method is invoked on the array to compute updated hash,
- * and the number of bytes in the frame is set to 0.
- * Thus, after appending all bytes, the array contain only those bytes
- * that were not used in computing final hash value yet.
- *
- * No checks on arguments passed to the method, that is,
- * a calling method is responsible for such checks.
- *
- * @params
- * intArray - int array containing bytes to which to append;
- * intArray.length >= (BYTES_OFFSET+6)
- * @params
- * byteInput - array of bytes to use for the update
- * @params
- * from - the offset to start in the "byteInput" array
- * @params
- * to - a number of the last byte in the input array to use,
- * that is, for first byte "to"==0, for last byte "to"==input.length-1
- */
- static void updateHash(int[] intArray, byte[] byteInput, int fromByte, int toByte) {
-
- // As intArray contains a packed bytes
- // the buffer's index is in the intArray[BYTES_OFFSET] element
-
- int index = intArray[BYTES_OFFSET];
- int i = fromByte;
- int maxWord;
- int nBytes;
-
- int wordIndex = index >>2;
- int byteIndex = index & 0x03;
-
- intArray[BYTES_OFFSET] = ( index + toByte - fromByte + 1 ) & 077 ;
-
- // In general case there are 3 stages :
- // - appending bytes to non-full word,
- // - writing 4 bytes into empty words,
- // - writing less than 4 bytes in last word
-
- if ( byteIndex != 0 ) { // appending bytes in non-full word (as if)
-
- for ( ; ( i <= toByte ) && ( byteIndex < 4 ) ; i++ ) {
- intArray[wordIndex] |= ( byteInput[i] & 0xFF ) << ((3 - byteIndex)<<3) ;
- byteIndex++;
- }
- if ( byteIndex == 4 ) {
- wordIndex++;
- if ( wordIndex == 16 ) { // intArray is full, computing hash
-
- computeHash(intArray);
- wordIndex = 0;
- }
- }
- if ( i > toByte ) { // all input bytes appended
- return ;
- }
- }
-
- // writing full words
-
- maxWord = (toByte - i + 1) >> 2; // # of remaining full words, may be "0"
- for ( int k = 0; k < maxWord ; k++ ) {
-
- intArray[wordIndex] = ( ((int) byteInput[i ] & 0xFF) <<24 ) |
- ( ((int) byteInput[i +1] & 0xFF) <<16 ) |
- ( ((int) byteInput[i +2] & 0xFF) <<8 ) |
- ( ((int) byteInput[i +3] & 0xFF) ) ;
- i += 4;
- wordIndex++;
-
- if ( wordIndex < 16 ) { // buffer is not full yet
- continue;
- }
- computeHash(intArray); // buffer is full, computing hash
- wordIndex = 0;
- }
-
- // writing last incomplete word
- // after writing free byte positions are set to "0"s
-
- nBytes = toByte - i +1;
- if ( nBytes != 0 ) {
-
- int w = ((int) byteInput[i] & 0xFF) <<24 ;
-
- if ( nBytes != 1 ) {
- w |= ((int) byteInput[i +1] & 0xFF) <<16 ;
- if ( nBytes != 2) {
- w |= ((int) byteInput[i +2] & 0xFF) <<8 ;
- }
- }
- intArray[wordIndex] = w;
- }
-
- return ;
- }
-
-}
diff --git a/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1PRNG_SecureRandomImpl.java b/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1PRNG_SecureRandomImpl.java
deleted file mode 100644
index 5c0e328..0000000
--- a/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1PRNG_SecureRandomImpl.java
+++ /dev/null
@@ -1,564 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.harmony.security.provider.crypto;
-
-import dalvik.system.BlockGuard;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.security.InvalidParameterException;
-import java.security.ProviderException;
-import java.security.SecureRandomSpi;
-import libcore.io.Streams;
-import libcore.util.EmptyArray;
-
-import static org.apache.harmony.security.provider.crypto.SHA1Constants.*;
-
-/**
- * This class extends the SecureRandomSpi class implementing all its abstract methods.
- *
- * <p>To generate pseudo-random bits, the implementation uses technique described in
- * the "Random Number Generator (RNG) algorithms" section, Appendix A,
- * JavaTM Cryptography Architecture, API Specification & Reference.
- */
-public class SHA1PRNG_SecureRandomImpl extends SecureRandomSpi implements Serializable {
-
- private static final long serialVersionUID = 283736797212159675L;
-
- private static FileInputStream devURandom;
- static {
- try {
- devURandom = new FileInputStream(new File("/dev/urandom"));
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- // constants to use in expressions operating on bytes in int and long variables:
- // END_FLAGS - final bytes in words to append to message;
- // see "ch.5.1 Padding the Message, FIPS 180-2"
- // RIGHT1 - shifts to right for left half of long
- // RIGHT2 - shifts to right for right half of long
- // LEFT - shifts to left for bytes
- // MASK - mask to select counter's bytes after shift to right
-
- private static final int[] END_FLAGS = { 0x80000000, 0x800000, 0x8000, 0x80 };
-
- private static final int[] RIGHT1 = { 0, 40, 48, 56 };
-
- private static final int[] RIGHT2 = { 0, 8, 16, 24 };
-
- private static final int[] LEFT = { 0, 24, 16, 8 };
-
- private static final int[] MASK = { 0xFFFFFFFF, 0x00FFFFFF, 0x0000FFFF,
- 0x000000FF };
-
- // HASHBYTES_TO_USE defines # of bytes returned by "computeHash(byte[])"
- // to use to form byte array returning by the "nextBytes(byte[])" method
- // Note, that this implementation uses more bytes than it is defined
- // in the above specification.
- private static final int HASHBYTES_TO_USE = 20;
-
- // value of 16 defined in the "SECURE HASH STANDARD", FIPS PUB 180-2
- private static final int FRAME_LENGTH = 16;
-
- // miscellaneous constants defined in this implementation:
- // COUNTER_BASE - initial value to set to "counter" before computing "nextBytes(..)";
- // note, that the exact value is not defined in STANDARD
- // HASHCOPY_OFFSET - offset for copy of current hash in "copies" array
- // EXTRAFRAME_OFFSET - offset for extra frame in "copies" array;
- // as the extra frame follows the current hash frame,
- // EXTRAFRAME_OFFSET is equal to length of current hash frame
- // FRAME_OFFSET - offset for frame in "copies" array
- // MAX_BYTES - maximum # of seed bytes processing which doesn't require extra frame
- // see (1) comments on usage of "seed" array below and
- // (2) comments in "engineNextBytes(byte[])" method
- //
- // UNDEFINED - three states of engine; initially its state is "UNDEFINED"
- // SET_SEED call to "engineSetSeed" sets up "SET_SEED" state,
- // NEXT_BYTES call to "engineNextByte" sets up "NEXT_BYTES" state
-
- private static final int COUNTER_BASE = 0;
-
- private static final int HASHCOPY_OFFSET = 0;
-
- private static final int EXTRAFRAME_OFFSET = 5;
-
- private static final int FRAME_OFFSET = 21;
-
- private static final int MAX_BYTES = 48;
-
- private static final int UNDEFINED = 0;
-
- private static final int SET_SEED = 1;
-
- private static final int NEXT_BYTES = 2;
-
- private static SHA1PRNG_SecureRandomImpl myRandom;
-
- // Structure of "seed" array:
- // - 0-79 - words for computing hash
- // - 80 - unused
- // - 81 - # of seed bytes in current seed frame
- // - 82-86 - 5 words, current seed hash
- private transient int[] seed;
-
- // total length of seed bytes, including all processed
- private transient long seedLength;
-
- // Structure of "copies" array
- // - 0-4 - 5 words, copy of current seed hash
- // - 5-20 - extra 16 words frame;
- // is used if final padding exceeds 512-bit length
- // - 21-36 - 16 word frame to store a copy of remaining bytes
- private transient int[] copies;
-
- // ready "next" bytes; needed because words are returned
- private transient byte[] nextBytes;
-
- // index of used bytes in "nextBytes" array
- private transient int nextBIndex;
-
- // variable required according to "SECURE HASH STANDARD"
- private transient long counter;
-
- // contains int value corresponding to engine's current state
- private transient int state;
-
- // The "seed" array is used to compute both "current seed hash" and "next bytes".
- //
- // As the "SHA1" algorithm computes a hash of entire seed by splitting it into
- // a number of the 512-bit length frames (512 bits = 64 bytes = 16 words),
- // "current seed hash" is a hash (5 words, 20 bytes) for all previous full frames;
- // remaining bytes are stored in the 0-15 word frame of the "seed" array.
- //
- // As for calculating "next bytes",
- // both remaining bytes and "current seed hash" are used,
- // to preserve the latter for following "setSeed(..)" commands,
- // the following technique is used:
- // - upon getting "nextBytes(byte[])" invoked, single or first in row,
- // which requires computing new hash, that is,
- // there is no more bytes remaining from previous "next bytes" computation,
- // remaining bytes are copied into the 21-36 word frame of the "copies" array;
- // - upon getting "setSeed(byte[])" invoked, single or first in row,
- // remaining bytes are copied back.
-
- /**
- * Creates object and sets implementation variables to their initial values
- */
- public SHA1PRNG_SecureRandomImpl() {
-
- seed = new int[HASH_OFFSET + EXTRAFRAME_OFFSET];
- seed[HASH_OFFSET] = H0;
- seed[HASH_OFFSET + 1] = H1;
- seed[HASH_OFFSET + 2] = H2;
- seed[HASH_OFFSET + 3] = H3;
- seed[HASH_OFFSET + 4] = H4;
-
- seedLength = 0;
- copies = new int[2 * FRAME_LENGTH + EXTRAFRAME_OFFSET];
- nextBytes = new byte[DIGEST_LENGTH];
- nextBIndex = HASHBYTES_TO_USE;
- counter = COUNTER_BASE;
- state = UNDEFINED;
- }
-
- /*
- * The method invokes the SHA1Impl's "updateHash(..)" method
- * to update current seed frame and
- * to compute new intermediate hash value if the frame is full.
- *
- * After that it computes a length of whole seed.
- */
- private void updateSeed(byte[] bytes) {
-
- // on call: "seed" contains current bytes and current hash;
- // on return: "seed" contains new current bytes and possibly new current hash
- // if after adding, seed bytes overfill its buffer
- SHA1Impl.updateHash(seed, bytes, 0, bytes.length - 1);
-
- seedLength += bytes.length;
- }
-
- /**
- * Changes current seed by supplementing a seed argument to the current seed,
- * if this already set;
- * the argument is used as first seed otherwise. <BR>
- *
- * The method overrides "engineSetSeed(byte[])" in class SecureRandomSpi.
- *
- * @param
- * seed - byte array
- * @throws
- * NullPointerException - if null is passed to the "seed" argument
- */
- protected synchronized void engineSetSeed(byte[] seed) {
-
- if (seed == null) {
- throw new NullPointerException("seed == null");
- }
-
- if (state == NEXT_BYTES) { // first setSeed after NextBytes; restoring hash
- System.arraycopy(copies, HASHCOPY_OFFSET, this.seed, HASH_OFFSET,
- EXTRAFRAME_OFFSET);
- }
- state = SET_SEED;
-
- if (seed.length != 0) {
- updateSeed(seed);
- }
- }
-
- /**
- * Returns a required number of random bytes. <BR>
- *
- * The method overrides "engineGenerateSeed (int)" in class SecureRandomSpi. <BR>
- *
- * @param
- * numBytes - number of bytes to return; should be >= 0.
- * @return
- * byte array containing bits in order from left to right
- * @throws
- * InvalidParameterException - if numBytes < 0
- */
- protected synchronized byte[] engineGenerateSeed(int numBytes) {
-
- byte[] myBytes; // byte[] for bytes returned by "nextBytes()"
-
- if (numBytes < 0) {
- throw new NegativeArraySizeException(Integer.toString(numBytes));
- }
- if (numBytes == 0) {
- return EmptyArray.BYTE;
- }
-
- if (myRandom == null) {
- myRandom = new SHA1PRNG_SecureRandomImpl();
- myRandom.engineSetSeed(getRandomBytes(DIGEST_LENGTH));
- }
-
- myBytes = new byte[numBytes];
- myRandom.engineNextBytes(myBytes);
-
- return myBytes;
- }
-
- /**
- * Writes random bytes into an array supplied.
- * Bits in a byte are from left to right. <BR>
- *
- * To generate random bytes, the "expansion of source bits" method is used,
- * that is,
- * the current seed with a 64-bit counter appended is used to compute new bits.
- * The counter is incremented by 1 for each 20-byte output. <BR>
- *
- * The method overrides engineNextBytes in class SecureRandomSpi.
- *
- * @param
- * bytes - byte array to be filled in with bytes
- * @throws
- * NullPointerException - if null is passed to the "bytes" argument
- */
- protected synchronized void engineNextBytes(byte[] bytes) {
-
- int i, n;
-
- long bits; // number of bits required by Secure Hash Standard
- int nextByteToReturn; // index of ready bytes in "bytes" array
- int lastWord; // index of last word in frame containing bytes
- final int extrabytes = 7;// # of bytes to add in order to computer # of 8 byte words
-
- if (bytes == null) {
- throw new NullPointerException("bytes == null");
- }
-
- lastWord = seed[BYTES_OFFSET] == 0 ? 0
- : (seed[BYTES_OFFSET] + extrabytes) >> 3 - 1;
-
- if (state == UNDEFINED) {
-
- // no seed supplied by user, hence it is generated thus randomizing internal state
- updateSeed(getRandomBytes(DIGEST_LENGTH));
- nextBIndex = HASHBYTES_TO_USE;
-
- // updateSeed(...) updates where the last word of the seed is, so we
- // have to read it again.
- lastWord = seed[BYTES_OFFSET] == 0 ? 0
- : (seed[BYTES_OFFSET] + extrabytes) >> 3 - 1;
-
- } else if (state == SET_SEED) {
-
- System.arraycopy(seed, HASH_OFFSET, copies, HASHCOPY_OFFSET,
- EXTRAFRAME_OFFSET);
-
- // possible cases for 64-byte frame:
- //
- // seed bytes < 48 - remaining bytes are enough for all, 8 counter bytes,
- // 0x80, and 8 seedLength bytes; no extra frame required
- // 48 < seed bytes < 56 - remaining 9 bytes are for 0x80 and 8 counter bytes
- // extra frame contains only seedLength value at the end
- // seed bytes > 55 - extra frame contains both counter's bytes
- // at the beginning and seedLength value at the end;
- // note, that beginning extra bytes are not more than 8,
- // that is, only 2 extra words may be used
-
- // no need to set to "0" 3 words after "lastWord" and
- // more than two words behind frame
- for (i = lastWord + 3; i < FRAME_LENGTH + 2; i++) {
- seed[i] = 0;
- }
-
- bits = (seedLength << 3) + 64; // transforming # of bytes into # of bits
-
- // putting # of bits into two last words (14,15) of 16 word frame in
- // seed or copies array depending on total length after padding
- if (seed[BYTES_OFFSET] < MAX_BYTES) {
- seed[14] = (int) (bits >>> 32);
- seed[15] = (int) (bits & 0xFFFFFFFF);
- } else {
- copies[EXTRAFRAME_OFFSET + 14] = (int) (bits >>> 32);
- copies[EXTRAFRAME_OFFSET + 15] = (int) (bits & 0xFFFFFFFF);
- }
-
- nextBIndex = HASHBYTES_TO_USE; // skipping remaining random bits
- }
- state = NEXT_BYTES;
-
- if (bytes.length == 0) {
- return;
- }
-
- nextByteToReturn = 0;
-
- // possibly not all of HASHBYTES_TO_USE bytes were used previous time
- n = (HASHBYTES_TO_USE - nextBIndex) < (bytes.length - nextByteToReturn) ? HASHBYTES_TO_USE
- - nextBIndex
- : bytes.length - nextByteToReturn;
- if (n > 0) {
- System.arraycopy(nextBytes, nextBIndex, bytes, nextByteToReturn, n);
- nextBIndex += n;
- nextByteToReturn += n;
- }
-
- if (nextByteToReturn >= bytes.length) {
- return; // return because "bytes[]" are filled in
- }
-
- n = seed[BYTES_OFFSET] & 0x03;
- for (;;) {
- if (n == 0) {
-
- seed[lastWord] = (int) (counter >>> 32);
- seed[lastWord + 1] = (int) (counter & 0xFFFFFFFF);
- seed[lastWord + 2] = END_FLAGS[0];
-
- } else {
-
- seed[lastWord] |= (int) ((counter >>> RIGHT1[n]) & MASK[n]);
- seed[lastWord + 1] = (int) ((counter >>> RIGHT2[n]) & 0xFFFFFFFF);
- seed[lastWord + 2] = (int) ((counter << LEFT[n]) | END_FLAGS[n]);
- }
- if (seed[BYTES_OFFSET] > MAX_BYTES) {
- copies[EXTRAFRAME_OFFSET] = seed[FRAME_LENGTH];
- copies[EXTRAFRAME_OFFSET + 1] = seed[FRAME_LENGTH + 1];
- }
-
- SHA1Impl.computeHash(seed);
-
- if (seed[BYTES_OFFSET] > MAX_BYTES) {
-
- System.arraycopy(seed, 0, copies, FRAME_OFFSET, FRAME_LENGTH);
- System.arraycopy(copies, EXTRAFRAME_OFFSET, seed, 0,
- FRAME_LENGTH);
-
- SHA1Impl.computeHash(seed);
- System.arraycopy(copies, FRAME_OFFSET, seed, 0, FRAME_LENGTH);
- }
- counter++;
-
- int j = 0;
- for (i = 0; i < EXTRAFRAME_OFFSET; i++) {
- int k = seed[HASH_OFFSET + i];
- nextBytes[j] = (byte) (k >>> 24); // getting first byte from left
- nextBytes[j + 1] = (byte) (k >>> 16); // getting second byte from left
- nextBytes[j + 2] = (byte) (k >>> 8); // getting third byte from left
- nextBytes[j + 3] = (byte) (k); // getting fourth byte from left
- j += 4;
- }
-
- nextBIndex = 0;
- j = HASHBYTES_TO_USE < (bytes.length - nextByteToReturn) ? HASHBYTES_TO_USE
- : bytes.length - nextByteToReturn;
-
- if (j > 0) {
- System.arraycopy(nextBytes, 0, bytes, nextByteToReturn, j);
- nextByteToReturn += j;
- nextBIndex += j;
- }
-
- if (nextByteToReturn >= bytes.length) {
- break;
- }
- }
- }
-
- private void writeObject(ObjectOutputStream oos) throws IOException {
-
- int[] intData = null;
-
- final int only_hash = EXTRAFRAME_OFFSET;
- final int hashes_and_frame = EXTRAFRAME_OFFSET * 2 + FRAME_LENGTH;
- final int hashes_and_frame_extra = EXTRAFRAME_OFFSET * 2 + FRAME_LENGTH
- * 2;
-
- oos.writeLong(seedLength);
- oos.writeLong(counter);
- oos.writeInt(state);
- oos.writeInt(seed[BYTES_OFFSET]);
-
- int nRemaining = (seed[BYTES_OFFSET] + 3) >> 2; // converting bytes in words
- // result may be 0
- if (state != NEXT_BYTES) {
-
- // either the state is UNDEFINED or previous method was "setSeed(..)"
- // so in "seed[]" to serialize are remaining bytes (seed[0-nRemaining]) and
- // current hash (seed[82-86])
-
- intData = new int[only_hash + nRemaining];
-
- System.arraycopy(seed, 0, intData, 0, nRemaining);
- System.arraycopy(seed, HASH_OFFSET, intData, nRemaining,
- EXTRAFRAME_OFFSET);
-
- } else {
- // previous method was "nextBytes(..)"
- // so, data to serialize are all the above (two first are in "copies" array)
- // and current words in both frame and extra frame (as if)
-
- int offset = 0;
- if (seed[BYTES_OFFSET] < MAX_BYTES) { // no extra frame
-
- intData = new int[hashes_and_frame + nRemaining];
-
- } else { // extra frame is used
-
- intData = new int[hashes_and_frame_extra + nRemaining];
-
- intData[offset] = seed[FRAME_LENGTH];
- intData[offset + 1] = seed[FRAME_LENGTH + 1];
- intData[offset + 2] = seed[FRAME_LENGTH + 14];
- intData[offset + 3] = seed[FRAME_LENGTH + 15];
- offset += 4;
- }
-
- System.arraycopy(seed, 0, intData, offset, FRAME_LENGTH);
- offset += FRAME_LENGTH;
-
- System.arraycopy(copies, FRAME_LENGTH + EXTRAFRAME_OFFSET, intData,
- offset, nRemaining);
- offset += nRemaining;
-
- System.arraycopy(copies, 0, intData, offset, EXTRAFRAME_OFFSET);
- offset += EXTRAFRAME_OFFSET;
-
- System.arraycopy(seed, HASH_OFFSET, intData, offset,
- EXTRAFRAME_OFFSET);
- }
- for (int i = 0; i < intData.length; i++) {
- oos.writeInt(intData[i]);
- }
-
- oos.writeInt(nextBIndex);
- oos.write(nextBytes, nextBIndex, HASHBYTES_TO_USE - nextBIndex);
- }
-
- private void readObject(ObjectInputStream ois) throws IOException,
- ClassNotFoundException {
-
- seed = new int[HASH_OFFSET + EXTRAFRAME_OFFSET];
- copies = new int[2 * FRAME_LENGTH + EXTRAFRAME_OFFSET];
- nextBytes = new byte[DIGEST_LENGTH];
-
- seedLength = ois.readLong();
- counter = ois.readLong();
- state = ois.readInt();
- seed[BYTES_OFFSET] = ois.readInt();
-
- int nRemaining = (seed[BYTES_OFFSET] + 3) >> 2; // converting bytes in words
-
- if (state != NEXT_BYTES) {
-
- for (int i = 0; i < nRemaining; i++) {
- seed[i] = ois.readInt();
- }
- for (int i = 0; i < EXTRAFRAME_OFFSET; i++) {
- seed[HASH_OFFSET + i] = ois.readInt();
- }
- } else {
- if (seed[BYTES_OFFSET] >= MAX_BYTES) {
-
- // reading next bytes in seed extra frame
- seed[FRAME_LENGTH] = ois.readInt();
- seed[FRAME_LENGTH + 1] = ois.readInt();
- seed[FRAME_LENGTH + 14] = ois.readInt();
- seed[FRAME_LENGTH + 15] = ois.readInt();
- }
- // reading next bytes in seed frame
- for (int i = 0; i < FRAME_LENGTH; i++) {
- seed[i] = ois.readInt();
- }
- // reading remaining seed bytes
- for (int i = 0; i < nRemaining; i++) {
- copies[FRAME_LENGTH + EXTRAFRAME_OFFSET + i] = ois.readInt();
- }
- // reading copy of current hash
- for (int i = 0; i < EXTRAFRAME_OFFSET; i++) {
- copies[i] = ois.readInt();
- }
- // reading current hash
- for (int i = 0; i < EXTRAFRAME_OFFSET; i++) {
- seed[HASH_OFFSET + i] = ois.readInt();
- }
- }
-
- nextBIndex = ois.readInt();
- Streams.readFully(ois, nextBytes, nextBIndex, HASHBYTES_TO_USE - nextBIndex);
- }
-
- private static byte[] getRandomBytes(int byteCount) {
- if (byteCount <= 0) {
- throw new IllegalArgumentException("Too few bytes requested: " + byteCount);
- }
-
- BlockGuard.Policy originalPolicy = BlockGuard.getThreadPolicy();
- try {
- BlockGuard.setThreadPolicy(BlockGuard.LAX_POLICY);
- byte[] result = new byte[byteCount];
- Streams.readFully(devURandom, result, 0, byteCount);
- return result;
- } catch (Exception ex) {
- throw new ProviderException("Couldn't read " + byteCount + " random bytes", ex);
- } finally {
- BlockGuard.setThreadPolicy(originalPolicy);
- }
- }
-}
diff --git a/luni/src/main/native/Register.cpp b/luni/src/main/native/Register.cpp
index 787a149..d0230ee 100644
--- a/luni/src/main/native/Register.cpp
+++ b/luni/src/main/native/Register.cpp
@@ -61,8 +61,6 @@
REGISTER(register_libcore_icu_NativeConverter);
REGISTER(register_libcore_icu_NativeDecimalFormat);
REGISTER(register_libcore_icu_NativeIDN);
- REGISTER(register_libcore_icu_NativeNormalizer);
- REGISTER(register_libcore_icu_NativePluralRules);
REGISTER(register_libcore_icu_TimeZoneNames);
REGISTER(register_libcore_icu_Transliterator);
REGISTER(register_libcore_io_AsynchronousCloseMonitor);
diff --git a/luni/src/main/native/android_system_OsConstants.cpp b/luni/src/main/native/android_system_OsConstants.cpp
index 3cc9b06..c064130 100644
--- a/luni/src/main/native/android_system_OsConstants.cpp
+++ b/luni/src/main/native/android_system_OsConstants.cpp
@@ -386,6 +386,7 @@
initConstant(env, c, "O_RDONLY", O_RDONLY);
initConstant(env, c, "O_RDWR", O_RDWR);
initConstant(env, c, "O_SYNC", O_SYNC);
+ initConstant(env, c, "O_DSYNC", O_DSYNC);
initConstant(env, c, "O_TRUNC", O_TRUNC);
initConstant(env, c, "O_WRONLY", O_WRONLY);
initConstant(env, c, "POLLERR", POLLERR);
diff --git a/luni/src/main/native/libcore_icu_NativeNormalizer.cpp b/luni/src/main/native/libcore_icu_NativeNormalizer.cpp
deleted file mode 100644
index 2d5e282..0000000
--- a/luni/src/main/native/libcore_icu_NativeNormalizer.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-#define LOG_TAG "NativeNormalizer"
-
-#include "IcuUtilities.h"
-#include "JNIHelp.h"
-#include "JniConstants.h"
-#include "JniException.h"
-#include "ScopedJavaUnicodeString.h"
-#include "unicode/normlzr.h"
-
-static jstring NativeNormalizer_normalizeImpl(JNIEnv* env, jclass, jstring s, jint intMode) {
- ScopedJavaUnicodeString src(env, s);
- if (!src.valid()) {
- return NULL;
- }
- UNormalizationMode mode = static_cast<UNormalizationMode>(intMode);
- UErrorCode status = U_ZERO_ERROR;
- icu::UnicodeString dst;
- icu::Normalizer::normalize(src.unicodeString(), mode, 0, dst, status);
- maybeThrowIcuException(env, "Normalizer::normalize", status);
- return dst.isBogus() ? NULL : env->NewString(dst.getBuffer(), dst.length());
-}
-
-static jboolean NativeNormalizer_isNormalizedImpl(JNIEnv* env, jclass, jstring s, jint intMode) {
- ScopedJavaUnicodeString src(env, s);
- if (!src.valid()) {
- return JNI_FALSE;
- }
- UNormalizationMode mode = static_cast<UNormalizationMode>(intMode);
- UErrorCode status = U_ZERO_ERROR;
- UBool result = icu::Normalizer::isNormalized(src.unicodeString(), mode, status);
- maybeThrowIcuException(env, "Normalizer::isNormalized", status);
- return result;
-}
-
-static JNINativeMethod gMethods[] = {
- NATIVE_METHOD(NativeNormalizer, normalizeImpl, "(Ljava/lang/String;I)Ljava/lang/String;"),
- NATIVE_METHOD(NativeNormalizer, isNormalizedImpl, "(Ljava/lang/String;I)Z"),
-};
-void register_libcore_icu_NativeNormalizer(JNIEnv* env) {
- jniRegisterNativeMethods(env, "libcore/icu/NativeNormalizer", gMethods, NELEM(gMethods));
-}
diff --git a/luni/src/main/native/libcore_icu_NativePluralRules.cpp b/luni/src/main/native/libcore_icu_NativePluralRules.cpp
deleted file mode 100644
index f278485..0000000
--- a/luni/src/main/native/libcore_icu_NativePluralRules.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-#define LOG_TAG "NativePluralRules"
-
-#include "IcuUtilities.h"
-#include "JNIHelp.h"
-#include "JniConstants.h"
-#include "JniException.h"
-#include "ScopedUtfChars.h"
-#include "unicode/plurrule.h"
-
-#include <string>
-
-static icu::PluralRules* toPluralRules(jlong address) {
- return reinterpret_cast<icu::PluralRules*>(static_cast<uintptr_t>(address));
-}
-
-static void NativePluralRules_finalizeImpl(JNIEnv*, jclass, jlong address) {
- delete toPluralRules(address);
-}
-
-static jlong NativePluralRules_forLocaleImpl(JNIEnv* env, jclass, jstring javaLocaleName) {
- // The icu4c PluralRules returns a "other: n" default rule for the deprecated locales Java uses.
- // Work around this by translating back to the current language codes.
- std::string localeName(ScopedUtfChars(env, javaLocaleName).c_str());
- if (localeName[0] == 'i' && localeName[1] == 'w') {
- localeName[0] = 'h';
- localeName[1] = 'e';
- } else if (localeName[0] == 'i' && localeName[1] == 'n') {
- localeName[0] = 'i';
- localeName[1] = 'd';
- } else if (localeName[0] == 'j' && localeName[1] == 'i') {
- localeName[0] = 'y';
- localeName[1] = 'i';
- }
-
- icu::Locale locale = icu::Locale::createFromName(localeName.c_str());
- UErrorCode status = U_ZERO_ERROR;
- icu::PluralRules* result = icu::PluralRules::forLocale(locale, status);
- maybeThrowIcuException(env, "PluralRules::forLocale", status);
- return reinterpret_cast<uintptr_t>(result);
-}
-
-static jint NativePluralRules_quantityForIntImpl(JNIEnv*, jclass, jlong address, jint value) {
- icu::UnicodeString keyword = toPluralRules(address)->select(value);
- if (keyword == "zero") {
- return 0;
- } else if (keyword == "one") {
- return 1;
- } else if (keyword == "two") {
- return 2;
- } else if (keyword == "few") {
- return 3;
- } else if (keyword == "many") {
- return 4;
- } else {
- return 5;
- }
-}
-
-static JNINativeMethod gMethods[] = {
- NATIVE_METHOD(NativePluralRules, finalizeImpl, "(J)V"),
- NATIVE_METHOD(NativePluralRules, forLocaleImpl, "(Ljava/lang/String;)J"),
- NATIVE_METHOD(NativePluralRules, quantityForIntImpl, "(JI)I"),
-};
-void register_libcore_icu_NativePluralRules(JNIEnv* env) {
- jniRegisterNativeMethods(env, "libcore/icu/NativePluralRules", gMethods, NELEM(gMethods));
-}
diff --git a/luni/src/main/native/sub.mk b/luni/src/main/native/sub.mk
index 78ec37a..1906185 100644
--- a/luni/src/main/native/sub.mk
+++ b/luni/src/main/native/sub.mk
@@ -41,8 +41,6 @@
libcore_icu_NativeConverter.cpp \
libcore_icu_NativeDecimalFormat.cpp \
libcore_icu_NativeIDN.cpp \
- libcore_icu_NativeNormalizer.cpp \
- libcore_icu_NativePluralRules.cpp \
libcore_icu_TimeZoneNames.cpp \
libcore_icu_Transliterator.cpp \
libcore_io_AsynchronousCloseMonitor.cpp \
diff --git a/luni/src/test/java/libcore/icu/NativePluralRulesTest.java b/luni/src/test/java/libcore/icu/NativePluralRulesTest.java
deleted file mode 100644
index 76179b4..0000000
--- a/luni/src/test/java/libcore/icu/NativePluralRulesTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2009 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 libcore.icu;
-
-import java.util.Locale;
-
-public class NativePluralRulesTest extends junit.framework.TestCase {
- public void testNegatives() throws Exception {
- // icu4c's behavior changed, but we prefer to preserve compatibility.
- NativePluralRules en_US = NativePluralRules.forLocale(new Locale("en", "US"));
- assertEquals(NativePluralRules.OTHER, en_US.quantityForInt(2));
- assertEquals(NativePluralRules.ONE, en_US.quantityForInt(1));
- assertEquals(NativePluralRules.OTHER, en_US.quantityForInt(0));
- assertEquals(NativePluralRules.OTHER, en_US.quantityForInt(-1));
- assertEquals(NativePluralRules.OTHER, en_US.quantityForInt(-2));
-
- NativePluralRules ar = NativePluralRules.forLocale(new Locale("ar"));
- assertEquals(NativePluralRules.ZERO, ar.quantityForInt(0));
- assertEquals(NativePluralRules.OTHER, ar.quantityForInt(-1)); // Not ONE.
- assertEquals(NativePluralRules.OTHER, ar.quantityForInt(-2)); // Not TWO.
- assertEquals(NativePluralRules.OTHER, ar.quantityForInt(-3)); // Not FEW.
- assertEquals(NativePluralRules.OTHER, ar.quantityForInt(-11)); // Not MANY.
- assertEquals(NativePluralRules.OTHER, ar.quantityForInt(-100));
- }
-
- public void testEnglish() throws Exception {
- NativePluralRules npr = NativePluralRules.forLocale(new Locale("en", "US"));
- assertEquals(NativePluralRules.OTHER, npr.quantityForInt(0));
- assertEquals(NativePluralRules.ONE, npr.quantityForInt(1));
- assertEquals(NativePluralRules.OTHER, npr.quantityForInt(2));
- }
-
- public void testCzech() throws Exception {
- NativePluralRules npr = NativePluralRules.forLocale(new Locale("cs", "CZ"));
- assertEquals(NativePluralRules.OTHER, npr.quantityForInt(0));
- assertEquals(NativePluralRules.ONE, npr.quantityForInt(1));
- assertEquals(NativePluralRules.FEW, npr.quantityForInt(2));
- assertEquals(NativePluralRules.FEW, npr.quantityForInt(3));
- assertEquals(NativePluralRules.FEW, npr.quantityForInt(4));
- assertEquals(NativePluralRules.OTHER, npr.quantityForInt(5));
- }
-
- public void testArabic() throws Exception {
- NativePluralRules npr = NativePluralRules.forLocale(new Locale("ar"));
- assertEquals(NativePluralRules.ZERO, npr.quantityForInt(0));
- assertEquals(NativePluralRules.ONE, npr.quantityForInt(1));
- assertEquals(NativePluralRules.TWO, npr.quantityForInt(2));
- for (int i = 3; i <= 10; ++i) {
- assertEquals(NativePluralRules.FEW, npr.quantityForInt(i));
- }
- assertEquals(NativePluralRules.MANY, npr.quantityForInt(11));
- assertEquals(NativePluralRules.MANY, npr.quantityForInt(99));
- assertEquals(NativePluralRules.OTHER, npr.quantityForInt(100));
- assertEquals(NativePluralRules.OTHER, npr.quantityForInt(101));
- assertEquals(NativePluralRules.OTHER, npr.quantityForInt(102));
- assertEquals(NativePluralRules.FEW, npr.quantityForInt(103));
- assertEquals(NativePluralRules.MANY, npr.quantityForInt(111));
- }
-
- public void testHebrew() throws Exception {
- // java.util.Locale will translate "he" to the deprecated "iw".
- NativePluralRules he = NativePluralRules.forLocale(new Locale("he"));
- assertEquals(NativePluralRules.ONE, he.quantityForInt(1));
- assertEquals(NativePluralRules.TWO, he.quantityForInt(2));
- assertEquals(NativePluralRules.OTHER, he.quantityForInt(3));
- assertEquals(NativePluralRules.OTHER, he.quantityForInt(10));
- }
-}
-
diff --git a/luni/src/test/java/libcore/java/lang/OldAndroidMonitorTest.java b/luni/src/test/java/libcore/java/lang/OldAndroidMonitorTest.java
index 4760c6d..8ef507a 100755
--- a/luni/src/test/java/libcore/java/lang/OldAndroidMonitorTest.java
+++ b/luni/src/test/java/libcore/java/lang/OldAndroidMonitorTest.java
@@ -18,6 +18,8 @@
import junit.framework.TestCase;
+import java.util.concurrent.CountDownLatch;
+
public class OldAndroidMonitorTest extends TestCase {
public void testWaitArgumentsTest() throws Exception {
@@ -102,363 +104,69 @@
}
}
- private class Interrupter extends Thread {
- private final Waiter waiter;
+ /**
+ * A thread that blocks forever on {@code wait()} until it's interrupted.
+ */
+ static class Waiter extends Thread {
+ private final Object lock;
+ private final CountDownLatch cdl;
+ private boolean wasInterrupted;
- Interrupter(String name, Waiter waiter) {
- super(name);
- this.waiter = waiter;
- }
-
- public void run() {
- try {
- run_inner();
- } catch (Throwable t) {
- OldAndroidMonitorTest.errorException = t;
- OldAndroidMonitorTest.testThread.interrupt();
- }
- }
-
- private void run_inner() {
- // System.out.println("InterruptTest: starting waiter");
- waiter.start();
-
- try {
- Thread.currentThread().sleep(500);
- } catch (InterruptedException ex) {
- throw new RuntimeException("Test sleep interrupted.", ex);
- }
-
- /* Waiter is spinning, and its monitor should still be thin.
- */
- // System.out.println("Test interrupting waiter");
- waiter.interrupt();
- waiter.spin = false;
-
- for (int i = 0; i < 3; i++) {
- /* Wait for the waiter to start waiting.
- */
- synchronized (waiter.interrupterLock) {
- try {
- waiter.interrupterLock.wait();
- } catch (InterruptedException ex) {
- throw new RuntimeException("Test wait interrupted.", ex);
- }
- }
-
- /* Before interrupting, grab the waiter lock, which
- * guarantees that the waiter is already sitting in wait().
- */
- synchronized (waiter) {
- //System.out.println("Test interrupting waiter (" + i + ")");
- waiter.interrupt();
- }
- }
-
- // System.out.println("Test waiting for waiter to die.");
- try {
- waiter.join();
- } catch (InterruptedException ex) {
- throw new RuntimeException("Test join interrupted.", ex);
- }
- // System.out.println("InterruptTest done.");
- }
+ public Waiter(Object lock, CountDownLatch cdl) {
+ this.lock = lock;
+ this.cdl = cdl;
+ wasInterrupted = false;
}
- private class Waiter extends Thread {
- Object interrupterLock = new Object();
- volatile boolean spin = true;
-
- Waiter(String name) {
- super(name);
- }
-
- public void run() {
- try {
- run_inner();
- } catch (Throwable t) {
- OldAndroidMonitorTest.errorException = t;
- OldAndroidMonitorTest.testThread.interrupt();
- }
- }
-
- void run_inner() {
- // System.out.println("Waiter spinning");
- while (spin) {
- // We're going to get interrupted while we spin.
- }
-
- if (interrupted()) {
- // System.out.println("Waiter done spinning; interrupted.");
- } else {
- throw new RuntimeException("Thread not interrupted " +
- "during spin");
- }
-
- synchronized (this) {
- boolean sawEx = false;
-
- try {
- synchronized (interrupterLock) {
- interrupterLock.notify();
- }
- // System.out.println("Waiter calling wait()");
- this.wait();
- } catch (InterruptedException ex) {
- sawEx = true;
- // System.out.println("wait(): Waiter caught " + ex);
- }
- // System.out.println("wait() finished");
-
- if (!sawEx) {
- throw new RuntimeException("Thread not interrupted " +
- "during wait()");
- }
- }
- synchronized (this) {
- boolean sawEx = false;
-
- try {
- synchronized (interrupterLock) {
- interrupterLock.notify();
- }
- // System.out.println("Waiter calling wait(1000)");
- this.wait(1000);
- } catch (InterruptedException ex) {
- sawEx = true;
- // System.out.println("wait(1000): Waiter caught " + ex);
- }
- // System.out.println("wait(1000) finished");
-
- if (!sawEx) {
- throw new RuntimeException("Thread not interrupted " +
- "during wait(1000)");
- }
- }
- synchronized (this) {
- boolean sawEx = false;
-
- try {
- synchronized (interrupterLock) {
- interrupterLock.notify();
- }
- // System.out.println("Waiter calling wait(1000, 5000)");
- this.wait(1000, 5000);
- } catch (InterruptedException ex) {
- sawEx = true;
- // System.out.println("wait(1000, 5000): Waiter caught " + ex);
- }
- // System.out.println("wait(1000, 5000) finished");
-
- if (!sawEx) {
- throw new RuntimeException("Thread not interrupted " +
- "during wait(1000, 5000)");
- }
- }
-
- // System.out.println("Waiter returning");
- }
- }
-
- private static Throwable errorException;
- private static Thread testThread;
-
- // TODO: Flaky test. Add back MediumTest annotation once fixed
- public void testInterruptTest() throws Exception {
-
-
- testThread = Thread.currentThread();
- errorException = null;
-
- Waiter waiter = new Waiter("InterruptTest Waiter");
- Interrupter interrupter =
- new Interrupter("InterruptTest Interrupter", waiter);
- interrupter.start();
-
- try {
- interrupter.join();
- waiter.join();
- } catch (InterruptedException ex) {
- throw new RuntimeException("Test join interrupted.", ex);
- }
-
- if (errorException != null) {
- throw new RuntimeException("InterruptTest failed",
- errorException);
- }
-
-
-
-
- }
-
- private static void deepWait(int depth, Object lock) {
- synchronized (lock) {
- if (depth > 0) {
- deepWait(depth - 1, lock);
- } else {
- String threadName = Thread.currentThread().getName();
- try {
- // System.out.println(threadName + " waiting");
- lock.wait();
- // System.out.println(threadName + " done waiting");
- } catch (InterruptedException ex) {
- // System.out.println(threadName + " interrupted.");
- }
- }
- }
- }
-
- private class Worker extends Thread {
- Object lock;
- int id;
-
- Worker(int id, Object lock) {
- super("Worker(" + id + ")");
- this.id = id;
- this.lock = lock;
- }
-
- public void run() {
- int iterations = 0;
-
- while (OldAndroidMonitorTest.running) {
- OldAndroidMonitorTest.deepWait(id, lock);
- iterations++;
- }
- // System.out.println(getName() + " done after " + iterations + " iterations.");
- }
- }
-
- private static Object commonLock = new Object();
- private static Boolean running = false;
-
-
- public void testNestedMonitors() throws Exception {
- final int NUM_WORKERS = 5;
-
- Worker w[] = new Worker[NUM_WORKERS];
- int i;
-
- for (i = 0; i < NUM_WORKERS; i++) {
- w[i] = new Worker(i * 2 - 1, new Object());
- }
-
- running = true;
-
- // System.out.println("NestedMonitors: starting workers");
- for (i = 0; i < NUM_WORKERS; i++) {
- w[i].start();
- }
-
- try {
- Thread.currentThread().sleep(1000);
- } catch (InterruptedException ex) {
- // System.out.println("Test sleep interrupted.");
- }
-
- for (i = 0; i < 100; i++) {
- for (int j = 0; j < NUM_WORKERS; j++) {
- synchronized (w[j].lock) {
- w[j].lock.notify();
- }
- }
- }
-
- // System.out.println("NesterMonitors: stopping workers");
- running = false;
- for (i = 0; i < NUM_WORKERS; i++) {
- synchronized (w[i].lock) {
- w[i].lock.notifyAll();
- }
- }
- }
-
- private static class CompareAndExchange extends Thread {
- static Object toggleLock = null;
- static int toggle = -1;
- static Boolean running = false;
-
+ @Override
public void run() {
- toggleLock = new Object();
- toggle = -1;
-
- Worker w1 = new Worker(0, 1);
- Worker w2 = new Worker(2, 3);
- Worker w3 = new Worker(4, 5);
- Worker w4 = new Worker(6, 7);
-
- running = true;
-
- // System.out.println("CompareAndExchange: starting workers");
-
- w1.start();
- w2.start();
- w3.start();
- w4.start();
-
- try {
- this.sleep(10000);
- } catch (InterruptedException ex) {
- // System.out.println(getName() + " interrupted.");
- }
-
- // System.out.println("MonitorTest: stopping workers");
- running = false;
-
- toggleLock = null;
- }
-
- class Worker extends Thread {
- int i1;
- int i2;
-
- Worker(int i1, int i2) {
- super("Worker(" + i1 + ", " + i2 + ")");
- this.i1 = i1;
- this.i2 = i2;
- }
-
- public void run() {
- int iterations = 0;
-
- /* Latch this because run() may set the static field to
- * null at some point.
- */
- Object toggleLock = CompareAndExchange.toggleLock;
-
- // System.out.println(getName() + " running");
+ synchronized (lock) {
try {
- while (CompareAndExchange.running) {
- synchronized (toggleLock) {
- int test;
- int check;
-
- if (CompareAndExchange.toggle == i1) {
- this.sleep(5 + i2);
- CompareAndExchange.toggle = test = i2;
- } else {
- this.sleep(5 + i1);
- CompareAndExchange.toggle = test = i1;
- }
- if ((check = CompareAndExchange.toggle) != test) {
-// System.out.println("Worker(" + i1 + ", " +
-// i2 + ") " + "test " + test +
-// " != toggle " + check);
- throw new RuntimeException(
- "locked value changed");
- }
- }
-
- iterations++;
+ cdl.countDown();
+ while (true) {
+ lock.wait();
}
} catch (InterruptedException ex) {
- // System.out.println(getName() + " interrupted.");
+ wasInterrupted = true;
}
-
-// System.out.println(getName() + " done after " +
-// iterations + " iterations.");
}
}
+
+ public boolean wasInterrupted() {
+ synchronized (lock) {
+ return wasInterrupted;
+ }
+ }
+ }
+
+ public void testInterrupt() throws Exception {
+ final Object lock = new Object();
+ final CountDownLatch cdl = new CountDownLatch(1);
+ final Waiter waiter = new Waiter(lock, cdl);
+
+ waiter.start();
+
+ // Wait for the "waiter" to start and acquire |lock| for the first time.
+ try {
+ cdl.await();
+ } catch (InterruptedException ie) {
+ fail();
+ }
+
+ // Interrupt |waiter| after we acquire |lock|. This ensures that |waiter| is
+ // currently blocked on a call to "wait".
+ synchronized (lock) {
+ waiter.interrupt();
+ }
+
+ // Wait for the waiter to complete.
+ try {
+ waiter.join();
+ } catch (InterruptedException ie) {
+ fail();
+ }
+
+ // Assert than an InterruptedException was thrown.
+ assertTrue(waiter.wasInterrupted());
}
}
diff --git a/luni/src/test/java/libcore/java/util/OldTimeZoneTest.java b/luni/src/test/java/libcore/java/util/OldTimeZoneTest.java
index 7a5fc4a..04396f4 100644
--- a/luni/src/test/java/libcore/java/util/OldTimeZoneTest.java
+++ b/luni/src/test/java/libcore/java/util/OldTimeZoneTest.java
@@ -17,7 +17,6 @@
package libcore.java.util;
-import dalvik.annotation.AndroidOnly;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
@@ -103,7 +102,6 @@
assertEquals("Pacific Standard Time", tz.getDisplayName(false, TimeZone.LONG));
}
- @AndroidOnly("fail on RI. See comment below")
public void test_getDisplayNameZILjava_util_Locale() {
TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
assertEquals("Pacific Daylight Time", tz.getDisplayName(true, TimeZone.LONG, Locale.US));
diff --git a/luni/src/test/java/libcore/javax/crypto/spec/AlgorithmParameterGeneratorTestDH.java b/luni/src/test/java/libcore/javax/crypto/spec/AlgorithmParameterGeneratorTestDH.java
index e64fb9e..b3ff4ad7 100644
--- a/luni/src/test/java/libcore/javax/crypto/spec/AlgorithmParameterGeneratorTestDH.java
+++ b/luni/src/test/java/libcore/javax/crypto/spec/AlgorithmParameterGeneratorTestDH.java
@@ -15,7 +15,6 @@
*/
package libcore.javax.crypto.spec;
-import dalvik.annotation.BrokenTest;
import tests.security.AlgorithmParameterGeneratorTest;
import tests.security.AlgorithmParameterKeyAgreementHelper;
@@ -26,9 +25,7 @@
super("DH", new AlgorithmParameterKeyAgreementHelper("DH"));
}
- // Broken Test: Suffers from DH slowness, disabling for now
public void testAlgorithmParameterGenerator() {
super.testAlgorithmParameterGenerator();
}
-
}
diff --git a/luni/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBETest.java b/luni/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBETest.java
index f21374f..da070b6 100644
--- a/luni/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBETest.java
+++ b/luni/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBETest.java
@@ -15,8 +15,6 @@
*/
package org.apache.harmony.crypto.tests.javax.crypto.func;
-import dalvik.annotation.AndroidOnly;
-
import junit.framework.TestCase;
public class CipherPBETest extends TestCase {
@@ -32,7 +30,6 @@
.getTotalFailuresNumber());
}
- @AndroidOnly("Not supported by RI (maybe with a different name)")
public void test_PBEWithSHAand3KeyTripleDES() throws Exception {
CipherPBEThread PBEWITHSHAAND3KEYTRIPLEDESCBC = new CipherPBEThread(
"PBEWITHSHAAND3-KEYTRIPLEDES-CBC", new int[] {112, 168},
diff --git a/luni/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementFunctionalTest.java b/luni/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementFunctionalTest.java
index acb06ae..95f4191 100644
--- a/luni/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementFunctionalTest.java
+++ b/luni/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementFunctionalTest.java
@@ -15,12 +15,9 @@
*/
package org.apache.harmony.crypto.tests.javax.crypto.func;
-import dalvik.annotation.BrokenTest;
-
import junit.framework.TestCase;
public class KeyAgreementFunctionalTest extends TestCase {
- @BrokenTest("Too slow - disabling for now")
public void test_KeyAgreement() throws Exception {
String[] algArray = {"DES", "DESede"};
diff --git a/luni/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPublicKeyTest.java b/luni/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPublicKeyTest.java
index 471d670..bc7b338 100644
--- a/luni/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPublicKeyTest.java
+++ b/luni/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPublicKeyTest.java
@@ -22,8 +22,6 @@
package org.apache.harmony.crypto.tests.javax.crypto.interfaces;
-import dalvik.annotation.BrokenTest;
-
import junit.framework.TestCase;
import java.math.BigInteger;
@@ -51,7 +49,6 @@
-6628103563352519193L);
}
- @BrokenTest("Too slow - disabling for now")
public void test_getParams() throws Exception {
KeyPairGenerator kg = KeyPairGenerator.getInstance("DH");
kg.initialize(1024);
diff --git a/luni/src/test/java/org/apache/harmony/security/tests/java/security/Identity2Test.java b/luni/src/test/java/org/apache/harmony/security/tests/java/security/Identity2Test.java
index 3625dee..1362fc6 100644
--- a/luni/src/test/java/org/apache/harmony/security/tests/java/security/Identity2Test.java
+++ b/luni/src/test/java/org/apache/harmony/security/tests/java/security/Identity2Test.java
@@ -17,7 +17,6 @@
package org.apache.harmony.security.tests.java.security;
-import dalvik.annotation.AndroidOnly;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
@@ -259,8 +258,8 @@
/**
* java.security.Identity#removeCertificate(java.security.Certificate)
*/
- @AndroidOnly("Spec says: Removing unknown certificates throw an exception. "
- + "The RI ignores unknown certificates.")
+ // 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());
diff --git a/luni/src/test/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java b/luni/src/test/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java
index aa0ec67..77588f6 100644
--- a/luni/src/test/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java
+++ b/luni/src/test/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java
@@ -293,53 +293,8 @@
}
/**
- * Two {@link SecureRandom} objects, created with
- * {@link SecureRandom#getInstance(String)} and initialized before use
- * with the same seed, should return the same results.<p>
- *
- * In the future, it may sense to disallow seeding {@code SecureRandom},
- * as it tends to be error prone and open up security holes.
- * See {@link SecureRandom} for more details about insecure seeding.
- *
- * Note that this only works with the Harmony "Crypto" provider.
- */
- public void testSameSeedGeneratesSameResults() throws Exception {
- byte[] seed1 = { 'a', 'b', 'c' };
- SecureRandom sr1 = SecureRandom.getInstance("SHA1PRNG", "Crypto");
- sr1.setSeed(seed1);
-
- byte[] seed2 = { 'a', 'b', 'c' };
- SecureRandom sr2 = SecureRandom.getInstance("SHA1PRNG", "Crypto");
- sr2.setSeed(seed2);
-
- assertTrue(sr1.nextLong() == sr2.nextLong());
- }
-
- /**
- * Assert that a {@link SecureRandom} object seeded from a constant
- * seed always returns the same value, even across VM restarts.
- *
- * Future versions of Android may change the implementation of
- * SHA1PRNG, so users of {@code SecureRandom} should not assume
- * the same seed will always produce the same value. This test
- * is not a guarantee of future compatibility.
- *
- * In fact, this test only works with the Harmony "Crypto" provider.
- */
- public void testAlwaysSameValueWithSameSeed() throws Exception {
- byte[] seed1 = { 'a', 'b', 'c' };
- SecureRandom sr1 = SecureRandom.getInstance("SHA1PRNG", "Crypto");
- sr1.setSeed(seed1);
-
- // This long value has no special meaning and may change in the future.
- assertEquals(6180693691264871500l, sr1.nextLong());
- }
-
- /**
* Validate that calling {@link SecureRandom#setSeed} <b>after</b> generating
* a random number compliments, but doesn't replace, the existing seed.
- *
- * Compare this test to {@link #testAlwaysSameValueWithSameSeed()}.
*/
public void testSetSeedComplimentsAfterFirstRandomNumber() throws Exception {
byte[] seed1 = { 'a', 'b', 'c' };
diff --git a/luni/src/test/java/tests/security/cert/X509CRLSelector2Test.java b/luni/src/test/java/tests/security/cert/X509CRLSelector2Test.java
index f2e814d..1e4dce9 100644
--- a/luni/src/test/java/tests/security/cert/X509CRLSelector2Test.java
+++ b/luni/src/test/java/tests/security/cert/X509CRLSelector2Test.java
@@ -1,7 +1,5 @@
package tests.security.cert;
-import dalvik.annotation.AndroidOnly;
-
import junit.framework.TestCase;
import org.apache.harmony.security.asn1.ASN1Integer;
@@ -237,8 +235,6 @@
* criteria, if specified minCRL value matches the selector, and if CRL with
* inappropriate crlNumber value does not match the selector.
*/
- @AndroidOnly("Uses specific class: " +
- "org.apache.harmony.security.asn1.ASN1OctetString.")
public void testSetMinCRLNumberLjava_math_BigInteger() {
X509CRLSelector selector = new X509CRLSelector();
BigInteger minCRL = new BigInteger("10000");
@@ -261,8 +257,6 @@
* criteria, if specified maxCRL value matches the selector, and if CRL with
* inappropriate crlNumber value does not match the selector.
*/
- @AndroidOnly("Uses specific class: " +
- "org.apache.harmony.security.asn1.ASN1OctetString.")
public void testSetMaxCRLNumberLjava_math_BigInteger() {
X509CRLSelector selector = new X509CRLSelector();
BigInteger maxCRL = new BigInteger("10000");
@@ -459,9 +453,6 @@
* crl which matche to the initial selector should match to the clone and
* the change of clone should not cause the change of initial selector.
*/
- @AndroidOnly("Uses specific classes: " +
- "org.apache.harmony.security.asn1.ASN1OctetString, " +
- "org.apache.harmony.security.asn1.ASN1Integer.")
public void testClone() {
X509CRLSelector selector = new X509CRLSelector();
X500Principal iss1 = new X500Principal("O=First Org.");
diff --git a/luni/src/test/java/tests/security/cert/X509CRLTest.java b/luni/src/test/java/tests/security/cert/X509CRLTest.java
index c0163f3..746da9a 100644
--- a/luni/src/test/java/tests/security/cert/X509CRLTest.java
+++ b/luni/src/test/java/tests/security/cert/X509CRLTest.java
@@ -22,8 +22,6 @@
package tests.security.cert;
-import dalvik.annotation.AndroidOnly;
-
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -270,8 +268,8 @@
* Check if the default implementation throws NullPointerException
* on null input data.
*/
- @AndroidOnly("Test filed on RI: getRevokedCertificate throws " +
- "RuntimeException.")
+ // AndroidOnly("Test filed on RI: getRevokedCertificate throws " +
+ // "RuntimeException.")
public void testGetRevokedCertificate() {
try {
tbt_crl.getRevokedCertificate((X509Certificate) null);
diff --git a/luni/src/test/java/tests/targets/security/MessageDigestTestMD2.java b/luni/src/test/java/tests/targets/security/MessageDigestTestMD2.java
index 6811bc0..4483da4 100644
--- a/luni/src/test/java/tests/targets/security/MessageDigestTestMD2.java
+++ b/luni/src/test/java/tests/targets/security/MessageDigestTestMD2.java
@@ -15,7 +15,6 @@
*/
package tests.targets.security;
-import dalvik.annotation.AndroidOnly;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
@@ -24,7 +23,6 @@
public class MessageDigestTestMD2 extends TestCase {
- @AndroidOnly("Android doesn't include MD2 message digest algorithm")
public void testMessageDigest1() throws Exception{
try {
MessageDigest digest = MessageDigest.getInstance("MD2");
@@ -42,7 +40,6 @@
}
}
- @AndroidOnly("Android allows usage of MD2 in third party providers")
public void testMessageDigest2() throws Exception{
Provider provider = new MyProvider();
diff --git a/luni/src/test/java/tests/targets/security/SignatureTestMD2withRSA.java b/luni/src/test/java/tests/targets/security/SignatureTestMD2withRSA.java
index c9126ef..90ac2fa 100644
--- a/luni/src/test/java/tests/targets/security/SignatureTestMD2withRSA.java
+++ b/luni/src/test/java/tests/targets/security/SignatureTestMD2withRSA.java
@@ -15,7 +15,6 @@
*/
package tests.targets.security;
-import dalvik.annotation.AndroidOnly;
import java.security.InvalidKeyException;
import java.security.InvalidParameterException;
import java.security.NoSuchAlgorithmException;
@@ -29,7 +28,6 @@
public class SignatureTestMD2withRSA extends TestCase {
- @AndroidOnly("Android doesn't include MD2withRSA signature algorithm")
public void testSignature() {
// MD2 must not be part of android.
@@ -91,7 +89,6 @@
}
}
- @AndroidOnly("Android allows usage of MD2withRSA in third party providers")
public void testSignature2() throws Exception{
Provider provider = new MyProvider();
diff --git a/luni/src/test/java/tests/targets/security/cert/CertificateTest.java b/luni/src/test/java/tests/targets/security/cert/CertificateTest.java
index dd06249..8044f4f 100644
--- a/luni/src/test/java/tests/targets/security/cert/CertificateTest.java
+++ b/luni/src/test/java/tests/targets/security/cert/CertificateTest.java
@@ -15,7 +15,6 @@
*/
package tests.targets.security.cert;
-import dalvik.annotation.AndroidOnly;
import java.io.ByteArrayInputStream;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
@@ -602,7 +601,6 @@
}
}
- @AndroidOnly("MD2 is not supported by Android")
public void testVerifyMD2() throws Exception {
Provider[] providers = Security.getProviders("CertificateFactory.X509");
for (Provider provider : providers) {