package org.bouncycastle.crypto.fpe;

/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
public class FPEFF1Engine extends org.bouncycastle.crypto.fpe.FPEEngine {
    public FPEFF1Engine(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") || org.bouncycastle.util.Properties.d("org.bouncycastle.fpe.disable_ff1")) {
            throw new java.lang.UnsupportedOperationException("FF1 encryption disabled");
        }
    }

    @Override // org.bouncycastle.crypto.fpe.FPEEngine
    protected int a(byte[] bArr, int i, int i2, byte[] bArr2, int i3) {
        int i4;
        byte[] bArrO;
        if (this.c.b() > 256) {
            bArrO = org.bouncycastle.crypto.fpe.FPEEngine.f(org.bouncycastle.crypto.fpe.SP80038G.p(this.a, this.c.c(), this.c.d(), org.bouncycastle.crypto.fpe.FPEEngine.g(bArr), i, i2 / 2));
            i4 = i2;
        } else {
            i4 = i2;
            bArrO = org.bouncycastle.crypto.fpe.SP80038G.o(this.a, this.c.c(), this.c.d(), bArr, i, i4);
        }
        java.lang.System.arraycopy(bArrO, 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[] bArrU;
        if (this.c.b() > 256) {
            bArrU = org.bouncycastle.crypto.fpe.FPEEngine.f(org.bouncycastle.crypto.fpe.SP80038G.v(this.a, this.c.c(), this.c.d(), org.bouncycastle.crypto.fpe.FPEEngine.g(bArr), i, i2 / 2));
            i4 = i2;
        } else {
            i4 = i2;
            bArrU = org.bouncycastle.crypto.fpe.SP80038G.u(this.a, this.c.c(), this.c.d(), bArr, i, i4);
        }
        java.lang.System.arraycopy(bArrU, 0, bArr2, i3, i4);
        return i4;
    }

    @Override // org.bouncycastle.crypto.fpe.FPEEngine
    public java.lang.String c() {
        return "FF1";
    }

    @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());
    }
}
