298 lines
11 KiB
Java
298 lines
11 KiB
Java
|
package scb.yek;
|
||
|
|
||
|
import com.google.common.base.Ascii;
|
||
|
import java.io.IOException;
|
||
|
import java.io.InputStream;
|
||
|
import java.io.UnsupportedEncodingException;
|
||
|
import java.nio.charset.Charset;
|
||
|
import java.security.Key;
|
||
|
import java.security.MessageDigest;
|
||
|
import java.security.NoSuchAlgorithmException;
|
||
|
import java.security.spec.AlgorithmParameterSpec;
|
||
|
import javax.crypto.Cipher;
|
||
|
import javax.crypto.spec.IvParameterSpec;
|
||
|
import javax.crypto.spec.SecretKeySpec;
|
||
|
import net.sf.scuba.smartcards.ISO7816;
|
||
|
import net.sf.scuba.smartcards.ISOFileInfo;
|
||
|
import o.Awr;
|
||
|
import o.C14957gcv;
|
||
|
import o.C17133uFJ;
|
||
|
import o.DFY;
|
||
|
import o.TAC;
|
||
|
import o.TVH;
|
||
|
import o.guE;
|
||
|
import org.bouncycastle.crypto.signers.PSSSigner;
|
||
|
import org.bouncycastle.pqc.jcajce.spec.McElieceCCA2KeyGenParameterSpec;
|
||
|
import org.jmrtd.lds.CVCAFile;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public final class AESUtil {
|
||
|
private static byte a;
|
||
|
private static int b;
|
||
|
private static long c;
|
||
|
public static final AESUtil d;
|
||
|
private static char[] e;
|
||
|
private static int f;
|
||
|
private static short[] g;
|
||
|
private static byte[] h;
|
||
|
private static int i;
|
||
|
private static final byte[] j = {124, -126, ISO7816.INS_MSE, 69, 47, -8, -47, 46, -6, -5, -7, 8, Ascii.SYN, -31, 5, -18, 15, -19, -9};
|
||
|
private static final int k = 120;
|
||
|
|
||
|
public final native String aesIVFromJNI();
|
||
|
|
||
|
public final native String aesKeyFromJNI();
|
||
|
|
||
|
private AESUtil() {
|
||
|
}
|
||
|
|
||
|
static {
|
||
|
a();
|
||
|
b();
|
||
|
d = new AESUtil();
|
||
|
byte b2 = (byte) 1;
|
||
|
byte b3 = (byte) (-b2);
|
||
|
Object[] objArr = new Object[1];
|
||
|
l(b2, b3, (byte) (b3 + 1), objArr);
|
||
|
c((String) objArr[0]);
|
||
|
}
|
||
|
|
||
|
public final String d(String str) {
|
||
|
C14957gcv.e(str, "");
|
||
|
try {
|
||
|
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||
|
cipher.init(2, c(), e());
|
||
|
C14957gcv.c(cipher, "");
|
||
|
String b2 = guE.b(cipher, str);
|
||
|
return b2 == null ? "" : b2;
|
||
|
} catch (Exception e2) {
|
||
|
throw new RuntimeException(e2);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private final AlgorithmParameterSpec e() {
|
||
|
try {
|
||
|
String aesIVFromJNI = aesIVFromJNI();
|
||
|
Object[] objArr = new Object[1];
|
||
|
m(new byte[]{0, 1, 1, 0, 1}, new int[]{0, 5, 0, 0}, true, objArr);
|
||
|
Charset forName = Charset.forName((String) objArr[0]);
|
||
|
C14957gcv.c(forName, "");
|
||
|
byte[] bytes = aesIVFromJNI.getBytes(forName);
|
||
|
C14957gcv.c(bytes, "");
|
||
|
return new IvParameterSpec(bytes);
|
||
|
} catch (UnsupportedEncodingException unused) {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private final Key c() {
|
||
|
try {
|
||
|
MessageDigest messageDigest = MessageDigest.getInstance(McElieceCCA2KeyGenParameterSpec.SHA256);
|
||
|
String aesKeyFromJNI = aesKeyFromJNI();
|
||
|
Object[] objArr = new Object[1];
|
||
|
m(new byte[]{0, 1, 1, 0, 1}, new int[]{0, 5, 0, 0}, true, objArr);
|
||
|
Charset forName = Charset.forName((String) objArr[0]);
|
||
|
C14957gcv.c(forName, "");
|
||
|
byte[] bytes = aesKeyFromJNI.getBytes(forName);
|
||
|
C14957gcv.c(bytes, "");
|
||
|
return new SecretKeySpec(messageDigest.digest(bytes), "AES");
|
||
|
} catch (UnsupportedEncodingException | NoSuchAlgorithmException unused) {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static InputStream e(InputStream inputStream, int i2, int i3, byte[] bArr) throws IOException {
|
||
|
int length = bArr.length;
|
||
|
byte[] bArr2 = new byte[length];
|
||
|
System.arraycopy(bArr, 0, bArr2, 0, length);
|
||
|
TAC.c(bArr2, a, c);
|
||
|
return new C17133uFJ(inputStream, i3, bArr2, Awr.e(i2));
|
||
|
}
|
||
|
|
||
|
private static void m(byte[] bArr, int[] iArr, boolean z, Object[] objArr) {
|
||
|
TVH tvh = new TVH();
|
||
|
int i2 = iArr[0];
|
||
|
int i3 = iArr[1];
|
||
|
int i4 = iArr[2];
|
||
|
int i5 = iArr[3];
|
||
|
char[] cArr = e;
|
||
|
if (cArr != null) {
|
||
|
int length = cArr.length;
|
||
|
char[] cArr2 = new char[length];
|
||
|
for (int i6 = 0; i6 < length; i6++) {
|
||
|
cArr2[i6] = (char) (cArr[i6] ^ (-8866788418154882037L));
|
||
|
}
|
||
|
cArr = cArr2;
|
||
|
}
|
||
|
char[] cArr3 = new char[i3];
|
||
|
System.arraycopy(cArr, i2, cArr3, 0, i3);
|
||
|
if (bArr != null) {
|
||
|
char[] cArr4 = new char[i3];
|
||
|
tvh.c = 0;
|
||
|
char c2 = 0;
|
||
|
while (tvh.c < i3) {
|
||
|
if (bArr[tvh.c] == 1) {
|
||
|
cArr4[tvh.c] = (char) (((cArr3[tvh.c] * 2) + 1) - c2);
|
||
|
} else {
|
||
|
cArr4[tvh.c] = (char) ((cArr3[tvh.c] * 2) - c2);
|
||
|
}
|
||
|
c2 = cArr4[tvh.c];
|
||
|
tvh.c++;
|
||
|
}
|
||
|
cArr3 = cArr4;
|
||
|
}
|
||
|
if (i5 > 0) {
|
||
|
char[] cArr5 = new char[i3];
|
||
|
System.arraycopy(cArr3, 0, cArr5, 0, i3);
|
||
|
int i7 = i3 - i5;
|
||
|
System.arraycopy(cArr5, 0, cArr3, i7, i5);
|
||
|
System.arraycopy(cArr5, i5, cArr3, 0, i7);
|
||
|
}
|
||
|
if (z) {
|
||
|
char[] cArr6 = new char[i3];
|
||
|
tvh.c = 0;
|
||
|
while (tvh.c < i3) {
|
||
|
cArr6[tvh.c] = cArr3[(i3 - tvh.c) - 1];
|
||
|
tvh.c++;
|
||
|
}
|
||
|
cArr3 = cArr6;
|
||
|
}
|
||
|
if (i4 > 0) {
|
||
|
tvh.c = 0;
|
||
|
while (tvh.c < i3) {
|
||
|
cArr3[tvh.c] = (char) (cArr3[tvh.c] - iArr[2]);
|
||
|
tvh.c++;
|
||
|
}
|
||
|
}
|
||
|
objArr[0] = new String(cArr3);
|
||
|
}
|
||
|
|
||
|
private static void n(short s, byte b2, int i2, int i3, int i4, Object[] objArr) {
|
||
|
DFY dfy = new DFY();
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
int i5 = ((int) (f ^ (-7303220121662775787L))) + i2;
|
||
|
int i6 = i5 == -1 ? 1 : 0;
|
||
|
if (i6 != 0) {
|
||
|
byte[] bArr = h;
|
||
|
if (bArr != null) {
|
||
|
int length = bArr.length;
|
||
|
byte[] bArr2 = new byte[length];
|
||
|
for (int i7 = 0; i7 < length; i7++) {
|
||
|
bArr2[i7] = (byte) (bArr[i7] ^ (-7303220121662775787L));
|
||
|
}
|
||
|
bArr = bArr2;
|
||
|
}
|
||
|
if (bArr != null) {
|
||
|
i5 = (byte) (((byte) (h[i3 + ((int) (b ^ (-7303220121662775787L)))] ^ (-7303220121662775787L))) + ((int) (f ^ (-7303220121662775787L))));
|
||
|
} else {
|
||
|
i5 = (short) (((short) (g[i3 + ((int) (b ^ (-7303220121662775787L)))] ^ (-7303220121662775787L))) + ((int) (f ^ (-7303220121662775787L))));
|
||
|
}
|
||
|
}
|
||
|
if (i5 > 0) {
|
||
|
dfy.c = ((i3 + i5) - 2) + ((int) (b ^ (-7303220121662775787L))) + i6;
|
||
|
dfy.a = (char) (i4 + ((int) (i ^ (-7303220121662775787L))));
|
||
|
sb.append(dfy.a);
|
||
|
dfy.e = dfy.a;
|
||
|
byte[] bArr3 = h;
|
||
|
if (bArr3 != null) {
|
||
|
int length2 = bArr3.length;
|
||
|
byte[] bArr4 = new byte[length2];
|
||
|
for (int i8 = 0; i8 < length2; i8++) {
|
||
|
bArr4[i8] = (byte) (bArr3[i8] ^ (-7303220121662775787L));
|
||
|
}
|
||
|
bArr3 = bArr4;
|
||
|
}
|
||
|
boolean z = bArr3 != null;
|
||
|
dfy.d = 1;
|
||
|
while (dfy.d < i5) {
|
||
|
if (z) {
|
||
|
byte[] bArr5 = h;
|
||
|
dfy.c = dfy.c - 1;
|
||
|
dfy.a = (char) (dfy.e + (((byte) (((byte) (bArr5[r9] ^ (-7303220121662775787L))) + s)) ^ b2));
|
||
|
} else {
|
||
|
short[] sArr = g;
|
||
|
dfy.c = dfy.c - 1;
|
||
|
dfy.a = (char) (dfy.e + (((short) (((short) (sArr[r9] ^ (-7303220121662775787L))) + s)) ^ b2));
|
||
|
}
|
||
|
sb.append(dfy.a);
|
||
|
dfy.e = dfy.a;
|
||
|
dfy.d++;
|
||
|
}
|
||
|
}
|
||
|
objArr[0] = sb.toString();
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Removed duplicated region for block: B:10:0x0028 */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:7:0x0020 */
|
||
|
/* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:10:0x0028 -> B:4:0x002a). Please report as a decompilation issue!!! */
|
||
|
/*
|
||
|
Code decompiled incorrectly, please refer to instructions dump.
|
||
|
To view partially-correct add '--show-bad-code' argument
|
||
|
*/
|
||
|
private static void l(byte r5, int r6, byte r7, java.lang.Object[] r8) {
|
||
|
/*
|
||
|
byte[] r0 = scb.yek.AESUtil.j
|
||
|
int r5 = r5 * 4
|
||
|
int r5 = 102 - r5
|
||
|
int r7 = r7 * 5
|
||
|
int r1 = r7 + 6
|
||
|
int r6 = r6 + 4
|
||
|
byte[] r1 = new byte[r1]
|
||
|
int r7 = r7 + 5
|
||
|
r2 = 0
|
||
|
if (r0 != 0) goto L16
|
||
|
r3 = r7
|
||
|
r4 = r2
|
||
|
goto L2a
|
||
|
L16:
|
||
|
r3 = r2
|
||
|
L17:
|
||
|
int r6 = r6 + 1
|
||
|
byte r4 = (byte) r5
|
||
|
r1[r3] = r4
|
||
|
int r4 = r3 + 1
|
||
|
if (r3 != r7) goto L28
|
||
|
java.lang.String r5 = new java.lang.String
|
||
|
r5.<init>(r1, r2)
|
||
|
r8[r2] = r5
|
||
|
return
|
||
|
L28:
|
||
|
r3 = r0[r6]
|
||
|
L2a:
|
||
|
int r3 = -r3
|
||
|
int r5 = r5 + r3
|
||
|
int r5 = r5 + (-2)
|
||
|
r3 = r4
|
||
|
goto L17
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: scb.yek.AESUtil.l(byte, int, byte, java.lang.Object[]):void");
|
||
|
}
|
||
|
|
||
|
static void a() {
|
||
|
e = new char[]{39959, 39993, 39986, 40006, 40031, 39964, 40002, 40041, 40033, 40033, 40003, 40002, 40041, 40033, 40033, 40003, 40002, 40034, 40037, 40006, 40027, 40032, 40041, 40003, 40004, 40039, 40032, 40037, 40034, 39999, 40038, 40047, 40041, 40044, 40041, 40047, 40039, 40019, 40101, 40070, 40066, 40102, 40102, 40108, 40123, 40100, 40099, 40103, 40123, 40121, 40088, 39999, 40037, 40058, 40058, 40040, 40040, 40039, 40045, 40045, 40034, 39995, 40035, 40038, 40057, 40062, 40034, 40034, 40033, 40046, 40017, 40019, 40077, 40193, 40206, 40180, 40207, 40192, 40195, 40200, 40029, 40117, 40130, 40136, 40129, 40131, 40128, 40132, 40155, 40133, 39977, 40014, 40022, 40039, 40045};
|
||
|
b = -2025229523;
|
||
|
f = 1406017030;
|
||
|
i = 463551612;
|
||
|
h = new byte[]{67, ISOFileInfo.FILE_IDENTIFIER, 71, 85, -94, 113, ISOFileInfo.DATA_BYTES2, 85, 70, ISOFileInfo.A1, CVCAFile.CAR_TAG, -66, 76, 69, -70, -86, 86, -71, 79, 99, -103, -103, ISO7816.INS_READ_RECORD_STAMPED, 82, ISOFileInfo.SECURITY_ATTR_EXP, 109, 117, -124, 117, -34, 47, -2, 0, ISO7816.INS_UPDATE_BINARY, 72, 72, -69, -71, 94, 92, -90, PSSSigner.TRAILER_IMPLICIT, -78, ISO7816.INS_REHABILITATE_CHV, ISO7816.INS_READ_BINARY, ISO7816.INS_READ_BINARY2, 92, 108, Byte.MIN_VALUE, CVCAFile.CAR_TAG, ISO7816.INS_READ_RECORD2, 81, -81, 89, -89, ISOFileInfo.A1, Ascii.NAK, Ascii.NAK, Ascii.NAK, Ascii.NAK, Ascii.NAK, Ascii.NAK, Ascii.NAK, Ascii.NAK};
|
||
|
}
|
||
|
|
||
|
static void b() {
|
||
|
c = -5460580109075031448L;
|
||
|
a = ISO7816.INS_PUT_DATA;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Removed duplicated region for block: B:121:0x069c A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:49:0x03da A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||
|
/*
|
||
|
Code decompiled incorrectly, please refer to instructions dump.
|
||
|
To view partially-correct add '--show-bad-code' argument
|
||
|
*/
|
||
|
private static void c(java.lang.String r31) {
|
||
|
/*
|
||
|
Method dump skipped, instructions count: 1973
|
||
|
To view this dump add '--comments-level debug' option
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: scb.yek.AESUtil.c(java.lang.String):void");
|
||
|
}
|
||
|
}
|