Search in sources :

Example 1 with DSAKeyGenerationParameters

use of org.bouncycastle.crypto.params.DSAKeyGenerationParameters in project robovm by robovm.

the class KeyPairGeneratorSpi method generateKeyPair.

public KeyPair generateKeyPair() {
    if (!initialised) {
        DSAParametersGenerator pGen = new DSAParametersGenerator();
        pGen.init(strength, certainty, random);
        param = new DSAKeyGenerationParameters(random, pGen.generateParameters());
        engine.init(param);
        initialised = true;
    }
    AsymmetricCipherKeyPair pair = engine.generateKeyPair();
    DSAPublicKeyParameters pub = (DSAPublicKeyParameters) pair.getPublic();
    DSAPrivateKeyParameters priv = (DSAPrivateKeyParameters) pair.getPrivate();
    return new KeyPair(new BCDSAPublicKey(pub), new BCDSAPrivateKey(priv));
}
Also used : DSAParametersGenerator(org.bouncycastle.crypto.generators.DSAParametersGenerator) DSAPublicKeyParameters(org.bouncycastle.crypto.params.DSAPublicKeyParameters) KeyPair(java.security.KeyPair) AsymmetricCipherKeyPair(org.bouncycastle.crypto.AsymmetricCipherKeyPair) DSAKeyGenerationParameters(org.bouncycastle.crypto.params.DSAKeyGenerationParameters) DSAPrivateKeyParameters(org.bouncycastle.crypto.params.DSAPrivateKeyParameters) AsymmetricCipherKeyPair(org.bouncycastle.crypto.AsymmetricCipherKeyPair)

Example 2 with DSAKeyGenerationParameters

use of org.bouncycastle.crypto.params.DSAKeyGenerationParameters in project robovm by robovm.

the class KeyPairGeneratorSpi method initialize.

public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException {
    if (!(params instanceof DSAParameterSpec)) {
        throw new InvalidAlgorithmParameterException("parameter object not a DSAParameterSpec");
    }
    DSAParameterSpec dsaParams = (DSAParameterSpec) params;
    param = new DSAKeyGenerationParameters(random, new DSAParameters(dsaParams.getP(), dsaParams.getQ(), dsaParams.getG()));
    engine.init(param);
    initialised = true;
}
Also used : DSAParameterSpec(java.security.spec.DSAParameterSpec) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) DSAKeyGenerationParameters(org.bouncycastle.crypto.params.DSAKeyGenerationParameters) DSAParameters(org.bouncycastle.crypto.params.DSAParameters)

Aggregations

DSAKeyGenerationParameters (org.bouncycastle.crypto.params.DSAKeyGenerationParameters)2 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)1 KeyPair (java.security.KeyPair)1 DSAParameterSpec (java.security.spec.DSAParameterSpec)1 AsymmetricCipherKeyPair (org.bouncycastle.crypto.AsymmetricCipherKeyPair)1 DSAParametersGenerator (org.bouncycastle.crypto.generators.DSAParametersGenerator)1 DSAParameters (org.bouncycastle.crypto.params.DSAParameters)1 DSAPrivateKeyParameters (org.bouncycastle.crypto.params.DSAPrivateKeyParameters)1 DSAPublicKeyParameters (org.bouncycastle.crypto.params.DSAPublicKeyParameters)1