Enhanced support for DESFire tag emulation#351
Enhanced support for DESFire tag emulation#351maxieds wants to merge 32 commits intoemsec:masterfrom
Conversation
…ich uses a lot of extra buffer space - when was the last time this compiled with make desfire?
…e (run multiple times) - Still need to check the command runs live
…kefile (DESFire emulation)
|
Please note that this pull request is currently incomplete. I am stashing a working copy of the write-up for the PR here tonight. I am still working on the implementation of the software-based AES-192 and AES-256 encryption modes. This was supposed to be a one-day project, but as in most things software I am going to have to quit, sleep and multiply by 2-3. I will post back when the final branch is ready to be reviewed. |
…led - still not working - see added comments in the source code about possible ways to fix the issue
|
When it comes to the AES192/256 bootloaders: As far as I'm aware, the HW crypto engine in the XMEGA supports only 128bit AES. The AN you linked only describes a process for the bootloader to decrypt AES192/256 encrypted FW. So this is relevant iff we'd encrypt our FW builds. BTW, while it's nice to have the option to set the PICC specific settings (ATQA, manufacturer data, ...) using terminal commands, is it possible that those functions are using up the much needed space? It's perfectly ok to only change the UID (and possibly ATQA) using the terminal commands and rely on the UPLOAD/DOWNLOAD function for the rest. This would mean that those fields can only be changed by uploading a dump (which is definitely fine and easy). As for the huge LUT for Gallagher: Unfortunately, that has to be there. It's a reverse engineered LUT from a different project. |
|
The build script code to grep the config file for complete default configuration of a DESFire tag is implemented with a bash script (not built into the firmware) that outputs Update (see below): No, it's not the default configuration structures. |
…ady to begin LibNFC testing code
|
What remains to complete the pull request is to write the LibNFC test code for the new AES-192 and AES-256 encryption routines. I'm going to have to come back to this another day. |
… - Kludgy hack: restrict the Chameleon terminal commands to only essential functionality (tweak as needed) - it works again
|
The issue with Gallagher support compilation is now fixed. @tomaspre: Does the new build have all the terminal commands you need to run Gallagher support? |
|
I've been thinking about this over the weekend, and I feel like it's a better idea to restrict the number of slots to seven or maybe even six. That should be enough space for all the code. :-) |
…- Now works after restricting to two config slots (cannot go higher)
|
@tomaspre |
…ifact (minor changes)
…cryption modes II (cleanup)
…cryption modes III
|
@fptrs @david-oswald $ LIBNFC_LOG_LEVEL=3 nfc-list -v
info libnfc.config Unable to open file: /opt/local/etc/nfc/libnfc.conf
debug libnfc.config Unable to open directory: /opt/local/etc/nfc/devices.d
debug libnfc.general log_level is set to 3
debug libnfc.general allow_autoscan is set to true
debug libnfc.general allow_intrusive_scan is set to false
debug libnfc.general 0 device(s) defined by user
nfc-list uses libnfc 1.7.1
debug libnfc.driver.acr122_usb device found: Bus 020 Device 009 Name ACS ACR122
debug libnfc.general 1 device(s) found using acr122_usb driver
debug libnfc.general 0 device(s) found using pn53x_usb driver
debug libnfc.driver.acr122_usb 3 element(s) have been decoded from "acr122_usb:020:009"
error libnfc.driver.acr122_usb Unable to set alternate setting on USB interface (Result too large)
debug libnfc.general Unable to open "acr122_usb:020:009".
nfc-list: ERROR: Unable to open NFC device: acr122_usb:020:009
$ LIBNFC_LOG_LEVEL=3 nfc-scan-device -v
info libnfc.config Unable to open file: /opt/local/etc/nfc/libnfc.conf
debug libnfc.config Unable to open directory: /opt/local/etc/nfc/devices.d
debug libnfc.general log_level is set to 3
debug libnfc.general allow_autoscan is set to true
debug libnfc.general allow_intrusive_scan is set to false
debug libnfc.general 0 device(s) defined by user
nfc-scan-device uses libnfc 1.7.1
debug libnfc.driver.acr122_usb device found: Bus 020 Device 010 Name ACS ACR122
debug libnfc.general 1 device(s) found using acr122_usb driver
debug libnfc.general 0 device(s) found using pn53x_usb driver
1 NFC device(s) found:
debug libnfc.driver.acr122_usb 3 element(s) have been decoded from "acr122_usb:020:010"
error libnfc.driver.acr122_usb Unable to set alternate setting on USB interface (Result too large)
debug libnfc.general Unable to open "acr122_usb:020:010".
nfc_open failed for acr122_usb:020:010Please merge the commits into the DESFire emulation when you can. Thank you guys at KAOS for the development hardware :) |
|
@fptrs @david-oswald |
|
The KAOS guys have tasked me with some maintenance for this repo. I'll try to go through your code and merge it asap. However, since you were not able to test it, it will probably take some time. Also, could you please let me know of a practical use case for AES192/256 in DESFire? :-) As far as I know, even DESFire EV3 only supports AES128. |
|
@tomaspre |
|
@tomaspre # From within the Github firmware directory:
$ cd Software/DESFireLibNFCTesting
$ make
$ chmod + x ./Bin/TestAuthenticateAES*.exe
# Touch Chameleon RevG to ACR reader:
$ ./Bin/TestAuthenticateAES128.exe
$ ./Bin/TestAuthenticateAES192.exe
$ ./Bin/TestAuthenticateAES256.exeAs far as whether Mifare DESFire tags in the wild support better than AES-128 bit encryption, I could not find a good data sheet reference, though Google's AI suggests the following: |
|
@tomaspre |
|
@maxieds DESFire EV1/EV2/EV3 only support AES128. Complementary products around the DESFire family have some support of greater key length (eg. NXP SAM AV3), but the RFID chip itself not at this moment. Still, it could be good to be future proof for the next generation DESFire products I guess. |

Pull request - Enhanced support for DESFire emulation
New features provided
DF_KEYSCRUBcommand in the Chameleon terminal. It overwrites the DESFire AES/3DES key and IV buffers with random bytes one time. Successive calls to this command can be used to effectively obliterate the stored key data.but this boot loader support would allow hardware enabled AES-192 and AES-256 encryption.
Makefile. These settings are discussed in the DESFire Support documentation. The relevantMakefilelines for the default configurations are reproduced below:Firmware/Chameleon-Mini/DESFireCustomConfig/*.cfg) default PICC configurations. See the DESFire Support documentation: custom builds usingmake desire-custom-tag. The configuration file syntax is as in the following skeleton file:# Configuration settings to emulate a custom tag UID=xxxxxxxxxxxxxx ATS=NNxxxx[...] ATQA=xxxx ManuID=xx HwType=xx HwSubtype=xx HwProtoType=xx HwVers=mmMM SwType=xx SwSubtype=xx SwProtoType=xx SwVers=mmMM BatchNo=xxxxxxxxxx ProdDate=WWYYFirmware/Chameleon-Mini/Makefile:SETTINGS += -DDESFIRE_DEFAULT_PICC_MASTER_KEY='"My key string..."'DESFire Gallagher support
Note that DESFire Gallagher support is now optional and enabled in the
Firmware/Chameleon-MiniMakefileby uncommenting:TODO / NOTE: The current firmware compiled with
make clean && make desfirecrashes out with the following error when building with DESFire Gallagher support (enabled as above): "Application Section size 66205 excedes maximum allowed 65536. Please disable some features in Makefile" -- even with extended AES-192/256 support disabled. Can we save some space by omitting the largelut(scramblefunction) buffer and compute these values on the fly -- possibly with a penalty of slower scramble function performance?