From e4bee2861ecfae035ff5bf9a3a117e0952fdd71b Mon Sep 17 00:00:00 2001 From: frankmorgner Date: Sat, 25 Sep 2010 05:20:20 +0000 Subject: [PATCH] deactivate emulators sm context, when host sends sm protected apdus git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@279 96b47cad-a561-4643-ad3b-153ac7d7599c --- ccid/src/pace/sm.h | 2 +- ccid/src/sm.c | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ccid/src/pace/sm.h b/ccid/src/pace/sm.h index 80dc6a9..5d043e8 100644 --- a/ccid/src/pace/sm.h +++ b/ccid/src/pace/sm.h @@ -53,7 +53,7 @@ struct sm_ctx { sc_apdu_t *sm_apdu); }; -int sm_transmit_apdu(const struct sm_ctx *sctx, sc_card_t *card, +int sm_transmit_apdu(struct sm_ctx *sctx, sc_card_t *card, sc_apdu_t *apdu); #ifdef __cplusplus diff --git a/ccid/src/sm.c b/ccid/src/sm.c index 2f85233..2c2a65e 100644 --- a/ccid/src/sm.c +++ b/ccid/src/sm.c @@ -579,7 +579,7 @@ err: return r; } -int sm_transmit_apdu(const struct sm_ctx *sctx, sc_card_t *card, +int sm_transmit_apdu(struct sm_ctx *sctx, sc_card_t *card, sc_apdu_t *apdu) { sc_apdu_t sm_apdu; @@ -590,13 +590,14 @@ int sm_transmit_apdu(const struct sm_ctx *sctx, sc_card_t *card, sm_apdu.resp = rbuf; sm_apdu.resplen = sizeof rbuf; - if ((apdu->cla & 0x0C) == 0x0C) { - sc_debug(card->ctx, "Given APDU is already protected with some secure messaging."); + if (!sctx || !sctx->active) { + sc_debug(card->ctx, "Secure messaging disabled."); return sc_transmit_apdu(card, apdu); } - if (!sctx || !sctx->active) { - sc_debug(card->ctx, "Secure messaging disabled."); + if ((apdu->cla & 0x0C) == 0x0C) { + sc_debug(card->ctx, "Given APDU is already protected with some secure messaging. Deactivating own SM context."); + sctx->active = 0; return sc_transmit_apdu(card, apdu); }