package org.bouncycastle.crypto.engines;

/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
public class RSABlindingEngine implements org.bouncycastle.crypto.AsymmetricBlockCipher {
    private org.bouncycastle.crypto.engines.RSACoreEngine a;
    private org.bouncycastle.crypto.params.RSAKeyParameters b;
    private java.math.BigInteger c;
    private boolean d;

    private java.math.BigInteger a(java.math.BigInteger bigInteger) {
        return bigInteger.multiply(this.c.modPow(this.b.g(), this.b.i())).mod(this.b.i());
    }

    private java.math.BigInteger b(java.math.BigInteger bigInteger) {
        java.math.BigInteger bigIntegerI = this.b.i();
        return bigInteger.multiply(org.bouncycastle.util.BigIntegers.n(bigIntegerI, this.c)).mod(bigIntegerI);
    }

    @Override // org.bouncycastle.crypto.AsymmetricBlockCipher
    public int getInputBlockSize() {
        return this.a.c();
    }

    @Override // org.bouncycastle.crypto.AsymmetricBlockCipher
    public int getOutputBlockSize() {
        return this.a.d();
    }

    @Override // org.bouncycastle.crypto.AsymmetricBlockCipher
    public void init(boolean z, org.bouncycastle.crypto.CipherParameters cipherParameters) {
        if (cipherParameters instanceof org.bouncycastle.crypto.params.ParametersWithRandom) {
            cipherParameters = ((org.bouncycastle.crypto.params.ParametersWithRandom) cipherParameters).a();
        }
        org.bouncycastle.crypto.params.RSABlindingParameters rSABlindingParameters = (org.bouncycastle.crypto.params.RSABlindingParameters) cipherParameters;
        this.a.f(z, rSABlindingParameters.b());
        this.d = z;
        this.b = rSABlindingParameters.b();
        this.c = rSABlindingParameters.a();
    }

    @Override // org.bouncycastle.crypto.AsymmetricBlockCipher
    public byte[] processBlock(byte[] bArr, int i, int i2) {
        java.math.BigInteger bigIntegerA = this.a.a(bArr, i, i2);
        return this.a.b(this.d ? a(bigIntegerA) : b(bigIntegerA));
    }
}
