Hi all,
I am currently implementing one SC driver and I have run into a
problem with T=0 Case 2 command response length.

Standard says that this response can be :
1) 6C Luicc (i.e. 2 bytes); or
2) INS [Data(Luicc)] 90 00 (i.e. Luicc + 3 bytes)

There are other variations with "61" and "6C" PBs, but in any case it
turns out that for the same command [CLA INS P1 P2 P3=00],
response can vary in length and is not known in advance.

I can not read byte by byte and analyse it because :
1) It should be done in a transport layer, so I have to exit my driver
RX function
2) When I do this, there is a danger of RX FIFO overflow while I am in
transport layer processing,
because now driver is not popping bytes from RX FIFO (which is only 8
bytes). And if a card is sending long answer and
I exited my driver code to analyse first byte, havoc might happen.

As a result, before calling my drivers RX function I have to know in
advance how much bytes I have to receive,
and stay in my driver's RX function until I received this number of
bytes, while popping RX FIFO to some location in memory.


I have an impression that here :
http://www.opensc-project.org/openct/browser/trunk/src/ifd/proto-t0.c
in the code implemented by Olaf, byte by byte is analyzed.

My question is also how this is possible, because card is sending you
like a crazy, without stop.
Do you have some interrupt in your driver for each byte arrived to
remove it from your RX FIFO ?
That would be too much interruptions for me, I want as much bytes as
possible in the FIFO before interrupts arrive and tell me to pop it.


What is the best way to implement Case 2 response END detection :
1) To demand always 256 (maximum) length from UICC and have timeout
which will say : no more characters arriving, so it must be the end of
message.
2) To insert some kind of T=0 dependence in the driver itself
(datalink layer) which will take a look at every byte arriving (which
I did not want to do. I wanted to keep byte sending/receiving
transparent for the driver, and do analysis in the transport layer. I
do not want to pollute my driver with T=0 dependencies).
3) Something other that I am missing right now ?


BTW.
Luicc is defined like :

Luicc: exact length of data available in the UICC to be returned in
response to the case 2 or 4 Command received by
the UICC

Is it always not known by the terminal before issuing first Case 2
command, or there is a way to know this value in advance (I guess no,
and I guess it changes dynamically depending on the command and the
card state.)

BR,
Drasko
_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to