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.DHKeyGenerationParameters; import org.bouncycastle.crypto.params.DHParameters; import org.bouncycastle.crypto.params.DHPrivateKeyParameters; import org.bouncycastle.crypto.params.DHPublicKeyParameters; /* loaded from: classes6.dex */ public class DHKeyPairGenerator implements AsymmetricCipherKeyPairGenerator { private DHKeyGenerationParameters param; @Override // org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator public void init(KeyGenerationParameters keyGenerationParameters) { this.param = (DHKeyGenerationParameters) keyGenerationParameters; } @Override // org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator public AsymmetricCipherKeyPair generateKeyPair() { DHKeyGeneratorHelper dHKeyGeneratorHelper = DHKeyGeneratorHelper.INSTANCE; DHParameters parameters = this.param.getParameters(); BigInteger calculatePrivate = dHKeyGeneratorHelper.calculatePrivate(parameters, this.param.getRandom()); return new AsymmetricCipherKeyPair((AsymmetricKeyParameter) new DHPublicKeyParameters(dHKeyGeneratorHelper.calculatePublic(parameters, calculatePrivate), parameters), (AsymmetricKeyParameter) new DHPrivateKeyParameters(calculatePrivate, parameters)); } }