From 20157f9f8045159d4ca08314f4a429730b5ca77a Mon Sep 17 00:00:00 2001 From: Frank Morgner Date: Thu, 23 Apr 2015 22:47:36 +0200 Subject: [PATCH] if boxing is not supported, select MF resets the state of the card which may be confused by the commands with CLA=FF (and is more lightweight than an actual reset) --- npa/src/boxing.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/npa/src/boxing.c b/npa/src/boxing.c index f88dbc5..eb56d77 100644 --- a/npa/src/boxing.c +++ b/npa/src/boxing.c @@ -929,9 +929,25 @@ void sc_detect_boxing_cmds(sc_reader_t *reader) || apdu.sw2 != 0x00 || boxing_buf_to_pace_capabilities(reader->ctx, apdu.resp, apdu.resplen, &capabilities) != SC_SUCCESS) { - if (reader) + if (reader) { sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL, "%s does not support boxing commands", reader->name); + memset(&apdu, 0, sizeof(apdu)); + apdu.cse = SC_APDU_CASE_3; + apdu.cla = 0x00; + apdu.ins = 0xA4; + apdu.p1 = 8; + apdu.p2 = 0x0C; + apdu.data = rbuf; + rbuf[0] = 0x3F; + rbuf[1] = 0x00; + apdu.datalen = 2; + apdu.lc = 2; + apdu.resp = NULL; + apdu.resplen = 0; + apdu.le = 0; + reader->ops->transmit(reader, &apdu); + } } else { if (capabilities & SC_READER_CAP_PIN_PAD && !(reader->capabilities & SC_READER_CAP_PIN_PAD)) {