From 4e6962b25e5461c55fe12629ab7ce04a024918af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Skupnik?= Date: Sun, 6 Jan 2019 15:50:22 +0100 Subject: [PATCH] Add fingerprint authentication --- KeePass/Forms/MainForm.cs | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/KeePass/Forms/MainForm.cs b/KeePass/Forms/MainForm.cs index 62fe20b4..f2d29227 100644 --- a/KeePass/Forms/MainForm.cs +++ b/KeePass/Forms/MainForm.cs @@ -24,6 +24,7 @@ using System.Drawing; using System.Globalization; using System.IO; +using System.Net; using System.Media; using System.Security; using System.Text; @@ -868,9 +869,11 @@ private void OnEntryCopyUserName(object sender, EventArgs e) true, this, pe, m_docMgr.SafeFindContainerOf(pe))) StartClipboardCountdown(); } - + private void OnEntryCopyPassword(object sender, EventArgs e) { + if (!IsAllowedToCopyPassword()) return; + PwEntry pe = GetSelectedEntry(false); Debug.Assert(pe != null); if(pe == null) return; @@ -885,6 +888,35 @@ private void OnEntryCopyPassword(object sender, EventArgs e) StartClipboardCountdown(); } + private bool IsAllowedToCopyPassword() + { + SetStatusEx("Fingerprint verification..."); + + HttpWebResponse response = null; + try + { + HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://raspberrypi.fritz.box"); + request.Method = "GET"; + + response = (HttpWebResponse)request.GetResponse(); + } catch (WebException e) + { + if (e.Status == WebExceptionStatus.ProtocolError) + { + response = (HttpWebResponse)e.Response; + Console.Write("Errorcode: {0}", (int)response.StatusCode); + } + else + { + Console.Write("Error: {0}", e.Status); + } + SetStatusEx("Fingerprint verification FAILED, denied access to password"); + return false; + } + + return response != null && response.StatusCode == HttpStatusCode.OK; + } + private void OnEntryOpenUrl(object sender, EventArgs e) { PerformDefaultUrlAction(null, true);