Default NFC commands - nfc

I'm trying to figure out how one encodes an NFC tag so that it provokes default behavior on NFC enabled devices akin to what's depicted in this youtube video:
http://www.youtube.com/watch?v=HQFrQLpxhno
My assumption is that the NFC tag must contain the instruction for the listening device to use whatever means it can to follow a link (?)... I'm guessing of course, but that would make sense. My bigger question is where do I find the full spec for what default commands are possible via NFC.
TIA

You can find command specifications for various types of NFC tags at http://www.nfc-forum.org/specs/spec_list/#tagtypes
Message types, to which an NFC-enabled device may respond, are detailed at http://www.nfc-forum.org/specs/spec_list/#rtds

Related

Is it possible to translate Javacard code to NFC?

I was wondering if it is possible to code on a NFC whatever we would code with Javacard ? I have a project where a smart card contains a biometric id to be scaned and and we want to do it wirelessly with a NFC. Do you think that is possible ? What are the boundaries of NFC ? Is it possible to do whatever we do with Javacard on NFC ? Sorry I have a lot of questions I'm not very familiar with the topic.
Yes it is possible for some Javacard's to be interacted with via NFC.
See https://github.com/OpenJavaCard/openjavacard-ndef as an example.
The answer is yes - many contactless and dual-interface cards are in fact running JavaCard applications. When you go to the higher protocol layers, the commands (APDUs) exchanged using NFC are basically the sames as using the contact interface.
In essence, NFC is a communication channel, while Javacard describes a programming framework (requiring a processor card with a certain processing power). Of course those two can be combined.
NFC is also used as term for rather dumb tags, which may provide some hardwired cryptography (as DESFire does) but not much beyond that except data storage space. There is no way, on which such a tag can process even the most basic "hello world" applet, and mastering the same communication technology does not not help much in that respect. Computing a digital signature can be considered as litmus test, what you really have.

Reading emulated NFC tag (pn71501) using IDTronic Evo HF or ACS ACR1252U

I have a device that is emulating nfc tag using pn71501 chip. I don't know how exactly code works in that device but what I definitely know this chip can emulate tag using only ISO14443 standard. So both my readers can read this type of tags but by some reason I can read from this device is UID, nothing else. As I know reading memory from tag with ISO 14443 requires block authentication but it doesn't help for me. For reading tags using IDtronic EVO HF I use software downloaded from here: https://download.idtronic.de/Card%20Reader/Card%20Reader%20HF%20SET%20SDK.zip
For ACS ACR1252U I tried many different apps including my own apps and none of them could read it.
Interesting fact is that android and ios devices can read it.
If you look at the datasheet for that chip it says "PN7150 does not support a complete card protocol. This has to be handled by the host controller"
So the chip itself might not be doing any more than than ISO 14443 A-3 and B-2 parts which really only includes the Anticollision and UID and then storing/transmitting data is handled by the host controller using the higher level protocol parts.
Also the free software you get with card readers tend to be very basic and just reads the UID for inventory purposes, you have to write your own software if you want to do more with these readers and they usually like the ACR1252U have a datasheet on how to do this.
So the question is what is the host controller attached to the NCF chip doing and software it is running?
Update based on comments
I would assume that host controller does implement one of the higher level protocols for a Type 3 or 4 Tag (most likely Type 4)
The you just need to write a program for the USB readers to correctly issue the right commands to read the right type 3 or 4 Tag.
As noted the Android (or Iphone) "Taginfo" App from NXP implements reading using the Type 3 and 4 protocols, so this should tell you what the Tag is behaving as and the you can write the software for the USB readers to match.
Type 3 and 4 specifications

Sending data, using HCE, or using secure element? (Android, Kotlin, Mifare 1k)

I'm trying to implement the functionality for emulating a Mifare One (1K/S50, ISO14443A) chip to be able to use a phone with NFC capability instead of a physical Mifare card or, if possible sending only the data to the reader.
I have this type of reader/writer: https://www.evelta.com/er302-high-frequency-nfc-writer-usb/
After looking around on forums, stackoverflow questions I found this article to be the best example:
https://medium.com/the-almanac/how-to-build-a-simple-smart-card-emulator-reader-for-android-7975fae4040f
I implemented the HCE part, run the program, and the reader beleives my phone is a Mifare chip, so far so good.
My problems:
No matter what "standard" Authentication key I tried to use...it gives me Auth error. I read this question about Auth: Authentication failure for Mifare 1K NFC tag using ACR122U NFC reader, it works on a physical Mifare card...but I don't know how to set or get to know the keys for the emulated one.
I don't get why this example emulates that exact Mifare chip type...even breakpoints don't work in the APDUService, but the reader detecting a Mifare cheap somehow.
After reading about it, I get I can't 100% emulate a physical card, so I have to send all the data I want in my APDU response with the service somehow (I beleive it's the transreceive part).
However I can't even authenticate.
I tried to look for other possible solutions:
AndroidBeam: Android - Android p2p...sounds simple, relatively high-level API, but it's being deprecated, moreover it's not guaranted that the reader will even use Android...it might be a 'simple' USB reader hardware like the one I use.
SecureElement: Ironically...it seems to be the most recommended, I read that 'yes, it's possible for mifare' and things like that, yet I couldn't find a good example of it and the official Google docs don't have any good example. I read that it's for "ISO/IEC 7816-4", but Mifare 1K is ISO14443A, so I'm a bit sceptic about this API.
"Simply" sending the data to the reader: If I could just simply "push" the data out to the reader when it's reading the phone without complicating the matter or emulating anything...it would be great but I don't know if it's even possible. This whole NFC topic seems to be more and more complex.
So alltogether I only need to do one thing: taking the data and send it to the reader.
I realized it's a fairy tale like illusion to beleive it's as simple as it sounds, still, I hope there is a way to do it.
If I could send the data in it's own, without emulating Mifare or anything...after all what matters is that the data on the card, not the type of the chip, the more simple the solution will be, the better.
Sorry for possible English grammar mistakes.
The problem is you cannot use HCE on Android to emulate a Mifare Classic 1K (https://www.nxp.com/docs/en/data-sheet/MF1S50YYX_V1.pdf) as this is a custom Type NFC card. As HCE is about emulating Type 4 cards. See https://developer.android.com/guide/topics/connectivity/nfc/hce#SupportedProtocols
And the below image helps understand the type.
You can see this from it's datasheet, nowhere does it talk about AID's and standard Type 4 NFC commands
Though Type 2 and Type 4 can share the Anti Collision mechanism and Reading the UID (which is part of the process) any other access methods are not shared.
Type 4 Spec for reference is at http://apps4android.org/nfc-specifications/NFCForum-TS-Type-4-Tag_2.0.pdf
I have seen some USB readers that offer on reader emulation of other card types but not HCE where the host does the emulation not the NFC hardware.
The Authentication on Type 4 Cards or emulated ones is handled differently.
You can emulate a MIFARE DESFire Card as that is a Type 4 card.
The specs of your card reader are not documented well and it looks very "lite" and that it does not support any of the higher level protocols needed to talk to non Mifare Classic cards. It could support them but as Mifare protocol was the original spec, it could be possible for it to be and old design and only support the Mifare protocol.

How to get the user-set "custom name" of IOUSBDeviceInterface

If I use the IOKit methods to list USB devices, I can get something like "AirPod Case", but I don't know how to get "Francisco's AirPods". I've looked around a the various keys you can ask for, but none I've found bring up these "settable" names, only the standard "product names".
I don't know the answer as a fact, but I can give you some ideas for chasing it down:
The customised name is probably transferred as part of a higher-level protocol, or via vendor specific requests, not via standardised USB device descriptors. There is a small chance it might be advertised via a vendor specific descriptor, but this seems unlikely
I don't own any AirPods, so I don't know what kind of data protocol the AirPod case uses for communicating with a Mac, but you can try to find documentation or source code for that protocol, for example in case anyone has worked out how to use them from Linux and written a tool or library for that.
Finally, you can reverse engineer it yourself, by logging the USB traffic to and from the device when using existing software that is capable of reading the name you are after. On macOS, it's possible to do this using Wireshark. Start logging USB traffic, launch the software that talks to the device, then trawl through the logs to see if you can spot the string, then work out what request caused it to be returned.

NFC IsoDep - Initial transactions

I have a NFC card that implements Mifare Plus over IsoDep, NFCa, and NDEF.
I am communicating with the card via a PC dongle, and libNfc (not android).
I have read thru the 7816-4 but am still confused as to what the first steps I should be taking when communicating with the card. Should I for example be selecting the MF or EFDir? Reading from these files?
To program reading and writing NDEF data on a Type 4 Tag requires either the NFC Forum Type 4 Tag specification or learning from existing open source code. NFC Forum specifications must now be paid for, depending on budget the other approach may be more appealing. For someone suitably familiar with the Python programming language a source of inspiration may be the Type 4 Tag reader implementation of http://nfcpy.org, in file nfc/tag/tt4.py.

Resources