Pages

Tuesday, January 10, 2012

APDU Structure

When we are doing smartcard programming we should properly know the structure of the APDU.
APDUs has two categories, Command APDU and Response APDU (C-APDU and R-APDU)

Command APDU
Field
Length(byte)
Comment
CLA
1
indicates the type of command
INS
1
indicates the specific command Ex: Get Data
P1
1
Instruction parameter 1  for the command
P2
1
Instruction parameter 2  for the command
Lc
N
Number of bytes in the data field
Data
Nc
Contain the data
Le
N
The maximum number of bytes expected in the data field in the response APDU

Response APDU
Field
Length(byte)
Comment
Response Data
N
Response Data
SW1-SW2
2
Status of the command processing Ex: Success : 90 00

Example to select the applet.

C-APDU : 00 A4 04 00 08 A0 00 00 00 03 00 00 00
R-APDU : 6F 10 84 08 A0 00 00 00 03 00 00 00 A5 04 9F 65 01 FF 90 00

No comments:

Post a Comment