bugfix: case 2 extended length apdu are now recognized

git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@267 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
frankmorgner
2010-09-16 10:08:07 +00:00
parent 74f45f03fe
commit 593c0ce77a

View File

@@ -103,6 +103,14 @@ int build_apdu(sc_context_t *ctx, const u8 *buf, size_t len, sc_apdu_t *apdu)
if (*p == 0 && len > 2) { if (*p == 0 && len > 2) {
/* ...must be an extended length APDU */ /* ...must be an extended length APDU */
p++; p++;
if (len == 3) {
apdu->le = (*p++)<<8;
apdu->le += *p++;
if (apdu->le == 0)
apdu->le = 0xffff;
len -= 3;
apdu->cse = SC_APDU_CASE_2_SHORT;
} else {
apdu->lc = (*p++)<<8; apdu->lc = (*p++)<<8;
apdu->lc += *p++; apdu->lc += *p++;
len -= 3; len -= 3;
@@ -133,6 +141,7 @@ int build_apdu(sc_context_t *ctx, const u8 *buf, size_t len, sc_apdu_t *apdu)
(unsigned long) len); (unsigned long) len);
return SC_ERROR_INVALID_DATA; return SC_ERROR_INVALID_DATA;
} }
}
} else { } else {
apdu->lc = *p++; apdu->lc = *p++;
len--; len--;
@@ -172,7 +181,9 @@ int build_apdu(sc_context_t *ctx, const u8 *buf, size_t len, sc_apdu_t *apdu)
apdu->flags = SC_APDU_FLAGS_NO_GET_RESP|SC_APDU_FLAGS_NO_RETRY_WL; apdu->flags = SC_APDU_FLAGS_NO_GET_RESP|SC_APDU_FLAGS_NO_RETRY_WL;
sc_debug(ctx, "APDU, %d bytes:\tins=%02x p1=%02x p2=%02x", sc_debug(ctx, "Case %d %s APDU, %u bytes:\tins=%02x p1=%02x p2=%02x",
apdu->cse & SC_APDU_SHORT_MASK,
(apdu->cse & SC_APDU_EXT) != 0 ? "extended" : "short",
(unsigned int) len0, apdu->ins, apdu->p1, apdu->p2); (unsigned int) len0, apdu->ins, apdu->p1, apdu->p2);
return SC_SUCCESS; return SC_SUCCESS;