How to Read EMV based smart VISA card details

孤者浪人 提交于 2019-12-03 06:19:57

First of all PPSE applet is nothing specific for VISA nor for MasterCard. It is defined by EMV, and it is used as you correctly noticed for listing the AIDs of the available payment applications on the card. But if it is not there the terminals try all the supported AIDs to build the candidate list.

If you want to select the VISA applet, but you do not know the complete AID you can use partial selection. Since all the VISA AIDs begin with the VISA's RID: A0 00 00 00 03. You can try to send this command:

This will return the first instance:

00 A4 04 00 05 A0 00 00 00 03 00

and this will give you more if you have on your card:

00 A4 04 02 05 A0 00 00 00 03 00

So the problem is you don't know AID of your application on the card? There's no method to get them (except PSE), you have to know first what applications on card you support. So the "List of AIDs" is list of AIDs you support, which was told you by your acquirer. You can try to create this list yourself basing on some standard AIDs which you have listed here: http://en.wikipedia.org/wiki/EMV#Application_selection

It is kind of weird for me... My research indicates that for VISA that application will always be available, but for Mastercard it is not mandatory...

Anyway, Here is the command I send to my cardreader inorder to select that application:

//               OP CL P1 P2 LN DATA------------------------------------- EL
//select command 00 A4 04 00 0E 31 50 41 59 2E 53 59 53 2E 44 44 46 30 31 00

NSString* str= @"1PAY.SYS.DDF01";
NSData* data=[str dataUsingEncoding:NSUTF8StringEncoding];
int datalength = data.length; 
NSMutableData *selectPSECommand = [[NSMutableData alloc] init];

[selectPSECommand appendBytes:"\x00" length:1]; //command class
[selectPSECommand appendBytes:"\xA4" length:1]; //APDU_INSTRUCTION_SELECT_FILE
[selectPSECommand appendBytes:"\x04" length:1]; //select file by name
[selectPSECommand appendBytes:"\x00" length:1]; //First or only occurrence of file
[selectPSECommand appendBytes:&datalength length:1]; //data length
[selectPSECommand appendData:data]; //the data we are sending
[selectPSECommand appendBytes:"\x00" length:1]; //expected response length. here it is 0. We are only selecting a file.

The code sample is for Objective C.

Compare the data you send with the data I'm sending and see if it corresponds. In the meantime, I'll be looking into running through the AID list.

Hope it helps. Ezfrag

You can use an AID List like this one. However some cards respond with "wrong" data when iterating through the list. i.e., I had the case where a V-Pay VISA card was read as Maestro. If you have to iterate through a big AID List to "open" the card info, I would recommend you to add a flag to get the actual AIDs from the card, then go back to the main method to read the card with the main AID provided.

Something like:

  1. Read Card iterating through a AID List
  2. If 0x90 is returned (successful read), extract data
  3. Check where the data returned is of type AID (0x4f).
  4. When so, clear your list and get the data again with the proper AID now that you know it is right for sure as it comes directly from the card.

As the AID usually comes in the first records from the card, this loop ensures the process is correct at a minimum time cost.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!