# How to replace CVC3, ATC and unpredictable number in EMV contactless track data?

I am trying to gather the correct track data given CVC3 and a bunch of positional parameters. But the EMV C-2 kernel book is about as dumb as you might imagine (can anyone kill anyone to include an example!?!). Can anyone help with this example:

``````9f62 - pcvc3(t1)  - Position of CVC3 in track1: 0x38 (4-6?)
9f63 - punatc(t1) - Unpredictable Number Track1 Pos: 0x3C6 (2-3 7-10?)
9f64 - natc(t1)   - Digits in track1 ATC: 4
9f65 - pcvc3(t2)  - Position of CVC3 in track2: 0x38 (4-6)
9f66 - punatc(t2) - Unpredictable Number Track2 Pos: 0x3C6 (2-3 7-10?)
9f67 - Digits in track2 ATC: 4
```

```

After successfully generating the checksum:

``````9f61 - track2 CVC3 - 2EF4
9f60 - track1 CVC3 - 609B
9f36 - ATC - 1E47
```

```

Assuming a discretionary data field starts with all 0s, how does it end? The spectrum says this:

Convert binary encoded CVC3 (Track2) to BCD encoding the appropriate number expressed in base 10. Copy the q least significant digits of the CVC3 encoded BCD (Track2) at the appropriate "discretionary data" positions in Track 2. The corresponding positions are denoted by q non-zero bits in PCVC3 (Track2 ).

I read it like: CVC3 = 0x609B = 24731 (so copy 731? What does BCD have to do with this? Or do they just say "Copy 731 as bcd encoded into a byte array"?)

+3

source to share

yes, you're right, it's pretty dumb. you are correct to convert the p values ​​(pCVC3 and PUNATC) to binary. (0011 1000, 0011 1100 0110 for your track1 p values), you then align the correct values ​​correctly with the discretionary data. Example

``````Bxxxxxxxxxxxxxxxx^ /^14111014010000000000
....000000000000000000CCC000
....00000000000000AAAA000UU0
```

```

so you say that you CVC3 for track 1 is 609B, which is 24.731, since you are asking PCVC3 for only 3 chars that you set 731 to. your ATC is 1E47, which is 7751. your PUNATC asks for 4 digits, so you will use 7751. FYI ... if the ATC is lower than the requested characters, which you dialed from 0. Your unpredictable number is even more complicated ... so you make a 4 byte random number. convert it to uint (base 10) and then mark the 8 most significant bytes as 0. Example. let's say your random 4 bytes is 29A6 06AE. at the base 10, which is 698 746 542. mark the first 8 characters with 0. and you will be left with 000 000 002. you will place 02 for you with an unpredictable placment number .. so .. all that said your track would look like this

``````Bxxxxxxxxxxxxxxxx^ /^14111014017751731020
```

```

the last character is equal to the length of digits with an unpredictable number (numeric). which was 02 .. so the last digit 2 makes your final track data

``````%Bxxxxxxxxxxxxxxxx^ /^1411014017751731022;
```

```

track2 is very similar. good luck with him. I understand your frustrations with this. :)

+3

source

All Articles