From 6ea973b79ef8f53a250313f34218680a7b5fb1b4 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 17 May 2012 15:53:34 +0200 Subject: iso7816_uart: Make sure ATR is separated from normal APDU in all cases Prior to this patch, the ATR was not send in a separate USB message for cards that are T=0 only. --- firmware/src/simtrace/iso7816_uart.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/firmware/src/simtrace/iso7816_uart.c b/firmware/src/simtrace/iso7816_uart.c index 5f1bad0..52522c0 100644 --- a/firmware/src/simtrace/iso7816_uart.c +++ b/firmware/src/simtrace/iso7816_uart.c @@ -275,13 +275,23 @@ static void set_state(struct iso7816_3_handle *ih, enum iso7816_3_state new_stat ih->state = new_state; } +static void atr_done_wait_apdu(struct iso7816_3_handle *ih) +{ + set_atr_state(ih, ATR_S_DONE); + /* send off the USB context */ + ih->rctx_must_be_sent = 1; + /* update the waiting time */ + ih->waiting_time = 960 * di_table[ih->di] * ih->wi; + tc_etu_set_wtime(ih->waiting_time); +} + static enum iso7816_3_state transition_to_tck(struct iso7816_3_handle *ih) { if (ih->prot_t_supported == 0x01) { /* If only T=0 supported, there is no TCK but we * immediately transition to APDUs */ - set_atr_state(ih, ATR_S_DONE); + atr_done_wait_apdu(ih); return ISO7816_S_WAIT_APDU; } else { set_atr_state(ih, ATR_S_WAIT_TCK); @@ -371,12 +381,7 @@ process_byte_atr(struct iso7816_3_handle *ih, u_int8_t byte) break; case ATR_S_WAIT_TCK: /* FIXME: process and verify the TCK */ - set_atr_state(ih, ATR_S_DONE); - /* send off the USB context */ - ih->rctx_must_be_sent = 1; - /* update the waiting time */ - ih->waiting_time = 960 * di_table[ih->di] * ih->wi; - tc_etu_set_wtime(ih->waiting_time); + atr_done_wait_apdu(ih); return ISO7816_S_WAIT_APDU; } -- cgit v1.2.3