Our Online Store have the new products: RFID antenna board. Currently it can work with JC10M24R and JCOP4 card chips.
Compared with normal cards, the antenna board module has a smaller size and fixed holes, which is easy to integrate in the IOT(Internet Of Things) project.

T0 Parsing

JavaCard Applet Development Related Questions and Answers.
User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

T0 Parsing

Post by mabel » Thu Jul 26, 2018 1:12 am

Just want to write something about T0, welcome any comments.

1. Introduction to JavaCard power-on process
The following figure shows the data captured during the JavaCard power-on process. It sent 3B firstly, then ATR value.
After the JavaCard is powered on, it will be converted to each other in various states. The following figure shows the conversion relationship of JavaCard various states.
2. Introduction to ATR
ATR consists of 5 parts:
|TS|T0|interface character|historical character|check character|
TS: initial character.
T0: format byte.
TS
TS defines whether convention is forward or reverse. Usually it uses 3B,3B is HHL HHH LL as shown above.

T0
Indicates whether the interface byte exists and the number of history byte

Interface byte
Communications parameters

historical byte
Smart card operating feature

check character

Example: 3B 61 00 00 80
HHLH HHLL 0110 0001 0000 0000 0000 0000 1000 0000
3B H = 1,Transfer the low bit firstly
T0 TB1、TC1 exsit,one historical bit.
TB1 Abandon
TC1 Extra guard time integer N=0。
historical character 80
When T0 is only supported, the check character cannot be added.
Please refer to 7816-3 to know more about T0.
You do not have the required permissions to view the files attached to this post. Please login first.

User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: T0 Parsing

Post by mabel » Thu Jul 26, 2018 2:00 am

3. Introduction to PPS
PPS consists of 4 parts:

|PPSS|PPS0|PPS1,PPS2,PPS3|PCK|

PPSS: 0xFF
PPS0(format byte): indicate whether the following PPSx exists and specify the protocol type
PPS1 PPS2 PPS3: Communications parameters and so on
PCK: check character

4. Basic concept in T0

Character frame in T0
T0 is a character transfer protocol. Each frame of it is a character, the following figure shows how a character looks like in transmission

Basic time unit etu
1 etu = (Fi/Di) * (1/f)

GT : Minimum time interval between two consecutive characters in the same direction
GT = 12etu + R*(N/f)
N:Extra guard time integer, defined by TC1. The default is 0.

WT:The maximum time interval between the characters sent by card and the characters sent by the previous one (card or card reader)
WT = WI*960*(Fi/f)
WI:It’s TC2 when TC2 exists. When TC2 does not exist, the default value is 10.


To be continued...
You do not have the required permissions to view the files attached to this post. Please login first.

User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: T0 Parsing

Post by mabel » Wed Aug 08, 2018 1:22 am

5. Basic principles of T0 protocol

(1) The communication protocol is opened after PPS is completed.
(2) The interface device sends a 5-byte command header to the card
(3) The card sends process byte.
(4) Transfer data in one direction under the control of the process byte
Note: Under T0 protocol, both reader and card know the transmission direction and length of data in advance.
There are 3 kinds of process bytes.
You do not have the required permissions to view the files attached to this post. Please login first.

User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: T0 Parsing

Post by mabel » Wed Aug 08, 2018 1:27 am

6. APDU formats

There are 4 kinds of APDU formats
Case1: CLA INS P1 P2
Case2: CLA INS P1 P2 Le
Case3: CLA INS P1 P2 Lc Data
Case4: CLA INS P1 P2 Lc Data Le

Case1
TPDU:CLA INS P1 P2 00
CLA INS P1 P2 00 <- Smart Card Reader
Card-> SW1 SW2

java code:
Case (byte)0x11:
break;
You do not have the required permissions to view the files attached to this post. Please login first.

User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: T0 Parsing

Post by mabel » Wed Aug 08, 2018 1:41 am

Case2S

TPDU: CLA INS P1 P2 Le
(1)Le is in line with expectation.
CLA INS P1 P2 Le <- Smart Card Reader
Card-> DATA SW1 SW2
(2)Le does not meet expectations and does not prompt for data length as well.
CLA INS P1 P2 Le <- Smart Card Reader
Card -> 67 00
(3)Le does not meet expectations, but prompts for data length.
CLA INS P1 P2 Le <- Smart Card Reader
Card -> 6C SW2
CLA INS P1 P2 SW2 <- Smart Card Reader
Card -> DATA SW1 SW2
(4)SW=9XYZ,且SW != 9000
CLA INS P1 P2 Le <- Smart Card Reader
Card -> DATA 9XYZ

Java code:
case (byte)0x20:
le = (short)(buf[ISO7816.OFFSET_LC]);
if (le != 0x6)
{
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
}
for(i = 1; i <= 6; i++)
{
buf[(short)(i - 1)] = (byte)i;
}
apdu.setOutgoingAndSend((short)0, (short)6);
break;

When Case2S Le is in line with expectation:
You do not have the required permissions to view the files attached to this post. Please login first.

User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: T0 Parsing

Post by mabel » Wed Aug 08, 2018 1:42 am

When Case2S Le doesn’t meet the expectation:
You do not have the required permissions to view the files attached to this post. Please login first.

User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: T0 Parsing

Post by mabel » Wed Aug 08, 2018 1:45 am

Another example of Case2S:
Java code:
case (byte)0x21:
for(i = 1; i <= 6; i++)
{
buf[(short)(i - 1)] = (byte)i;
}
apdu.setOutgoingAndSend((short)0, (short)6);
break;
When needing 6C00:
You do not have the required permissions to view the files attached to this post. Please login first.

User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: T0 Parsing

Post by mabel » Wed Aug 08, 2018 1:49 am

Case 3S

TPDU: CLA INS P1 P2 Lc
CLA INS P1 P2 Lc <- Smart Card Reader
Card-> SW1 SW2
java code:
case (byte)0x30:
le = apdu.setIncomingAndReceive();
break;
You do not have the required permissions to view the files attached to this post. Please login first.
Last edited by mabel on Wed Aug 08, 2018 1:57 am, edited 2 times in total.

User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: T0 Parsing

Post by mabel » Wed Aug 08, 2018 1:52 am

Case 4S
TPDU: CLA INS P1 P2 Lc DATA Le
(1)SW1=6X, and SW1̸=61,62,63
CLA INS P1 P2 Lc <- Smart Card Reader
Card-> 6X SW2
(2)61XX
CLA INS P1 P2 Lc <- Smart Card Reader
Card -> INS
DATA <- Smart Card Reader
Card -> 61 Nx
CLA C0 P1 P2 P3=min(Le, Nx) <- Smart Card Reader
Card -> DATA SW1 SW2

java code:
case (byte)0x41:
le = apdu.setIncomingAndReceive();
for(i = 1; i <= 6; i++)
{
buf[(short)(i - 1)] = (byte)i;
}
apdu.setOutgoingAndSend((short)0, (short)6);
break;
You do not have the required permissions to view the files attached to this post. Please login first.

DaHuFa
Posts: 53
Joined: Mon Jun 04, 2018 5:07 am
Points :392
Contact:

Re: T0 Parsing

Post by DaHuFa » Tue Aug 14, 2018 4:16 am

I expect learn more~
For example, T1 and contactless and so on. :lol:

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 44 guests

JavaCard OS : Disclaimer