115 lines
4.0 KiB
Java
115 lines
4.0 KiB
Java
|
package o;
|
||
|
|
||
|
import com.eracom.OBM2.OAEPEncodedMsgException;
|
||
|
import java.security.NoSuchAlgorithmException;
|
||
|
import java.security.SecureRandom;
|
||
|
import java.util.Properties;
|
||
|
|
||
|
/* renamed from: o.wMj, reason: case insensitive filesystem */
|
||
|
/* loaded from: classes.dex */
|
||
|
public final class C17386wMj {
|
||
|
int a;
|
||
|
String b;
|
||
|
byte[] c;
|
||
|
private byte[] d;
|
||
|
private String e;
|
||
|
private Properties h;
|
||
|
|
||
|
public C17386wMj(dJC djc, int i) throws OAEPEncodedMsgException {
|
||
|
this(djc, i, null);
|
||
|
}
|
||
|
|
||
|
public C17386wMj(dJC djc, int i, Properties properties) throws OAEPEncodedMsgException {
|
||
|
this.d = new byte[16];
|
||
|
this.h = properties;
|
||
|
int i2 = i - 1;
|
||
|
this.c = new byte[i2];
|
||
|
int i3 = i - ((djc.a.b().c + 1) << 1);
|
||
|
int i4 = i2 - djc.a.b().c;
|
||
|
Byte[] bArr = new Byte[i3];
|
||
|
byte[] bArr2 = new byte[i3];
|
||
|
byte[] bArr3 = new byte[djc.a.b().c];
|
||
|
byte[] bArr4 = new byte[i4];
|
||
|
byte[] bArr5 = new byte[i4];
|
||
|
byte[] bArr6 = new byte[i4];
|
||
|
int i5 = djc.a.b().c;
|
||
|
byte[] bArr7 = new byte[i5];
|
||
|
byte[] bArr8 = new byte[djc.a.b().c];
|
||
|
byte[] bArr9 = new byte[djc.a.b().c];
|
||
|
if (djc == null) {
|
||
|
throw new OAEPEncodedMsgException("Error no : 30 - Invalid PIN Message");
|
||
|
}
|
||
|
int i6 = djc.d;
|
||
|
Properties properties2 = this.h;
|
||
|
if (i6 < ((properties2 == null || properties2.getProperty("param_ISO_FORMAT_0_PAN") == null) ? 17 : 8) || i6 > i3) {
|
||
|
throw new OAEPEncodedMsgException("Error no : 31 Invalid PIN message length");
|
||
|
}
|
||
|
int size = djc.b.size();
|
||
|
for (int i7 = 0; i7 < size; i7++) {
|
||
|
bArr[i7] = (Byte) djc.b.elementAt(i7);
|
||
|
}
|
||
|
try {
|
||
|
SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
|
||
|
secureRandom.nextBytes(this.d);
|
||
|
byte[] b = djc.a.b().b(this.d, 16);
|
||
|
for (int i8 = 0; i8 < i4; i8++) {
|
||
|
bArr4[i8] = 0;
|
||
|
}
|
||
|
System.arraycopy(b, 0, bArr4, 0, djc.a.b().c);
|
||
|
int i9 = djc.a.b().c + (((i4 - djc.a.b().c) - i6) - 1);
|
||
|
bArr4[i9] = 1;
|
||
|
for (int i10 = 0; i10 < i6; i10++) {
|
||
|
bArr2[i10] = bArr[i10].byteValue();
|
||
|
}
|
||
|
System.arraycopy(bArr2, 0, bArr4, i9 + 1, i6);
|
||
|
secureRandom.nextBytes(bArr7);
|
||
|
d(djc, bArr7, bArr5, i4, i);
|
||
|
for (int i11 = 0; i11 < i4; i11++) {
|
||
|
bArr6[i11] = (byte) (bArr4[i11] ^ bArr5[i11]);
|
||
|
}
|
||
|
d(djc, bArr6, bArr8, djc.a.b().c, i);
|
||
|
for (int i12 = 0; i12 < i5; i12++) {
|
||
|
bArr9[i12] = (byte) (bArr7[i12] ^ bArr8[i12]);
|
||
|
}
|
||
|
System.arraycopy(bArr9, 0, this.c, 0, djc.a.b().c);
|
||
|
System.arraycopy(bArr6, 0, this.c, djc.a.b().c, i4);
|
||
|
this.e = C15605gzv.c(this.c);
|
||
|
this.b = C15605gzv.c(this.d);
|
||
|
} catch (NoSuchAlgorithmException e) {
|
||
|
throw new RuntimeException("Secure random generator is not available", e);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static void c(int i, byte[] bArr) {
|
||
|
bArr[0] = (byte) (i >>> 24);
|
||
|
bArr[1] = (byte) (i >>> 16);
|
||
|
bArr[2] = (byte) (i >>> 8);
|
||
|
bArr[3] = (byte) i;
|
||
|
}
|
||
|
|
||
|
private static void d(dJC djc, byte[] bArr, byte[] bArr2, int i, int i2) {
|
||
|
int i3 = djc.a.b().c;
|
||
|
byte[] bArr3 = new byte[4];
|
||
|
byte[] bArr4 = new byte[i2 - 1];
|
||
|
byte[] bArr5 = new byte[djc.a.b().c];
|
||
|
int length = bArr.length;
|
||
|
int i4 = i / djc.a.b().c;
|
||
|
int i5 = i - (djc.a.b().c * i4);
|
||
|
if (i5 > 0) {
|
||
|
i4++;
|
||
|
}
|
||
|
int i6 = djc.a.b().c;
|
||
|
for (int i7 = 0; i7 < i4; i7++) {
|
||
|
c(i7, bArr3);
|
||
|
System.arraycopy(bArr, 0, bArr4, 0, length);
|
||
|
System.arraycopy(bArr3, 0, bArr4, length, 4);
|
||
|
byte[] b = djc.a.b().b(bArr4, length + 4);
|
||
|
int i8 = djc.a.b().c;
|
||
|
if (i7 == i4 - 1 && i5 > 0) {
|
||
|
i6 = i5;
|
||
|
}
|
||
|
System.arraycopy(b, 0, bArr2, i8 * i7, i6);
|
||
|
}
|
||
|
}
|
||
|
}
|