libopensc: SM: not all the APDUs need to be wrapped

For some cards some APDUs are always transmitted in a plain mode,
even if SM session is opened.
For these APDUs the 'get_sm_apdu' card's handler returns SUCCESS without wrapped APDU version.
In such cases 'transmit' is called for the plain APDU.
This commit is contained in:
Viktor Tarasov 2012-06-19 18:04:37 +02:00
parent 68e217ceee
commit 0914b1eca7
1 changed files with 8 additions and 2 deletions

View File

@ -475,8 +475,12 @@ 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)
LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "cannot get SM APDU");
if (!sm_apdu) {
/* 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);
LOG_FUNC_RETURN(ctx, rv);
}
/* check if SM APDU is still valid */
rv = sc_check_apdu(card, sm_apdu);
@ -507,6 +511,8 @@ sc_single_transmit(struct sc_card *card, struct sc_apdu *apdu)
if (card->reader->ops->transmit == NULL)
LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "cannot transmit APDU");
sc_log(ctx, "CLA:%X, INS:%X, P1:%X, P2:%X, data(%i) %p",
apdu->cla, apdu->ins, apdu->p1, apdu->p2, apdu->datalen, apdu->data);
#ifdef ENABLE_SM
if (card->sm_ctx.sm_mode == SM_MODE_TRANSMIT)
return sc_single_sm_transmit(card, apdu);