8157387: StrongSecureRandom.java timeout after push for JDK-8141039
Reviewed-by: xuelei, wetmore
This commit is contained in:
parent
7827c194e7
commit
43402ad3fb
@ -272,8 +272,6 @@ sun/security/pkcs11/tls/TestMasterSecret.java 8077138,8023434
|
||||
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/tools/keytool/autotest.sh 8130302 generic-
|
||||
|
||||
sun/security/x509/URICertStore/ExtensionsWithLDAP.java 8134577 generic-all
|
||||
|
||||
sun/security/provider/SecureRandom/StrongSecureRandom.java 8157387 linux-all
|
||||
|
||||
############################################################################
|
||||
|
||||
# jdk_sound
|
||||
|
@ -36,9 +36,6 @@ import java.util.*;
|
||||
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 @@ public class StrongSecureRandom {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 class StrongSecureRandom {
|
||||
|
||||
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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user