8137255: sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java timeouts intermittently
Sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java timeouts intermittently due to large DSA key parameter generation. Reviewed-by: valeriep
This commit is contained in:
parent
f86a99352f
commit
4ed9567218
@ -288,8 +288,6 @@ sun/security/krb5/auto/HttpNegotiateServer.java 8038079 generic-
|
||||
|
||||
sun/security/tools/keytool/autotest.sh 8130302 generic-all
|
||||
|
||||
sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java 8137255 generic-all
|
||||
|
||||
sun/security/x509/URICertStore/ExtensionsWithLDAP.java 8134577 generic-all
|
||||
|
||||
sun/security/provider/SecureRandom/StrongSecureRandom.java 8157387 linux-all
|
||||
|
@ -33,6 +33,7 @@ import java.security.spec.DSAParameterSpec;
|
||||
import java.security.spec.InvalidParameterSpecException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/*
|
||||
* @test
|
||||
@ -41,26 +42,15 @@ import java.util.List;
|
||||
* @summary Verify that DSAGenParameterSpec can and can only be used to generate
|
||||
* DSA within some certain range of key sizes as described in the class
|
||||
* specification (L, N) as (1024, 160), (2048, 224), (2048, 256) and
|
||||
* (3072, 256) should be OK for DSAGenParameterSpec. But the real
|
||||
* implementation SUN doesn't support (3072, 256).
|
||||
* @run main TestDSAGenParameterSpec
|
||||
* (3072, 256) should be OK for DSAGenParameterSpec.
|
||||
* @run main TestDSAGenParameterSpec 2048,256,true 2048,224,true 1024,160,true 4096,256 3072,224 2048,160 1024,224 512,160
|
||||
* @run main TestDSAGenParameterSpec 3072,256,true
|
||||
*/
|
||||
public class TestDSAGenParameterSpec {
|
||||
|
||||
private static final String ALGORITHM_NAME = "DSA";
|
||||
private static final String PROVIDER_NAME = "SUN";
|
||||
|
||||
private static final List<DataTuple> DATA = Arrays.asList(
|
||||
new DataTuple(1024, 160, true, true),
|
||||
new DataTuple(2048, 224, true, true),
|
||||
new DataTuple(2048, 256, true, true),
|
||||
new DataTuple(3072, 256, true, false),
|
||||
new DataTuple(1024, 224),
|
||||
new DataTuple(2048, 160),
|
||||
new DataTuple(4096, 256),
|
||||
new DataTuple(512, 160),
|
||||
new DataTuple(3072, 224));
|
||||
|
||||
private static void testDSAGenParameterSpec(DataTuple dataTuple)
|
||||
throws NoSuchAlgorithmException, NoSuchProviderException,
|
||||
InvalidParameterSpecException, InvalidAlgorithmParameterException {
|
||||
@ -84,14 +74,7 @@ public class TestDSAGenParameterSpec {
|
||||
checkParam(param, genParamSpec);
|
||||
System.out.println("Test case passed");
|
||||
} catch (InvalidParameterException ipe) {
|
||||
// The DSAGenParameterSpec API support this, but the real
|
||||
// implementation in SUN doesn't
|
||||
if (!dataTuple.isSunProviderSupported) {
|
||||
System.out.println("Test case passed: expected "
|
||||
+ "InvalidParameterException is caught");
|
||||
} else {
|
||||
throw new RuntimeException("Test case failed.", ipe);
|
||||
}
|
||||
throw new RuntimeException("Test case failed.", ipe);
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,11 +110,9 @@ public class TestDSAGenParameterSpec {
|
||||
throw new RuntimeException("Wrong seed length");
|
||||
}
|
||||
|
||||
// use the parameters to generate real DSA keys
|
||||
KeyPairGenerator keyGen = KeyPairGenerator.getInstance(ALGORITHM_NAME,
|
||||
PROVIDER_NAME);
|
||||
keyGen.initialize(spec);
|
||||
keyGen.generateKeyPair();
|
||||
}
|
||||
|
||||
private static DSAGenParameterSpec createGenParameterSpec(
|
||||
@ -158,10 +139,21 @@ public class TestDSAGenParameterSpec {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
for (DataTuple dataTuple : DATA) {
|
||||
List<DataTuple> dataTuples = Arrays.stream(args)
|
||||
.map(arg -> arg.split(",")).map(params -> {
|
||||
int primePLen = Integer.valueOf(params[0]);
|
||||
int subprimeQLen = Integer.valueOf(params[1]);
|
||||
boolean isDSASpecSupported = false;
|
||||
if (params.length == 3) {
|
||||
isDSASpecSupported = Boolean.valueOf(params[2]);
|
||||
}
|
||||
return new DataTuple(primePLen, subprimeQLen,
|
||||
isDSASpecSupported);
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
for (DataTuple dataTuple : dataTuples) {
|
||||
testDSAGenParameterSpec(dataTuple);
|
||||
}
|
||||
System.out.println("All tests passed");
|
||||
}
|
||||
|
||||
private static class DataTuple {
|
||||
@ -169,18 +161,13 @@ public class TestDSAGenParameterSpec {
|
||||
private int primePLen;
|
||||
private int subprimeQLen;
|
||||
private boolean isDSASpecSupported;
|
||||
private boolean isSunProviderSupported;
|
||||
|
||||
private DataTuple(int primePLen, int subprimeQLen,
|
||||
boolean isDSASpecSupported, boolean isSunProviderSupported) {
|
||||
boolean isDSASpecSupported) {
|
||||
this.primePLen = primePLen;
|
||||
this.subprimeQLen = subprimeQLen;
|
||||
this.isDSASpecSupported = isDSASpecSupported;
|
||||
this.isSunProviderSupported = isSunProviderSupported;
|
||||
}
|
||||
|
||||
private DataTuple(int primePLen, int subprimeQLen) {
|
||||
this(primePLen, subprimeQLen, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user