Example usage for org.bouncycastle.jce.spec ElGamalParameterSpec ElGamalParameterSpec

List of usage examples for org.bouncycastle.jce.spec ElGamalParameterSpec ElGamalParameterSpec

Introduction

In this page you can find the example usage for org.bouncycastle.jce.spec ElGamalParameterSpec ElGamalParameterSpec.

Prototype

public ElGamalParameterSpec(BigInteger p, BigInteger g) 

Source Link

Document

Constructs a parameter set for Diffie-Hellman, using a prime modulus p and a base generator g.

Usage

From source file:ElGamalPrivatePGKey.java

License:Open Source License

public ElGamalPrivatePGKey(ElGamalPrivateKeySpec spec) {
    this.x = spec.getX();
    this.elSpec = new ElGamalParameterSpec(spec.getParams().getP(), spec.getParams().getG());
}

From source file:ElGamalPrivatePGKey.java

License:Open Source License

public ElGamalPrivatePGKey(PrivateKeyInfo info) {
    ElGamalParameter params = new ElGamalParameter((ASN1Sequence) info.getAlgorithmId().getParameters());
    DERInteger derX = (DERInteger) info.getPrivateKey();

    this.x = derX.getValue();
    this.elSpec = new ElGamalParameterSpec(params.getP(), params.getG());
}

From source file:ElGamalPrivatePGKey.java

License:Open Source License

public ElGamalPrivatePGKey(ElGamalPrivateKeyParameters params) {
    this.x = params.getX();
    this.elSpec = new ElGamalParameterSpec(params.getParameters().getP(), params.getParameters().getG());
}

From source file:ElGamalPrivatePGKey.java

License:Open Source License

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    x = (BigInteger) in.readObject();

    this.elSpec = new ElGamalParameterSpec((BigInteger) in.readObject(), (BigInteger) in.readObject());
}

From source file:ElGamalPublicPGKey.java

License:Open Source License

public ElGamalPublicPGKey(ElGamalPublicKeySpec spec) {
    this.y = spec.getY();
    this.elSpec = new ElGamalParameterSpec(spec.getParams().getP(), spec.getParams().getG());
}

From source file:ElGamalPublicPGKey.java

License:Open Source License

public ElGamalPublicPGKey(ElGamalPublicKeyParameters params) {
    this.y = params.getY();
    this.elSpec = new ElGamalParameterSpec(params.getParameters().getP(), params.getParameters().getG());
}

From source file:ElGamalPublicPGKey.java

License:Open Source License

public ElGamalPublicPGKey(SubjectPublicKeyInfo info) {
    ElGamalParameter params = new ElGamalParameter((ASN1Sequence) info.getAlgorithmId().getParameters());
    DERInteger derY = null;/*from  w  ww.j  a  v  a  2  s  .com*/

    try {
        derY = (DERInteger) info.getPublicKey();
    } catch (IOException e) {
        throw new IllegalArgumentException("invalid info structure in DSA public key");
    }

    this.y = derY.getValue();
    this.elSpec = new ElGamalParameterSpec(params.getP(), params.getG());
}

From source file:ElGamalPublicPGKey.java

License:Open Source License

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    this.y = (BigInteger) in.readObject();
    this.elSpec = new ElGamalParameterSpec((BigInteger) in.readObject(), (BigInteger) in.readObject());
}

From source file:SELSKeyGen.java

License:Open Source License

private static void LSKeyGen(String LSUserId, String LSPass, int expsec) throws Exception {
    KeyPairGenerator dsaKpg = KeyPairGenerator.getInstance("DSA", "BC");
    KeyPair dsaKp;/* ww  w.  j  ava 2 s. c  o  m*/
    KeyPairGenerator elgKpg;
    ElGamalParameterSpec elParams = new ElGamalParameterSpec(p, g);
    KeyPair elgKp;

    //   LS
    FileOutputStream out1 = new FileOutputStream(SELS_LIST_PATH + "/LS_secret.asc");
    FileOutputStream out2 = new FileOutputStream(SELS_LIST_PATH + "/LS_pub.asc");

    dsaKpg = KeyPairGenerator.getInstance("DSA", "BC");
    dsaKpg.initialize(1024);
    dsaKp = dsaKpg.generateKeyPair();

    elgKpg = KeyPairGenerator.getInstance("ELGAMAL", "BC");
    elgKpg.initialize(elParams);
    elgKp = elgKpg.generateKeyPair();
    secKeyLS = (ElGamalPrivateKey) elgKp.getPrivate();
    exportKeyPair(out1, out2, dsaKp, elgKp, LSUserId, LSPass.toCharArray(), true, expsec);
}

From source file:SELSKeyGen.java

License:Open Source License

private static void LMKeyGen(String LMUserId, String LMPass, int expsec) throws Exception {
    KeyPairGenerator dsaKpg = KeyPairGenerator.getInstance("DSA", "BC");
    KeyPair dsaKp;/*from  www  . j  a  v  a2  s .c  o  m*/
    KeyPairGenerator elgKpg;
    ElGamalParameterSpec elParams = new ElGamalParameterSpec(p, g);
    KeyPair elgKp;

    //   LM
    FileOutputStream out1 = new FileOutputStream(SELS_LIST_PATH + "/LM_secret.asc");
    FileOutputStream out2 = new FileOutputStream(SELS_LIST_PATH + "/LM_pub.asc");

    dsaKpg = KeyPairGenerator.getInstance("DSA", "BC");
    dsaKpg.initialize(1024);
    dsaKp = dsaKpg.generateKeyPair();

    elgKpg = KeyPairGenerator.getInstance("ELGAMAL", "BC");
    elgKpg.initialize(elParams);
    elgKp = elgKpg.generateKeyPair();
    secKeyLM = (ElGamalPrivateKey) elgKp.getPrivate();
    exportKeyPair(out1, out2, dsaKp, elgKp, LMUserId, LMPass.toCharArray(), true, expsec);
}