package org.bouncycastle.crypto.fpe;

/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
public class FPEFF3_1Engine extends org.bouncycastle.crypto.fpe.FPEEngine {
    public FPEFF3_1Engine(org.bouncycastle.crypto.BlockCipher blockCipher) {
        super(blockCipher);
        if (blockCipher.b() != 16) {
            throw new java.lang.IllegalArgumentException("base cipher needs to be 128 bits");
        }
        if (org.bouncycastle.util.Properties.d("org.bouncycastle.fpe.disable")) {
            throw new java.lang.UnsupportedOperationException("FPE disabled");
        }
    }

    @Override // org.bouncycastle.crypto.fpe.FPEEngine
    protected int a(byte[] bArr, int i, int i2, byte[] bArr2, int i3) {
        int i4;
        byte[] bArrQ;
        if (this.c.b() > 256) {
            bArrQ = org.bouncycastle.crypto.fpe.FPEEngine.f(org.bouncycastle.crypto.fpe.SP80038G.r(this.a, this.c.c(), this.c.d(), org.bouncycastle.crypto.fpe.FPEEngine.g(bArr), i, i2 / 2));
            i4 = i2;
        } else {
            i4 = i2;
            bArrQ = org.bouncycastle.crypto.fpe.SP80038G.q(this.a, this.c.c(), this.c.d(), bArr, i, i4);
        }
        java.lang.System.arraycopy(bArrQ, 0, bArr2, i3, i4);
        return i4;
    }

    @Override // org.bouncycastle.crypto.fpe.FPEEngine
    protected int b(byte[] bArr, int i, int i2, byte[] bArr2, int i3) {
        int i4;
        byte[] bArrX;
        if (this.c.b() > 256) {
            bArrX = org.bouncycastle.crypto.fpe.FPEEngine.f(org.bouncycastle.crypto.fpe.SP80038G.y(this.a, this.c.c(), this.c.d(), org.bouncycastle.crypto.fpe.FPEEngine.g(bArr), i, i2 / 2));
            i4 = i2;
        } else {
            i4 = i2;
            bArrX = org.bouncycastle.crypto.fpe.SP80038G.x(this.a, this.c.c(), this.c.d(), bArr, i, i4);
        }
        java.lang.System.arraycopy(bArrX, 0, bArr2, i3, i4);
        return i4;
    }

    @Override // org.bouncycastle.crypto.fpe.FPEEngine
    public java.lang.String c() {
        return "FF3-1";
    }

    @Override // org.bouncycastle.crypto.fpe.FPEEngine
    public void d(boolean z, org.bouncycastle.crypto.CipherParameters cipherParameters) {
        this.b = z;
        org.bouncycastle.crypto.params.FPEParameters fPEParameters = (org.bouncycastle.crypto.params.FPEParameters) cipherParameters;
        this.c = fPEParameters;
        this.a.init(!fPEParameters.e(), this.c.a().d());
        if (this.c.d().length != 7) {
            throw new java.lang.IllegalArgumentException("tweak should be 56 bits");
        }
    }
}
