EMV/CAM2 Exits For APTRA Advance NDC: NCR University Course
EMV/CAM2 Exits For APTRA Advance NDC: NCR University Course
Subject:
March 2012
Command and Response and BER-TLV
Copyright © 2009
By NCR Corporation
Duluth, Georgia, U.S.A.
All Rights Reserved
Revision Record
You should have already heard or read the ICC Basics seminar
which talked briefly about the ISO7816-4 structure for commands
and responses as well as a list of commands.
The reason we are covering this again in more detail, and the
reason why it is so important that you understand this level of
detail, is that during any card transaction, if there is an error in
processing, the command that the ATM is sending to the card and
the response from the card is logged to the journal printer and is
your only source of information for determining the error.
00 A4 04 00 07 A0 00 00 00 04 10 10 00
From this we can see that the terminal was issuing a Select
command to the card and that it was the first time this particular
a “select by name” command was sent to the card. The
application that the card was trying to select was a MasterCard
application.
6A 82
90 00 6F 17 84 07 A0 00 00 00 04 10 10 A5 0C 50 0A 4D
61 73 74 65 72 43 61 72 64
So, how did we get from all that Hex, to that explanation?
All communication between the The terminal submits commands to the ICC and the ICC
terminal and the ICC is a responds; this is the only communication between the 2 devices.
command from the Terminal
The command structure is:
which results in a response
from the ICC
CLA 1 byte Class of Instruction
00 A4 04 00 07 A0 00 00 00 04 10 10 00
So the first byte, 00 is the Class of Instruction and the next byte
A4 is the Instruction Code.
On page 146 of this file (Page 130 in the footer) you see the Select
command has CLA 00 INS A4.
The next parameter, Lc, is the Length of the Data being given to
the ICC as part of the command. The EMV specification says (in
section 11.3.3) that for the Select command “The data field of the
command message contains the PSE name or the DF name or the
AID to be selected.” (AID is the Application Identifier, also
known as the Application Name)
So the name being selected is 07 bytes long. The next 7 bytes are
“A0 00 00 00 04 10 10” so this is the name that the select
command is trying to select.
The second part of the AID is called the PIX, can be from 0 to 11
bytes long and is defined by the card scheme. Both Visa and
MasterCard use “1010” for their Debit/Credit applications.
The details of this second part are available from the card scheme,
some examples are:
The EMV standard allows for Short Select. The name of a Visa
Short Select Credit/Debit application is A0000000031010. If an issuer wanted
to put 2 Visa applications on the same chip, Visa tell them to call
the applications A000000003101001 and A000000003101002.
The terminal will only ever try to select the standard Visa name,
A0000000031010. An ICC with multiple applications must
support Short Select which means that when it receives the first
select command of A0000000031010 the ICC will respond with
“A000000003101001 found”. The terminal can see that the
returned name is longer than that used in the Select command
and can therefore send a second Select command for the same
name.
6A 82
Page 150 (134 in the footer) tells us that this response means “File
Not Found”, so there are no MasterCard Credit/Debit
applications on this card. Had it found one, the response might
have been:
90 00 6F 17 84 07 A0 00 00 00 04 10 10 A5 0C 50 0A 4D
61 73 74 65 72 43 61 72 64
The first 2 bytes are SW1 and SW2 which page 150 (134 in the
footer) of the same EMV Terminal Interface guide says:
“’9000’ indicates a successful execution of the command”.
The rest is Data returned from the ICC, page 149 (133 in the
footer) of the same EMV guide tells us that a valid response to a
successful selection of an application (ADF – Application
Definition File) begins ‘6F’ and contains 2 mandatory objects, DF
(Directory File) Name and FCI (File Control Information)
Proprietary Template. The FCI Proprietary Template may contain
7 optional data objects, the last one of which can itself contain any
number of card scheme specific data objects.
BER-TLV
So the first item to look for when looking at Data is the Tag,
If the least significant 5 bits of
which can be either 1 byte or 2 byte. Look up the tag you are
the first byte are all 1, then it is
given in the relevant EMV document.
a 2 byte tag (almost always if
the first byte ends in F then it
Following the tag there must be a “length” (normally 1 byte), this
is a 2 byte tag).
is the length of the actual data expressed in Hex. With tag 87 we
know from the EMV manual that we are expecting length 1.
87 01 01
Going back to the example of the data returned from the earlier
Our Example Select command, we had the following data:
6F 17 84 07 A0 00 00 00 04 10 10 A5 0C 50 0A 4D 61 73
74 65 72 43 61 72 64
Either from page 149 of the “EMV v4.2 Book 1 ICC to Terminal
Interface CR05.pdf” or from page 170 of the “EMV v4.2 Book 3
Application Specification CR05.pdf” guide we find that tag 6F is
the File Control Information (FCI) Template.
4D 61 73 74 65 72 43 61 72 64
81 80
Note 1: SFI stands for Short File Identifier and is the number of
the Data File in use.