use of org.bouncycastle.crypto.params.DSAParameterGenerationParameters in project robovm by robovm.
the class AlgorithmParameterGeneratorSpi method engineGenerateParameters.
protected AlgorithmParameters engineGenerateParameters() {
DSAParametersGenerator pGen;
if (strength <= 1024) {
pGen = new DSAParametersGenerator();
} else {
pGen = new DSAParametersGenerator(new SHA256Digest());
}
if (random == null) {
random = new SecureRandom();
}
if (strength == 1024) {
params = new DSAParameterGenerationParameters(1024, 160, 80, random);
pGen.init(params);
} else if (strength > 1024) {
params = new DSAParameterGenerationParameters(strength, 256, 80, random);
pGen.init(params);
} else {
pGen.init(strength, 20, random);
}
DSAParameters p = pGen.generateParameters();
AlgorithmParameters params;
try {
params = AlgorithmParameters.getInstance("DSA", BouncyCastleProvider.PROVIDER_NAME);
params.init(new DSAParameterSpec(p.getP(), p.getQ(), p.getG()));
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
return params;
}
use of org.bouncycastle.crypto.params.DSAParameterGenerationParameters in project xipki by xipki.
the class DSAParameterCache method getNewDSAParameterSpec.
// CHECKSTYLE:SKIP
public static DSAParameterSpec getNewDSAParameterSpec(int plength, int qlength, SecureRandom random) {
final int certainty = 80;
SecureRandom tmpRandom = (random == null) ? new SecureRandom() : random;
DSAParametersGenerator paramGen = new DSAParametersGenerator(new SHA512Digest());
DSAParameterGenerationParameters genParams = new DSAParameterGenerationParameters(plength, qlength, certainty, tmpRandom);
paramGen.init(genParams);
DSAParameters dsaParams = paramGen.generateParameters();
return new DSAParameterSpec(dsaParams.getP(), dsaParams.getQ(), dsaParams.getG());
}
Aggregations