简体   繁体   中英

Decode EMV TLV Data

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.

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.

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM