From 993ded3f9d2b056044b083b75567f9c8896e3fb0 Mon Sep 17 00:00:00 2001 From: Arron Wang Date: Wed, 21 May 2014 01:09:39 +0200 Subject: ace: Add length option for get refresh tag operation In command INS_GET_GP_DATA, when try to get the refresh tag value, the return value is not null, then we need to set the resp_lenght to 0. Also the response value for get refresh tag operation is (tag, length, value), we missed the length option in current code. --- se/ace.c | 9 ++++++--- se/apdu.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/se/ace.c b/se/ace.c index 523cbb6..8033029 100644 --- a/se/ace.c +++ b/se/ace.c @@ -54,6 +54,7 @@ uint8_t gp_aid[] = {0xA0, 0x00, 0x00, 0x01, #define APDU_STATUS_LEN 2 #define GET_ALL_DATA_CMD_LEN 2 #define GET_REFRESH_DATA_CMD_LEN 2 +#define GET_REFRESH_DATA_TAG_LEN 1 #define GET_REFRESH_TAG_LEN 8 /* if ((APDU_header & rule->mask) == rule->header) then APDU is allowed */ @@ -551,10 +552,11 @@ static void get_refresh_gp_data_cb(void *context, if (err) return; - if (apdu_length != GET_REFRESH_DATA_CMD_LEN + GET_REFRESH_TAG_LEN + APDU_STATUS_LEN) + if (apdu_length != GET_REFRESH_DATA_CMD_LEN + GET_REFRESH_DATA_TAG_LEN + + GET_REFRESH_TAG_LEN + APDU_STATUS_LEN) return; - if (apdu[0] != 0xDF || apdu[1] != 0x20) + if (apdu[0] != 0xDF || apdu[1] != 0x20 || apdu[2] != 0x08) return; ace = g_try_malloc0(sizeof(struct seel_ace)); @@ -563,7 +565,8 @@ static void get_refresh_gp_data_cb(void *context, ace->se = se; - memcpy(ace->rules_tag, apdu + GET_REFRESH_DATA_CMD_LEN, GET_REFRESH_TAG_LEN); + memcpy(ace->rules_tag, apdu + GET_REFRESH_DATA_CMD_LEN + + GET_REFRESH_DATA_TAG_LEN, GET_REFRESH_TAG_LEN); get_all_gp_data = __seel_apdu_get_all_gp_data(); if (!get_all_gp_data) diff --git a/se/apdu.c b/se/apdu.c index a5f037f..0436e7e 100644 --- a/se/apdu.c +++ b/se/apdu.c @@ -229,7 +229,7 @@ struct seel_apdu *__seel_apdu_get_refresh_gp_data(void) DBG(""); return alloc_apdu(CLA_PROPRIETARY_CMD, 0, INS_GET_GP_DATA, - 0xDF, 0x20, 0, NULL, -1); + 0xDF, 0x20, 0, NULL, 0xB); } static int apdu_trailer_status(struct iso7816_apdu_resp *trailer) -- cgit v1.2.3