8157387: StrongSecureRandom.java timeout after push for JDK-8141039
authorweijun
Fri, 17 Jun 2016 09:46:36 +0800
changeset 39048 2de4043496e1
parent 39047 cf08ea56b4de
child 39049 1108f7f41940
8157387: StrongSecureRandom.java timeout after push for JDK-8141039 Reviewed-by: xuelei, wetmore
jdk/test/ProblemList.txt
jdk/test/sun/security/provider/SecureRandom/StrongSecureRandom.java
--- a/jdk/test/ProblemList.txt	Fri Jun 17 09:46:34 2016 +0800
+++ b/jdk/test/ProblemList.txt	Fri Jun 17 09:46:36 2016 +0800
@@ -272,8 +272,6 @@
 sun/security/pkcs11/tls/TestPRF.java                            8077138,8023434 windows-all
 sun/security/pkcs11/tls/TestPremaster.java                      8077138,8023434 windows-all
 
-sun/security/provider/SecureRandom/StrongSecureRandom.java      8051770 macosx-10.10
-
 sun/security/pkcs11/rsa/TestKeyPairGenerator.java               8074580 generic-all
 
 sun/security/krb5/auto/HttpNegotiateServer.java                 8038079 generic-all
@@ -282,8 +280,6 @@
 
 sun/security/x509/URICertStore/ExtensionsWithLDAP.java          8134577 generic-all
 
-sun/security/provider/SecureRandom/StrongSecureRandom.java      8157387 linux-all
-
 ############################################################################
 
 # jdk_sound
--- a/jdk/test/sun/security/provider/SecureRandom/StrongSecureRandom.java	Fri Jun 17 09:46:34 2016 +0800
+++ b/jdk/test/sun/security/provider/SecureRandom/StrongSecureRandom.java	Fri Jun 17 09:46:36 2016 +0800
@@ -36,9 +36,6 @@
 public class StrongSecureRandom {
 
     private static final String os = System.getProperty("os.name", "unknown");
-    private static final String DRBG_CONFIG = "securerandom.drbg.config";
-    private static final String DRBG_CONFIG_VALUE
-            = Security.getProperty(DRBG_CONFIG);
 
     private static void testDefaultEgd() throws Exception {
         // No SecurityManager installed.
@@ -50,55 +47,6 @@
         }
     }
 
-    /**
-     * Verify if the mechanism is DRBG type.
-     * @param mech Mechanism name
-     * @return True if the mechanism name is DRBG type else False.
-     */
-    private static boolean isDRBG(String mech) {
-        return mech.contains("_DRBG");
-    }
-
-    private static void testSecureRandomImpl(String algo, boolean drbg)
-            throws Exception {
-
-        byte[] ba;
-        final String secureRandomSource
-                = Security.getProperty("securerandom.source");
-        try {
-            String urandom = "file:/dev/urandom";
-
-            System.out.println("Testing new SeedGenerator and EGD");
-
-            Security.setProperty("securerandom.source", urandom);
-            if (!Security.getProperty("securerandom.source").equals(urandom)) {
-                throw new Exception("Couldn't set securerandom.source");
-            }
-
-            /*
-             * Take out a large number of bytes in hopes of blocking.
-             * Don't expect this to happen, unless something is broken on Linux
-             */
-            SecureRandom sr = null;
-            if (drbg) {
-                Security.setProperty(DRBG_CONFIG, algo);
-                sr = SecureRandom.getInstance("DRBG");
-            } else {
-                sr = SecureRandom.getInstance(algo);
-            }
-            if (!sr.getAlgorithm().equals(isDRBG(algo) ? "DRBG" : algo)) {
-                throw new Exception("sr.getAlgorithm(): " + sr.getAlgorithm());
-            }
-
-            ba = sr.generateSeed(4096);
-            sr.nextBytes(ba);
-            sr.setSeed(ba);
-        } finally {
-            Security.setProperty("securerandom.source", secureRandomSource);
-            Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE);
-        }
-    }
-
     private static void testNativePRNGImpls() throws Exception {
         SecureRandom sr;
         byte[] ba;
@@ -259,10 +207,7 @@
 
     public static void main(String args[]) throws Exception {
         testDefaultEgd();
-        for (String algo : new String[]{
-            "SHA1PRNG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) {
-            testSecureRandomImpl(algo, isDRBG(algo));
-        }
+
         testNativePRNGImpls();
         testAllImpls();