Mercurial > hg > openjdk > jdk6 > jdk
changeset 1777:247f32d6d275
8137255: sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java timeouts intermittently
Summary: sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java timeouts intermittently due to large DSA key parameter generation.
Reviewed-by: valeriep
Contributed-by: John Jiang <sha.jiang@oracle.com>
author | igerasim |
---|---|
date | Fri, 08 Sep 2017 10:41:02 -0700 |
parents | c8d9e53ac95e |
children | 3143bede98b7 |
files | test/sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java |
diffstat | 1 files changed, 20 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/test/sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java Thu Sep 24 18:16:56 2015 +0000 +++ b/test/sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java Fri Sep 08 10:41:02 2017 -0700 @@ -33,6 +33,7 @@ import java.security.spec.InvalidParameterSpecException; import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; /* * @test @@ -40,26 +41,15 @@ * @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 { @@ -83,14 +73,7 @@ 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); } } @@ -126,11 +109,9 @@ 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( @@ -157,10 +138,21 @@ } 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 { @@ -168,18 +160,13 @@ 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); } } } +