From 6218b337fbc63e540cf976777295aa24e10f4e83 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 15 Jun 2023 19:31:24 +1000 Subject: [PATCH] main: Added Yubikey device check and removed redundant code - Added a check for the number of connected Yubikeys - Removed redundant code that prompts user to insert Yubikey before unlocking. --- FireWallet/MainForm.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/FireWallet/MainForm.cs b/FireWallet/MainForm.cs index 0bef43a..26b88f0 100644 --- a/FireWallet/MainForm.cs +++ b/FireWallet/MainForm.cs @@ -2285,6 +2285,15 @@ namespace FireWallet NotifyForm notifyForm = new NotifyForm("Insert Yubikey\nThis will use your yubikey to encrypt your account password."); notifyForm.ShowDialog(); notifyForm.Dispose(); + var devices = YubiKeyDevice.FindAll(); + if (devices.Count() != 1) + { + NotifyForm notifyForm2 = new NotifyForm("Please insert your yubikey and try again."); + notifyForm2.ShowDialog(); + notifyForm2.Dispose(); + return; + } + NotifyForm yubiLoadingForm = new NotifyForm("Encrypting. . .", false); yubiLoadingForm.Show(); @@ -2295,7 +2304,7 @@ namespace FireWallet { //Assumes there is exactly one yubikey connected and it has a RSA2048 certificate in slot 9d //PIV PIN is assumed to be 123456 - var devices = YubiKeyDevice.FindAll(); + var ykDevice = devices.First(); PivSession piv = new(ykDevice); @@ -2350,9 +2359,6 @@ namespace FireWallet } private string YubiUnlock() { - NotifyForm notifyForm = new NotifyForm("Insert Yubikey to unlock"); - notifyForm.ShowDialog(); - notifyForm.Dispose(); NotifyForm yubiLoadingForm = new NotifyForm("Decrypting. . .", false); yubiLoadingForm.Show(); // Wait for the form to load