Example usage for org.bouncycastle.jce.interfaces ElGamalPublicKey getParameters

List of usage examples for org.bouncycastle.jce.interfaces ElGamalPublicKey getParameters

Introduction

In this page you can find the example usage for org.bouncycastle.jce.interfaces ElGamalPublicKey getParameters.

Prototype

public ElGamalParameterSpec getParameters();

Source Link

Usage

From source file:ElGamalPublicPGKey.java

License:Open Source License

public ElGamalPublicPGKey(ElGamalPublicKey key) {
    this.y = key.getY();
    this.elSpec = key.getParameters();
}

From source file:genkeys.java

License:Open Source License

private static PublicKeyPacket publicKeyPacket(PublicKey key, int algorithm, Date time) throws PGPException {
    BCPGKey bcpgKey;//from w  ww .ja  v a 2  s  .c o m
    if (key instanceof RSAPublicKey) {
        RSAPublicKey rK = (RSAPublicKey) key;
        bcpgKey = new RSAPublicBCPGKey(rK.getModulus(), rK.getPublicExponent());
    } else if (key instanceof DSAPublicKey) {
        DSAPublicKey dK = (DSAPublicKey) key;
        DSAParams dP = dK.getParams();
        bcpgKey = new DSAPublicBCPGKey(dP.getP(), dP.getQ(), dP.getG(), dK.getY());
    } else if (key instanceof ElGamalPublicKey) {
        ElGamalPublicKey eK = (ElGamalPublicKey) key;
        ElGamalParameterSpec eS = eK.getParameters();
        bcpgKey = new ElGamalPublicBCPGKey(eS.getP(), eS.getG(), eK.getY());
    } else {
        throw new PGPException("unknown key class");
    }

    return new PublicKeyPacket(algorithm, time, bcpgKey);
}