diff --git a/npa/src/boxing.c b/npa/src/boxing.c index b901c80..3c7eb9c 100644 --- a/npa/src/boxing.c +++ b/npa/src/boxing.c @@ -46,11 +46,6 @@ #include "libopensc/apdu.c" #endif -#ifndef HAVE_LIST_ITERATOR_NEXT -#include "opensc/src/common/simclist.c" -#endif - - static const u8 boxing_cla = 0xff; static const u8 boxing_ins = 0x9a; static const u8 boxing_p1 = 0x04; @@ -737,6 +732,11 @@ void sc_detect_boxing_cmds(sc_reader_t *reader) } #ifndef DISABLE_GLOBAL_BOXING_INITIALIZATION + +#ifndef HAVE_LIST_ITERATOR_NEXT +#include "opensc/src/common/simclist.c" +#endif + void sc_initialize_boxing_cmds(sc_context_t *ctx) { sc_reader_t *reader; diff --git a/npa/src/card-npa.c b/npa/src/card-npa.c index f699f6a..112eba8 100644 --- a/npa/src/card-npa.c +++ b/npa/src/card-npa.c @@ -21,6 +21,7 @@ #include "iso-sm-internal.h" #include "libopensc/internal.h" #include "libopensc/pace.h" +#include #include #include @@ -61,6 +62,10 @@ static int npa_init(sc_card_t * card) card->drv_data = NULL; card->caps |= SC_CARD_CAP_APDU_EXT | SC_CARD_CAP_RNG; +#ifdef DISABLE_GLOBAL_BOXING_INITIALIZATION + sc_detect_boxing_cmds(card->reader); +#endif + return SC_SUCCESS; } diff --git a/npa/src/npa-tool.c b/npa/src/npa-tool.c index 7fe0187..948b094 100644 --- a/npa/src/npa-tool.c +++ b/npa/src/npa-tool.c @@ -370,7 +370,9 @@ main (int argc, char **argv) exit(1); } -#ifndef DISABLE_GLOBAL_BOXING_INITIALIZATION +#ifdef DISABLE_GLOBAL_BOXING_INITIALIZATION + sc_detect_boxing_cmds(card->reader); +#else sc_initialize_boxing_cmds(ctx); #endif diff --git a/npa/src/npa.c b/npa/src/npa.c index 1f9e5fa..46a3c92 100644 --- a/npa/src/npa.c +++ b/npa/src/npa.c @@ -1206,10 +1206,6 @@ int perform_pace(sc_card_t *card, } } -#ifdef DISABLE_GLOBAL_BOXING_INITIALIZATION - sc_detect_boxing_cmds(card->reader); -#endif - if (card->reader->capabilities & SC_READER_CAP_PACE_GENERIC && card->reader->ops->perform_pace) { r = card->reader->ops->perform_pace(card->reader, &pace_input, pace_output); diff --git a/npa/src/npa/boxing.h b/npa/src/npa/boxing.h index 5070223..20108a2 100644 --- a/npa/src/npa/boxing.h +++ b/npa/src/npa/boxing.h @@ -30,9 +30,11 @@ extern "C" { #define DISABLE_GLOBAL_BOXING_INITIALIZATION #ifndef DISABLE_GLOBAL_BOXING_INITIALIZATION - /** initialize boxing for all available readers */ - /* currently disabled, because the OpenSC PC/SC reader implementation - * allows a transmit only when a card is connected. */ + /** initialize boxing for all available readers once on the application + * layer */ + /* The OpenSC PC/SC reader implementation allows a transmit only when a + * card is connected. So testing for boxing commands will yield an error + * then. */ void sc_initialize_boxing_cmds(sc_context_t *ctx); #else void sc_detect_boxing_cmds(sc_reader_t *reader);