summaryrefslogtreecommitdiff
path: root/firmware/src/simtrace
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-05-17 15:53:34 +0200
committerHarald Welte <laforge@gnumonks.org>2012-05-18 21:52:32 +0200
commit6ea973b79ef8f53a250313f34218680a7b5fb1b4 (patch)
tree68a0e4b294cacd12d27d1cb47c3983f22849f2eb /firmware/src/simtrace
parent5aae62cb7b099663d80f83591bd4f6f824fc88fb (diff)
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.
Diffstat (limited to 'firmware/src/simtrace')
-rw-r--r--firmware/src/simtrace/iso7816_uart.c19
1 files 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;
}
personal git repositories of Harald Welte. Your mileage may vary