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.
This commit is contained in:
Nathan Woodburn 2023-06-15 19:31:24 +10:00
parent 79350570fd
commit 6218b337fb
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -2285,6 +2285,15 @@ namespace FireWallet
NotifyForm notifyForm = new NotifyForm("Insert Yubikey\nThis will use your yubikey to encrypt your account password."); NotifyForm notifyForm = new NotifyForm("Insert Yubikey\nThis will use your yubikey to encrypt your account password.");
notifyForm.ShowDialog(); notifyForm.ShowDialog();
notifyForm.Dispose(); 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); NotifyForm yubiLoadingForm = new NotifyForm("Encrypting. . .", false);
yubiLoadingForm.Show(); yubiLoadingForm.Show();
@ -2295,7 +2304,7 @@ namespace FireWallet
{ {
//Assumes there is exactly one yubikey connected and it has a RSA2048 certificate in slot 9d //Assumes there is exactly one yubikey connected and it has a RSA2048 certificate in slot 9d
//PIV PIN is assumed to be 123456 //PIV PIN is assumed to be 123456
var devices = YubiKeyDevice.FindAll();
var ykDevice = devices.First(); var ykDevice = devices.First();
PivSession piv = new(ykDevice); PivSession piv = new(ykDevice);
@ -2350,9 +2359,6 @@ namespace FireWallet
} }
private string YubiUnlock() private string YubiUnlock()
{ {
NotifyForm notifyForm = new NotifyForm("Insert Yubikey to unlock");
notifyForm.ShowDialog();
notifyForm.Dispose();
NotifyForm yubiLoadingForm = new NotifyForm("Decrypting. . .", false); NotifyForm yubiLoadingForm = new NotifyForm("Decrypting. . .", false);
yubiLoadingForm.Show(); yubiLoadingForm.Show();
// Wait for the form to load // Wait for the form to load