From b4ebc4882b3acbcf1e197f44a7f133aba1c55ca0 Mon Sep 17 00:00:00 2001 From: Frank Morgner Date: Tue, 7 Apr 2015 16:51:19 +0200 Subject: [PATCH] moved sm_stop() to OpenSC as sc_sm_stop() --- npa/configure.ac | 4 ++-- npa/src/card-npa.c | 5 +++-- npa/src/example.c | 3 ++- npa/src/iso-sm.c | 19 ------------------- npa/src/npa-tool.c | 3 ++- npa/src/npa/iso-sm.h | 12 ------------ npa/src/opensc | 2 +- 7 files changed, 10 insertions(+), 38 deletions(-) diff --git a/npa/configure.ac b/npa/configure.ac index d850523..0fc0c2d 100644 --- a/npa/configure.ac +++ b/npa/configure.ac @@ -57,8 +57,8 @@ LIBS="$LDFLAGS $OPENSC_LIBS" AC_CHECK_HEADERS([libopensc/opensc.h libopensc/sm.h libopensc/pace.h], [], [AC_MSG_ERROR([OpenSC headers not found])]) -AC_MSG_CHECKING([for iasecc_sm_external_authentication]) -AC_TRY_LINK_FUNC(iasecc_sm_external_authentication, +AC_MSG_CHECKING([for sc_sm_stop]) +AC_TRY_LINK_FUNC(sc_sm_stop, [ AC_MSG_RESULT([yes]) ], [ AC_MSG_ERROR([Cannot link against libopensc with SM]) ]) AC_CHECK_FUNCS([sc_apdu_get_octets _sc_match_atr list_iterator_next]) diff --git a/npa/src/card-npa.c b/npa/src/card-npa.c index be917e3..b2cd0c8 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 "libopensc/sm.h" #include "card-npa.h" #include #include @@ -377,7 +378,7 @@ err: static int npa_finish(sc_card_t * card) { - sm_stop(card); + sc_sm_stop(card); npa_drv_data_free(card->drv_data); card->drv_data = NULL; EAC_cleanup(); @@ -655,7 +656,7 @@ static int npa_logout(sc_card_t *card) { struct sc_apdu apdu; - sm_stop(card); + sc_sm_stop(card); if (card->reader->capabilities & SC_READER_CAP_PACE_GENERIC) { /* If PACE is done between reader and card, SM is transparent to us as diff --git a/npa/src/example.c b/npa/src/example.c index 7c7f266..475e26e 100644 --- a/npa/src/example.c +++ b/npa/src/example.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include #include #include #include @@ -127,7 +128,7 @@ err: if (pace_output.id_pcd) free(pace_output.id_pcd); - sm_stop(card); + sc_sm_stop(card); sc_reset(card, 1); sc_disconnect_card(card); sc_release_context(ctx); diff --git a/npa/src/iso-sm.c b/npa/src/iso-sm.c index f153ba2..3f47cb2 100644 --- a/npa/src/iso-sm.c +++ b/npa/src/iso-sm.c @@ -720,20 +720,6 @@ int iso_sm_start(struct sc_card *card, struct iso_sm_ctx *sctx) return SC_SUCCESS; } -int sm_stop(struct sc_card *card) -{ - int r = SC_SUCCESS; - - if (card) { - if (card->sm_ctx.sm_mode == SM_MODE_TRANSMIT - && card->sm_ctx.ops.close) - r = card->sm_ctx.ops.close(card); - card->sm_ctx.sm_mode = SM_MODE_NONE; - } - - return r; -} - #else int iso_sm_close(struct sc_card *card) @@ -760,9 +746,4 @@ int iso_sm_start(struct sc_card *card, struct iso_sm_ctx *sctx) return SC_ERROR_NOT_SUPPORTED; } -int sm_stop(struct sc_card *card) -{ - return SC_ERROR_NOT_SUPPORTED; -} - #endif diff --git a/npa/src/npa-tool.c b/npa/src/npa-tool.c index 25b9fe7..9c0e756 100644 --- a/npa/src/npa-tool.c +++ b/npa/src/npa-tool.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -790,7 +791,7 @@ err: if (templates) ASN1_AUXILIARY_DATA_free(templates); - sm_stop(card); + sc_sm_stop(card); sc_reset(card, 1); sc_disconnect_card(card); sc_release_context(ctx); diff --git a/npa/src/npa/iso-sm.h b/npa/src/npa/iso-sm.h index 8c4a90f..60b10a9 100644 --- a/npa/src/npa/iso-sm.h +++ b/npa/src/npa/iso-sm.h @@ -118,18 +118,6 @@ struct iso_sm_ctx *iso_sm_ctx_create(void); */ int iso_sm_start(struct sc_card *card, struct iso_sm_ctx *sctx); -/** - * @brief Stops SM and frees allocated ressources. - * - * Calls \a card->sm_ctx.ops.close() if available and \c card->sm_ctx.sm_mode - * is \c SM_MODE_TRANSMIT - * - * @param[in] card - * - * @return \c SC_SUCCESS or error code if an error occurred - */ -int sm_stop(struct sc_card *card); - #ifdef __cplusplus } #endif diff --git a/npa/src/opensc b/npa/src/opensc index 88ec461..8ea328f 160000 --- a/npa/src/opensc +++ b/npa/src/opensc @@ -1 +1 @@ -Subproject commit 88ec461bc5b6041e0417df569de74875253f05d3 +Subproject commit 8ea328ff7fb311e582f312fe4f145c1af0d52390