what-the-bank/sources/org/bouncycastle/crypto/paddings/ISO7816d4Padding.java

43 lines
1.3 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.crypto.paddings;
import java.security.SecureRandom;
import org.bouncycastle.crypto.InvalidCipherTextException;
/* loaded from: classes6.dex */
public class ISO7816d4Padding implements BlockCipherPadding {
@Override // org.bouncycastle.crypto.paddings.BlockCipherPadding
public void init(SecureRandom secureRandom) throws IllegalArgumentException {
}
@Override // org.bouncycastle.crypto.paddings.BlockCipherPadding
public int padCount(byte[] bArr) throws InvalidCipherTextException {
int length = bArr.length - 1;
while (length > 0 && bArr[length] == 0) {
length--;
}
if (bArr[length] == Byte.MIN_VALUE) {
return bArr.length - length;
}
throw new InvalidCipherTextException("pad block corrupted");
}
@Override // org.bouncycastle.crypto.paddings.BlockCipherPadding
public String getPaddingName() {
return "ISO7816-4";
}
@Override // org.bouncycastle.crypto.paddings.BlockCipherPadding
public int addPadding(byte[] bArr, int i) {
int length = bArr.length;
bArr[i] = Byte.MIN_VALUE;
int i2 = i;
while (true) {
i2++;
if (i2 >= bArr.length) {
return length - i;
}
bArr[i2] = 0;
}
}
}