Mifare DESFire EV1 4k Manufacturer Block - uniqueidentifier

I was recently using a Mifare Classic 1k smartcard. I used the manufacturer block (sector 0, block 0) to identify the card, since the UID of Mifare Classic cards is not really unique.
My application scenario is that I want to read an identifier from the smartcard and compare it to a database, in which every user has a smartcard assigned to them. So a user can log in with their card.
Now I have to use new Mifare DESFire EV1 4k cards. Do these cards also have something like the manufacturer block or just the 7-byte UID? Is it safe to use this UID to identify the card?

You can expect the 7-byte UID of genuine MIFARE DESFire EV1 cards to be unique. Be aware, though, that DESFire EV1 cards can be configured to use a random 4-byte UID. In that case, the UID is randomly generated for each RF activation. The 7-byte UID of such cards can only be obtained using the GetCardUID command (command code 0x51) after authentication.
However, you should be aware (in particular considering your use case) that the UID can easily be cloned and is not suitable to authenticate cards (or their users). See also
Serials on NFC Tags - truly unique? cloneable?
How do NFC tags prevent copying?
If you want something that is compareable to the manufacturer block of MIFARE Classic (i.e. something that reveals information about the product type and the production batch), MIFARE DESFire cards have a GetVersion command (command code 0x60).
Finally, note that the manufacturer block of a MIFARE Classic card does not really provide more uniqueness than the UID on its own. The reason for this is that the first 4 bytes of the manufacturer block are the UID itself. The next byte is the checksum over the UID (so its value is the same for cards with the same UID). The next 3 bytes are the SAK and ATQA values, which are typically '88' and '0400' for all (most?) MIFARE Classic 1K cards. The remaining bytes identify the chip type (hence identical for all cards of same type) and the production batch (hence identical for at least each batch).

Related

NFC sticker to launch website with unique URL

I can encoded an NFC Sticker with a website that will open when I tap it with a mobile phone. For the application I want to use it for I need to be able to expire that link so the user can't just save the URL and use it again. Basically I need to be able to put a random string in the URL that changes each time it gets scanned, such as www.mywebsite.com/TCHQ23, www.mywebsite.com/LQ8FT, ect.
Is this possible with a regular NFC sticker? If not, what kind of device would I use to make this happen? I know there are Arduino modules that can do this, but is there a simpler method or a ready made product that can act as an NFC but have the URL changed by a computer via a USB cable?
Thanks
NFC tags (some) have a feature called "Mirroring". You can mirror the read counter value to the URL, which gets incremented every time you tap it to reader i.e. Every time read command is called, the counter increases by 1. Tags like NTAG 213, NTAG 215 etc have that feature.
Update:
If your requirement is to get a portion of URL to to return random data and on a cheaper tag or sticker then I would suggest considering NTAG 213 tag, which is cost friendly and also have Mirroring feature supported.
If your URL data is http://www.abc#xyz.com then once the counter Mirroring is enabled (read counter must be enabled first) it will look something like
http://www.abc#xyz.com?000001
The last 6 digit value gets increased by value 1,every time a read command is invoked. (000002, 000003, 000004 and so on)
you can refer this link for more info
So your card/device has to present when read a NDEF record with a link in it (A "Well Known Type 1 with a record type definition of type U, etc), this will cause most phones to open a browser automatically
Some details on the Record type needed at https://www.oreilly.com/library/view/beginning-nfc/9781449324094/ch04.html
Most cards have the ability to store some static data, some have as #Adarsh Rotte says have counters, random number generators, crypto, password protection, mirroring (backup) of data, other functions but non of these will help as these custom functions and are card specific and don't / cannot present the data to match the NFC NDEF specification.
There is one type of card that can do this called JavaCard as these can run fully programmable Java Apps. These can be programmed to respond to NFC read request with the right NDEF measure where the URL can be generated on the fly.
There is a github repo with an example Java App to run on these cards that shows how to respond with and NDEF message at https://github.com/OpenJavaCard/openjavacard-ndef.
Watch out for https://github.com/OpenJavaCard/openjavacard-ndef/issues/10 if trying to use this, the default magic AID number is not the right one for NDEF and should be configured at the time you install the App on the Card.
This app emulates the behaviour of an NFC Type 4 spec card.
You would also need to customise it to have the right NDEF payload data with the right generated URL ending.
There are examples of the Card make/model supported by this App listed on the the github pages some are dual interface cards but there are some without the chip contacts and only NFC interface.
Generating the URL ending could be challenging or easy depending on level of security/validation you need.
Starting from a Random String which would be easy to fake because it has no level of validation, to a obfuscated counter, to a public key type encrypted counter.
There are also other solutions to generating the NDEF data with the right URL that don't use a Card and usually require there own power to run.
Some options:-
An Android phone can do what is call Host Card Emulation (HCE) which is very like what the JavaCard is doing, it is pretending to be a NFC Type 4 Card and the response it sends if fully programmable and could be the right type of NDEF message as per the JavaCard.
There are some "Card Reader" Devices that can be attach to a PC/Raspberry Pie via USB can also do HCE like the Android phone. e.g. https://www.acs.com.hk/en/products/342/acr1252u-usb-nfc-reader-iii-nfc-forum-certified-reader/ - this is well documented in the datasheets on how to do.
There are some other "Card Reader" modules that can connect via I2C to Arduino that can do HCE as well. (Technically most Arduino PN532 Chip's which are used in a lot of USB readers as well can do HCE but it is a bit undocumented on how to do it - see section 4 of https://www.nxp.com/docs/en/user-guide/141520.pdf)
There are some other chips that can act as static data NFC devices the also have an I2C interface to write the static data but allow a "pass through" mode to the I2C interface, again these tend to be NFC Type 4 but do some of the HCE type work for you.
e.g. the M24SR04-Y https://www.st.com/resource/en/datasheet/m24sr04-g.pdf can do it
So technically possible with a variety of methods but all not that simple to implement BUT not "Sticker" type format of NFC devices tend to be very simple NFC device as the format restricts the complexity of the hardware contained in them.

What is the composition of the manufacturer block of a Mifare Classic?

What information is contained within the manufacturer block of a Mifare Classic? From what I can gather:
Bytes 0 through 4 contain the UID
Byte 5 contains the BCC for the UID
What about the rest of the data?
The data sheet provides no clue, and also does not distinguish between byte 5 and others (so these may be different in chips by other manufacturers).
I assume, that you mean a sort of checksum, but don't recognize the abbreviation BCC.

Cheap DIY Desfire EV1 reader to identify students

I would like to build a (cheap) device to identify students at my university using their Student Card (called "ISIC").
My Phone (via its NFC reader on Android) tells me that these cards are :
NXP MIFARE DESFire / NXP MIFARE DESFire EV1
So far, I've tried hooking up an RC522 chip to an arduino board but wasn't able to communicate with the card (libraries are under development but I can't seem to get them working with this setup).
This is what I had in mind :
Raspberry pi 0
PN532 NFC/RFID controller breakout board
v1.6 by adafruit (which seems to be the best choice possible according to the nfc-tools wiki)
Before buying everything, here are my questions :
Has someone ever tried reading that kind of card with this board ?
Is there a cheaper and/or easier solution ?
Thanks a lot !
Depending on the situation I would recommend one of 2 options:
If you can firstly read all cards of your students and correlate the unique-UID (unique ID number for each contactless card) of each card with each student.
If you need to read the information of the card to get the student identification.
For Case 1: If your situation is "1", I would recommend that you just read the UID of each MIFARE DESFire EV1 and as far as you know the card UID of each student you would be able to identify them. Reading the UID of a MIFARE DESFire card is very easy and immediate with any reader or Android Smartphone; but before going forward with this option you should firstly check that the MIFARE DESFire cards are configured to have a non-Random UID.
To do so just read the UID of a single MIFARE DESFire card and check that the 1st byte of the UID:
If 1st byte = 0x08 -> Random UID (4 byte length)
If 1st byte = 0x04 -> You can use this proposal (7 byte length)
If "1st byte = 0x04" then you can just develop an Android application or a C application with a PC/SC reader or Raspberry PI very easily.
For Case 2:Then you need to understand how is the data stored in the MIFARE DESFire cards, if they have encription keys... You can develop applications with Android, Raspberry PI or desktop reader, but you'll need to understand better how does MIFARE DESFire EV1 works and of course the protection keys (if they have).
I hope it helps!

NFC - New Ntag21X

I'm attempting to start coding for the new NTAG21X due to be released by the end of the year. There is very limited information available regarding the new tags. Only released to partners :-(
I'm trying to figure out how to use:
password protection on the tag. Will this be a key stored in one of the sectors and how will you go about reading NDEF? Do you pass the password to read?
originality signature. Will it be a sector as on Mifare where you write key and lock the page(s) to protect.
NTAG21x is (will be) a NFC Forum Type 2 Tag (T2T) device, like NTAG203 (hence the "2" in the names). You can expect accessing functionality will be similar to standard T2T (and MIFARE Ultralight) read/write commands (so no MIFARE Classic sectors). Reading of NDEF shall be according to the T2T spec, so no password required. Write protect could be possible (similar to MIFARE Ultralight C).

is UID of mifare classic editable?

It would be nice if UID is write-protected so that I can use it to detect card clones.
So, can it be modified?
Yes and no. The standard Mifare Classic has a locked sector 0, where the UID is stored. However, if you Google changeable uid mifare, you'll find several (comparatively expensive) cards for sale with sector 0 unlocked.
As far as I know, the UID-s of the Mifare Classic are'nt guaranteed to be unique, so beware of that problem.

Resources