Hi, On 20 April 2010 22:21, Denis Kenzior <[email protected]> wrote: >> Rereading the etsi ts102.221 the "Le" field in the Envelope APDU >> (11.2.2.2) is not explictly defined "not present", instead it says >> "empty or maximum length of expected data". It doesn't say what the >> default value is when empty so I conclude it's safer to have the field >> present or the card may think it's not allowed to send any response at >> all -- depending on the implementer's interpretation of the spec. >> >> 10.1.6 says the field is the maximum respose length expected, but then >> some commands suggest it should be the exact length wanted and some >> make the field obligatory. > > So I re-read that part of the spec, and I can see why we might want it. > However, this quote seemed rather interesting: "Le set to '00' indicates that > the terminal expects to receive at most the maximum number of bytes, i.e. 256, > in the response ADPU. The UICC may return any number of bytes in the range 1 > to 256." > > Shouldn't that 'FF' be changed to '00'? Also, you might want to include the > relevant passage or Spec/Section reference in this code so we don't wonder > where it came from in the future.
Attached patch adds a comment and changes the FF to 00. I guess it is largely theoretical right now. The issue again with "any number of bytes in the range 1 to 256" is that this prohibits an empty response, which we want to allow too :) Maybe this should be a parameter of driver->envelope() Best regards
From 78cd3b4882647a6c42f53572de1423d11464e342 Mon Sep 17 00:00:00 2001 From: Andrzej Zaborowski <[email protected]> Date: Tue, 20 Apr 2010 09:43:40 +0200 Subject: Comment on the Le field in ENVELOPE apdu. --- drivers/atmodem/stk.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/drivers/atmodem/stk.c b/drivers/atmodem/stk.c index 8cff4a2..cc02a8e 100644 --- a/drivers/atmodem/stk.c +++ b/drivers/atmodem/stk.c @@ -107,7 +107,19 @@ static void at_stk_envelope(struct ofono_stk *stk, int length, for (; length; length--) len += sprintf(buf + len, "%02hhX", *command++); - len += sprintf(buf + len, "FF"); + /* We append the "Le" field. ETSI ts102.221 is not very clear + * on whether it's mandatory, so stay on the safe side. + * Relevant sections: + * 10.1.6 defines "Le" as optional, doesn't say whether absence + * means no answer is wanted or only that it can have any + * length. If present the response data should consist of Le bytes. + * Then suggests "00" allows any length between 1 and 256 bytes. + * 11.2.2.2 says "Le" can be "empty" but again doesn't say what + * value is assumed in this case. If not "empty" the response + * should consist of Le or fewer bytes. This suggests we should + * use "FF" as the value. + */ + len += sprintf(buf + len, "00"); ret = g_at_chat_send(sd->chat, buf, csim_prefix, at_csim_envelope_cb, cbd, g_free); -- 1.6.1
_______________________________________________ ofono mailing list [email protected] http://lists.ofono.org/listinfo/ofono
