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.");
}
}
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;
}
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());
}
}
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();
}
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());
}
Aggregations