Hoernchen has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/42049?usp=email )
Change subject: fix wait time extension handling ......................................................................
fix wait time extension handling
Change-Id: I7527a4337ae857b9b2a4e982606fac770e677d73 --- M ccid_common/iso7816_fsm.c 1 file changed, 26 insertions(+), 14 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware refs/changes/49/42049/1
diff --git a/ccid_common/iso7816_fsm.c b/ccid_common/iso7816_fsm.c index 7b0ea5f..7e94c81 100644 --- a/ccid_common/iso7816_fsm.c +++ b/ccid_common/iso7816_fsm.c @@ -1488,12 +1488,18 @@ case ISO7816_E_RX_SINGLE: byte = get_rx_byte_evt(fi->proc.parent, data); LOGPFSML(fi, LOGL_DEBUG, "Received 0x%02x from UART\n", byte); - /* record byte */ - //msgb_apdu_sw(tfp->apdu) = byte << 8; - msgb_put_u8(tfp->tpdu, byte); - card_uart_set_rx_threshold(ip->uart, 1); - card_uart_ctrl(ip->uart, CUART_CTL_RX_TIMER_HINT, 1); - osmo_fsm_inst_state_chg(fi, TPDU_S_SW2, 0, 0); + if (byte == 0x60) { + /* NULL: wait for actual SW1 */ + card_uart_set_rx_threshold(ip->uart, 1); + card_uart_ctrl(ip->uart, CUART_CTL_RX_TIMER_HINT, 1); + osmo_fsm_inst_state_chg(fi, TPDU_S_SW1, 0, 0); + } else { + /* record SW1 byte */ + msgb_put_u8(tfp->tpdu, byte); + card_uart_set_rx_threshold(ip->uart, 1); + card_uart_ctrl(ip->uart, CUART_CTL_RX_TIMER_HINT, 1); + osmo_fsm_inst_state_chg(fi, TPDU_S_SW2, 0, 0); + } break; default: OSMO_ASSERT(0); @@ -1511,14 +1517,18 @@ case ISO7816_E_RX_SINGLE: byte = get_rx_byte_evt(fi->proc.parent, data); LOGPFSML(fi, LOGL_DEBUG, "Received 0x%02x from UART\n", byte); - /* record SW2 byte */ - //msgb_apdu_sw(tfp->apdu) &= 0xFF00; - //msgb_apdu_sw(tfp->apdu) |= byte; - msgb_put_u8(tfp->tpdu, byte); - osmo_fsm_inst_state_chg(fi, TPDU_S_DONE, 0, 0); - /* Notify parent FSM */ - osmo_fsm_inst_dispatch(fi->proc.parent, ISO7816_E_TPDU_DONE_IND, tfp->tpdu); - + if (byte == 0x60) { + /* NULL: wait for actual SW2 */ + card_uart_set_rx_threshold(ip->uart, 1); + card_uart_ctrl(ip->uart, CUART_CTL_RX_TIMER_HINT, 1); + osmo_fsm_inst_state_chg(fi, TPDU_S_SW2, 0, 0); + } else { + /* record SW2 byte */ + msgb_put_u8(tfp->tpdu, byte); + osmo_fsm_inst_state_chg(fi, TPDU_S_DONE, 0, 0); + /* Notify parent FSM */ + osmo_fsm_inst_dispatch(fi->proc.parent, ISO7816_E_TPDU_DONE_IND, tfp->tpdu); + } break; default: OSMO_ASSERT(0); @@ -1615,6 +1625,7 @@ .name = "SW1", .in_event_mask = S(ISO7816_E_RX_SINGLE), .out_state_mask = S(TPDU_S_INIT) | + S(TPDU_S_SW1) | S(TPDU_S_SW2), .action = tpdu_s_sw1_action, }, @@ -1622,6 +1633,7 @@ .name = "SW2", .in_event_mask = S(ISO7816_E_RX_SINGLE), .out_state_mask = S(TPDU_S_INIT) | + S(TPDU_S_SW2) | S(TPDU_S_DONE), .action = tpdu_s_sw2_action, },