1 # Notes on Setting up NDEF (NDEF type4a)
6 - [Notes on Setting up NDEF type4a](#Notes-on-Setting-up-NDEF)
7 - [Table of Contents](#table-of-contents)
8 - [NDEF on Desfire EV1](#NDEF-on-Desfire-EV1)
9 - [Step 1. Create Application](#Step-1-Create-Application)
10 - [Step 2. Create the Capability Container file (CC File)](#Step-2-Create-the-Capability-Container-file-CC-File)
11 - [Step 3. Create the NDEF Record File](#Step-3-Create-the-NDEF-Record-File)
12 - [Check the NDEF Record works](#Check-the-NDEF-Record-works)
14 ## NDEF type4a on Desfire EV1
17 The follow is a guide to assist in setting up a single NDEF record on an Desfire EV1 (or later).
18 Please refere to the NDEF documention and standards for assistance on the actual NDEF record setup and structure.
20 It is assumed you are fimular with using a desfire cards and commands.
22 The follow notes are based on:
23 NXP - AN11004 - MIFARE DESFire as Type 4 Tag
24 Rev. 2.4 - 22 May 2013
26 In order to setup NDEF on a Mifare Desfire card you need to create an Application and two files inside that application.
27 The application and files have some special needs in order for the standands to work and the NDEF recrod to be found.
29 ### Step 1 Create Application
31 While I beleive the App ID and File IDs dont matter (for EV1 and later)
32 I did find a reference to using the values in this example.
34 The Application MUST have the DFName of D2760000850101
35 Note: That is the hex/binary data that needs to be stored!
37 DF Name : D2760000850101 <- **Important MUST be D2760000850101**
38 AID : 000001 <- In EV1 and later can be any AID
39 FID : E110 <- In EV1 and later can be any App - FID
40 Keys : 1 <- Any number of keys (based on your needs)
41 Encryption : AES <- Any encryption.
42 ISO 2 Byte FID : Yes <- **Important MUST support 2 Byte ISO File IDs**
44 ***Proxmark Command***
45 ``` hf mfdes createapp --aid 000001 --fid E110 --ks1 0B --ks2 A1 --dfhex D2760000850101 -t des -n 0 -k 0000000000000000```
48 ``` [+] Desfire application 000001 successfully created```
50 ### Step 2 Create the Compatibility Container file (CC File)
52 The CC File is a standard file to store the needed NDEF information to find your NDEF records. This example will contrain the setup for a single NDEF record.
53 Note: You can define more than one NDEF data file if needed (not covered in this example)
55 Type : Standard data file
56 FID : 01 <- File ID can be any uniqure File ID for this AID
57 ISO FID : E103 <- **Important MUST be the 2 byte ISO File of E103**
58 Size : 0F (15 bytes) <- May need to be longer in more advanced setups.
59 Comms : Plain <- **Important the file MUST support plain communication mode**
60 Permissions : E000 <- **Read Free** write change etc key 0)
61 Note: To allow public update, set Write to E as well.
62 All keys should be set as per normal desfire rules.
64 CC File (E103) example
66 000F20003B00340406E10400FF00FF
68 Usefull items in the CC File
70 000F20003B00340406 E104 00FF 00 FF
72 | | --- 00 = Write allowed, FF = Read Only
73 | ---------- The maxium size of the NDEF record (set to the NDEF record file size)
74 --------------- The ISO 2 byte File ID for the NDEF Record file
77 Note: the NDEF Record File Size should be <= the actual data file size and >= the amount of data you have. Its not how long the actual NDEF record is.
79 ***Proxmark Commands***
83 hf mfdes createfile --aid 000001 --fid 01 --isofid E103 --amode plain --size 00000F --rrights free --wrights key0 --rwrights key0 --chrights key0 -n 0 -t aes -k 00000000000000000000000000000000 -m plain
87 [=] ---- Create file settings ----
88 [+] File type : Standard data
89 [+] File number : 0x01 (1)
90 [+] File ISO number : 0xe103
91 [+] File comm mode : Plain
92 [+] Additional access: No
93 [+] Access rights : e000
96 [+] readwrite: key 0x00
98 [=] File size : 15 (0xF) bytes
99 [+] Standard data file 01 in the app 000001 created successfully
101 Write the CC record to the file
103 hf mfdes write --aid 000001 --fid 01 -d 000F20003B00340406E10400FF00FF -n 0 -t aes -k 00000000000000000000000000000000 -m plain
107 [=] Write data file 01 success
109 Check the contents of the CC file (note: no-auth was selected to ensure we can read without authentication, as needed for normal ndef discovery)
111 hf mfdes read --no-auth --aid 000001 --fid 01
115 [=] ------------------------------- File 01 data -------------------------------
116 [+] Read 15 bytes from file 0x01 offset 0
117 [=] Offset | Data | Ascii
118 [=] ----------------------------------------------------------------------------
119 [=] 0/0x00 | 00 0F 20 00 3B 00 34 04 06 E1 04 00 FF 00 FF | .. .;.4........
122 ### Step 3 Create the NDEF Record File
125 Type : Standard data file
126 FID : 02 <- File ID can be any uniqure File ID for this AID
127 ISO FID : E104 <- **Important MUST be the 2 byte ISO File set in the CC File**
128 Size : 00FF (255 bytes) <- Can be as big as needed, but should not be smaller then the value in the CC File
129 Comms : Plain <- **Important the file MUST support plain communication mode**
130 Permissions : E000 <- **Read Free** write change etc key 0)
131 Note: To allow public update set Write to E as well.
132 All keys should be set as per normal desfire rules.
135 NDEF data file example
137 000CD1010855016E78702E636F6DFE
139 Usefull Items in this NDEF example record
141 000C D10108 55 01 6E78702E636F6D FE
143 | | | ----------- nxp.com
144 | | -------------------- Well known record sub-type : 01 HTTP://, 02 HTTPS://
145 | ----------------------- ASCII U - URI
146 ---------------------------------- Lenght of the NDEF record (not inluding the trailing FE
148 ***Proxmark Commands***
150 Create the NDEF record file
152 hf mfdes createfile --aid 000001 --fid 02 --isofid E104 --amode plain --size 0000FF --rrights free --wrights key0 --rwrights key0 --chrights key0 -n 0 -t aes -k 00000000000000000000000000000000 -m plain
156 [=] ---- Create file settings ----
157 [+] File type : Standard data
158 [+] File number : 0x02 (2)
159 [+] File ISO number : 0xe104
160 [+] File comm mode : Plain
161 [+] Additional access: No
162 [+] Access rights : e000
165 [+] readwrite: key 0x00
166 [+] change : key 0x00
167 [=] File size : 255 (0xFF) bytes
168 [+] Standard data file 02 in the app 000001 created successfully
170 Write an NDEF record to the file
172 hf mfdes write --aid 000001 --fid 02 -d 000CD1010855016E78702E636F6DFE -n 0 -t aes -k 00000000000000000000000000000000 -m plain
176 [=] Write data file 02 success
179 ## Check the NDEF Record works
181 You can use any NDEF reading tool or device to check. If this card is presented to a mobile phone, it should visit the nxp.com web page.
183 ***Proxmark Command***
185 Check the contents of the NDEF record file
187 hf mfdes read --no-auth --aid 000001 --fid 02
191 [=] ------------------------------- File 02 data -------------------------------
192 [+] Read 255 bytes from file 0x02 offset 0
193 [=] Offset | Data | Ascii
194 [=] ----------------------------------------------------------------------------
195 [=] 0/0x00 | 00 0C D1 01 08 55 01 6E 78 70 2E 63 6F 6D FE 00 | .....U.nxp.com..
196 [=] 16/0x10 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
197 [=] 32/0x20 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
198 [=] 48/0x30 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
199 [=] 64/0x40 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
200 [=] 80/0x50 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
201 [=] 96/0x60 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
202 [=] 112/0x70 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
203 [=] 128/0x80 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
204 [=] 144/0x90 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
205 [=] 160/0xA0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
206 [=] 176/0xB0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
207 [=] 192/0xC0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
208 [=] 208/0xD0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
209 [=] 224/0xE0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
210 [=] 240/0xF0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ...............
212 Check if the NDEF record can be read correctly
218 [+] ------------ Capability Container file ------------
219 [+] Version... v2.0 ( 0x20 )
220 [+] Len....... 15 bytes ( 0x0F )
221 [+] Max bytes read 59 bytes ( 0x003B )
222 [+] Max bytes write 52 bytes ( 0x0034 )
224 [+] NDEF file control TLV
225 [+] (t) type of file.... 04
226 [+] (v) ................ 06
227 [+] file id............. E104
228 [+] Max NDEF filesize... 255 bytes ( 0x00FF )
230 [+] read ( 00 ) protection: disabled
231 [+] write ( FF ) protection: enabled
233 [+] ----------------- raw -----------------
234 [+] 000F20003B00340406E10400FF00FF
238 [=] -----------------------------------------------------
240 [+] 1 ....... Message begin
241 [+] 1 ...... Message end
242 [+] 0 ..... Chunk flag
243 [+] 1 .... Short record bit
244 [+] 0 ... ID Len present
246 [+] Header length...... 3
247 [+] Type length........ 1
248 [+] Payload length..... 8
249 [+] ID length.......... 0
250 [+] Record length...... 12
251 [+] Type name format... [ 0x01 ] Well Known Record
257 [=] 00: 01 6E 78 70 2E 63 6F 6D | .nxp.com
260 [=] uri... http://www.nxp.com