Вы находитесь на странице: 1из 5

COMMAND APDU CONTENTS:

CLA INS P1 P2 [LC FIELD] [DATA FIELD] [LE FIELD]

COMMAND NAME LENGTH DESCRIPTION


CLA Class 1 Class of instruction
INS Instruction 1 Instruction code
P1 Parameter 1 1 Instruction P1
P2 Parameter 2 1 Instruction P2
LC FIELD Length Variable= Number of BYTES in data field of command
1 or 3
DATA FIELD Data LC String of BYTES sent in the data field of the
command
LE FIELD Length Variable Maximum number of Bytes excepted in the data
<=3 field of response to the command

RESPONSE APDU:

BODY TRAILER
[DATA FIELD] SW1 SW2

COMMAND NAME LENGTH DESCRIPTION


DATA FIELD Data =lr String of bytes received in the data field
of the response
SW1 Status byte 1 Command processing status
SW2 Status byte 1 Command processing
status
EXECUTION PROCESS:

Command in string format

Parse the string into command message APDU

Check the INS value and execute the command accordingly

Set the status word (SW1,SW2) in response message APDU

FILE OPRETIONS:

(I) Create file (DF/EF):

Command APDU

CLA INS P1 P2 LC DATA LE


0 E0 - 0 - - 0

P1 is 00 for DF
P1 is 01 for EF
Data contains the file identifier

Errors Handled
SW1 SW2 DESCRIPTION
6A 84 Not enough memory space
6A 89 File already exists
6A 8A DF name already existd

(II) Select a specified file (DF/EF):

Command APDU
CLA INS P1 P2 LC DATA LE
0 A4 - 0 - - 0
P1 is 08 to consider the path given in data field is from MF complete path
P1 is 09 to consider the path given in data field is from currently selected directory
Data contains the path of the file

Errors Handled
SW1 SW2 DESCRIPTION
6A 82 File not found
6A 86 Incorrect parameter P1-P2

(III)Write data to the Elementary file:

Command APDU
CLA INS P1 P2 LC DATA LE
0 D0 0 - - - 0

P2 offset in the file from where we need to write the data into the file.
data contains actual data to be stored.

Errors Handled
SW1 SW2 DESCRIPTION
65 81 Memory status failure
69 86 Command not allowed (no current EF)
6B 0 Wrong parameters/offset outside EF

(IV)Read data from the elementary file:

Command APDU
CLA INS P1 P2 LC DATA LE
0 B0 0 - 0 Nothing -

P2 is offset in the file where we need to read the data from the file
Le is the length of the data field excepted in the response message command

Errors Handled
SW1 SW2 DESCRIPTION
62 82 End of file reached before reading Le Byte
67 0 Wrong field
69 86 Command not allowed (no current EF)
6B 0 Wrong parameters/offset outside the EF
6A 86 Incorrect parameters P1-P2
(V)Update data in the elementary file(update-BINARY):

Command APDU
CLA INS P1 P2 LC DATA LE
0 6 0 - - - 0

Errors Handled
SW1 SW2 DESCRIPTION
65 81 Memory status failure
69 86 Command not allowed (no current EF)
6B 0 Wrong parameters/offset outside the EF

(VI)Erase data in the EF:

Command APDU
CLA INS P1 P2 LC DATA LE
0 0E 0 - 0 nothing 0

P2 is the offset in the file from where we need to erase the data

Errors Handled
SW1 SW2 DESCRIPTION
65 81 Memory status failure
69 86 Command not allowed(no current EF)
6B 0 Wrong parameters/offset outside the EF

(VII)Delete file (DF/EF):

Command APDU
CLA INS P1 P2 LC DATA LE
0 E4 - 0 0 Nothing 0

P1 value is 00 to delete DF and 01 to delete EF.


It deletes the currently selected EF/DF.

Errors Handled
SW1 SW2 DESCRIPTION
6A 82 File not found
6A 86 Incorrect parameters p1-p2
69 86 Command not allowed (no current EF/DF)

Вам также может понравиться