Application Protocol Data Unit i.e. APDU is a communication Protocol between the smart card and smart card reader.
APDU can be divided into two subcategories -
The structure of command and response of APDU defined in ISO 7816-4
Command APDU will contain 4 mandatory bytes in it, those are CLS, INS, P1 and P2
CLASS - CLS - APDU Class - denotes type of command. This can be standard or proprietary.
INSTRUCTION - INS - Instruction Code - denotes specific command, e.g. Update Data, Delete Data etc.
P1 - P2 - Indicates parameters (offsets) for data to be written or updated.
Lc - Indicates length of data passed.
DATA - Will contain actual data, of length specified by Lc.
Response APDU will at least contain 2 bytes
SW1 - Status Word first byte
SW2 - Status Word second byte
Based on SW1 and SW2, card reader will come to know, if given Command APDU is executed on Card successfully or not, and if not what is error.
In notmal scenario, Status word for Success is 90 00.
APDU can be divided into two subcategories -
- Command APDU
After receiving such APDU on smart card, it will be executed on smart card based on implementation and command sent.
- Response APDU
The structure of command and response of APDU defined in ISO 7816-4
Command APDU will contain 4 mandatory bytes in it, those are CLS, INS, P1 and P2
CLASS - CLS - APDU Class - denotes type of command. This can be standard or proprietary.
INSTRUCTION - INS - Instruction Code - denotes specific command, e.g. Update Data, Delete Data etc.
P1 - P2 - Indicates parameters (offsets) for data to be written or updated.
Lc - Indicates length of data passed.
DATA - Will contain actual data, of length specified by Lc.
Response APDU will at least contain 2 bytes
SW1 - Status Word first byte
SW2 - Status Word second byte
Based on SW1 and SW2, card reader will come to know, if given Command APDU is executed on Card successfully or not, and if not what is error.
In notmal scenario, Status word for Success is 90 00.
No comments:
Post a Comment