How to read an EMV transaction log

By · published · technically reviewed

Runs in your browser. This page loads no analytics or third-party scripts and does not send what you type.

An APDU log records the commands the terminal sent to the card and the responses the card returned. This article covers a contact EMV transaction, in the order the commands appear in a log. Contactless transactions use other entry points (the PPSE, 2PAY.SYS.DDF01) and kernel-specific flows; they are not covered here.

The EMV transaction walkthrough shows one complete contact chip-and-PIN purchase with every command and response computed live. Read it alongside this article.

Application selection (SELECT)

On a contact card the terminal can select the Payment System Environment (PSE), 1PAY.SYS.DDF01:

00 A4 04 00 0E
31 50 41 59 2E 53 59 53
2E 44 44 46 30 31
00

(CLA INS P1 P2 and Lc = 14, then the name 1PAY.SYS.DDF01 in ASCII, then Le.)

The PSE’s FCI points to a directory file, which the terminal reads with READ RECORD to build the list of applications. If the card has no PSE (6A82, file not found) or the terminal does not use it, the terminal selects the AIDs it supports one by one, with 00 A4 04 00 and the AID. The response to a successful SELECT is an FCI template (tag 6F) with the DF name, the application label and, if the card wants terminal data in the next step, the PDOL. Parse it with the TLV parser. 6283 in response to SELECT means the application is blocked.

Initiate processing (GET PROCESSING OPTIONS)

80 A8 00 00 sends the data the PDOL asked for, inside command template 83 (or 83 00 when there is no PDOL). The card returns the Application Interchange Profile (AIP, tag 82) and the Application File Locator (AFL, tag 94), either as format 1 (tag 80) or format 2 (tag 77). The AIP declares which offline data authentication methods the card supports, whether it supports cardholder verification and whether issuer authentication is performed.

Read application data (READ RECORD)

The terminal reads every record the AFL lists with 00 B2, P1 = record number, P2 = SFI × 8 + 4. The records hold the certificates, the CDOLs, the CVM list and the other application data. The AFL builder decodes the AFL, lists the records in order and assembles the static data used for offline data authentication.

Offline data authentication

The terminal picks one method that both sides support:

  • SDA checks a signature over the static data. No command is sent; the terminal works from the records already read.
  • DDA checks a dynamic signature that the card generates in response to INTERNAL AUTHENTICATE (00 88 00 00), which the terminal sends before the first GENERATE AC.
  • CDA combines the dynamic signature with the cryptogram: the card signs in its response to GENERATE AC, and the terminal verifies that signature after the GENERATE AC response arrives. In a CDA log there is no INTERNAL AUTHENTICATE; the GENERATE AC command has the CDA bit set in P1 and the response contains the Signed Dynamic Application Data (tag 9F4B).

In all three cases the terminal first recovers the issuer certificate with the CA public key and the ICC certificate (for DDA and CDA) with the issuer key. The EMV certificate validator does the same recovery and hash checks.

Processing restrictions, cardholder verification, risk management

Processing restrictions (version, dates, usage control) are terminal checks and send no command. Cardholder verification follows the card’s CVM list:

  • offline plaintext PIN: VERIFY, 00 20 00 80 with a format 2 PIN block;
  • offline enciphered PIN: GET CHALLENGE (00 84 00 00 00), then VERIFY with P2 = 88;
  • online PIN: no command to the card; the PIN goes to the issuer in the authorisation message.

The terminal may read the PIN Try Counter first with GET DATA (80 CA 9F 17). Terminal risk management may read the ATC and the Last Online ATC Register with GET DATA for velocity checking. Each outcome sets bits in the TVR; see TVR structure and what to check when a flag is set.

First GENERATE AC

80 AE asks the card for a cryptogram. P1 gives the type requested (00 AAC, 40 TC, 80 ARQC, plus 10 when CDA is requested). The command data are the values the card’s CDOL1 asked for, without tags. The card answers with the Cryptogram Information Data (9F27), the ATC (9F36), the Application Cryptogram (9F26) and the Issuer Application Data (9F10). The CID says which cryptogram the card actually returned: the card may return a lower one than requested (an AAC when an ARQC was requested), never a higher one.

Online authorisation and completion

For an ARQC the terminal goes online. The issuer’s response may carry issuer authentication data (the ARPC, tag 91) and issuer scripts (templates 71 and 72). Depending on the card, the terminal sends the ARPC in EXTERNAL AUTHENTICATE (00 82 00 00) or in the data of the second GENERATE AC. Scripts in template 71 are sent before the second GENERATE AC and those in template 72 after it. The second GENERATE AC asks for a TC (approve) or an AAC (decline), with the data the card’s CDOL2 asked for. To check an ARQC or an ARPC with test keys, use the ARQC verifier.

Status words

Every response ends with a two-byte status word (SW1 SW2).

Status wordMeaning
9000Normal completion
61xxxx more bytes available with GET RESPONSE (T=0)
6CxxWrong Le; repeat the command with Le = xx
6283Selected file invalidated (on SELECT: application blocked)
6985Conditions of use not satisfied
6983Authentication method blocked (after VERIFY: PIN blocked)
6A82File or application not found
6A83Record not found
63CxA counter with value x; its meaning depends on the command

63Cx is generic in ISO 7816-4. In response to VERIFY it gives the number of PIN tries remaining (63C2: wrong PIN, two tries left). After another command, read it in that command’s context. The decoder below names status words with the command they answer.

Decoder

Paste a log or a single command or response. The default example is a short contactless selection; replace it with your own contact log. Comments, direction markers and timestamps are removed before decoding.

Input

Paste a single APDU or a full log.

3 commands, 3 responses decoded.

Result

SELECT
CLA 00 (inter-industry) · INS A4 · P1 04 P2 00: Select by name (AID/DF) · case 4 · Lc 14 · Le 256
data 325041592E5359532E4444463031
SW 9000 Success: normal processing
data 6F2E840E325041592E5359532E4444463031A51CBF0C1961174F07A00000000310105009564953412043415244870101
6F File Control Information (FCI) Template [46]
84 Dedicated File (DF) Name [14]
325041592E5359532E4444463031
A5 File Control Information (FCI) Proprietary Template [28]
BF0C FCI Issuer Discretionary Data [25]
61 Application Template [23]
4F Application Dedicated File (ADF) Name / AID [7]
A0000000031010
50 Application Label [9]
564953412043415244
→ VISA CARD
87 Application Priority Indicator [1]
01
SELECT
CLA 00 (inter-industry) · INS A4 · P1 04 P2 00: Select by name (AID/DF) · case 4 · Lc 7 · Le 256
data A0000000031010
SW 9000 Success: normal processing
data 6F198407A0000000031010A50E5009564953412043415244870101
6F File Control Information (FCI) Template [25]
84 Dedicated File (DF) Name [7]
A0000000031010
A5 File Control Information (FCI) Proprietary Template [14]
50 Application Label [9]
564953412043415244
→ VISA CARD
87 Application Priority Indicator [1]
01
GET PROCESSING OPTIONS (GPO)
CLA 80 (proprietary) · INS A8 · P1 00 P2 00 · case 4 · Lc 2 · Le 256
data 8300
83 Command Template [0]
(empty value)
SW 9000 Success: normal processing
data 771282024000940C080101001001020118010200
77 Response Message Template Format 2 [18]
82 Application Interchange Profile (AIP) [2]
4000
✓ b1 bit7: SDA supported
94 Application File Locator (AFL) [12]
080101001001020118010200
→ 3 entries, 5 records to read, 1 used for offline data authentication
· Entry 1: SFI 1, record 1, 0 for offline data authentication
· Entry 2: SFI 2, records 1–2, 1 for offline data authentication
· Entry 3: SFI 3, records 1–2, 0 for offline data authentication

The planned EMV for Developers course covers the transaction flow in more detail.

References

See also

Related tools