package org.bouncycastle.crypto.paddings;

/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
public class ISO7816d4Padding implements org.bouncycastle.crypto.paddings.BlockCipherPadding {
    @Override // org.bouncycastle.crypto.paddings.BlockCipherPadding
    public int a(byte[] bArr, int i) {
        int length = bArr.length - i;
        bArr[i] = -128;
        while (true) {
            i++;
            if (i >= bArr.length) {
                return length;
            }
            bArr[i] = 0;
        }
    }

    @Override // org.bouncycastle.crypto.paddings.BlockCipherPadding
    public int b(byte[] bArr) throws org.bouncycastle.crypto.InvalidCipherTextException {
        int length = bArr.length;
        int i = -1;
        int i2 = -1;
        while (true) {
            length--;
            if (length < 0) {
                break;
            }
            int i3 = bArr[length] & 255;
            i ^= ((((i3 ^ 128) - 1) >> 31) & i2) & (length ^ i);
            i2 &= (i3 - 1) >> 31;
        }
        if (i >= 0) {
            return bArr.length - i;
        }
        throw new org.bouncycastle.crypto.InvalidCipherTextException("pad block corrupted");
    }

    @Override // org.bouncycastle.crypto.paddings.BlockCipherPadding
    public void c(java.security.SecureRandom secureRandom) {
    }
}
