Use a PN532 board. Simplify your work with an Arduino-based host, use this library .
Define a connection.
#include <Arduino.h> #include <SPI.h> #include <PN532_SPI.h> #include <PN532.h> PN532_SPI intfc(SPI,5); PN532 nfc(intfc);
Check for a card or phone:
success = nfc.inListPassiveTarget(); if (success) { ...
Define communication buffer:
uint8_t apdubuffer[255] = {}; uint8_t apdulen;
and send the SELECT PPSE command:
apdulen = 255; success2 = sendAPDU(0x00, 0xA4, 0x04, 0x00, "2PAY.SYS.DDF01", 0x00, &apdubuffer[0], &apdulen);
if successful, then:
//fromHEX("A0000000031010") - VISA //fromHEX("A0000000041010") - MC success2 = sendAPDU(0x00, 0xA4, 0x04, 0x00, fromHEX("A0000000031010"), 0x00, &apdubuffer[0], &apdulen);
and you can read the internal map files (SFI / REC), for example:
success2 = sendAPDU(0x00, 0xB2, rec_num, (sfi_num << 3)+4, 0x00, &apdubuffer[0], &apdulen);
It is best to find the PAN / ICC public key, indeed, as unique to the card, but before the PAN / ICC many bytes will be presented, imho, unique enough and sufficient for authentication
In the end, you will need the following overloads:
bool sendAPDU(byte cla, byte ins, byte p1, byte p2, String aid, byte le, uint8_t *response, uint8_t *resp_len) { uint8_t cmdbuf[255]; memset(&cmdbuf[0],0,255); cmdbuf[0] = cla; cmdbuf[1] = ins; cmdbuf[2] = p1; cmdbuf[3] = p2; cmdbuf[4] = aid.length(); int i; for (i=0;i<aid.length();i++) cmdbuf[5+i] = aid[i]; cmdbuf[6+i] = le;
and this too:
uint8_t fromHexBuf[255]; uint8_t* fromHEX(String hexs) { int i = hexs.length()/2; fromHexBuf[0] = i; int x=0; while (i) { char buf[3]; char *tmp; buf[0] = hexs[2*x]; buf[1] = hexs[2*x+1]; buf[2] = 0; uint8_t v = strtol(&buf[0], &tmp, 16);