Question

Is there any library in Android that can communicate with NFC device due to ISO 7816-4 standard? I mean ready commands that implements the APDU's and there's no need to send bytes manualy?

Or maybe the only way to do it is to send to my device bytes from APDU? If so, how to construct proper APDU and figure out fields values (CLA, INS etc...)?

My intention is to enter the directory on card and read files from the card.

Thanks for sharing your knowledge - in advance :)

Was it helpful?

Solution

I'm not aware of a standard library (neither for android nor any other plattform) and the probability to find one is low, since cards have so different subsets of commands and features implemented. What benefit has a uniform library, if one has no certainty, that the resulting APDU will work? Therefore most solutions employ a middleware, which uses description files showing the supported features, sometimes combined with some active code to reformat the commands or compose a wanted functionality by a sequence of APDUs. Due to the big efforts for such a solution, most of them are strictly purpose-oriented, like PKCS#11. So either your solution addresses a small sector, for which such a framework exists, or you will have to combine these bytes yourself. Have a look at this answer for 7816 pointers, where part 4, part 8 and part 9 are most important, or search for ISO 24727 (also a multi-part standard) which also attempts a unifying front-end over cards from different manufacturers.

A problem with your specific problem is, that there is no standardized "directory" command (proprietary commands often exist). While there is an EF.DIR, it is simply a list of applications on card (represented by their AIDs), which is a level above the files, so you would need the application specification in addition. Also reading is likely to require an access right, so some kind of authentication (PIN or challenge-response test) will be needed before.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top