Card verification values: CVV, CVV2, iCVV
The three digits on the back of your card aren’t random and aren’t stored anywhere. They’re a MAC (Message Authentication Code) of the card number, expiry date and a service code, computed with the issuer’s card verification key (CVK) and squeezed into decimal digits.
- compute a CVV step by step;
- explain why one card has three different check values;
- say who needs the CVK and why;
- translate between Visa and Mastercard names.
1. One algorithm, three values
| Value | Where it lives | Service code used | Checks… |
|---|---|---|---|
| CVV / CVC1 | Magnetic stripe | the card’s real one (e.g. 201, 101) | the stripe wasn’t forged |
| CVV2 / CVC2 | Printed on the back | 000 | online buyer has the physical card |
| iCVV / Chip CVC | Track-2 image inside the chip | 999 | stripe data copied from a chip can’t be used on a stripe |
Because the service code is part of the input, the three values are unrelated. Steal the chip’s track data, write it to a stripe, and the issuer sees an iCVV in a stripe transaction: declined.
Names: Visa says CVV (Card Verification Value)/CVV2 (Card Verification Value 2, the printed code)/iCVV, Mastercard says CVC1 (Card Verification Code 1, on the magnetic stripe)/CVC2 (Card Verification Code 2, the printed code)/Chip CVC (Card Verification Code, Mastercard’s name for CVV), Amex CSC (Card Security Code). Same idea, same algorithm for Visa and Mastercard.
2. The algorithm
- Concatenate PAN (Primary Account Number, the card number) ‖ expiry (YYMM) ‖ service code, pad with zeros to 32 digits.
- Split into two 16-digit (8-byte) blocks.
- Encrypt block 1 with single DES (Data Encryption Standard) under the left half of the CVK (key A).
- XOR (exclusive OR) the result with block 2.
- Encrypt with 3DES (Triple DES) under the full CVK (A‖B).
- Scan the hex result left to right, take the first three decimal digits.
The structure — encrypt, XOR the next block, encrypt — is CBC-MAC from module 1. A CVV is a 3-digit MAC.
3. Who needs the CVK
- The issuer processor — verifies CVV/CVV2/iCVV on every authorisation.
- The card bureau — computes the values to encode on the stripe and chip and print on the back (unless the processor sends them precomputed).
- The card network — if it does stand-in processing (STIP) when the issuer is unreachable, or offers CVV2 verification as a service.
Each one receives it in its own zone, under its own ZMK (Zone Master Key), as a C0 key block. Usually one CVK (Card Verification Key) per BIN (or per product range).
Exercises
Which service code is used to compute CVV2?
Where is a card’s CVV2 stored by the issuer?
- In the card database, encrypted
- Nowhere: it’s recomputed on demand with the CVK
- On the chip
Hint
Calculator: set the service code with the “printed (CVV2)” button.Hint
Compute the value for each service code and see which matches.A card is reissued with the same PAN but a new expiry date. Without changing the CVK, what happens to the CVV2?
- It changes (almost certainly)
- It stays the same
- The CVK must be rotated first
The CVK for a BIN (Bank Identification Number, the first 6–8 digits of the PAN) leaks. What is the realistic damage and fix?
- Anyone with PANs and expiries can mint valid CVV2s; generate a new CVK and reissue the BIN’s cards
- Change the KCV (Key Check Value)
- Nothing — chip transactions are still safe, so CVV2 doesn’t matter