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

212 lines
8.7 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package o;
import android.content.Context;
import android.content.SharedPreferences;
import android.security.keystore.KeyGenParameterSpec;
import android.util.Base64;
import com.google.android.gms.stats.CodePackage;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import o.C16996sxu;
import o.mwP;
import o.sQp;
/* loaded from: classes3.dex */
public final class Fwm {
protected Map<String, Object> a;
private final Context d;
private IaX f;
private Xwp i;
private SharedPreferences j;
private final String c = "SecureStorageAndroid";
protected String e = "VGhpcyBpcyB0aGUgcHJlZml4IGZvciBhIHNlY3VyZSBzdG9yYWdlCg";
private String b = "FlutterSecureStorage";
private Boolean g = Boolean.FALSE;
private final Charset h = StandardCharsets.UTF_8;
public Fwm(Context context) {
this.d = context.getApplicationContext();
}
private boolean d() {
return !this.g.booleanValue() && this.a.containsKey("encryptedSharedPreferences") && this.a.get("encryptedSharedPreferences").equals("true");
}
/* JADX INFO: Access modifiers changed from: package-private */
public final boolean e(String str) {
c();
return this.j.contains(str);
}
/* JADX INFO: Access modifiers changed from: package-private */
public final String b(String str) throws Exception {
c();
String string = this.j.getString(str, null);
return d() ? string : a(string);
}
public final Map<String, String> a() throws Exception {
c();
Map<String, ?> all = this.j.getAll();
HashMap hashMap = new HashMap();
for (Map.Entry<String, ?> entry : all.entrySet()) {
if (entry.getKey().contains(this.e)) {
String key = entry.getKey();
StringBuilder sb = new StringBuilder();
sb.append(this.e);
sb.append('_');
String replaceFirst = key.replaceFirst(sb.toString(), "");
if (d()) {
hashMap.put(replaceFirst, (String) entry.getValue());
} else {
hashMap.put(replaceFirst, a((String) entry.getValue()));
}
}
}
return hashMap;
}
/* JADX INFO: Access modifiers changed from: package-private */
public final void e(String str, String str2) throws Exception {
c();
SharedPreferences.Editor edit = this.j.edit();
if (d()) {
edit.putString(str, str2);
} else {
edit.putString(str, Base64.encodeToString(this.i.c(str2.getBytes(this.h)), 0));
}
edit.apply();
}
public final void c(String str) {
c();
SharedPreferences.Editor edit = this.j.edit();
edit.remove(str);
edit.apply();
}
/* JADX INFO: Access modifiers changed from: package-private */
public final void b() {
c();
SharedPreferences.Editor edit = this.j.edit();
edit.clear();
if (!d()) {
this.f.Oj_(edit);
}
edit.apply();
}
private void c() {
if (this.a.containsKey("sharedPreferencesName") && !((String) this.a.get("sharedPreferencesName")).isEmpty()) {
this.b = (String) this.a.get("sharedPreferencesName");
}
if (this.a.containsKey("preferencesKeyPrefix") && !((String) this.a.get("preferencesKeyPrefix")).isEmpty()) {
this.e = (String) this.a.get("preferencesKeyPrefix");
}
SharedPreferences sharedPreferences = this.d.getSharedPreferences(this.b, 0);
if (this.i == null) {
try {
this.f = new IaX(sharedPreferences, this.a);
if (d()) {
IaX iaX = this.f;
Context context = this.d;
this.i = iaX.b.storageCipher.b(context, iaX.c.keyCipher.d(context));
} else {
IaX iaX2 = this.f;
if (iaX2.c != iaX2.e || iaX2.b != iaX2.a) {
IaX iaX3 = this.f;
try {
Context context2 = this.d;
this.i = iaX3.b.storageCipher.b(context2, iaX3.c.keyCipher.d(context2));
HashMap hashMap = new HashMap();
for (Map.Entry<String, ?> entry : sharedPreferences.getAll().entrySet()) {
Object value = entry.getValue();
String key = entry.getKey();
if ((value instanceof String) && key.contains(this.e)) {
hashMap.put(key, a((String) value));
}
}
Context context3 = this.d;
this.i = iaX3.a.storageCipher.b(context3, iaX3.e.keyCipher.d(context3));
SharedPreferences.Editor edit = sharedPreferences.edit();
for (Map.Entry entry2 : hashMap.entrySet()) {
edit.putString((String) entry2.getKey(), Base64.encodeToString(this.i.c(((String) entry2.getValue()).getBytes(this.h)), 0));
}
iaX3.Oj_(edit);
edit.apply();
} catch (Exception unused) {
Context context4 = this.d;
this.i = iaX3.b.storageCipher.b(context4, iaX3.c.keyCipher.d(context4));
}
} else {
IaX iaX4 = this.f;
Context context5 = this.d;
this.i = iaX4.a.storageCipher.b(context5, iaX4.e.keyCipher.d(context5));
}
}
} catch (Exception unused2) {
}
}
if (!d()) {
this.j = sharedPreferences;
return;
}
try {
Context context6 = this.d;
sQp.IeS ieS = new sQp.IeS(context6);
KeyGenParameterSpec build = new KeyGenParameterSpec.Builder("_androidx_security_master_key_", 3).setEncryptionPaddings("NoPadding").setBlockModes(CodePackage.GCM).setKeySize(256).build();
sQp.LWm lWm = ieS.a;
if (!ieS.c.equals(sQp.IeS.HBt.AN_(build))) {
StringBuilder sb = new StringBuilder("KeyGenParamSpec's key alias does not match provided alias (");
sb.append(ieS.c);
sb.append(" vs ");
sb.append(sQp.IeS.HBt.AN_(build));
throw new IllegalArgumentException(sb.toString());
}
ieS.d = build;
sQp d = sQp.IeS.HBt.d(ieS);
String str = this.b;
mwP.IeS ieS2 = mwP.IeS.AES256_SIV;
mwP.LWm lWm2 = mwP.LWm.AES256_GCM;
String str2 = d.e;
Pdj.a();
C3127are.c();
Context applicationContext = context6.getApplicationContext();
C16996sxu.RVV rvv = new C16996sxu.RVV();
rvv.e = C3294aun.c(ieS2.mDeterministicAeadKeyTemplateName);
VJf e = rvv.a(applicationContext, "__androidx_security_crypto_encrypted_prefs_key_keyset__", str).d("android-keystore://".concat(String.valueOf(str2))).d().e();
C16996sxu.RVV rvv2 = new C16996sxu.RVV();
rvv2.e = C3294aun.c(lWm2.mAeadKeyTemplateName);
VJf e2 = rvv2.a(applicationContext, "__androidx_security_crypto_encrypted_prefs_value_keyset__", str).d("android-keystore://".concat(String.valueOf(str2))).d().e();
mwP mwp = new mwP(str, str2, applicationContext.getSharedPreferences(str, 0), (InterfaceC4280bVg) e2.d(InterfaceC4280bVg.class), (GHh) e.d(GHh.class));
this.j = mwp;
try {
for (Map.Entry<String, ?> entry3 : sharedPreferences.getAll().entrySet()) {
Object value2 = entry3.getValue();
String key2 = entry3.getKey();
if ((value2 instanceof String) && key2.contains(this.e)) {
mwp.edit().putString(key2, a((String) value2)).apply();
sharedPreferences.edit().remove(key2).apply();
}
}
SharedPreferences.Editor edit2 = sharedPreferences.edit();
IaX.Oi_(edit2);
edit2.apply();
} catch (Exception unused3) {
}
} catch (Exception unused4) {
this.j = sharedPreferences;
this.g = Boolean.TRUE;
}
}
private String a(String str) throws Exception {
if (str == null) {
return null;
}
return new String(this.i.a(Base64.decode(str, 0)), this.h);
}
}