what-the-bank/sources/o/APu.java

122 lines
5.2 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package o;
import java.security.Key;
import org.bouncycastle.pqc.jcajce.spec.McElieceCCA2KeyGenParameterSpec;
import org.json.JSONObject;
/* loaded from: classes3.dex */
public final class APu {
public static final String d;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public static class LWm {
boolean d = false;
String a = McElieceCCA2KeyGenParameterSpec.SHA256;
boolean e = false;
String c = "AES";
int b = 128;
LWm() {
}
}
public static String d(String str, String str2, String str3, String str4, String str5) {
return a(str, str2, str3, C17796znh.c(str4), str5);
}
private static String a(String str, String str2, String str3, byte[] bArr, String str4) {
byte[] e;
LWm lWm = new LWm();
try {
JSONObject jSONObject = new JSONObject(str);
if (jSONObject.has("hash") && !jSONObject.isNull("hash")) {
lWm.d = jSONObject.getBoolean("hash");
}
if (jSONObject.has("hashAlgo") && !jSONObject.isNull("hashAlgo") && !jSONObject.getString("hashAlgo").trim().isEmpty()) {
lWm.a = jSONObject.getString("hashAlgo");
}
if (jSONObject.has("symmetric") && !jSONObject.isNull("symmetric")) {
lWm.e = jSONObject.getBoolean("symmetric");
}
if (jSONObject.has("symmetricAlgo") && !jSONObject.isNull("symmetricAlgo") && !jSONObject.getString("symmetricAlgo").trim().isEmpty()) {
lWm.c = jSONObject.getString("symmetricAlgo");
}
if (jSONObject.has("symmetricKeyLength") && !jSONObject.isNull("symmetricKeyLength") && jSONObject.getInt("symmetricKeyLength") > 0) {
lWm.b = jSONObject.getInt("symmetricKeyLength");
}
if (lWm.d && lWm.e && ("AES".equals(lWm.c) || "SM4".equals(lWm.c))) {
Key b = xZE.b(str2);
byte[] d2 = C17796znh.d(str3);
byte[] c = xZE.c(lWm.b / 8);
byte[] c2 = xZE.c(16);
if ("AES".equals(lWm.c)) {
e = xZE.b(xZE.c(c, "AES"), bArr, "AES/CBC/Pkcs5Padding", c2);
} else if ("SM4".equals(lWm.c)) {
if (!DSF.b()) {
throw new IllegalStateException("SM Crypto library cannot be found");
}
e = C1166XVy.e(c, bArr, c2);
} else {
StringBuilder sb = new StringBuilder("Unsupported symmetric algorithm: ");
sb.append(lWm.c);
throw new IllegalArgumentException(sb.toString());
}
if (!McElieceCCA2KeyGenParameterSpec.SHA256.equals(lWm.a) && !"SM3".equals(lWm.a)) {
StringBuilder sb2 = new StringBuilder("Unsupported hash algorithm: ");
sb2.append(lWm.a);
throw new IllegalArgumentException(sb2.toString());
}
byte[] d3 = ozZ.d(c, xZE.e(lWm.a, ozZ.d(c2, e)), d2, c2);
byte[] c3 = xZE.c(16);
byte[] b2 = xZE.b(b, d3, "RSA/ECB/OAEPWithSHA1AndMGF1Padding", c3);
String a = C17796znh.a(ozZ.d(new byte[]{2}, ozZ.a(c3.length, 1), c3, ozZ.a(b2.length, 2), b2, e));
if (str4 == null || str4.trim().isEmpty()) {
return a;
}
StringBuilder sb3 = new StringBuilder();
sb3.append(str4);
sb3.append(",");
sb3.append(a);
return sb3.toString();
}
if (lWm.e) {
StringBuilder sb4 = new StringBuilder("Invalid cipher params combination, cipherParams=");
sb4.append(str);
throw new IllegalArgumentException(sb4.toString());
}
Key b3 = xZE.b(str2);
byte[] d4 = C17796znh.d(str3);
byte[] bArr2 = new byte[0];
if (lWm.d) {
bArr2 = xZE.e(McElieceCCA2KeyGenParameterSpec.SHA256, bArr);
}
byte[] d5 = ozZ.d(bArr, bArr2, d4);
byte[] c4 = xZE.c(16);
byte[] b4 = xZE.b(b3, d5, "RSA/ECB/OAEPWithSHA1AndMGF1Padding", c4);
StringBuilder sb5 = new StringBuilder();
sb5.append(C17796znh.a(c4));
sb5.append(":");
sb5.append(C17796znh.a(b4));
String obj = sb5.toString();
if (str4 == null || str4.trim().isEmpty()) {
return obj;
}
StringBuilder sb6 = new StringBuilder();
sb6.append(str4);
sb6.append(",");
sb6.append(obj);
return sb6.toString();
} catch (Exception e2) {
throw new RuntimeException("Failed to encrypt", e2);
}
}
static {
JSONObject jSONObject = new UjT().e(McElieceCCA2KeyGenParameterSpec.SHA256).d;
JSONObject jSONObject2 = new UjT().b("AES", 128).e(McElieceCCA2KeyGenParameterSpec.SHA256).d;
d = new UjT().b("AES", 256).e(McElieceCCA2KeyGenParameterSpec.SHA256).d.toString();
JSONObject jSONObject3 = new UjT().b("SM4", 128).e("SM3").d;
}
}