1*91608e2aSPeter MaydellUniversal Second Factor (U2F) USB Key Device 2*91608e2aSPeter Maydell============================================ 3*91608e2aSPeter Maydell 4*91608e2aSPeter MaydellU2F is an open authentication standard that enables relying parties 5*91608e2aSPeter Maydellexposed to the internet to offer a strong second factor option for end 6*91608e2aSPeter Maydelluser authentication. 7*91608e2aSPeter Maydell 8*91608e2aSPeter MaydellThe second factor is provided by a device implementing the U2F 9*91608e2aSPeter Maydellprotocol. In case of a USB U2F security key, it is a USB HID device 10*91608e2aSPeter Maydellthat implements the U2F protocol. 11*91608e2aSPeter Maydell 12*91608e2aSPeter MaydellQEMU supports both pass-through of a host U2F key device to a VM, 13*91608e2aSPeter Maydelland software emulation of a U2F key. 14*91608e2aSPeter Maydell 15*91608e2aSPeter Maydell``u2f-passthru`` 16*91608e2aSPeter Maydell---------------- 17*91608e2aSPeter Maydell 18*91608e2aSPeter MaydellThe ``u2f-passthru`` device allows you to connect a real hardware 19*91608e2aSPeter MaydellU2F key on your host to a guest VM. All requests made from the guest 20*91608e2aSPeter Maydellare passed through to the physical security key connected to the 21*91608e2aSPeter Maydellhost machine and vice versa. 22*91608e2aSPeter Maydell 23*91608e2aSPeter MaydellIn addition, the dedicated pass-through allows you to share a single 24*91608e2aSPeter MaydellU2F security key with several guest VMs, which is not possible with a 25*91608e2aSPeter Maydellsimple host device assignment pass-through. 26*91608e2aSPeter Maydell 27*91608e2aSPeter MaydellYou can specify the host U2F key to use with the ``hidraw`` 28*91608e2aSPeter Maydelloption, which takes the host path to a Linux ``/dev/hidrawN`` device: 29*91608e2aSPeter Maydell 30*91608e2aSPeter Maydell.. parsed-literal:: 31*91608e2aSPeter Maydell |qemu_system| -usb -device u2f-passthru,hidraw=/dev/hidraw0 32*91608e2aSPeter Maydell 33*91608e2aSPeter MaydellIf you don't specify the device, the ``u2f-passthru`` device will 34*91608e2aSPeter Maydellautoscan to take the first U2F device it finds on the host (this 35*91608e2aSPeter Maydellrequires a working libudev): 36*91608e2aSPeter Maydell 37*91608e2aSPeter Maydell.. parsed-literal:: 38*91608e2aSPeter Maydell |qemu_system| -usb -device u2f-passthru 39*91608e2aSPeter Maydell 40*91608e2aSPeter Maydell``u2f-emulated`` 41*91608e2aSPeter Maydell---------------- 42*91608e2aSPeter Maydell 43*91608e2aSPeter Maydell``u2f-emulated`` is a completely software emulated U2F device. 44*91608e2aSPeter MaydellIt uses `libu2f-emu <https://github.com/MattGorko/libu2f-emu>`__ 45*91608e2aSPeter Maydellfor the U2F key emulation. libu2f-emu 46*91608e2aSPeter Maydellprovides a complete implementation of the U2F protocol device part for 47*91608e2aSPeter Maydellall specified transports given by the FIDO Alliance. 48*91608e2aSPeter Maydell 49*91608e2aSPeter MaydellTo work, an emulated U2F device must have four elements: 50*91608e2aSPeter Maydell 51*91608e2aSPeter Maydell * ec x509 certificate 52*91608e2aSPeter Maydell * ec private key 53*91608e2aSPeter Maydell * counter (four bytes value) 54*91608e2aSPeter Maydell * 48 bytes of entropy (random bits) 55*91608e2aSPeter Maydell 56*91608e2aSPeter MaydellTo use this type of device, these have to be configured, and these 57*91608e2aSPeter Maydellfour elements must be passed one way or another. 58*91608e2aSPeter Maydell 59*91608e2aSPeter MaydellAssuming that you have a working libu2f-emu installed on the host, 60*91608e2aSPeter Maydellthere are three possible ways to configure the ``u2f-emulated`` device: 61*91608e2aSPeter Maydell 62*91608e2aSPeter Maydell * ephemeral 63*91608e2aSPeter Maydell * setup directory 64*91608e2aSPeter Maydell * manual 65*91608e2aSPeter Maydell 66*91608e2aSPeter MaydellEphemeral is the simplest way to configure; it lets the device generate 67*91608e2aSPeter Maydellall the elements it needs for a single use of the lifetime of the device. 68*91608e2aSPeter MaydellIt is the default if you do not pass any other options to the device. 69*91608e2aSPeter Maydell 70*91608e2aSPeter Maydell.. parsed-literal:: 71*91608e2aSPeter Maydell |qemu_system| -usb -device u2f-emulated 72*91608e2aSPeter Maydell 73*91608e2aSPeter MaydellYou can pass the device the path of a setup directory on the host 74*91608e2aSPeter Maydellusing the ``dir`` option; the directory must contain these four files: 75*91608e2aSPeter Maydell 76*91608e2aSPeter Maydell * ``certificate.pem``: ec x509 certificate 77*91608e2aSPeter Maydell * ``private-key.pem``: ec private key 78*91608e2aSPeter Maydell * ``counter``: counter value 79*91608e2aSPeter Maydell * ``entropy``: 48 bytes of entropy 80*91608e2aSPeter Maydell 81*91608e2aSPeter Maydell.. parsed-literal:: 82*91608e2aSPeter Maydell |qemu_system| -usb -device u2f-emulated,dir=$dir 83*91608e2aSPeter Maydell 84*91608e2aSPeter MaydellYou can also manually pass the device the paths to each of these files, 85*91608e2aSPeter Maydellif you don't want them all to be in the same directory, using the options 86*91608e2aSPeter Maydell 87*91608e2aSPeter Maydell * ``cert`` 88*91608e2aSPeter Maydell * ``priv`` 89*91608e2aSPeter Maydell * ``counter`` 90*91608e2aSPeter Maydell * ``entropy`` 91*91608e2aSPeter Maydell 92*91608e2aSPeter Maydell.. parsed-literal:: 93*91608e2aSPeter Maydell |qemu_system| -usb -device u2f-emulated,cert=$DIR1/$FILE1,priv=$DIR2/$FILE2,counter=$DIR3/$FILE3,entropy=$DIR4/$FILE4 94