parse Extended Length Information in EF.ATR/INFO

This commit is contained in:
Frank Morgner 2016-06-27 18:03:51 +02:00 committed by Viktor Tarasov
parent 9a325fc1db
commit 2909ba28a9
3 changed files with 23 additions and 1 deletions

View File

@ -31,7 +31,7 @@
#include "asn1.h"
#include "iso7816.h"
static int
static int
sc_parse_ef_atr_content(struct sc_card *card, unsigned char *buf, size_t buflen)
{
struct sc_context *ctx = card->ctx;
@ -68,6 +68,21 @@ sc_parse_ef_atr_content(struct sc_card *card, unsigned char *buf, size_t buflen)
ef_atr.df_selection, ef_atr.unit_size, ef_atr.card_capabilities);
}
if (ef_atr.card_capabilities & ISO7816_CAP_EXTENDED_LENGTH_INFO) {
/* Extended Length Information in EF.ATR/INFO */
tag = sc_asn1_find_tag(ctx, buf, buflen, ISO7816_TAG_II_EXTENDED_LENGTH, &taglen);
if (tag && taglen >= 8) {
/* The command- and response-APDU size limitations are defined by
* two integers, each nested in a DO'02'.
* We skip parsing the nested DOs and jump directly to the numbers */
ef_atr.max_command_apdu = bebytes2ushort(tag + 2);
ef_atr.max_response_apdu = bebytes2ushort(tag + 6);
sc_log(ctx, "EF.ATR: Biggest command APDU %u bytes, response APDU %u",
(unsigned long) ef_atr.max_command_apdu,
(unsigned long) ef_atr.max_response_apdu);
}
}
tag = sc_asn1_find_tag(ctx, buf, buflen, ISO7816_TAG_II_AID, &taglen);
if (tag) {
if (taglen > sizeof(ef_atr.aid.value))

View File

@ -38,6 +38,11 @@ extern "C" {
#define ISO7816_TAG_II_STATUS_LCS 0x81
#define ISO7816_TAG_II_STATUS_SW 0x82
#define ISO7816_TAG_II_STATUS_LCS_SW 0x83
#define ISO7816_TAG_II_EXTENDED_LENGTH 0x7F66
#define ISO7816_CAP_CHAINING 0x80
#define ISO7816_CAP_EXTENDED_LENGTH 0x40
#define ISO7816_CAP_EXTENDED_LENGTH_INFO 0x20
/* Other interindustry data tags */
#define IASECC_TAG_II_IO_BUFFER_SIZES 0xE0

View File

@ -242,6 +242,8 @@ struct sc_ef_atr {
unsigned char df_selection;
size_t unit_size;
unsigned char card_capabilities;
size_t max_command_apdu;
size_t max_response_apdu;
struct sc_aid aid;