Download Application Programming Notes, Java Card 3 Platform

Transcript
4.2
■
Case 4S. The legacy case 4. LC and LE are less than 256 bytes of data.
■
Case 4E. The extended version of Case 4. LC or LE are greater than 256 bytes of
data.
Extended APDU Format
To express extended length, the APDU format has changed. The table below
summarizes the format defined by ISO 7816-4:2005 for extended length APDU. Any
APDU classified as extended must follow this format.
TABLE 4-1
Extended APDU Format
Field
Description
Number of Bytes
Command Header
Class byte CLA
1
Command Header
Instruction byte INS
1
Command Header
Parameter bytes P1- P2
2
LC Field
Absent for Nc = 0. Present for Nc > 0
0, 1, or 3
Data Field
Absent if Nc = 0, present if Nc >0
Nc
LE Field
Absent for Ne = 0, present for Ne > 0
0, 1, 2 or 3
Response Data
Absent if Nr = 0, present if Nr >0
Nr (max. Ne)
Response Status
Status bytes SW1 SW2
2
NOTATION
Nc = command data length
Ne = expected response data length
Nr = actual response data length
The encoding rules are defined as:
For LC:
■
If LC field is absent, Nc = 0.
■
If LC is present as one byte with values between 01 and FF, then Nc = 1..255
accordingly, and it will be a short field.
■
If LC is present as an extended field, then it will be three bytes in length: byte one
will be 00, bytes two and three will contain a 16-bit value representing the length
of the data Nc with values between 1 and 65535.
For LE:
4-2
Application Programming Notes, Java Card 3 Platform, Classic Edition • July 2009