I´m starting a new project, I´m new using EMV reader and Javax SmartCardIO.
I have the list of the RID for each type of card, however the only thing I can access without knowing the type of card is the ATR, I´m wondering if there is a way to get the RID or the card type with only this info, any help is welcome.
Thanks in advance!
EDIT:
I tried to execute the select PSE command with this method:
public static byte[] selectPSE(CardChannel channel) throws CardException {
byte[] selectPSE = {(byte)0x00, (byte)0xA4, (byte)0x04, (byte)0x00, (byte)0x0E, (byte)0x31, (byte)0x50, (byte)0x41, (byte)0x59, (byte)0x2E, (byte)0x53, (byte)0x59, (byte)0x53, (byte)0x2E, (byte)0x44, (byte)0x44, (byte)0x46, (byte)0x30, (byte)0x31};
CommandAPDU command = new CommandAPDU(selectPSE);
ResponseAPDU response = channel.transmit(command);
System.out.println(response.getBytes());
return response.getBytes();
}
However, It is only working with an AMEX and Visa, I´m getting the error 6a82 with two MasterCard Cards(credit and debit).
This looks very strange, as far as I know all the major card issuers (including MasterCard) use 1PAY.SYS.DDF01, I can get the information I want with Try and Error of the AID but I don´t think this is the best solution.
AID (Application ID) = RID(Registered Application ID) || PIX (Property Application Extension)
The best way how to recognize what application is installed on card - make Select PSE. Detailed description in EMV Book 1, 12 Application Selection, 12.3.2 Using the PSE.
Full algorithm you can find on Figure 17: Terminal Logic Using Directories.
Quick algorithm:
1) Command Select PSE or PPSE.
Send: 00 A4 04 00 0E 31 50 41 59 2E 53 59 53 2E 44 44 46 30 31 00
Responce will will contain:
'6F' FCI Template M
'84' DF Name M
'A5' FCI Proprietary Template M
'88' SFI of the Directory Elementary File M
'5F2D' Language Preference O
'9F11' Issuer Code Table Index O
'BF0C' FCI Issuer Discretionary Data O
Here you can find SFI of PSE.
2) Command ReadRecord 1 SFI X
Send: 00 B2 01 0C 00
Receive list of tag.
'70' Application Elementary File (AEF) Data Template
'61' Application Template
'70' Application Elementary File (AEF) Data Template
'61' Application Template
'4F' Application Identifier (AID)
'50' Application Label
... and so on
Look there for Tag '4F' Application Identifier (AID). From it you can extract and compare RID.
Аlso you can:
1) Get own list of AID and successively SELECT application from it.
2) SELECT Default or Next applications and get AID from response.
There is no way to get RID values from card with ATR. ATR is used to identify card hardware and software, it is not used to get info about installed applications(visa, visa electron, mastercard etc) https://eftlab.com/index.php/site-map/knowledge-base/212-emv-rid
There is one way to get installed applications , reading Payment System Environment(PSE ) of card . You can send Read PSE commands to contact cards and Read Proximity PSE command for contactless cards
Contact PSE:
00A404000E315041592E5359532E4444463031
Contactless PPSE:
00A404000E325041592E5359532E444446303100
And then you must parse if there is more than one installed application.
来源:https://stackoverflow.com/questions/36297722/smartcardio-emv-reader-find-my-card-type-with-only-the-atr-number