package org.bouncycastle.crypto.generators;

/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
public class CramerShoupKeyPairGenerator implements org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator {
    private static final java.math.BigInteger h = java.math.BigInteger.valueOf(1);
    private org.bouncycastle.crypto.params.CramerShoupKeyGenerationParameters g;

    private org.bouncycastle.crypto.params.CramerShoupPublicKeyParameters c(org.bouncycastle.crypto.params.CramerShoupParameters cramerShoupParameters, org.bouncycastle.crypto.params.CramerShoupPrivateKeyParameters cramerShoupPrivateKeyParameters) {
        java.math.BigInteger bigIntegerA = cramerShoupParameters.a();
        java.math.BigInteger bigIntegerB = cramerShoupParameters.b();
        java.math.BigInteger bigIntegerC = cramerShoupParameters.c();
        return new org.bouncycastle.crypto.params.CramerShoupPublicKeyParameters(cramerShoupParameters, bigIntegerA.modPow(cramerShoupPrivateKeyParameters.h(), bigIntegerC).multiply(bigIntegerB.modPow(cramerShoupPrivateKeyParameters.i(), bigIntegerC)), bigIntegerA.modPow(cramerShoupPrivateKeyParameters.j(), bigIntegerC).multiply(bigIntegerB.modPow(cramerShoupPrivateKeyParameters.k(), bigIntegerC)), bigIntegerA.modPow(cramerShoupPrivateKeyParameters.l(), bigIntegerC));
    }

    private org.bouncycastle.crypto.params.CramerShoupPrivateKeyParameters d(java.security.SecureRandom secureRandom, org.bouncycastle.crypto.params.CramerShoupParameters cramerShoupParameters) {
        java.math.BigInteger bigIntegerC = cramerShoupParameters.c();
        return new org.bouncycastle.crypto.params.CramerShoupPrivateKeyParameters(cramerShoupParameters, e(bigIntegerC, secureRandom), e(bigIntegerC, secureRandom), e(bigIntegerC, secureRandom), e(bigIntegerC, secureRandom), e(bigIntegerC, secureRandom));
    }

    private java.math.BigInteger e(java.math.BigInteger bigInteger, java.security.SecureRandom secureRandom) {
        java.math.BigInteger bigInteger2 = h;
        return org.bouncycastle.util.BigIntegers.g(bigInteger2, bigInteger.subtract(bigInteger2), secureRandom);
    }

    @Override // org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator
    public org.bouncycastle.crypto.AsymmetricCipherKeyPair a() {
        org.bouncycastle.crypto.params.CramerShoupParameters cramerShoupParametersC = this.g.c();
        org.bouncycastle.crypto.params.CramerShoupPrivateKeyParameters cramerShoupPrivateKeyParametersD = d(this.g.a(), cramerShoupParametersC);
        org.bouncycastle.crypto.params.CramerShoupPublicKeyParameters cramerShoupPublicKeyParametersC = c(cramerShoupParametersC, cramerShoupPrivateKeyParametersD);
        cramerShoupPrivateKeyParametersD.m(cramerShoupPublicKeyParametersC);
        return new org.bouncycastle.crypto.AsymmetricCipherKeyPair(cramerShoupPublicKeyParametersC, cramerShoupPrivateKeyParametersD);
    }

    @Override // org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator
    public void b(org.bouncycastle.crypto.KeyGenerationParameters keyGenerationParameters) {
        org.bouncycastle.crypto.params.CramerShoupKeyGenerationParameters cramerShoupKeyGenerationParameters = (org.bouncycastle.crypto.params.CramerShoupKeyGenerationParameters) keyGenerationParameters;
        this.g = cramerShoupKeyGenerationParameters;
        org.bouncycastle.crypto.CryptoServicesRegistrar.a(new org.bouncycastle.crypto.constraints.DefaultServiceProperties("CramerShoupKeyGen", org.bouncycastle.crypto.constraints.ConstraintUtils.a(cramerShoupKeyGenerationParameters.c().c()), this.g.c(), org.bouncycastle.crypto.CryptoServicePurpose.KEYGEN));
    }
}
