static void PrintNeo(string name) { Console.WriteLine($"[NEO] Device: {name}"); if (!YubikeyNeoManager.Instance.IsValidDevice(name)) { Console.WriteLine(" Not a valid NEO device"); } else { using (YubikeyNeoDevice device = YubikeyNeoManager.Instance.OpenDevice(name)) { Console.WriteLine($" Serial : {device.GetSerialNumber()}"); Console.WriteLine($" Mode : {device.GetMode()}"); Console.WriteLine($" Version : {device.GetVersion()}"); } } Console.WriteLine(); }
private void RefreshInsertedKeyInfo() { string devName = YubikeyNeoManager.Instance.ListDevices().FirstOrDefault(); bool hasDevice = !string.IsNullOrEmpty(devName); foreach (Control control in gbInsertedYubikey.Controls) { if (control.Name.StartsWith("lbl")) { control.Visible = hasDevice; } } if (!hasDevice) { return; } lblAlreadyEnrolled.Visible = _hasBeenEnrolled; using (YubikeyNeoDevice dev = YubikeyNeoManager.Instance.OpenDevice(devName)) { YubicoNeoMode currentMode = dev.GetMode(); if (currentMode.HasCcid) { lblInsertedMode.ForeColor = Color.Black; } else { lblInsertedMode.ForeColor = Color.Red; } lblInsertedSerial.Text = dev.GetSerialNumber().ToString(); lblInsertedMode.Text = currentMode.ToString(); lblInsertedFirmware.Text = dev.GetVersion().ToString(); } }
private void YubikeyStateChange() { string devName = YubikeyNeoManager.Instance.ListDevices().FirstOrDefault(); bool hasDevice = !string.IsNullOrEmpty(devName); btnExportCert.Enabled = false; btnViewCert.Enabled = false; if (hasDevice) { using (YubikeyNeoDevice dev = YubikeyNeoManager.Instance.OpenDevice(devName)) { YubicoLib.YubikeyNeo.YubicoNeoMode currentMode = dev.GetMode(); bool enableCcid = !currentMode.HasCcid; btnExportCert.Enabled = !enableCcid; btnViewCert.Enabled = !enableCcid; } } RefreshInsertedKey(); }
private void RefreshInsertedKey() { List <string> listDevices = YubikeyNeoManager.Instance.ListDevices().ToList(); string devName = listDevices.FirstOrDefault(); bool hasDevice = !string.IsNullOrEmpty(devName); foreach (Control control in gbInsertedKey.Controls) { if (control.Name.StartsWith("lbl")) { control.Visible = hasDevice; } } if (hasDevice) { using (YubikeyNeoDevice dev = YubikeyNeoManager.Instance.OpenDevice(devName)) { int serialNumber = dev.GetSerialNumber(); lblInsertedSerial.Text = serialNumber.ToString(); lblInsertedFirmware.Text = dev.GetVersion().ToString(); lblInsertedMode.Text = dev.GetMode().ToString(); lblInsertedHasBeenEnrolled.Text = _dataStore.Search(serialNumber).Any().ToString(); } } if (listDevices.Count > 1) { lblMultipleKeys.Text = $"{listDevices.Count:N0} keys inserted"; } else { lblMultipleKeys.Text = ""; } }