libopensc: parse EF.ATR: redefine 'STATUS' macros ...
thanks to Andre Zepezauer for his precious remarks git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5083 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
56c05c6a6a
commit
772ab4cefb
|
@ -38,8 +38,16 @@ sc_parse_ef_atr_content(struct sc_card *card, unsigned char *buf, size_t buflen)
|
|||
const unsigned char *tag = NULL;
|
||||
size_t taglen;
|
||||
struct sc_ef_atr ef_atr;
|
||||
unsigned char category = *buf;
|
||||
|
||||
LOG_FUNC_CALLED(ctx);
|
||||
|
||||
category = *buf;
|
||||
|
||||
/* IAS/ECC specific: skip second 'zero' byte */
|
||||
if (*(++buf) == 0x00)
|
||||
++buf;
|
||||
|
||||
tag = sc_asn1_find_tag(ctx, buf, buflen, ISO7816_TAG_II_CARD_SERVICE, &taglen);
|
||||
if (tag && taglen >= 1) {
|
||||
ef_atr.card_service = *tag;
|
||||
|
@ -74,6 +82,7 @@ sc_parse_ef_atr_content(struct sc_card *card, unsigned char *buf, size_t buflen)
|
|||
sc_log(ctx, "EF.ATR: AID '%s'", sc_dump_hex(ef_atr.aid.value, ef_atr.aid.len));
|
||||
}
|
||||
|
||||
/* IAS/ECC specific issuer data: contains the max send/recv buffer sizes in plain and SM modes */
|
||||
tag = sc_asn1_find_tag(ctx, buf, buflen, IASECC_TAG_II_IO_BUFFER_SIZES, &taglen);
|
||||
if (tag) {
|
||||
size_t len = taglen > sizeof(ef_atr.issuer_data) ? sizeof(ef_atr.issuer_data) : taglen;
|
||||
|
@ -90,11 +99,13 @@ sc_parse_ef_atr_content(struct sc_card *card, unsigned char *buf, size_t buflen)
|
|||
memcpy(ef_atr.allocation_oid.value, tag, taglen);
|
||||
}
|
||||
|
||||
tag = sc_asn1_find_tag(ctx, buf, buflen, ISO7816_TAG_II_STATUS, &taglen);
|
||||
if (category == ISO7816_II_CATEGORY_TLV) {
|
||||
tag = sc_asn1_find_tag(ctx, buf, buflen, ISO7816_TAG_II_STATUS_SW, &taglen);
|
||||
if (tag && taglen == 2) {
|
||||
ef_atr.status = *(tag + 0) * 0x100 + *(tag + 1);
|
||||
sc_log(ctx, "EF.ATR: status word 0x%X", ef_atr.status);
|
||||
}
|
||||
}
|
||||
|
||||
if (!card->ef_atr)
|
||||
card->ef_atr = calloc(1, sizeof(struct sc_ef_atr));
|
||||
|
|
|
@ -21,6 +21,9 @@ extern "C" {
|
|||
#define ISO7816_TAG_FCP_ACLS 0x86
|
||||
|
||||
/* ISO7816 interindustry data tags */
|
||||
#define ISO7816_II_CATEGORY_TLV 0x80
|
||||
#define ISO7816_II_CATEGORY_NOT_TLV 0x00
|
||||
|
||||
#define ISO7816_TAG_II_CARD_SERVICE 0x43
|
||||
#define ISO7816_TAG_II_INITIAL_ACCESS_DATA 0x44
|
||||
#define ISO7816_TAG_II_CARD_ISSUER_DATA 0x45
|
||||
|
@ -28,7 +31,9 @@ extern "C" {
|
|||
#define ISO7816_TAG_II_CARD_CAPABILITIES 0x47
|
||||
#define ISO7816_TAG_II_AID 0x4F
|
||||
#define ISO7816_TAG_II_ALLOCATION_SCHEME 0x78
|
||||
#define ISO7816_TAG_II_STATUS 0x82
|
||||
#define ISO7816_TAG_II_STATUS_LCS 0x81
|
||||
#define ISO7816_TAG_II_STATUS_SW 0x82
|
||||
#define ISO7816_TAG_II_STATUS_LCS_SW 0x83
|
||||
|
||||
/* Other interindustry data tags */
|
||||
#define IASECC_TAG_II_IO_BUFFER_SIZES 0xE0
|
||||
|
|
Loading…
Reference in New Issue