use of java.security.AlgorithmParameterGenerator in project jdk8u_jdk by JetBrains.
the class TestDSAGenParameterSpec method testDSAGenParameterSpec.
private static void testDSAGenParameterSpec(DataTuple dataTuple) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidParameterSpecException, InvalidAlgorithmParameterException {
System.out.printf("Test case: primePLen=%d, " + "subprimeQLen=%d%n", dataTuple.primePLen, dataTuple.subprimeQLen);
AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance(ALGORITHM_NAME, PROVIDER_NAME);
DSAGenParameterSpec genParamSpec = createGenParameterSpec(dataTuple);
// genParamSpec will be null if IllegalAE is thrown when expected.
if (genParamSpec == null) {
return;
}
try {
apg.init(genParamSpec, null);
AlgorithmParameters param = apg.generateParameters();
checkParam(param, genParamSpec);
System.out.println("Test case passed");
} catch (InvalidParameterException ipe) {
// 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);
}
}
}
Aggregations