Example usage for org.bouncycastle.crypto.generators ElGamalKeyPairGenerator init

List of usage examples for org.bouncycastle.crypto.generators ElGamalKeyPairGenerator init

Introduction

In this page you can find the example usage for org.bouncycastle.crypto.generators ElGamalKeyPairGenerator init.

Prototype

public void init(KeyGenerationParameters param) 

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 av  a  2s .c  o  m
 */
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);
}