1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 14:28:07 +00:00

src/apps/webauthn: pad last packet with zeros (#544)

This commit is contained in:
Tomas Susanka 2019-04-10 16:30:55 +02:00 committed by Pavol Rusnak
parent 2227fc60b8
commit a36c100eb9

View File

@ -77,6 +77,9 @@ _APDU_LC2 = const(5) # uint8_t lc2; // Length field, MSB
_APDU_LC3 = const(6) # uint8_t lc3; // Length field, LSB
_APDU_DATA = const(7) # uint8_t data[1]; // Data field
_FRAME_INIT_SIZE = 57
_FRAME_CONT_SIZE = 59
def frame_init() -> dict:
# uint32_t cid; // Channel identifier
@ -300,7 +303,10 @@ async def send_cmd(cmd: Cmd, iface: io.HID) -> None:
write = loop.wait(iface.iface_num() | io.POLL_WRITE)
while offset < datalen:
frm.seq = seq
offset += utils.memcpy(frm.data, 0, cmd.data, offset, datalen)
copied = utils.memcpy(frm.data, 0, cmd.data, offset, datalen)
offset += copied
if copied < _FRAME_CONT_SIZE:
frm.data[copied:] = bytearray(_FRAME_CONT_SIZE - copied)
while True:
await write
if iface.write(buf) > 0: