100% found this document useful (1 vote)
443 views

APDU Basic Commands

This document describes APDU commands and response codes used for smart card communication. It defines the fields and lengths of command and response APDUs including CLA, INS, P1-P2, Lc, Le, and command and response data. Examples are given of common commands like getting the card version, serial number, EEPROM size, selecting a file, reading and writing binary data, and reading and writing records. Screenshots demonstrate getting the card serial number during file selection and authenticating, opening, reading from, and writing to a file.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
443 views

APDU Basic Commands

This document describes APDU commands and response codes used for smart card communication. It defines the fields and lengths of command and response APDUs including CLA, INS, P1-P2, Lc, Le, and command and response data. Examples are given of common commands like getting the card version, serial number, EEPROM size, selecting a file, reading and writing binary data, and reading and writing records. Screenshots demonstrate getting the card serial number during file selection and authenticating, opening, reading from, and writing to a file.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

APDU COMMANDS OUTPUT CODES

Command APDU
Length
Field name Description
(bytes)
Instruction class - indicates the type of command, e.g. interindustry or
CLA 1
proprietary
INS 1 Instruction code - indicates the specific command, e.g. "write data"
Instruction parameters for the command, e.g. offset into file at which to write
P1-P2 2
the data
Encodes the number (Nc) of bytes of command data to follow

0 bytes denotes Nc=0


Lc 0, 1 or 3 1 byte with a value from 1 to 255 denotes Nc with the same value
3 bytes, the first of which must be 0, denotes Nc in the range 1 to 65 535 (all
three bytes may not be zero)

Command
Nc Nc bytes of data
data
Encodes the maximum number (Ne) of response bytes expected

0 bytes denotes Ne=0


1 byte in the range 1 to 255 denotes that value of Ne, or 0 denotes Ne=256
Le 0, 1, 2 or 3 2 bytes (if extended Lc was present in the command) in the range 1 to 65 535
denotes Ne of that value, or two zero bytes denotes 65 536
3 bytes (if Lc was not present in the command), the first of which must be 0,
denote Ne in the same way as two-byte Le

Response APDU

Some of the basic commands for APDU are listed Below :-

# Get Card Version


80 A4 00 00 02 FF 00
80 14 06 00 08

# Get Card Serial Number


80 A4 00 00 02 FF 00
80 14 00 00 08

# Get EEPROM Size


80 14 05 00 00

# Send Issuer Code


80 20 07 00 08 41 43 4F 53 54 45 53 54

# > Select File


80 A4 00 00 02 FF 04

Copyright © Nex-G | Skills | NESPL


# Read Binary
80 20 07 00 08 41 43 4F 53 54 45 53 54
80 A4 00 00 02 FF 04
80 B0 00 00 04

# Write Binary
80 20 07 00 08 41 43 4F 53 54 45 53 54
80 A4 00 00 02 FF 04
80 D0 00 00 04 01 02 03 04

# Read Record
80 20 07 00 08 41 43 4F 53 54 45 53 54
80 A4 00 00 02 FF 04
80 B2 00 00 10

# Write Record
80 20 07 00 08 41 43 4F 53 54 45 53 54
80 A4 00 00 02 FF 04
80 B2 00 00 10
80 D2 00 00 10 01 02 03 04 50 53 02 20 02 23 43 35 35 34 44 54
80 B2 00 00 10

Some of the screenshot for the Code Runner are given below :-

The Below code Shows the Card Serial number while selecting the File FF 00

Copyright © Nex-G | Skills | NESPL


The Below figure Authenticates the user command by issuer code opens the file FF 04 reads the
data and writes the data .

Copyright © Nex-G | Skills | NESPL

You might also like