firmware: card_emu: fix 7816-3 10.3.2 0=256 case

add_tpdu_byte() accumulates bytes received from the reader, but passes
reader_to_card = 0, but ISO 7816-3 10.3.2 says P3 == 0 means 256 not 0

Only reachable with P3 == 0 in a receive data phase, but
simtrace2-cardem-pcsc only requests PB_AND_RX when there is command data.

Fix this anyway.

Change-Id: I0fa4741bc1293549816595e6b4e8af9e22bcfbc1
This commit is contained in:
Eric Wild
2026-07-28 17:42:32 +02:00
committed by lynxis lazus
parent f7170aff42
commit 58438bfdbc
+2 -1
View File
@@ -745,7 +745,8 @@ static void add_tpdu_byte(struct card_handle *ch, uint8_t byte)
{ {
struct msgb *msg; struct msgb *msg;
struct cardemu_usb_msg_rx_data *rd; struct cardemu_usb_msg_rx_data *rd;
unsigned int num_data_bytes = t0_num_data_bytes(ch->tpdu.hdr[_P3], 0); /* these are bytes the reader sends to us, so P3 is a literal count */
unsigned int num_data_bytes = t0_num_data_bytes(ch->tpdu.hdr[_P3], 1);
/* ensure we have a buffer */ /* ensure we have a buffer */
if (!ch->uart_rx_msg) { if (!ch->uart_rx_msg) {