Tuesday 15 January 2013

java - reading apple pay token using a ACR122 NFC reader -



java - reading apple pay token using a ACR122 NFC reader -

i have acr122 nfc reader , trying see if can read token generated apple pay. below code in java trying returns 4 alpha numeric character every time. apple pay iphone senses nfc reader - there specific apdu commands need send retrieve token?

import java.io.*; import java.util.*; import javax.smartcardio.*; public class cardtest { final protected static char[] hexarray = "0123456789abcdef".tochararray(); public static string bytestohex(byte[] bytes) { char[] hexchars = new char[bytes.length * 2]; int v; ( int j = 0; j < bytes.length; j++ ) { v = bytes[j] & 0xff; hexchars[j * 2] = hexarray[v >>> 4]; hexchars[j * 2 + 1] = hexarray[v & 0x0f]; } homecoming new string(hexchars); } public static void main(string[] args) throws exception { terminalfactory mill = terminalfactory.getinstance("pc/sc", null); system.out.println(factory); list<cardterminal> terminals = factory.terminals().list(); system.out.println("terminals: " + terminals); if (terminals.isempty()) { throw new exception("no card terminals available"); } cardterminal terminal = terminals.get(0); // maintain looping looking cards until application closed while( true ) { terminal.waitforcardpresent( 0 ); seek { card card = terminal.connect("*"); cardchannel channel = card.getbasicchannel(); commandapdu command = new commandapdu(new byte[]{(byte)0xff,(byte)0xca,(byte)0x00,(byte)0x00,(byte)0x04}); responseapdu response = channel.transmit(command); byte[] bytearray = response.getbytes(); system.out.println( bytestohex( bytearray ) ); thread.sleep(1000); } grab (cardexception e) { e.printstacktrace(); } } } }

the command issue

ff ca 00 00 04

will anti-collision identifier (or first 4 bytes of if had more 4 bytes) of smartcard (secure element) of iphone.

apple pay (over contactless interface) implements emv standard contactless payment cards. in order communicate contactless emv payment card, need implement protocol.

btw. don't think of payment token string of bytes. far more that. emv payment token can

a temporary payment "card" (limited single/limited time/limited number of transactions use) consists of temporary "credit card number" (etc.) , key used generate transaction authorization (-> typically used in hce applications, e.g. google wallet)

a permanent payment card (separate, fixed credit card number, validity period, secret key, etc.) used authorize payments later deducted linked credit card (-> seems used apple pay -- , used secure element based google wallet).

java iphone nfc acr122 applepay

No comments:

Post a Comment