diff --git a/src/libopensc/apdu.c b/src/libopensc/apdu.c index 2c5c0908..18ee135b 100644 --- a/src/libopensc/apdu.c +++ b/src/libopensc/apdu.c @@ -475,7 +475,7 @@ sc_single_sm_transmit(struct sc_card *card, struct sc_apdu *apdu) rv = card->sm_ctx.ops.get_sm_apdu(card, apdu, &sm_apdu); LOG_TEST_RET(ctx, rv, "get SM APDU error"); - if (!sm_apdu) { + if (rv == SC_ERROR_SM_NOT_APPLIED) { /* SM wrap of this APDU is ignored by card driver. * Send plain APDU to the reader driver */ rv = card->reader->ops->transmit(card->reader, apdu); diff --git a/src/libopensc/card-authentic.c b/src/libopensc/card-authentic.c index 20f0a1ee..54bf7dd5 100644 --- a/src/libopensc/card-authentic.c +++ b/src/libopensc/card-authentic.c @@ -2319,7 +2319,7 @@ authentic_sm_get_wrapped_apdu(struct sc_card *card, struct sc_apdu *plain, struc || (plain->cla==0x80 && plain->ins==0x50) ) { sc_log(ctx, "SM wrap is not applied for this APDU"); - LOG_FUNC_RETURN(ctx, SC_SUCCESS); + LOG_FUNC_RETURN(ctx, SC_ERROR_SM_NOT_APPLIED); } if (card->sm_ctx.sm_mode != SM_MODE_TRANSMIT) diff --git a/src/libopensc/errors.h b/src/libopensc/errors.h index 905ee845..8e5e62a0 100644 --- a/src/libopensc/errors.h +++ b/src/libopensc/errors.h @@ -119,6 +119,7 @@ extern "C" { #define SC_ERROR_SM_RAND_FAILED -1607 #define SC_ERROR_SM_KEYSET_NOT_FOUND -1608 #define SC_ERROR_SM_IFD_DATA_MISSING -1609 +#define SC_ERROR_SM_NOT_APPLIED -1610 /* Errors that do not fit the categories above */