MIFARE DESFire ® C console software example

Step by step overview of the MIFARE DESFire ® C console software example. 

1. Application overview

Link: https://www.d-logic.net/code/nfc-rfid-reader-sdk/ufr-ds-examples-c.git

When you start application, it looks like this:

MIFARE DESFire C Console software example - Digital Logic 1

Key for authentication, AID, AID key number for authentication, File ID and internal key index are read out from config.txt file.

 

1.1. Config file explanation (config.txt)

Configuration file config.txt is loaded when the application starts. There are key for authentication, AID, ordinal  number of key in AID for authentication, File ID and internal key index (when key stored into reader).

File structure:
DES key: 0000000000000000
AID 3 bytes hex: 000000
AID key number for auth: 0
File ID: 1
Internal key number: 0

First line contains key type, and hexadecimal value of key.
If key type is DES (8 bytes) then 16 characters must be entered (DES key: 0102030405060708)
If key type is 2K3DES (16 bytes) then 32 characters must be entered (2K3DES key: 01020304050607080910111213141516)
If key type is 3K3DES (24 bytes) then 48 characters must be entered (3K3DES key: 010203040506070809101112131415161718192021222324)
If key type is AES (16 bytes) then 32 characters must be entered (AES key: 01020304050607080910111213141516)

Second line contains AID, 6 characters must be entered (AID 3 bytes hex: 010203)

Third line contains ordinal number in application for authentication (0 to maximal number of application keys – 1)

Fourth line contains index of File ID in application. If the function don’t use this parameter, then this value be ignored.

Fifth line contains ordinal number of key for authentication stored into reader.

Configuration file can be changed from application when ‘t’ pressed (Change config parameters).
First, you will see current config.txt file with options 1 – 5 for changing and esc for back to main menu.

MIFARE DESFire C Console software example - Digital Logic 2

For key changing press ‘1’. There are four types of key for authentication.

MIFARE DESFire C Console software example - Digital Logic 3

For example press ‘3’ for 3K3DES key. Enter 24 bytes in hexadecimal format (48 characters).

MIFARE DESFire C Console software example - Digital Logic 4

When the changing is over, press ESC button for return in main menu, and then press ‘t’ for modification checking.

MIFARE DESFire C Console software example - Digital Logic 5

The type and value of authentication key is changed.

 

1.2.  Change authentication mode (0)

For switching between internal or provided key authentication, press ‘0’ on keyboard.
It looks like this (here is ‘0’ pressed twice):

MIFARE DESFire C Console software example - Digital Logic 6

 

1.3. Master key authentication (1)

For switching between master key authentication, press ‘1’ on keyboard.
It looks like this (here is ‘1’ pressed twice):

MIFARE DESFire C Console software example - Digital Logic 7

Whether authentication is required or not, depends on the master key of the card or application settings.

 

1.4. Get card UID (2)

For card UID (7 bytes) press ‘2’. Valid authentication with master or application key is required.

MIFARE DESFire C Console software example - Digital Logic 8

 

1.5. Format card (3)

Pressing number ‘3’ on your keyboard will cause formatting card (deleting all applications and files except AID with number: 000000).
Depends on which authentication mode you chose, it will look for AES key into reader (INTERNAL KEY) or in config.txt file (PROVIDED KEY).

MIFARE DESFire C Console software example - Digital Logic 9

 

1.6. DES to AES (4)

Changing the card master key from factory DES key 0x0000000000000000 to AES key 0x00000000000000000000000000000000.

 

1.7. AES to DES (5)

Changing the card master key from AES key 0x00000000000000000000000000000000 to DES key 0x0000000000000000.

 

1.8. Get free memory (6)

Read the quantity of available memory on the card. 

MIFARE DESFire C Console software example - Digital Logic 10

 

1.9. Set random ID (7)

Activating the random ID card options by Set Random ID button. Required authentication using card master key.
The card returns 4 bytes random ID instead 7 bytes unique ID.
Warning: this operation is irreversible.
When this option is activated, the UID can be read by special command that requires authentication using valid key.

 

1.10. Internal key lock (8)

You have to enter password (8 characters length) to lock keys enrollment. Factory password is “11111111”.

MIFARE DESFire C Console software example - Digital Logic 11

 

1.11. Internal key unlock (9)

To unlock the possibility to enroll keys into reader, you must enter the same password to unlock keys which is entered to lock keys enrollment. Factory password is “11111111”

MIFARE DESFire C Console software example - Digital Logic 12

 

1.12. Set baud rate (a)

After activating the option ‘Set baud rate’ by pressing ‘a’ on keyboard you will see multiple choices to choose for transceive and receive baud rate. Just enter the number next to option you want to choose.

MIFARE DESFire C Console software example - Digital Logic 13

 

1.13. Get baud rate (b)

Read values of transmit and receive baud rate of reader.

MIFARE DESFire C Console software example - Digital Logic 14

 

1.14. Store key into reader (c)

First choice the type of key.

MIFARE DESFire C Console software example - Digital Logic 15

For example choice 3K3DES key. Key 0x010203040506070809101112131415161718192021222324.
Internal key index is 0. For 3K3DES keys two key fields into reader will be occupied. In this case 0 and 1. First free key index is 2. For other key types just one key field will be used. 

MIFARE DESFire C Console software example - Digital Logic 16

 

1.15. Change key (d)

Changing card master, and application master and user keys. When changing master key, then may be change the key type and value of key. Into application all keys are same type, and key type don’t be changed.
For example change master key to 3K3DES type, and value 0x010203040506070809101112131415161718192021222324.

MIFARE DESFire C Console software example - Digital Logic 17

 

1.16. Change key setting (e)

For changing key settings, carefully read available settings and chose one. Take care about setting you chose, some of them cannot be changeable anymore. If you are changing settings for AID 000000 – IT CAN’T BE FORMATTED.

MIFARE DESFire C Console software example - Digital Logic 18

 

1.17. Get key setting (f)

Read card master or application master key settings and maximal number of application keys. For example read card master key settings.

MIFARE DESFire C Console software example - Digital Logic 19

 

1.18. Make application (g)

For example make application with AES keys. AID = 0xA10000. Maximal key number 3.

MIFARE DESFire C Console software example - Digital Logic 20

 

1.19. Delete application (h)

Enter AID to delete.

MIFARE DESFire C Console software example - Digital Logic 21

 

1.20. Make file (j)

In configuration file set the AID and application master key.
For example make Standard Data File, size 100 bytes, enciphered communication.

MIFARE DESFire C Console software example - Digital Logic 22

Example: Make value file. Lower limit is 0, upper limit is 200, initial value is 100. Enciphered communication mode.

MIFARE DESFire C Console software example - Digital Logic 23

Example: Make linear record file. Size of record is 100, maximal number of records is 3, enciphered communication mode.

MIFARE DESFire C Console software example - Digital Logic 24

 

1.21. Delete file (k)

In configuration file set the AID, and application master key. Enter File ID for deleting.

MIFARE DESFire C Console software example - Digital Logic 25

 

1.22. Write Std file or Record (l)

In configuration file set the AID,  application key for Write or Read&Write access, and File ID.
For example write text to Standard data file, enciphered communication mode. Text read from file write.txt. Size of text must be less or equal to size of file.

MIFARE DESFire C Console software example - Digital Logic 26

Example: Write record file.

MIFARE DESFire C Console software example - Digital Logic 26

 

1.23. Read Std file or Records (m)

In configuration file set the AID,  application master key, and File ID.
For example read data from Standard data file, enciphered communication mode. Read data will be saved into read.txt file.

MIFARE DESFire C Console software example - Digital Logic 28

Example: Read two records.

MIFARE DESFire C Console software example - Digital Logic 29

 

1.24. Read value file (n)

In the configuration file set authentication key, AID, AID key number for reading, and File ID.

MIFARE DESFire C Console software example - Digital Logic 30

1.25. Increase value file (o)

In the configuration file set authentication key, AID, AID key number for Read&Write access, and File ID.
Example: Increase value file by 20.

MIFARE DESFire C Console software example - Digital Logic 31

 

1.26. Decrease value file (p)

In the configuration file set authentication key, AID, AID key number for Read, Write or Read&Write access, and File ID.
Example: Decrease value file by 20.

MIFARE DESFire C Console software example - Digital Logic 32

 

1.27. Clear record file (r)

In the configuration file set authentication key, AID, AID key number for Read&Write access, and File ID. All records in the Linear or Cyclic Record file will be deleted.

MIFARE DESFire C Console software example - Digital Logic 33

 

1.28. Get Application AIDs (s)

In the configuration file set card master authentication key, AID = 0x000000.

MIFARE DESFire C Console software example - Digital Logic 34

 

Additional links:

To browse or download other software examples visit our Gitlab Software repository.
For purchasing our devices, visit our official online store.
Feel free to contact our technical support if you have any questions about our software examples.