private static void TestHardwareOnly() { var factory = (IHidDeviceFactory)Win32HidDeviceFactory.Instance; var devices = factory.FindAllAsync().Result; var fidoInfo = devices.Where(FidoU2FIdentification.IsFidoU2F).FirstOrDefault(); Console.WriteLine("Devices found:"); ShowDevices(devices); Console.WriteLine(); if (fidoInfo == null) { Console.WriteLine("Can't find FIDO device :-("); Console.ReadLine(); return; } Console.WriteLine(fidoInfo.Id); Console.WriteLine(fidoInfo.Manufacturer); Console.WriteLine(fidoInfo.Product); Console.WriteLine(fidoInfo.SerialNumber); Console.WriteLine("VID = 0x{0:X4}", fidoInfo.VendorId); Console.WriteLine("PID = 0x{0:X4}", fidoInfo.ProductId); using (var device = (Win32HidDevice)fidoInfo.OpenDeviceAsync().Result) { device.SetNumInputBuffers(64); var caps = device.Information.Capabilities; Console.WriteLine(caps.NumberFeatureButtonCaps); //Test(device); Console.WriteLine("Using high level API"); var u2f = new U2FHidKey(device, false); var init = u2f.InitAsync().Result; var pongShort = u2f.Ping(Encoding.UTF8.GetBytes("Pong !!").Segment()).Result; WriteBuffer(pongShort); var pong = u2f.Ping( Encoding.UTF8.GetBytes( "abcdefgh1-abcdefgh2-abcdefgh3-abcdefgh4-abcdefgh5-abcdefgh6-abcdefgh7-abcdefgh8-").Segment()) .Result; WriteBuffer(pong); if (init.Capabilities.HasFlag(U2FDeviceCapabilities.Wink)) { Console.WriteLine("Winking"); u2f.WinkAsync().Wait(); } Console.ReadLine(); } }
public void WinkSendCorrectBytes() { // Setup var scenario = HidScenario.Build(); scenario.Write(report => AssertWriteInitPacket(report.Data, TestChannel, U2FHidCommand.Wink)); scenario.Read(() => new HidInputReport(BuildInitPacket(TestChannel, U2FHidCommand.Wink))); var hid = CreateHidMock(); var device = new U2FHidKey(hid.Object, false); InitDevice(hid, device); scenario.Run(hid); // Act device.WinkAsync().Wait(); // Assert scenario.End(); }