diff --git a/src/stkutil.c b/src/stkutil.c index 5b258ab6..a96132cc 100644 --- a/src/stkutil.c +++ b/src/stkutil.c @@ -771,6 +771,24 @@ static gboolean parse_dataobj_card_reader_status( return parse_dataobj_common_byte(iter, byte); } +/* Defined in TS 102.223 Section 8.34 */ +static gboolean parse_dataobj_card_atr( + struct comprehension_tlv_iter *iter, void *user) +{ + struct stk_card_atr *ca = user; + const unsigned char *data; + unsigned int len = comprehension_tlv_iter_get_length(iter); + + if ((len < 1) || (len > sizeof(ca->atr))) + return FALSE; + + data = comprehension_tlv_iter_get_data(iter); + ca->len = len; + memcpy(ca->atr, data, len); + + return TRUE; +} + /* Defined in 102.223 Section 8.43 */ static gboolean parse_dataobj_imm_resp(struct comprehension_tlv_iter *iter, void *user) @@ -877,6 +895,8 @@ static dataobj_handler handler_for_type(enum stk_data_object_type type) return parse_dataobj_item_icon_id_list; case STK_DATA_OBJECT_TYPE_CARD_READER_STATUS: return parse_dataobj_card_reader_status; + case STK_DATA_OBJECT_TYPE_CARD_ATR: + return parse_dataobj_card_atr; case STK_DATA_OBJECT_TYPE_IMMEDIATE_RESPONSE: return parse_dataobj_imm_resp; case STK_DATA_OBJECT_TYPE_TEXT_ATTRIBUTE: diff --git a/src/stkutil.h b/src/stkutil.h index 4ff8c4b0..8047ed11 100644 --- a/src/stkutil.h +++ b/src/stkutil.h @@ -459,6 +459,15 @@ struct stk_item_icon_id_list { unsigned int len; }; +/* + * According to 102.223 Section 8.34 the length of CTLV is 1 byte. This means + * that the maximum size is 127 according to the rules of CTLVs. + */ +struct stk_card_atr { + unsigned char atr[127]; + unsigned int len; +}; + /* * According to 102.223 Section 8.72 the length of text attribute CTLV is 1 * byte. This means that the maximum size is 127 according to the rules