Example usage for org.bouncycastle.crypto.params ElGamalKeyGenerationParameters ElGamalKeyGenerationParameters

List of usage examples for org.bouncycastle.crypto.params ElGamalKeyGenerationParameters ElGamalKeyGenerationParameters

Introduction

In this page you can find the example usage for org.bouncycastle.crypto.params ElGamalKeyGenerationParameters ElGamalKeyGenerationParameters.

Prototype

public ElGamalKeyGenerationParameters(SecureRandom random, ElGamalParameters params) 

Source Link

Usage

From source file:util.secure.AsymKeysImpl.java

License:Open Source License

/**
 * This method is used to generate Public Key and Private Key
 * @param params/*from  w  w w . j a va 2 s  . com*/
 */
private void GenerateKeys(ElGamalParameters params, String password) {
    ElGamalKeyGenerationParameters elGP = new ElGamalKeyGenerationParameters(random, params);
    ElGamalKeyPairGenerator KeyPair = new ElGamalKeyPairGenerator();
    KeyPair.init(elGP);
    AsymmetricCipherKeyPair cipher1 = KeyPair.generateKeyPair();
    publicKey = ((ElGamalPublicKeyParameters) cipher1.getPublic()).getY();
    privateKey = ((ElGamalPrivateKeyParameters) cipher1.getPrivate()).getX();
    wellGenerated = true;
    encryptPrivateKey(password);
}