private void ReadFIDODevices() { //Read all FIDO devices var devPaths = new List <string>(); devPaths.AddRange(HIDAuthenticatorConnector.GetAllFIDODevicePaths()); //Any new devices, add a new connector object for it to the collection foreach (var devPath in devPaths) { if (!fidoDevices.ContainsKey(devPath)) { fidoDevices[devPath] = new HIDAuthenticatorConnector(devPath); fidoDevices[devPath].KeepAlive += OnKeepAlive; } } //Remove devices from the collection that are no longer present List <string> removedDevices = new List <string>(); removedDevices.AddRange(fidoDevices.Keys.Where(k => !devPaths.Contains(k))); foreach (var toRemove in removedDevices) { fidoDevices[toRemove].KeepAlive -= OnKeepAlive; fidoDevices.Remove(toRemove); } }
private void GetFirstUSBDevice() { List <string> fidoDevices = HIDAuthenticatorConnector.GetAllFIDODevicePaths(); if (fidoDevices.Count == 0) { //If there are no devices then we have no need for a connector con = null; return; } //If we already have a connector linked to this device then no further action is required if (fidoDevices.Contains(con?.GetDevicePath())) { return; } //Configure a new connector using the first returned device if (!(con is null)) { con.KeepAlive -= OnKeepAlive; } con = new HIDAuthenticatorConnector(fidoDevices[0]); con.KeepAlive += OnKeepAlive; }
private async void ButtonClientPINgetRetries_Click(object sender, RoutedEventArgs e) { var con2 = new HIDAuthenticatorConnector(); var res = await con2.ClientPINgetRetriesAsync(); if (res.DeviceStatus == g.FIDO2.CTAP.DeviceStatus.Ok) { MessageBox.Show($"ClientPINgetRetriesAsync\r\n- Status = {res.CTAPResponse.Status}\r\n- StatusMsg = {res.CTAPResponse.StatusMsg}\r\n- PIN Retry Count = {res.CTAPResponse.RetryCount}"); } }
private void ButtonFinds_Click(object sender, RoutedEventArgs e) { addLog("<List HID>"); var res = HIDAuthenticatorConnector.GetAllHIDDeviceInfo(); foreach (var info in res) { addLog(info); } addLog("<List HID - END>"); }
private async void ButtonWink_Click(object sender, RoutedEventArgs e) { var con2 = new HIDAuthenticatorConnector(); for (int intIc = 0; intIc < 5; intIc++) { var ret = await con2.WinkAsync(); await Task.Delay(1000); } }
private HIDAuthenticatorConnector GetCurrentConnector() { HIDAuthenticatorConnector con = null; if (fidoDevices.ContainsKey(CurrentDevicePath)) { con = fidoDevices[CurrentDevicePath]; } else { return(null); } if (!con.IsConnected()) { addLog($"Not connected to {CurrentDevicePath}"); return(null); } return(con); }
public MainWindow() { InitializeComponent(); con = new HIDAuthenticatorConnector(); con.KeepAlive += OnKeepAlive; }