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

83 lines
2.6 KiB
Java

package o;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Base64;
import java.security.Key;
import java.security.SecureRandom;
import java.security.spec.AlgorithmParameterSpec;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
/* renamed from: o.cnV, reason: case insensitive filesystem */
/* loaded from: classes3.dex */
public class C7395cnV implements Xwp {
private final SecureRandom a = new SecureRandom();
private Key b;
private final Cipher c;
protected int e() {
return 16;
}
public C7395cnV(Context context, zVr zvr) throws Exception {
String d = d();
SharedPreferences sharedPreferences = context.getSharedPreferences("FlutterSecureKeyStorage", 0);
SharedPreferences.Editor edit = sharedPreferences.edit();
String string = sharedPreferences.getString(d, null);
this.c = a();
if (string != null) {
try {
this.b = zvr.c(Base64.decode(string, 0), "AES");
return;
} catch (Exception unused) {
}
}
byte[] bArr = new byte[16];
this.a.nextBytes(bArr);
SecretKeySpec secretKeySpec = new SecretKeySpec(bArr, "AES");
this.b = secretKeySpec;
edit.putString(d, Base64.encodeToString(zvr.a(secretKeySpec), 0));
edit.apply();
}
protected Cipher a() throws Exception {
return Cipher.getInstance("AES/CBC/PKCS7Padding");
}
@Override // o.Xwp
public final byte[] c(byte[] bArr) throws Exception {
int e = e();
byte[] bArr2 = new byte[e];
this.a.nextBytes(bArr2);
this.c.init(1, this.b, d(bArr2));
byte[] doFinal = this.c.doFinal(bArr);
byte[] bArr3 = new byte[doFinal.length + e];
System.arraycopy(bArr2, 0, bArr3, 0, e);
System.arraycopy(doFinal, 0, bArr3, e, doFinal.length);
return bArr3;
}
@Override // o.Xwp
public final byte[] a(byte[] bArr) throws Exception {
int e = e();
byte[] bArr2 = new byte[e];
System.arraycopy(bArr, 0, bArr2, 0, e);
AlgorithmParameterSpec d = d(bArr2);
int length = bArr.length - e();
byte[] bArr3 = new byte[length];
System.arraycopy(bArr, e, bArr3, 0, length);
this.c.init(2, this.b, d);
return this.c.doFinal(bArr3);
}
protected AlgorithmParameterSpec d(byte[] bArr) {
return new IvParameterSpec(bArr);
}
protected String d() {
return "VGhpcyBpcyB0aGUga2V5IGZvciBhIHNlY3VyZSBzdG9yYWdlIEFFUyBLZXkK";
}
}