Search in sources :

Example 1 with ElGamalParameterSpec

use of com.github.zhenwei.provider.jce.spec.ElGamalParameterSpec in project LinLong-Java by zhenwei1108.

the class AlgorithmParametersSpi method engineInit.

protected void engineInit(byte[] params) throws IOException {
    try {
        ElGamalParameter elP = ElGamalParameter.getInstance(ASN1Primitive.fromByteArray(params));
        currentSpec = new ElGamalParameterSpec(elP.getP(), elP.getG());
    } catch (ClassCastException e) {
        throw new IOException("Not a valid ElGamal Parameter encoding.");
    } catch (ArrayIndexOutOfBoundsException e) {
        throw new IOException("Not a valid ElGamal Parameter encoding.");
    }
}
Also used : ElGamalParameter(com.github.zhenwei.core.asn1.oiw.ElGamalParameter) IOException(java.io.IOException) ElGamalParameterSpec(com.github.zhenwei.provider.jce.spec.ElGamalParameterSpec)

Example 2 with ElGamalParameterSpec

use of com.github.zhenwei.provider.jce.spec.ElGamalParameterSpec in project LinLong-Java by zhenwei1108.

the class KeyPairGeneratorSpi method initialize.

public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException {
    if (!(params instanceof ElGamalParameterSpec) && !(params instanceof DHParameterSpec)) {
        throw new InvalidAlgorithmParameterException("parameter object not a DHParameterSpec or an ElGamalParameterSpec");
    }
    if (params instanceof ElGamalParameterSpec) {
        ElGamalParameterSpec elParams = (ElGamalParameterSpec) params;
        param = new ElGamalKeyGenerationParameters(random, new ElGamalParameters(elParams.getP(), elParams.getG()));
    } else {
        DHParameterSpec dhParams = (DHParameterSpec) params;
        param = new ElGamalKeyGenerationParameters(random, new ElGamalParameters(dhParams.getP(), dhParams.getG(), dhParams.getL()));
    }
    engine.init(param);
    initialised = true;
}
Also used : InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) ElGamalParameters(com.github.zhenwei.core.crypto.params.ElGamalParameters) ElGamalKeyGenerationParameters(com.github.zhenwei.core.crypto.params.ElGamalKeyGenerationParameters) DHParameterSpec(javax.crypto.spec.DHParameterSpec) ElGamalParameterSpec(com.github.zhenwei.provider.jce.spec.ElGamalParameterSpec)

Example 3 with ElGamalParameterSpec

use of com.github.zhenwei.provider.jce.spec.ElGamalParameterSpec in project LinLong-Java by zhenwei1108.

the class AlgorithmParametersSpi method engineInit.

protected void engineInit(AlgorithmParameterSpec paramSpec) throws InvalidParameterSpecException {
    if (!(paramSpec instanceof ElGamalParameterSpec) && !(paramSpec instanceof DHParameterSpec)) {
        throw new InvalidParameterSpecException("DHParameterSpec required to initialise a ElGamal algorithm parameters object");
    }
    if (paramSpec instanceof ElGamalParameterSpec) {
        this.currentSpec = (ElGamalParameterSpec) paramSpec;
    } else {
        DHParameterSpec s = (DHParameterSpec) paramSpec;
        this.currentSpec = new ElGamalParameterSpec(s.getP(), s.getG());
    }
}
Also used : DHParameterSpec(javax.crypto.spec.DHParameterSpec) InvalidParameterSpecException(java.security.spec.InvalidParameterSpecException) ElGamalParameterSpec(com.github.zhenwei.provider.jce.spec.ElGamalParameterSpec)

Example 4 with ElGamalParameterSpec

use of com.github.zhenwei.provider.jce.spec.ElGamalParameterSpec in project LinLong-Java by zhenwei1108.

the class BCElGamalPrivateKey method readObject.

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    this.elSpec = new ElGamalParameterSpec((BigInteger) in.readObject(), (BigInteger) in.readObject());
    this.attrCarrier = new PKCS12BagAttributeCarrierImpl();
}
Also used : PKCS12BagAttributeCarrierImpl(com.github.zhenwei.provider.jcajce.provider.asymmetric.util.PKCS12BagAttributeCarrierImpl) BigInteger(java.math.BigInteger) ElGamalParameterSpec(com.github.zhenwei.provider.jce.spec.ElGamalParameterSpec)

Example 5 with ElGamalParameterSpec

use of com.github.zhenwei.provider.jce.spec.ElGamalParameterSpec in project LinLong-Java by zhenwei1108.

the class BCElGamalPublicKey method readObject.

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    this.elSpec = new ElGamalParameterSpec((BigInteger) in.readObject(), (BigInteger) in.readObject());
}
Also used : BigInteger(java.math.BigInteger) ElGamalParameterSpec(com.github.zhenwei.provider.jce.spec.ElGamalParameterSpec)

Aggregations

ElGamalParameterSpec (com.github.zhenwei.provider.jce.spec.ElGamalParameterSpec)7 BigInteger (java.math.BigInteger)4 DHParameterSpec (javax.crypto.spec.DHParameterSpec)2 ElGamalParameter (com.github.zhenwei.core.asn1.oiw.ElGamalParameter)1 ElGamalKeyGenerationParameters (com.github.zhenwei.core.crypto.params.ElGamalKeyGenerationParameters)1 ElGamalParameters (com.github.zhenwei.core.crypto.params.ElGamalParameters)1 PKCS12BagAttributeCarrierImpl (com.github.zhenwei.provider.jcajce.provider.asymmetric.util.PKCS12BagAttributeCarrierImpl)1 IOException (java.io.IOException)1 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)1 InvalidParameterSpecException (java.security.spec.InvalidParameterSpecException)1