Commit graph

130 commits

Author SHA1 Message Date
Robert Quattlebaum
ec91014ebf Properly handle edge cases in AN10922 key diversification
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
2019-10-29 11:21:56 -07:00
SloCompTech
c18f702840 Fix issues for NTAG21x tags
- Change default tag from NTAG_213 to NTAG_UNKNOWN so unknown tags can
  be detected.  ntag_get_info() MUST be called after connect;
- Fix reuse function which used to reset all tag info;
- Introduce ntag21x error reporting through freefare_error(3);
2018-03-09 23:19:30 +01:00
Robert Quattlebaum
9d88c18833 Support for AN10922 key derivation
This commit implements [AN10922][] key diversification, as described in issue #77.

[AN10922]: https://www.nxp.com/docs/en/application-note/AN10922.pdf
2018-01-08 22:08:37 -08:00
Romain Tartière
69bf99b33d Run make style to indent macros 2017-06-29 12:25:53 +02:00
Romain Tartière
94bf7059b4 Remove copyright comments.
The COPYRIGHT file is already here and is more complete, while the VCS
hold accurate information about contributors and conibution date.
2017-06-29 09:29:15 +02:00
Romain Tartière
73dc0529fa Run make style to fix style 2017-06-27 13:58:31 +02:00
Martin Dagarin
b2eca838c4 Added support for NTAG 21x tags (#53) 2017-06-27 10:50:50 +02:00
Romain Tartière
5e5a0828af Merge pull request #58 from swalkner/master
Fix build with CMake
2017-04-24 09:39:09 +02:00
Stefan Walkner
565ee18b8e Fix build with CMake
- Fix library finding ('nfc' instead of 'libnfc');
- Generate config.h from template on non-win32 platforms;
- While here, include protection for config.h in several files.
2017-04-24 09:35:08 +02:00
Romain Tartière
3975019b3c Fix cast from pointer to integer of different size 2017-04-19 13:15:19 +02:00
Eric Betts
1f3ed91214 Add macOS endian support to felicia read ndef example 2017-04-03 16:43:23 -07:00
Romain Tartière
e17a54c18e Check tag is a FeliCa before dumping it. 2016-01-18 17:13:22 +01:00
Romain Tartière
343959c5dc Stop leaking UID 2015-06-01 13:16:11 +02:00
Romain Tartière
2c47f42538 Actually accept -o. 2015-05-13 19:52:33 +02:00
Romain Tartière
ac50476c99 No need to connect/disconnect FeliCa targets. 2015-05-13 19:52:08 +02:00
Romain Tartière
6049acaf5a Introduce experimental FeliCa Lite API. 2015-05-13 02:06:55 +02:00
Romain Tartière
1ce3db3ca6 Improve naming consistency.
Ensure all MIFARE related names and structures start with "mifare_" or
"MIFARE_".
2015-05-12 13:52:18 +02:00
Romain Tartière
faac4ae5d8 Fix white spaces inconsistencies. 2015-05-12 13:19:00 +02:00
Romain Tartière
6984e162e6 Fix " \t" sequences. 2015-05-12 12:25:44 +02:00
Romain Tartière
07695f4c18 Remove subversion artifacts.
We do not have $Id$ to expand anymore.
2015-05-12 12:22:39 +02:00
Romain Tartière
42b21ff42f Rename MifareTag to FreefareTag.
Because we are libfreefare and not libmifare, the generic tag type
should not be so specific.
2015-05-11 18:55:20 +02:00
Romain Tartière
d946230aec Fix compiler warning. 2015-05-11 18:39:32 +02:00
Romain Tartière
646a20da34 Add missing break.
This had no incidence on the code, but this change make things more
consistent.
2014-04-13 19:47:56 +02:00
Romain Tartière
c42dfce78d Style. 2014-04-13 19:41:17 +02:00
Don Coleman
14219ab145 add -y flag to mifare-classic-write-ndef
write without confirmation
2013-07-14 22:55:56 +02:00
Philippe Teuwen
f86ad5a183 mifare-classic-read-ndef: skip NULL TLV & proprio TLV 2013-07-14 21:18:28 +02:00
Dominik Heidler
cc36619f13 mifare-classic-format option: read keys from dump 2013-05-03 09:58:22 +02:00
Philippe Teuwen
00e999dd52 Ugly fix as workaround of FIXME mifare_desfire.c read_data() 2013-04-29 00:51:06 +02:00
Philippe Teuwen
061b41ed2d Align with libnfc API change: test nfc_init() result 2013-03-30 18:07:34 +01:00
Philippe Teuwen
bddb688df6 Add mifare-ultralight-info to dpkg & CMakeList 2013-01-14 10:11:02 +01:00
Romuald Conty
3dd6edcb3a updates library examples to use libnfc 1.7.0 API 2012-12-23 21:30:10 +00:00
Philippe Teuwen
9fda402cd3 add test default ULC key in mifare-ultralight-info 2012-11-13 23:36:07 +00:00
Ludovic Rousseau
f60bb7e613 Fix compiler warning
mifare-desfire-access.c:102: warning: initialization discards qualifiers
from pointer target type
2012-05-18 16:27:23 +00:00
Ludovic Rousseau
4a8dc7a4c6 Fix compiler warning
mifare-classic-format.c:62: warning: no previous prototype for ‘display_progress’
2012-05-18 16:21:26 +00:00
Ludovic Rousseau
5dc7a20c1c Fix compiler warnings
mifare-classic-write-ndef.c:67: warning: no previous prototype for ‘search_sector_key’
mifare-classic-write-ndef.c:105: warning: no previous prototype for ‘fix_mad_trailer_block’
2012-05-18 16:20:15 +00:00
Ludovic Rousseau
1a9fcabf89 Declare internal function usage() as static 2012-05-18 16:18:45 +00:00
Philippe Teuwen
8418ac96e6 examples remove math.h and replace pow(2, x) by 1 << x 2012-05-17 07:40:29 +00:00
Philippe Teuwen
90f41b245e examples/mifare-desfire-create-ndef.c EV1: don't change key settings and set dynamically ndef size 2012-05-15 21:22:35 +00:00
Philippe Teuwen
465a6aaaf0 examples/mifare-desfire-*-ndef add support for mapping v2.0 and EV1 2012-05-15 21:22:25 +00:00
Philippe Teuwen
0268a9f975 examples/mifare-desfire-format also resets key settings 2012-05-15 21:22:16 +00:00
Philippe Teuwen
7594b53009 Restore explicit linkage to libnfc (revert partially r1011) 2012-05-15 14:46:09 +00:00
Philippe Teuwen
9d34554270 examples/mifare-desfire-create-ndef.c prepare for DF EV1 NDEF mapping 2012-05-15 12:34:17 +00:00
Philippe Teuwen
5bec80fb07 examples/mifare-desfire-ev1*: test version to ensure we've at least an EV1 2012-05-15 11:50:10 +00:00
Romain Tartiere
3c9331f1ce Add new example: mifare-ultralight-info. 2012-05-14 14:25:57 +00:00
Romain Tartiere
6587728f5e Don't link to the libnfc (twice) since the libfreefare itself is linked against it. 2012-05-14 14:19:59 +00:00
Philippe Teuwen
e9cf48081b few missing free() 2012-03-15 09:16:55 +00:00
Philippe Teuwen
e096f1f421 fix issues in spilling ndef data to stdout and fix bug in mifare-desfire-write-ndef 2012-03-15 08:56:14 +00:00
Philippe Teuwen
23700b5cdd add mifare-desfire-read-ndef, read CC in mifare-desfire-write-ndef 2012-03-15 01:48:43 +00:00
Philippe Teuwen
0b14aa4eb2 allow input file for mifare-desfire-write-ndef & small fixes 2012-03-14 23:52:05 +00:00
Philippe Teuwen
acf5180177 add non-default key option to mifare-desfire-* examples 2012-03-14 23:05:10 +00:00