32 lines
1.8 KiB
Java
32 lines
1.8 KiB
Java
|
package org.bouncycastle.crypto.generators;
|
||
|
|
||
|
import java.math.BigInteger;
|
||
|
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
|
||
|
import org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator;
|
||
|
import org.bouncycastle.crypto.KeyGenerationParameters;
|
||
|
import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
|
||
|
import org.bouncycastle.crypto.params.DHParameters;
|
||
|
import org.bouncycastle.crypto.params.ElGamalKeyGenerationParameters;
|
||
|
import org.bouncycastle.crypto.params.ElGamalParameters;
|
||
|
import org.bouncycastle.crypto.params.ElGamalPrivateKeyParameters;
|
||
|
import org.bouncycastle.crypto.params.ElGamalPublicKeyParameters;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public class ElGamalKeyPairGenerator implements AsymmetricCipherKeyPairGenerator {
|
||
|
private ElGamalKeyGenerationParameters param;
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator
|
||
|
public void init(KeyGenerationParameters keyGenerationParameters) {
|
||
|
this.param = (ElGamalKeyGenerationParameters) keyGenerationParameters;
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator
|
||
|
public AsymmetricCipherKeyPair generateKeyPair() {
|
||
|
DHKeyGeneratorHelper dHKeyGeneratorHelper = DHKeyGeneratorHelper.INSTANCE;
|
||
|
ElGamalParameters parameters = this.param.getParameters();
|
||
|
DHParameters dHParameters = new DHParameters(parameters.getP(), parameters.getG(), null, parameters.getL());
|
||
|
BigInteger calculatePrivate = dHKeyGeneratorHelper.calculatePrivate(dHParameters, this.param.getRandom());
|
||
|
return new AsymmetricCipherKeyPair((AsymmetricKeyParameter) new ElGamalPublicKeyParameters(dHKeyGeneratorHelper.calculatePublic(dHParameters, calculatePrivate), parameters), (AsymmetricKeyParameter) new ElGamalPrivateKeyParameters(calculatePrivate, parameters));
|
||
|
}
|
||
|
}
|