Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send APDU commands to a smartcard using Windows Phone 8 NFC application

I need to build a Windows Phone 8 application that can communicate with a smartcard using simple APDU commands. The smartcard contains data which my application needs to present on the phones UI. We currently have Android and IOS apps doing this, and now need to add a Windows version.

I've spent a fair bit of time playing with the Proximity API, and believe that the API is too restricted to do what I need. When i present a card to the NFC reader on a Nokia Lumia 620, i get a DeviceArrived event, but no message event. This, i believe, is because the card is not using NDEF. I also have a few Tags which do work fine.

So it seems that the way forward is to forget the proximity API and look for a library (C++) which can talk to the NFC reader more natively, which hopefully will allow my application to communicate with the card using simple APDU commands.

Has anyone communicated with smartcards using APDUs on a Windows Phone 8 app yet, and if so, what was the tech stack used? My hope is to use the C# managed environment (i.e. use the designers etc to create the UI) in combination with a library which can handle the communication with the card via the NFC reader buit into the phone.

Any advice would be greatly appreciated.

like image 386
Nick Wright Avatar asked Oct 04 '13 14:10

Nick Wright


3 Answers

It is supported starting in Windows Phone 8.1 however it requires driver support that is currently only available for the NXP PN547 NFC chip that is only available in the Lumia 830 and 73x devices (but most future devices should also support it going forward)

Assuming that hardware limitation isn't a deal-breaker for you, there's some sample code showing the use the of the APIs here: http://nfcsmartcardreader.codeplex.com

like image 131
Alex Avatar answered Nov 14 '22 07:11

Alex


There's good news and bad news. The good news is that there is definitely a managed APDU-level API. The bad news is that you can't use it! For starters, the API only provides access to the phone's secure element, and not to external cards over NFC. There doesn't seem to be a documented API for that.

Even if one exists, special contracts are needed with carriers/MNOs/manufacturers to even use them, and another with Microsoft to get them in the store. Everyone has their own interests here, and MNOs especially tend to guard them jealously. One need look only at Google Wallet's tribulations with NFC payments to see that.

The challenge here is business, not documentation. If you have the business side in place, you'll have the API - but I'm afraid that I can't help you with that!

like image 36
Ben Avatar answered Nov 14 '22 08:11

Ben


Ok, seems like we're in business. I've been testing smartcard communication using the Windows.Devices.SmartCards namespace delivered with windows phone 8.1.

There is one big'ish drawback, you do need a windows phone with the new PN547 chipset to play with it. But I have one, and its working well. Several lines of code and I'm talking with a JCOP smartcard using APDU's.

A great intro video here:

http://channel9.msdn.com/series/Building-Apps-for-Windows-Phone-8-1/15#time=25m40s

like image 1
Nick Wright Avatar answered Nov 14 '22 07:11

Nick Wright