Payment Cryptography, Hands-On
Module 6 · Keys on the card

EMV chip keys: IMK → card key → session key → ARQC

A stripe is a static recording; copy it and you have the card. A chip instead computes a fresh cryptogram for every transaction with a key that never leaves it. This module follows one transaction from the issuer’s master key to the chip and back.

By the end you can
  • explain derivation: one IMK, millions of card keys;
  • compute an ARQC and an ARPC with all intermediate steps;
  • say what each issuer master key (AC, SMI, SMC, IDN, CVC3) is for;
  • explain why the card bureau and the network need these keys.

1. Three levels of keys

IMK-ACissuer master key, one per BIN (Bank Identification Number, the first 6–8 digits of the PAN)/product
→ PAN (Primary Account Number, the card number), PSN (PAN Sequence Number) →
ICC (Integrated Circuit Card, the chip) MK-ACcard master key, one per card, on the chip
→ ATC (Application Transaction Counter) →
Session keyone per transaction
→ data →
ARQC (Authorization Request Cryptogram)8-byte MAC (Message Authentication Code)
  • Derivation, not storage. The issuer doesn’t store millions of card keys. It keeps one IMK (Issuer Master Key) and re-derives any card’s key on the fly from the PAN and PAN sequence number (PSN). EMV (Europay, Mastercard, Visa — the chip card standard) “Option A”: encrypt the last 16 digits of PAN‖PSN with the IMK for the left half, encrypt their inverse for the right half.
  • One compromised card ≠ compromised BIN. Extracting a card’s key (very hard) gives you one card. Derivation is one-way: you can’t go from the card key back to the IMK.
  • Session keys mix in the application transaction counter (ATC), so each transaction uses a different key.

2. ARQC and ARPC

At the terminal, the card signs the transaction data — amount, currency, date, terminal country, an unpredictable number from the terminal, its own ATC — with the session key. That MAC is the ARQC (Authorisation Request Cryptogram). The issuer recomputes it; if it matches, the card is genuine and the data unaltered. The issuer answers with an ARPC (Authorization Response Cryptogram), which the card checks to know the approval really came from its issuer.

Play: change the amount by one cent. The ARQC changes completely. Change the ATC: new session key, new ARQC. That’s why replaying an old cryptogram fails.

In real life There are several “cryptogram versions” (Visa CVN 10/18/22, Mastercard M/Chip CVN 10/16/17…) that differ in session key derivation and which data is MACed. The structure is always the one above. The widget uses the EMV common session key method and ARPC method 1.

3. The issuer master keys and what each is for

KeyAlso calledTR-31Used for
MK-ACIMK-AC, MDK, “card master key”E0Application cryptograms: ARQC, TC, AAC; ARPC
MK-SMIIMK-SMI, MAC keyE2Secure messaging integrity: MAC on issuer scripts sent to the card (block the card, change limits, PIN change)
MK-SMCIMK-SMC, “encryption key”E1Secure messaging confidentiality: encrypt data in scripts, e.g. the new PIN
MK-IDNICC dynamic number master keyE4Mastercard: a per-transaction dynamic number from the card
MK-CVC3CVC3 key(vendor-specific)Mastercard contactless mag-stripe mode: dynamic CVC3 instead of a static CVC1
CVKCVC key, CSCKC0Static CVV/CVC1, CVV2/CVC2, iCVV (module 5)

A key “set” for a new BIN is therefore typically: MK-AC, MK-SMI (Master Key for Secure Messaging Integrity), MK-SMC (+ MK-IDN, MK-CVC3 for Mastercard contactless) and a CVK (Card Verification Key) — each with its own KCV (Key Check Value).

4. Contactless: dynamic CVC3

Older contactless cards emulate a magnetic stripe. To stop that data being replayed, a card computes a dynamic CVC3 (Card Verification Code 3, dynamic, for contactless) per tap from its CVC3 key, the terminal’s unpredictable number and the ATC, and puts it into the track data.

5. Who needs these keys

  • Card bureau (personalisation): derives each card’s keys from the IMKs and writes them into the chip. Needs MK-AC, MK-SMI, MK-SMC (Master Key for Secure Messaging Confidentiality), MK-IDN (Master Key for the ICC Dynamic Number)/CVC3, and the CVK for iCVV and CVV (Card Verification Value) values.
  • Issuer processor: verifies ARQCs, generates ARPCs and scripts. Needs all of them.
  • Network: only if it verifies cryptograms on the issuer’s behalf (stand-in processing, on-behalf services). Typically MK-AC and CVK.
In the book The theory behind “a MAC with a fresh counter” is in §2.2 (MACs). EMV itself isn’t covered — EMV Book 2 (free from EMVCo) is the primary source.

Exercises

Which key is physically on the chip?

  • IMK-AC
  • The card’s own MK-AC (derived from the IMK)
  • All future session keys

Which issuer master key protects the confidentiality of a new PIN (Personal Identification Number) sent to the card in a script?

  • MK-SMI
  • MK-SMC
  • MK-AC
HintThe pipeline widget shows ① card master key — set IMK, PAN and PSN.
HintFill the pipeline widget. The amount is 12 digits; ATC is 4 hex digits.

A criminal records a genuine ARQC at a shop and replays it later for the same amount at another terminal. Why does it fail?

  • The unpredictable number and ATC differ, so the issuer’s recomputed ARQC won’t match
  • The issuer keeps a list of all used ARQCs
  • The terminal checks it against the card

You receive a new BIN’s key set from the bureau as TR-31 (ANSI X9 Technical Report 31, the key block format) blocks. One block has header B0096E0TX00E0000…, another B0096E1TX00E0000…. A colleague mapped them in the config as “Card Master Key” and “Encryption Key”. Are they right?

  • Yes: E0 is MK-AC and E1 is MK-SMC
  • No: E1 is the integrity key
  • No: E0 is the CVK