Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EMV TLV Java Function

I'm looking for a way to translate an EMV response with Java like with this online option:

http://www.emvlab.org/tlvutils/

where you put something like this EMV response:

6f3a8407a0000000031010a52f500b56495341204352454449548701015f2d086573656e707466729f12074352454449544f9f1101019f38039f1a02

and it will show you everything perfectly, I started doing something by myself but then I realize that maybe we could have two 9F38(PDOL) Strings not neccesary two same tags cuz I know it's impossible but maybe the value of a tag end in 9F and the start of the next tag would be 38 and that would give me an error... Now that I mention it, is that possible? cuz that was one of the main reasons why I stopped doing my own function..

Does any of you have written a function to do this already?

Thanks!

like image 316
JuanD Avatar asked May 04 '13 00:05

JuanD


People also ask

What is TLV in Java?

The acronym TLV stands for Tag, Length and Value. It's a way to encode a piece of information with a type, a length followed by the information itself. Three points must be known: The Value part may contents other TLVs. One can see TLVs as C structures, that can contain sub-structures.

What is TLV in EMV?

"EMV Tags" are usually mile-long alpha-numeric strings in a BER-TLV format. "TLV" or as it might be referred to as "SIMPLE-TLV" stands for "Tag Length Value".


1 Answers

https://github.com/binaryfoo/emv-bertlv should do the trick.

Using your example, the following code:

List<DecodedData> decoded = new RootDecoder().decode("6f3a8407a0000000031010a52f500b56495341204352454449548701015f2d086573656e707466729f12074352454449544f9f1101019f38039f1a02", "EMV", "constructed");
new DecodedWriter(System.out).write(decoded, "");

Will output:

[6F (FCI template)] 8407A0000000031010A52F500B56495341204352454449548701015F...1A02
[84 (dedicated file name)] A0000000031010
[A5 (FCI proprietary template)] 500B56495341204352454449548701015F2D086573656E707466729F...1A02
  [50 (application label)] VISA CREDIT
  [87 (application priority indicator)] 01
  [5F2D (language preference)] esenptfr
  [9F12 (application preferred name)] CREDITO
  [9F11 (issuer code table index)] 01
  [9F38 (PDOL - Processing data object list)] 9F1A02
    9F1A (terminal country code) 2 bytes
like image 74
aussie1984 Avatar answered Sep 28 '22 00:09

aussie1984