diff --git a/src/apps/fido_u2f/__init__.py b/src/apps/fido_u2f/__init__.py index e2e1d6a4c2..e4e3048107 100644 --- a/src/apps/fido_u2f/__init__.py +++ b/src/apps/fido_u2f/__init__.py @@ -191,6 +191,8 @@ def read_cmd(iface: int) -> Cmd: databuf = bytearray(bcnt) utils.memcpy(databuf, 0, data, 0, bcnt) data = databuf + else: + data = data[:bcnt] while datalen < bcnt: buf, = yield loop.select(iface) @@ -198,6 +200,11 @@ def read_cmd(iface: int) -> Cmd: cfrm = overlay_struct(buf, desc_cont) + if cfrm.seq == _CMD_INIT: + ifrm = overlay_struct(buf, desc_init) + data = ifrm.data[:ifrm.bcnt] + break + if cfrm.cid != cid: send_cmd(cmd_error(cfrm.cid, _ERR_CHANNEL_BUSY), iface) continue