ec91014ebf
This commit fixes issue #91. [AN10922][] specifies the key diversification algorithms used by the MIFARE SAM AV3. Support for these algorithms was added to `libfreefare` via pull-request #79. However, while every attempt was made to write a faithful implementation, the implemented code did not properly handle cases where the diversification data was less than or equal to the block size of the cipher: 16 bytes for AES, and 8 bytes for DES. This bug was identified in issue #91. This commit addresses this problem while providing a way to revert to the previous behavior in cases where it is necessary to maintain previous deployments. This was accomplished by introducing a new `flags` parameter to the `mifare_key_deriver_new_an10922` method. Normally, `flags` should simply be set to `AN10922_FLAG_DEFAULT`. However, if the previous behavior is required, it should be set to `AN10922_FLAG_EMULATE_ISSUE_91`. [AN10922][] does not include any test vectors that might have helped to identify this problem earlier. However, [AN10957][] (pages 13-14) was found to have a suitable example usage of [AN10922][] with an appropriately short value for *M* that we are using as a test vector to verify correct behavior. Note that the issue being addressed here is not a security issue: using the `AN10922_FLAG_EMULATE_ISSUE_91` should not be any less secure than using `AN10922_FLAG_DEFAULT`. [AN10922]: https://www.nxp.com/docs/en/application-note/AN10922.pdf [AN10957]: https://www.nxp.com/docs/en/application-note/AN10957.pdf |
||
---|---|---|
cmake | ||
contrib | ||
debian | ||
examples | ||
libfreefare | ||
m4 | ||
test | ||
.gitignore | ||
.travis-ci-build | ||
.travis.yml | ||
AUTHORS | ||
ChangeLog | ||
CMakeLists.txt | ||
configure.ac | ||
COPYING | ||
HACKING.md | ||
libfreefare.pc.in | ||
Makefile.am | ||
NEWS | ||
README.md | ||
TODO | ||
Updating.md |
Introduction
The libfreefare project provides a convenient API for MIFARE card manipulations.
It is part of the nfc-tools, you can find more info on them on the nfc-tools wiki.
If you are new to libfreefare or the nfc-tools, you should collect useful information on the project website and the dedicated forums.
Feature matrix
Tags
Tag | Status |
---|---|
FeliCa Lite | Supported |
MIFARE Classic 1k | Supported |
MIFARE Classic 4k | Supported |
MIFARE DESFire 2k | Supported |
MIFARE DESFire 4k | Supported |
MIFARE DESFire 8k | Supported |
MIFARE DESFire EV1 | Supported |
MIFARE Mini | Supported |
MIFARE Plus S 2k | Not supported |
MIFARE Plus S 4k | Not supported |
MIFARE Plus X 2k | Not supported |
MIFARE Plus X 4k | Not supported |
MIFARE Ultralight | Supported |
MIFARE Ultralight C | Supported |
NTAG21x | Supported |
Specifications
Specification | Status |
---|---|
Mifare Application Directory (MAD) v1 | Supported |
Mifare Application Directory (MAD) v2 | Supported |
Mifare Application Directory (MAD) v3 | Supported (part of Mifare DESFire support) |
Installation
For *NIX systems
You can use released version (see Download section) or development version:
First, ensure all dependencies are installed:
- libnfc;
- git;
- Autotools (autoconf, automake, libtool);
- OpenSSL development package.
apt-get install autoconf automake git libtool libssl-dev pkg-config
Clone this repository:
git clone https://github.com/nfc-tools/libfreefare.git
cd libfreefare
Before compiling, remember to run:
autoreconf -vis
You can now compile libfreefare the usual autotools way:
./configure --prefix=/usr
make
sudo make install
For Windows Systems
Requirements
- cmake
- make
- mingw{32,64}-gcc
Building
mingw64-cmake -DLIBNFC_INCLUDE_DIRS=/path/to/libnfc-source/include -DLIBNFC_LIBRARIES=/path/to/libnfc.dll
mingw64-make
Debug
In order to debug using gdb, you should tune the CFLAGS:
CFLAGS="-O0 -ggdb" ./configure --prefix=/usr
make clean all
It is then possible to debug examples using this kind of command from the root of the repository:
./libtool --mode=execute gdb examples/mifare-classic-write-ndef
If you are only interested in viewing transfert traces between the PCD and the PICC, simply use the --enable-debug
configure flag:
./configure --enable-debug
make clean all