简体   繁体   中英

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!

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

该项目包含处理EMV数据的代码http://code.google.com/p/javaemvreader/

You are on the right track. You can easily build your own EMV parser using the technique call TLV (Tag Length Value). Your raw data always comes back with a Tag, then after the tag is the length, using the length can get you the value.

So create three methods

method 1: Contains all the short tags method 2: Contains all the long tags method 3: Contains all the proprietary tags

So when you pass in your raw emv tag:

6f3a8407a0000000031010a52f500b56495341204352454449548701015f2d086573656e707466729f12074352454449544f9f1101019f38039f1a02

Loop through all those three methods, it will give you all the nice information that you need.

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