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

229 lines
9.5 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package o;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.hardware.biometrics.BiometricPrompt;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Build;
import android.os.CancellationSignal;
import android.security.keystore.KeyGenParameterSpec;
import android.security.keystore.KeyPermanentlyInvalidatedException;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.scb.phone.view.activity.prelogin.FingerprintHelperInterface;
import java.io.IOException;
import java.security.Key;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import o.fJV;
/* loaded from: classes.dex */
public final class fJR implements InterfaceC9031dbz {
private Context a;
private C11482egF b;
private final CancellationSignal d;
private KeyguardManager e;
@InterfaceC13391fZD
public fJR(Context context, KeyguardManager keyguardManager, FingerprintManager fingerprintManager) {
C14957gcv.e(context, "");
this.a = context;
this.e = keyguardManager;
this.d = new CancellationSignal();
this.b = new C11482egF(this.e, fingerprintManager);
}
/* loaded from: classes.dex */
public static final class LWm implements FingerprintHelperInterface.LWm {
private InterfaceC8982dbC e;
LWm(InterfaceC8982dbC interfaceC8982dbC) {
this.e = interfaceC8982dbC;
}
@Override // com.scb.phone.view.activity.prelogin.FingerprintHelperInterface.LWm
public final void c() {
this.e.j();
}
@Override // com.scb.phone.view.activity.prelogin.FingerprintHelperInterface.LWm
public final void b() {
this.e.c();
}
@Override // com.scb.phone.view.activity.prelogin.FingerprintHelperInterface.LWm
public final void d(String str) {
if (str != null) {
this.e.a();
}
}
@Override // com.scb.phone.view.activity.prelogin.FingerprintHelperInterface.LWm
public final void e(Throwable th) {
C14957gcv.e(th, "");
InterfaceC8982dbC interfaceC8982dbC = this.e;
th.getMessage();
interfaceC8982dbC.d();
}
}
private static SecretKey c() {
KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
if (keyStore != null) {
keyStore.load(null);
}
Key key = keyStore != null ? keyStore.getKey("default_key", null) : null;
if (key instanceof SecretKey) {
return (SecretKey) key;
}
return null;
}
@Override // o.InterfaceC9031dbz
public final boolean e() {
KeyguardManager keyguardManager;
if (Build.VERSION.SDK_INT < 28) {
Object systemService = this.a.getSystemService(HiAnalyticsConstant.HaKey.BI_KEY_FINGERPRINT);
FingerprintManager fingerprintManager = systemService instanceof FingerprintManager ? (FingerprintManager) systemService : null;
if (fingerprintManager != null && (keyguardManager = this.e) != null && keyguardManager.isKeyguardSecure() && fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints()) {
return true;
}
} else if (this.b.a()) {
fJV.IeS ieS = fJV.a;
Context context = this.a;
C14957gcv.e(context, "");
AXG a = AXG.a(context);
C14957gcv.c(a, "");
if (a.a()) {
return true;
}
}
return false;
}
@Override // o.InterfaceC9031dbz
public final boolean d() {
if (Build.VERSION.SDK_INT < 28) {
KeyguardManager keyguardManager = this.e;
if (keyguardManager != null && keyguardManager.isKeyguardSecure()) {
Object systemService = this.a.getSystemService(HiAnalyticsConstant.HaKey.BI_KEY_FINGERPRINT);
FingerprintManager fingerprintManager = systemService instanceof FingerprintManager ? (FingerprintManager) systemService : null;
if (fingerprintManager != null && fingerprintManager.isHardwareDetected()) {
return true;
}
}
return false;
}
return this.b.a();
}
@Override // o.InterfaceC9031dbz
public final void a() {
CancellationSignal cancellationSignal;
CancellationSignal cancellationSignal2 = this.b.e;
if (cancellationSignal2 != null && !cancellationSignal2.isCanceled() && (cancellationSignal = this.b.e) != null) {
cancellationSignal.cancel();
}
if (Build.VERSION.SDK_INT >= 28) {
this.d.cancel();
}
}
@Override // o.InterfaceC9031dbz
public final void d(final InterfaceC8982dbC interfaceC8982dbC) {
C14957gcv.e(interfaceC8982dbC, "");
try {
try {
SecretKey c = c();
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
C14957gcv.c(cipher, "");
if (c == null) {
try {
KeyGenerator keyGenerator = KeyGenerator.getInstance("AES", "AndroidKeyStore");
KeyGenParameterSpec.Builder encryptionPaddings = new KeyGenParameterSpec.Builder("default_key", 3).setBlockModes("CBC").setUserAuthenticationRequired(true).setEncryptionPaddings("PKCS7Padding");
C14957gcv.c(encryptionPaddings, "");
encryptionPaddings.setInvalidatedByBiometricEnrollment(true);
keyGenerator.init(encryptionPaddings.build());
keyGenerator.generateKey();
} catch (Exception e) {
guQ.a("generateSecretKey error:".concat(String.valueOf(e)), new Object[0]);
}
c = c();
}
cipher.init(1, c);
fJV.IeS ieS = fJV.a;
if (Build.VERSION.SDK_INT >= 28) {
C14957gcv.e(interfaceC8982dbC, "");
C14957gcv.e(cipher, "");
fJV.IeS ieS2 = fJV.a;
if (Build.VERSION.SDK_INT >= 28) {
BiometricPrompt.CryptoObject cryptoObject = new BiometricPrompt.CryptoObject(cipher);
CancellationSignal cancellationSignal = new CancellationSignal();
String string = this.a.getString(com.scb.phone.R.string.fingerprint_dialog_title);
String string2 = this.a.getString(com.scb.phone.R.string.app_name);
StringBuilder sb = new StringBuilder();
sb.append(string);
sb.append(" \"");
sb.append(string2);
sb.append("\"");
new BiometricPrompt.Builder(this.a).setTitle(sb.toString()).setDescription(this.a.getString(com.scb.phone.R.string.fingerprint_dialog_content)).setNegativeButton(this.a.getString(com.scb.phone.R.string.cancel), this.a.getMainExecutor(), new DialogInterface.OnClickListener(interfaceC8982dbC) { // from class: o.fJU
private InterfaceC8982dbC a;
@Override // android.content.DialogInterface.OnClickListener
public final void onClick(DialogInterface dialogInterface, int i) {
InterfaceC8982dbC interfaceC8982dbC2 = this.a;
C14957gcv.e(interfaceC8982dbC2, "");
interfaceC8982dbC2.e();
}
{
this.a = interfaceC8982dbC;
}
}).build().authenticate(cryptoObject, cancellationSignal, this.a.getMainExecutor(), new C12855fJQ(interfaceC8982dbC));
return;
}
return;
}
interfaceC8982dbC.b();
if (this.b.a()) {
C11482egF c11482egF = this.b;
LWm lWm = new LWm(interfaceC8982dbC);
if (c11482egF.d != null) {
c11482egF.b = lWm;
try {
c11482egF.e = new CancellationSignal();
c11482egF.d.authenticate(new FingerprintManager.CryptoObject(cipher), c11482egF.e, 0, c11482egF, null);
if (c11482egF.d.hasEnrolledFingerprints()) {
return;
}
lWm.b();
} catch (Exception e2) {
lWm.e(e2);
}
}
}
} catch (Exception e3) {
guQ.e(e3);
}
} catch (KeyPermanentlyInvalidatedException unused) {
interfaceC8982dbC.c();
}
}
@Override // o.InterfaceC9031dbz
public final void b() {
try {
KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
keyStore.load(null);
keyStore.deleteEntry("default_key");
} catch (IOException | KeyStoreException | NoSuchAlgorithmException | CertificateException e) {
guQ.e(e);
}
}
}