package org.bouncycastle.crypto.generators;

/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
public class GOST3410KeyPairGenerator implements org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator {
    private org.bouncycastle.crypto.params.GOST3410KeyGenerationParameters g;

    @Override // org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator
    public org.bouncycastle.crypto.AsymmetricCipherKeyPair a() {
        org.bouncycastle.crypto.params.GOST3410Parameters gOST3410ParametersC = this.g.c();
        java.security.SecureRandom secureRandomA = this.g.a();
        java.math.BigInteger bigIntegerC = gOST3410ParametersC.c();
        java.math.BigInteger bigIntegerB = gOST3410ParametersC.b();
        java.math.BigInteger bigIntegerA = gOST3410ParametersC.a();
        while (true) {
            java.math.BigInteger bigIntegerF = org.bouncycastle.util.BigIntegers.f(256, secureRandomA);
            if (bigIntegerF.signum() >= 1 && bigIntegerF.compareTo(bigIntegerC) < 0 && org.bouncycastle.math.ec.WNafUtil.h(bigIntegerF) >= 64) {
                return new org.bouncycastle.crypto.AsymmetricCipherKeyPair(new org.bouncycastle.crypto.params.GOST3410PublicKeyParameters(bigIntegerA.modPow(bigIntegerF, bigIntegerB), gOST3410ParametersC), new org.bouncycastle.crypto.params.GOST3410PrivateKeyParameters(bigIntegerF, gOST3410ParametersC));
            }
        }
    }

    @Override // org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator
    public void b(org.bouncycastle.crypto.KeyGenerationParameters keyGenerationParameters) {
        org.bouncycastle.crypto.params.GOST3410KeyGenerationParameters gOST3410KeyGenerationParameters = (org.bouncycastle.crypto.params.GOST3410KeyGenerationParameters) keyGenerationParameters;
        this.g = gOST3410KeyGenerationParameters;
        org.bouncycastle.crypto.CryptoServicesRegistrar.a(new org.bouncycastle.crypto.constraints.DefaultServiceProperties("GOST3410KeyGen", org.bouncycastle.crypto.constraints.ConstraintUtils.a(gOST3410KeyGenerationParameters.c().b()), this.g.c(), org.bouncycastle.crypto.CryptoServicePurpose.KEYGEN));
    }
}
