public BiometricEncryption(BiometricModule biometric, string keyId) : base(biometric, keyId) { _keyGen = biometric.KeyGenerator; Kp2aLog.Log("FP: CreateKey "); CreateKey(); }
protected override void OnResume() { base.OnResume(); BiometricModule fpModule = new BiometricModule(this); HideRadioButtons(); if (!fpModule.IsHardwareAvailable) { //seems like not all Samsung Devices (e.g. Note 4) don't support the Android 6 fingerprint API if (!TrySetupSamsung()) { SetError(Resource.String.fingerprint_hardware_error); } UpdateCloseDatabaseAfterFailedBiometricQuickUnlockVisibility(); return; } if (!fpModule.IsAvailable) { SetError(Resource.String.fingerprint_no_enrolled); return; } ShowRadioButtons(); UpdateCloseDatabaseAfterFailedBiometricQuickUnlockVisibility(); }
public BiometricCrypt(BiometricModule biometric, string keyId) { Kp2aLog.Log("FP: Create " + this.GetType().Name); _keyId = keyId; _cipher = biometric.Cipher; _keystore = biometric.Keystore; _activity = biometric.Activity; }
public BiometricDecryption(BiometricModule biometric, string keyId, Context context, string prefKey) : base(biometric, keyId) { _context = context; _iv = Base64.Decode(PreferenceManager.GetDefaultSharedPreferences(context).GetString(GetIvPrefKey(prefKey), null), 0); }
public BiometricDecryption(BiometricModule biometric, string keyId, byte[] iv) : base(biometric, keyId) { _iv = iv; }
private bool InitFingerprintUnlock() { Kp2aLog.Log("InitFingerprintUnlock"); if (_biometryIdentifier != null) { Kp2aLog.Log("Already listening for fingerprint!"); return(true); } var btn = FindViewById <ImageButton>(Resource.Id.fingerprintbtn); try { FingerprintUnlockMode um; Enum.TryParse(PreferenceManager.GetDefaultSharedPreferences(this).GetString(App.Kp2a.GetDbForQuickUnlock().CurrentFingerprintModePrefKey, ""), out um); btn.Visibility = (um != FingerprintUnlockMode.Disabled) ? ViewStates.Visible : ViewStates.Gone; if (um == FingerprintUnlockMode.Disabled) { _biometryIdentifier = null; return(false); } if (um == FingerprintUnlockMode.QuickUnlock && Util.GetCloseDatabaseAfterFailedBiometricQuickUnlock(this)) { maxNumFailedAttempts = 3; } BiometricModule fpModule = new BiometricModule(this); Kp2aLog.Log("fpModule.IsHardwareAvailable=" + fpModule.IsHardwareAvailable); if (fpModule.IsHardwareAvailable) //see FingerprintSetupActivity { _biometryIdentifier = new BiometricDecryption(fpModule, App.Kp2a.GetDbForQuickUnlock().CurrentFingerprintPrefKey, this, App.Kp2a.GetDbForQuickUnlock().CurrentFingerprintPrefKey); } if ((_biometryIdentifier == null) && (!BiometricDecryption.IsSetUp(this, App.Kp2a.GetDbForQuickUnlock().CurrentFingerprintPrefKey))) { try { Kp2aLog.Log("trying Samsung Fingerprint API..."); _biometryIdentifier = new BiometrySamsungIdentifier(this); btn.Click += (sender, args) => { if (_biometryIdentifier.Init()) { if (numFailedAttempts < maxNumFailedAttempts) { _biometryIdentifier.StartListening(this); } } }; Kp2aLog.Log("trying Samsung Fingerprint API...Seems to work!"); } catch (Exception) { Kp2aLog.Log("trying Samsung Fingerprint API...failed."); _biometryIdentifier = null; } } if (_biometryIdentifier == null) { FindViewById <ImageButton>(Resource.Id.fingerprintbtn).Visibility = ViewStates.Gone; return(false); } if (_biometryIdentifier.Init()) { Kp2aLog.Log("successfully initialized fingerprint."); btn.SetImageResource(Resource.Drawable.ic_fp_40px); _biometryIdentifier.StartListening(this); return(true); } else { Kp2aLog.Log("failed to initialize fingerprint."); HandleFingerprintKeyInvalidated(); } } catch (Exception e) { Kp2aLog.Log("Error initializing Fingerprint Unlock: " + e); btn.SetImageResource(Resource.Drawable.ic_fingerprint_error); btn.Tag = "Error initializing Fingerprint Unlock: " + e; _biometryIdentifier = null; } return(false); }