xref: /openbmc/qemu/hw/usb/u2f.c (revision b12498fc)
1*bb014a81SCésar Belley /*
2*bb014a81SCésar Belley  * U2F USB device.
3*bb014a81SCésar Belley  *
4*bb014a81SCésar Belley  * Copyright (c) 2020 César Belley <cesar.belley@lse.epita.fr>
5*bb014a81SCésar Belley  * Written by César Belley <cesar.belley@lse.epita.fr>
6*bb014a81SCésar Belley  *
7*bb014a81SCésar Belley  * Permission is hereby granted, free of charge, to any person obtaining a copy
8*bb014a81SCésar Belley  * of this software and associated documentation files (the "Software"), to deal
9*bb014a81SCésar Belley  * in the Software without restriction, including without limitation the rights
10*bb014a81SCésar Belley  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11*bb014a81SCésar Belley  * copies of the Software, and to permit persons to whom the Software is
12*bb014a81SCésar Belley  * furnished to do so, subject to the following conditions:
13*bb014a81SCésar Belley  *
14*bb014a81SCésar Belley  * The above copyright notice and this permission notice shall be included in
15*bb014a81SCésar Belley  * all copies or substantial portions of the Software.
16*bb014a81SCésar Belley  *
17*bb014a81SCésar Belley  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18*bb014a81SCésar Belley  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19*bb014a81SCésar Belley  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20*bb014a81SCésar Belley  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21*bb014a81SCésar Belley  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22*bb014a81SCésar Belley  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23*bb014a81SCésar Belley  * THE SOFTWARE.
24*bb014a81SCésar Belley  */
25*bb014a81SCésar Belley 
26*bb014a81SCésar Belley #include "qemu/osdep.h"
27*bb014a81SCésar Belley #include "qemu/module.h"
28*bb014a81SCésar Belley #include "qapi/error.h"
29*bb014a81SCésar Belley #include "hw/usb.h"
30*bb014a81SCésar Belley #include "hw/usb/hid.h"
31*bb014a81SCésar Belley #include "migration/vmstate.h"
32*bb014a81SCésar Belley #include "desc.h"
33*bb014a81SCésar Belley 
34*bb014a81SCésar Belley #include "u2f.h"
35*bb014a81SCésar Belley 
36*bb014a81SCésar Belley /* U2F key Vendor / Product */
37*bb014a81SCésar Belley #define U2F_KEY_VENDOR_NUM     0x46f4 /* CRC16() of "QEMU" */
38*bb014a81SCésar Belley #define U2F_KEY_PRODUCT_NUM    0x0005
39*bb014a81SCésar Belley 
40*bb014a81SCésar Belley enum {
41*bb014a81SCésar Belley     STR_MANUFACTURER = 1,
42*bb014a81SCésar Belley     STR_PRODUCT,
43*bb014a81SCésar Belley     STR_SERIALNUMBER,
44*bb014a81SCésar Belley     STR_CONFIG,
45*bb014a81SCésar Belley     STR_INTERFACE
46*bb014a81SCésar Belley };
47*bb014a81SCésar Belley 
48*bb014a81SCésar Belley static const USBDescStrings desc_strings = {
49*bb014a81SCésar Belley     [STR_MANUFACTURER]     = "QEMU",
50*bb014a81SCésar Belley     [STR_PRODUCT]          = "U2F USB key",
51*bb014a81SCésar Belley     [STR_SERIALNUMBER]     = "0",
52*bb014a81SCésar Belley     [STR_CONFIG]           = "U2F key config",
53*bb014a81SCésar Belley     [STR_INTERFACE]        = "U2F key interface"
54*bb014a81SCésar Belley };
55*bb014a81SCésar Belley 
56*bb014a81SCésar Belley static const USBDescIface desc_iface_u2f_key = {
57*bb014a81SCésar Belley     .bInterfaceNumber              = 0,
58*bb014a81SCésar Belley     .bNumEndpoints                 = 2,
59*bb014a81SCésar Belley     .bInterfaceClass               = USB_CLASS_HID,
60*bb014a81SCésar Belley     .bInterfaceSubClass            = 0x0,
61*bb014a81SCésar Belley     .bInterfaceProtocol            = 0x0,
62*bb014a81SCésar Belley     .ndesc                         = 1,
63*bb014a81SCésar Belley     .descs = (USBDescOther[]) {
64*bb014a81SCésar Belley         {
65*bb014a81SCésar Belley             /* HID descriptor */
66*bb014a81SCésar Belley             .data = (uint8_t[]) {
67*bb014a81SCésar Belley                 0x09,          /*  u8  bLength */
68*bb014a81SCésar Belley                 USB_DT_HID,    /*  u8  bDescriptorType */
69*bb014a81SCésar Belley                 0x10, 0x01,    /*  u16 HID_class */
70*bb014a81SCésar Belley                 0x00,          /*  u8  country_code */
71*bb014a81SCésar Belley                 0x01,          /*  u8  num_descriptors */
72*bb014a81SCésar Belley                 USB_DT_REPORT, /*  u8  type: Report */
73*bb014a81SCésar Belley                 0x22, 0,       /*  u16 len */
74*bb014a81SCésar Belley             },
75*bb014a81SCésar Belley         },
76*bb014a81SCésar Belley     },
77*bb014a81SCésar Belley     .eps = (USBDescEndpoint[]) {
78*bb014a81SCésar Belley         {
79*bb014a81SCésar Belley             .bEndpointAddress      = USB_DIR_IN | 0x01,
80*bb014a81SCésar Belley             .bmAttributes          = USB_ENDPOINT_XFER_INT,
81*bb014a81SCésar Belley             .wMaxPacketSize        = U2FHID_PACKET_SIZE,
82*bb014a81SCésar Belley             .bInterval             = 0x05,
83*bb014a81SCésar Belley         }, {
84*bb014a81SCésar Belley             .bEndpointAddress      = USB_DIR_OUT | 0x01,
85*bb014a81SCésar Belley             .bmAttributes          = USB_ENDPOINT_XFER_INT,
86*bb014a81SCésar Belley             .wMaxPacketSize        = U2FHID_PACKET_SIZE,
87*bb014a81SCésar Belley             .bInterval             = 0x05,
88*bb014a81SCésar Belley         },
89*bb014a81SCésar Belley     },
90*bb014a81SCésar Belley 
91*bb014a81SCésar Belley };
92*bb014a81SCésar Belley 
93*bb014a81SCésar Belley static const USBDescDevice desc_device_u2f_key = {
94*bb014a81SCésar Belley     .bcdUSB                        = 0x0100,
95*bb014a81SCésar Belley     .bMaxPacketSize0               = U2FHID_PACKET_SIZE,
96*bb014a81SCésar Belley     .bNumConfigurations            = 1,
97*bb014a81SCésar Belley     .confs = (USBDescConfig[]) {
98*bb014a81SCésar Belley         {
99*bb014a81SCésar Belley             .bNumInterfaces        = 1,
100*bb014a81SCésar Belley             .bConfigurationValue   = 1,
101*bb014a81SCésar Belley             .iConfiguration        = STR_CONFIG,
102*bb014a81SCésar Belley             .bmAttributes          = USB_CFG_ATT_ONE,
103*bb014a81SCésar Belley             .bMaxPower             = 15,
104*bb014a81SCésar Belley             .nif = 1,
105*bb014a81SCésar Belley             .ifs = &desc_iface_u2f_key,
106*bb014a81SCésar Belley         },
107*bb014a81SCésar Belley     },
108*bb014a81SCésar Belley };
109*bb014a81SCésar Belley 
110*bb014a81SCésar Belley static const USBDesc desc_u2f_key = {
111*bb014a81SCésar Belley     .id = {
112*bb014a81SCésar Belley         .idVendor          = U2F_KEY_VENDOR_NUM,
113*bb014a81SCésar Belley         .idProduct         = U2F_KEY_PRODUCT_NUM,
114*bb014a81SCésar Belley         .bcdDevice         = 0,
115*bb014a81SCésar Belley         .iManufacturer     = STR_MANUFACTURER,
116*bb014a81SCésar Belley         .iProduct          = STR_PRODUCT,
117*bb014a81SCésar Belley         .iSerialNumber     = STR_SERIALNUMBER,
118*bb014a81SCésar Belley     },
119*bb014a81SCésar Belley     .full = &desc_device_u2f_key,
120*bb014a81SCésar Belley     .str  = desc_strings,
121*bb014a81SCésar Belley };
122*bb014a81SCésar Belley 
123*bb014a81SCésar Belley static const uint8_t u2f_key_hid_report_desc[] = {
124*bb014a81SCésar Belley     0x06, 0xd0, 0xf1, /* Usage Page (FIDO) */
125*bb014a81SCésar Belley     0x09, 0x01,       /* Usage (FIDO) */
126*bb014a81SCésar Belley     0xa1, 0x01,       /* Collection (HID Application) */
127*bb014a81SCésar Belley     0x09, 0x20,       /*    Usage (FIDO data in) */
128*bb014a81SCésar Belley     0x15, 0x00,       /*        Logical Minimum (0) */
129*bb014a81SCésar Belley     0x26, 0xFF, 0x00, /*        Logical Maximum (0xff) */
130*bb014a81SCésar Belley     0x75, 0x08,       /*        Report Size (8) */
131*bb014a81SCésar Belley     0x95, 0x40,       /*        Report Count (0x40) */
132*bb014a81SCésar Belley     0x81, 0x02,       /*        Input (Data, Variable, Absolute) */
133*bb014a81SCésar Belley     0x09, 0x21,       /*    Usage (FIDO data out) */
134*bb014a81SCésar Belley     0x15, 0x00,       /*        Logical Minimum (0) */
135*bb014a81SCésar Belley     0x26, 0xFF, 0x00, /*        Logical Maximum  (0xFF) */
136*bb014a81SCésar Belley     0x75, 0x08,       /*        Report Size (8) */
137*bb014a81SCésar Belley     0x95, 0x40,       /*        Report Count (0x40) */
138*bb014a81SCésar Belley     0x91, 0x02,       /*        Output (Data, Variable, Absolute) */
139*bb014a81SCésar Belley     0xC0              /* End Collection */
140*bb014a81SCésar Belley };
141*bb014a81SCésar Belley 
u2f_key_reset(U2FKeyState * key)142*bb014a81SCésar Belley static void u2f_key_reset(U2FKeyState *key)
143*bb014a81SCésar Belley {
144*bb014a81SCésar Belley     key->pending_in_start = 0;
145*bb014a81SCésar Belley     key->pending_in_end = 0;
146*bb014a81SCésar Belley     key->pending_in_num = 0;
147*bb014a81SCésar Belley }
148*bb014a81SCésar Belley 
u2f_key_handle_reset(USBDevice * dev)149*bb014a81SCésar Belley static void u2f_key_handle_reset(USBDevice *dev)
150*bb014a81SCésar Belley {
151*bb014a81SCésar Belley     U2FKeyState *key = U2F_KEY(dev);
152*bb014a81SCésar Belley 
153*bb014a81SCésar Belley     u2f_key_reset(key);
154*bb014a81SCésar Belley }
155*bb014a81SCésar Belley 
u2f_key_handle_control(USBDevice * dev,USBPacket * p,int request,int value,int index,int length,uint8_t * data)156*bb014a81SCésar Belley static void u2f_key_handle_control(USBDevice *dev, USBPacket *p,
157*bb014a81SCésar Belley                int request, int value, int index, int length, uint8_t *data)
158*bb014a81SCésar Belley {
159*bb014a81SCésar Belley     U2FKeyState *key = U2F_KEY(dev);
160*bb014a81SCésar Belley     int ret;
161*bb014a81SCésar Belley 
162*bb014a81SCésar Belley     ret = usb_desc_handle_control(dev, p, request, value, index, length, data);
163*bb014a81SCésar Belley     if (ret >= 0) {
164*bb014a81SCésar Belley         return;
165*bb014a81SCésar Belley     }
166*bb014a81SCésar Belley 
167*bb014a81SCésar Belley     switch (request) {
168*bb014a81SCésar Belley     case InterfaceRequest | USB_REQ_GET_DESCRIPTOR:
169*bb014a81SCésar Belley         switch (value >> 8) {
170*bb014a81SCésar Belley         case 0x22:
171*bb014a81SCésar Belley             memcpy(data, u2f_key_hid_report_desc,
172*bb014a81SCésar Belley                    sizeof(u2f_key_hid_report_desc));
173*bb014a81SCésar Belley             p->actual_length = sizeof(u2f_key_hid_report_desc);
174*bb014a81SCésar Belley             break;
175*bb014a81SCésar Belley         default:
176*bb014a81SCésar Belley             goto fail;
177*bb014a81SCésar Belley         }
178*bb014a81SCésar Belley         break;
179*bb014a81SCésar Belley     case HID_GET_IDLE:
180*bb014a81SCésar Belley         data[0] = key->idle;
181*bb014a81SCésar Belley         p->actual_length = 1;
182*bb014a81SCésar Belley         break;
183*bb014a81SCésar Belley     case HID_SET_IDLE:
184*bb014a81SCésar Belley         key->idle = (uint8_t)(value >> 8);
185*bb014a81SCésar Belley         break;
186*bb014a81SCésar Belley     default:
187*bb014a81SCésar Belley     fail:
188*bb014a81SCésar Belley         p->status = USB_RET_STALL;
189*bb014a81SCésar Belley         break;
190*bb014a81SCésar Belley     }
191*bb014a81SCésar Belley 
192*bb014a81SCésar Belley }
193*bb014a81SCésar Belley 
u2f_key_recv_from_guest(U2FKeyState * key,USBPacket * p)194*bb014a81SCésar Belley static void u2f_key_recv_from_guest(U2FKeyState *key, USBPacket *p)
195*bb014a81SCésar Belley {
196*bb014a81SCésar Belley     U2FKeyClass *kc = U2F_KEY_GET_CLASS(key);
197*bb014a81SCésar Belley     uint8_t packet[U2FHID_PACKET_SIZE];
198*bb014a81SCésar Belley 
199*bb014a81SCésar Belley     if (kc->recv_from_guest == NULL || p->iov.size != U2FHID_PACKET_SIZE) {
200*bb014a81SCésar Belley         return;
201*bb014a81SCésar Belley     }
202*bb014a81SCésar Belley 
203*bb014a81SCésar Belley     usb_packet_copy(p, packet, p->iov.size);
204*bb014a81SCésar Belley     kc->recv_from_guest(key, packet);
205*bb014a81SCésar Belley }
206*bb014a81SCésar Belley 
u2f_pending_in_add(U2FKeyState * key,const uint8_t packet[U2FHID_PACKET_SIZE])207*bb014a81SCésar Belley static void u2f_pending_in_add(U2FKeyState *key,
208*bb014a81SCésar Belley                                const uint8_t packet[U2FHID_PACKET_SIZE])
209*bb014a81SCésar Belley {
210*bb014a81SCésar Belley     uint8_t index;
211*bb014a81SCésar Belley 
212*bb014a81SCésar Belley     if (key->pending_in_num >= U2FHID_PENDING_IN_NUM) {
213*bb014a81SCésar Belley         return;
214*bb014a81SCésar Belley     }
215*bb014a81SCésar Belley 
216*bb014a81SCésar Belley     index = key->pending_in_end;
217*bb014a81SCésar Belley     key->pending_in_end = (index + 1) % U2FHID_PENDING_IN_NUM;
218*bb014a81SCésar Belley     ++key->pending_in_num;
219*bb014a81SCésar Belley 
220*bb014a81SCésar Belley     memcpy(key->pending_in[index], packet, U2FHID_PACKET_SIZE);
221*bb014a81SCésar Belley }
222*bb014a81SCésar Belley 
u2f_pending_in_get(U2FKeyState * key)223*bb014a81SCésar Belley static uint8_t *u2f_pending_in_get(U2FKeyState *key)
224*bb014a81SCésar Belley {
225*bb014a81SCésar Belley     uint8_t index;
226*bb014a81SCésar Belley 
227*bb014a81SCésar Belley     if (key->pending_in_num == 0) {
228*bb014a81SCésar Belley         return NULL;
229*bb014a81SCésar Belley     }
230*bb014a81SCésar Belley 
231*bb014a81SCésar Belley     index = key->pending_in_start;
232*bb014a81SCésar Belley     key->pending_in_start = (index + 1) % U2FHID_PENDING_IN_NUM;
233*bb014a81SCésar Belley     --key->pending_in_num;
234*bb014a81SCésar Belley 
235*bb014a81SCésar Belley     return key->pending_in[index];
236*bb014a81SCésar Belley }
237*bb014a81SCésar Belley 
u2f_key_handle_data(USBDevice * dev,USBPacket * p)238*bb014a81SCésar Belley static void u2f_key_handle_data(USBDevice *dev, USBPacket *p)
239*bb014a81SCésar Belley {
240*bb014a81SCésar Belley     U2FKeyState *key = U2F_KEY(dev);
241*bb014a81SCésar Belley     uint8_t *packet_in;
242*bb014a81SCésar Belley 
243*bb014a81SCésar Belley     /* Endpoint number check */
244*bb014a81SCésar Belley     if (p->ep->nr != 1) {
245*bb014a81SCésar Belley         p->status = USB_RET_STALL;
246*bb014a81SCésar Belley         return;
247*bb014a81SCésar Belley     }
248*bb014a81SCésar Belley 
249*bb014a81SCésar Belley     switch (p->pid) {
250*bb014a81SCésar Belley     case USB_TOKEN_OUT:
251*bb014a81SCésar Belley         u2f_key_recv_from_guest(key, p);
252*bb014a81SCésar Belley         break;
253*bb014a81SCésar Belley     case USB_TOKEN_IN:
254*bb014a81SCésar Belley         packet_in = u2f_pending_in_get(key);
255*bb014a81SCésar Belley         if (packet_in == NULL) {
256*bb014a81SCésar Belley             p->status = USB_RET_NAK;
257*bb014a81SCésar Belley             return;
258*bb014a81SCésar Belley         }
259*bb014a81SCésar Belley         usb_packet_copy(p, packet_in, U2FHID_PACKET_SIZE);
260*bb014a81SCésar Belley         break;
261*bb014a81SCésar Belley     default:
262*bb014a81SCésar Belley         p->status = USB_RET_STALL;
263*bb014a81SCésar Belley         break;
264*bb014a81SCésar Belley     }
265*bb014a81SCésar Belley }
266*bb014a81SCésar Belley 
u2f_send_to_guest(U2FKeyState * key,const uint8_t packet[U2FHID_PACKET_SIZE])267*bb014a81SCésar Belley void u2f_send_to_guest(U2FKeyState *key,
268*bb014a81SCésar Belley                        const uint8_t packet[U2FHID_PACKET_SIZE])
269*bb014a81SCésar Belley {
270*bb014a81SCésar Belley     u2f_pending_in_add(key, packet);
271*bb014a81SCésar Belley     usb_wakeup(key->ep, 0);
272*bb014a81SCésar Belley }
273*bb014a81SCésar Belley 
u2f_key_unrealize(USBDevice * dev)274*bb014a81SCésar Belley static void u2f_key_unrealize(USBDevice *dev)
275*bb014a81SCésar Belley {
276*bb014a81SCésar Belley     U2FKeyState *key = U2F_KEY(dev);
277*bb014a81SCésar Belley     U2FKeyClass *kc = U2F_KEY_GET_CLASS(key);
278*bb014a81SCésar Belley 
279*bb014a81SCésar Belley     if (kc->unrealize != NULL) {
280*bb014a81SCésar Belley         kc->unrealize(key);
281*bb014a81SCésar Belley     }
282*bb014a81SCésar Belley }
283*bb014a81SCésar Belley 
u2f_key_realize(USBDevice * dev,Error ** errp)284*bb014a81SCésar Belley static void u2f_key_realize(USBDevice *dev, Error **errp)
285*bb014a81SCésar Belley {
286*bb014a81SCésar Belley     U2FKeyState *key = U2F_KEY(dev);
287*bb014a81SCésar Belley     U2FKeyClass *kc = U2F_KEY_GET_CLASS(key);
288*bb014a81SCésar Belley     Error *local_err = NULL;
289*bb014a81SCésar Belley 
290*bb014a81SCésar Belley     usb_desc_create_serial(dev);
291*bb014a81SCésar Belley     usb_desc_init(dev);
292*bb014a81SCésar Belley     u2f_key_reset(key);
293*bb014a81SCésar Belley 
294*bb014a81SCésar Belley     if (kc->realize != NULL) {
295*bb014a81SCésar Belley         kc->realize(key, &local_err);
296*bb014a81SCésar Belley         if (local_err != NULL) {
297*bb014a81SCésar Belley             error_propagate(errp, local_err);
298*bb014a81SCésar Belley             return;
299*bb014a81SCésar Belley         }
300*bb014a81SCésar Belley     }
301*bb014a81SCésar Belley     key->ep = usb_ep_get(dev, USB_TOKEN_IN, 1);
302*bb014a81SCésar Belley }
303*bb014a81SCésar Belley 
304*bb014a81SCésar Belley const VMStateDescription vmstate_u2f_key = {
305*bb014a81SCésar Belley     .name = "u2f-key",
306*bb014a81SCésar Belley     .version_id = 1,
307*bb014a81SCésar Belley     .minimum_version_id = 1,
308*bb014a81SCésar Belley     .fields = (VMStateField[]) {
309*bb014a81SCésar Belley         VMSTATE_USB_DEVICE(dev, U2FKeyState),
310*bb014a81SCésar Belley         VMSTATE_UINT8(idle, U2FKeyState),
311*bb014a81SCésar Belley         VMSTATE_UINT8_2DARRAY(pending_in, U2FKeyState,
312*bb014a81SCésar Belley             U2FHID_PENDING_IN_NUM, U2FHID_PACKET_SIZE),
313*bb014a81SCésar Belley         VMSTATE_UINT8(pending_in_start, U2FKeyState),
314*bb014a81SCésar Belley         VMSTATE_UINT8(pending_in_end, U2FKeyState),
315*bb014a81SCésar Belley         VMSTATE_UINT8(pending_in_num, U2FKeyState),
316*bb014a81SCésar Belley         VMSTATE_END_OF_LIST()
317*bb014a81SCésar Belley     }
318*bb014a81SCésar Belley };
319*bb014a81SCésar Belley 
u2f_key_class_init(ObjectClass * klass,void * data)320*bb014a81SCésar Belley static void u2f_key_class_init(ObjectClass *klass, void *data)
321*bb014a81SCésar Belley {
322*bb014a81SCésar Belley     DeviceClass *dc = DEVICE_CLASS(klass);
323*bb014a81SCésar Belley     USBDeviceClass *uc = USB_DEVICE_CLASS(klass);
324*bb014a81SCésar Belley 
325*bb014a81SCésar Belley     uc->product_desc   = "QEMU U2F USB key";
326*bb014a81SCésar Belley     uc->usb_desc       = &desc_u2f_key;
327*bb014a81SCésar Belley     uc->handle_reset   = u2f_key_handle_reset;
328*bb014a81SCésar Belley     uc->handle_control = u2f_key_handle_control;
329*bb014a81SCésar Belley     uc->handle_data    = u2f_key_handle_data;
330*bb014a81SCésar Belley     uc->handle_attach  = usb_desc_attach;
331*bb014a81SCésar Belley     uc->realize        = u2f_key_realize;
332*bb014a81SCésar Belley     uc->unrealize      = u2f_key_unrealize;
333*bb014a81SCésar Belley     dc->desc           = "QEMU U2F key";
334*bb014a81SCésar Belley     dc->vmsd           = &vmstate_u2f_key;
335*bb014a81SCésar Belley }
336*bb014a81SCésar Belley 
337*bb014a81SCésar Belley static const TypeInfo u2f_key_info = {
338*bb014a81SCésar Belley     .name          = TYPE_U2F_KEY,
339*bb014a81SCésar Belley     .parent        = TYPE_USB_DEVICE,
340*bb014a81SCésar Belley     .instance_size = sizeof(U2FKeyState),
341*bb014a81SCésar Belley     .abstract      = true,
342*bb014a81SCésar Belley     .class_size    = sizeof(U2FKeyClass),
343*bb014a81SCésar Belley     .class_init    = u2f_key_class_init,
344*bb014a81SCésar Belley };
345*bb014a81SCésar Belley 
u2f_key_register_types(void)346*bb014a81SCésar Belley static void u2f_key_register_types(void)
347*bb014a81SCésar Belley {
348*bb014a81SCésar Belley     type_register_static(&u2f_key_info);
349*bb014a81SCésar Belley }
350*bb014a81SCésar Belley 
351*bb014a81SCésar Belley type_init(u2f_key_register_types)
352