Debugging an ARQC mismatch
By IDNTEQ · published · technically reviewed
Runs in your browser. This page loads no analytics or third-party scripts and does not send what you type.
An ARQC mismatch means the card and the host computed different cryptograms from what should be the same inputs. The host’s error rarely says which input differs. Check the inputs in the order below. Use test keys only.
Step 0: identify the cryptogram version
Read the Cryptogram Version Number (CVN) from the Issuer Application Data (tag 9F10). The CVN decides the card key derivation, the session key, the data elements in the cryptogram and their padding. If the host assembles the data for a different version, nothing after this can match. The tag page for 9F10 decodes the Visa IAD formats and shows the CVN.
Card key: Option A or Option B
The card’s master key for application cryptograms (often called the UDK) is derived from the issuer master key with the PAN and PAN Sequence Number (EMV Book 2, Annex A1.4). Option A uses the rightmost 16 digits of PAN ‖ PSN. Option B applies to PANs longer than 16 digits: it hashes PAN ‖ PSN with SHA-1 and decimalises the result. For a PAN of 16 digits or fewer, Option B gives the same key as Option A, so the option only matters for longer PANs.
Confirm the card key by its KCV before going further. The KCV calculator gives it for a key you enter; the verifier shows the KCV of each derived key.
Session key
| Version | Card key | Session key | Padding | ARPC |
|---|---|---|---|---|
| Visa CVN 10 | Option A | none: the card key is used directly | ISO 9797-1 method 1 (zeros) | method 1 |
| Visa CVN 18 | Option B | EMV common session key, diversified by the ATC | ISO 9797-1 method 2 (80 00 …) | method 2 |
These are the settings of pyemv’s VisaCVN10 and VisaCVN18 classes. AWS Payment Cryptography’s Visa documentation agrees where it covers them: Option A and no session key for CVN 10, the EMV common session key for CVN 18. It also documents Visa CVN 22 as using the same derivation as CVN 18 with different transaction data.
For the EMV common session key, the ATC (9F36) is part of the derivation: if the host takes the ATC from the wrong field, or with its bytes swapped, the session key is wrong.
Mastercard versions differ. AWS documents Mastercard CVN 14 and 15 as using the EMV common session key, and CVN 12 and 13 as an older Mastercard-specific derivation that includes the unpredictable number. The verifier below can compute the first with its “EMV common session key” setting and the transaction data the Mastercard version defines; it does not implement the second.
Transaction data and padding
Check the data elements, their order and their lengths against the version. For Visa CVN 10 and 18 the data start with the elements EMV Book 2 recommends, in this order: amount, other amount, terminal country code, TVR, transaction currency code, transaction date, transaction type, unpredictable number, AIP and ATC. CVN 18 then adds the full IAD; CVN 10 adds the CVR. Amounts, dates, codes and the transaction type are numeric fields in BCD; one transposed field changes the whole MAC.
Padding is the other common difference: method 1 pads with zeros to a multiple of
8 bytes, method 2 adds 80 and then zeros. Some systems log the data already
padded. The verifier accepts the data with or without the padding.
ATC and unpredictable number
The ATC and the unpredictable number (9F37) are inputs to the cryptogram. If the host logged the UN differently from what the terminal sent to the card, the result will not match. Compare the raw values in the authorisation message (DE 55; the ISO 8583 decoder parses it) with the values in the terminal’s APDU log, not the parsed or reformatted ones.
The response cryptogram (ARPC)
When the ARQC verifies but the card rejects the issuer’s response, check the ARPC method. Method 1 encrypts the ARQC XORed with the response code: an 8-byte ARPC. Method 2 computes a MAC over the ARQC, the Card Status Update and optional proprietary data: a 4-byte ARPC. Visa CVN 10 uses method 1 and CVN 18 method 2. The ARPC must be computed over the ARQC the card sent, even when the issuer’s own expected ARQC differs.
Host side or card side
If the card is a known-good test card, treat its cryptogram as correct and investigate the host. If neither side is trusted, compute the cryptogram independently and compare it with both.
Verifier
The verifier re-runs the computation with common mistakes and reports any variation that reproduces the expected value. A matching variation points to one input difference to investigate; it does not prove the cause. Load one of the published examples first to see the published value next to the tool’s result.
Input
Result
The data the MAC covers
Labelled in the EMV Book 2 recommended order, which Visa CVN 10 and 18 follow; check other versions against their own layout. The MAC runs over 4 blocks of 8 bytes:
Derivation trace (7 steps)
Every intermediate value is shown so you can find which input is wrong. Runs in your browser. Test keys only.
The EMV transaction walkthrough shows an ARQC and ARPC being computed in a full transaction, for Visa CVN 10 and CVN 18. For a version the tool does not cover, or a mismatch that no variation explains, see EMV troubleshooting.
References
- EMVCo, EMV Integrated Circuit Card Specifications, Book 2: §8.1 (Application Cryptogram), §8.2 (ARPC methods 1 and 2), Annex A1.3 (common session key) and A1.4 (card master key, Options A and B)
- AWS Payment Cryptography user guide: Visa-specific functions (CVN 10, CVN 18/22)
- AWS Payment Cryptography user guide: Mastercard-specific functions (CVN 12/13, CVN 14/15)
- pyemv (Konstantin Novichikhin): cvn.py (VisaCVN10, VisaCVN18) and kd.py (Option A and B)
See also
- The EMV transaction walkthrough: one contact chip-and-PIN purchase, every command and cryptogram computed in your browser.
- The EMV and payments glossary, with the Brazilian Portuguese terms.
- For an investigation, see EMV transaction troubleshooting.
Related tools
Shows each derivation step and tests common input variations when an ARQC does not match.
KCV calculatorDES/TDES/AES KCV per component and of the combined key, with parity.
TLV parser / builderDecode BER-TLV with tag names, decoded values and the EMV bitmaps; DOL mode and share links.
ISO 8583 decoder & compareDecode an ISO 8583 message in a declared dialect, or compare two messages field by field.
MAC calculatorISO 9797-1 MAC, X9.19 Retail MAC and AES-CMAC.