2
votes

I am working on a POS application that supports EMV cards. I am able to read card data from a Verifone MX card reader in TLV, but I am facing issues in decoding the TLV data to readable data.

I am able to Split the data into TLV Tags and its values. The resultant value is in Hex instead of Decoded text.

Example:

This is a sample TLV data (I got this sample TLV Data here

6F2F840E325041592E5359532E4444463031A51DBF0C1A61184F07A0000000031010500A564953412044454249548701019000

When i check this TLV in TLVUtil, I get data in certain Tags in readable format (like Tag 50 here).

The Closest I could get in my application is this:

Tag Value
50  56495341204445424954
4F  A0000000031010
61  4F07A0000000031010500A56495341204445424954870101
6F  840E325041592E5359532E4444463031A51DBF0C1A61184F07A0000000031010500A56495341204445424954870101
84  325041592E5359532E4444463031
87  1
90  
A5  BF0C1A61184F07A0000000031010500A56495341204445424954870101
BF0C 61184F07A0000000031010500A56495341204445424954870101

I would like to know if there is any way to identify certain tags that need to be converted from Hex to string or if there is any TLV Parser and decoder available in .Net that can replicate the TLVUtil tool.

4
Are you sure your data isn't track1 encrypted? For example, if you run a card like 4186 0000 0000 1234, can you find that number in the data? If not, then the payload is probably encrypted, and the data will not parse nicely.tgolisch
Apart from card number , the reader returns other info like card holder's name , issuer bank etc. This info is returned in Hex code. I would like to identify these tags and convert them selectively.Rahul Vijayapuram
Sample Java Code you can try to follow same step in .Net >> String sHex = "6F2F840E325041592E5359532E4444463031A51DBF0C1A61184F07A0000000031010500A564953412044454249548701019000"; byte[] ba = new byte[sHex.length()/2]; for (int i=0;i<sHex.length()/2;i++) { ba[i] = (Integer.decode("0x"+sHex.substring(i*2, (i+1)*2))).byteValue(); } TLVList list=new TLVList(); list.unpack(ba); if(list.hasTag(0x91)){ // you can get needed tag like below list.getString(0x91); }Ganesh Kumar

4 Answers

1
votes

There are only a few tags that need to be converted to string. Generally tags that are put on POS screen personalized in hex equivalent of readable string.

  • 5F20 : Cardholder Name

  • 50 : Application Label.

  • 5F2D : Language Preference

You must know which tags can be converted.

5
votes

Complete list of EMV tags and are available in EMVCo 4.3 specification book 3 - you can download from here - https://www.emvco.com/download_agreement.aspx?id=654 How data is represented differs from field to field. Check 'Annex A - Data Elements Dictionary'

Details on encoding is mentioned in section 4.3

Read both the sections and your problem solved.

0
votes

As it seems to me, programmatically you can identify something like,

Tag is of one byte ( 5A - Pan number ) or it contain 2 byte ( 5F20 - CARD HOLDER NAME), AND

length is of 1 byte or 2 byte AND

Tag is primitiv or constructed. More you can read Here

and if you know the list you can get something useful Here, It define the format of tag that you are looking for.

Here you can hard coded the format as it is well defined.

Hope it helps.

0
votes

That data beginni g with 6F is a File Control Information (FCI) responded by an EMV card after SELECT command. There is an example in this video also decoded and explained. https://youtu.be/iWg8EBhsfjY

Its easy check it out