flipperdevices / flipperzero-firmware

Flipper Zero firmware source code
https://flipperzero.one
GNU General Public License v3.0
12.56k stars 2.68k forks source link

CCID: Updated types to match Short APDU size #3690

Closed kidbomb closed 3 months ago

kidbomb commented 3 months ago

What's new

The CCID stack currently implemented in Flipper operates in short APDU mode, which supports only 256 bytes for the data length. The buffer on furi_hal_usb_ccid.c already supports this size - however the data types on the callback functions are still using uint32_t instead of uint8_t. This PR updates the callbacks so they use uint8_t as the proper type for the data length

Verification

opensc-tool --atr

The command above shoud return 3b:00

opensc-tool --send-apdu 01:01:00:00

The command above should return

Received (SW1=0x90, SW2=0x00)`

opensc-tool --send-apdu 01:02:00:00

The command above should return:

Received (SW1=0x90, SW2=0x01):
62 63 bc

opensc-tool --send-apdu 01:03:00:00:02:CA:FE

The command above should return:

Received (SW1=0x90, SW2=0x02):
CA FE ..

Checklist (For Reviewer)

kidbomb commented 3 months ago

I'll keep it as uint32_t, since:

the CCID buffer size is already 255 in size we are already checking ii dwLength is < 255 i will add extended apdu support at some point anyway