Commit graph

417 commits

Author SHA1 Message Date
Romuald Conty
8b2de449c7 define le32toh and htole32, this allow to compile against libc that doesn't provide these functions (like Debian Lenny) 2010-02-24 21:52:45 +00:00
Romain Tartiere
8a62a843ac Fix the test_mifare_classic_format unit test. 2010-02-23 14:22:23 +00:00
Romain Tartiere
ce006c3cc9 Change a secret ninja guru one-line expression into a function and document what it is supposed to do and how it does it. 2010-02-23 12:05:14 +00:00
Romain Tartiere
5f7f8ffe2a Add support for MIFARE Classic 4K.
- New mifare_classic_first_sector_block(), mifare_classic_last_sector_block() functions to ease detection of sectors boundaries;
  - New unit tests for mifare_classic_first_sector_block() and mifare_classic_last_sector_block();
  - Start to update the API for consistently using blocks and not mixing blocks and sectors with mifare_classic_*() functions;
  - Update the mifare-classic-format(1) example to handle MIFARE Classic 1k and 4k.

Many thanks to Johann Dantant from SpringCard for giving me MIFARE Classic 4k cards.
2010-02-23 02:12:18 +00:00
Romain Tartiere
24a9198f41 Fix wrong MIFARE Classic 4K SAK. 2010-02-23 02:03:45 +00:00
Romain Tartiere
ffcc3174b2 Add missing block_number <- block that prevented full cache hits. 2010-02-23 02:00:04 +00:00
Romain Tartiere
0f8ec71198 Add a unit test for mifare_classic_get_uid(). 2010-02-22 17:30:50 +00:00
Romain Tartiere
e0d2405a30 Rework data structures allocations / frees.
- New mifare_*_tag_new() functions for allocating and initialising memory for a given MIFARE tag;
  - Rename mifare_*_free_tag() to mifare_*_tag_free() for consistent names with mifare_*_tag_new() functions.
2010-02-22 12:25:23 +00:00
Romain Tartiere
e52fbccb4a Remove unneeded header. 2010-02-22 12:05:48 +00:00
Romain Tartiere
74bc239a71 Abstract tag manipulation functions.
- Factorize Mifare*Tag as MifareTag;
  - Factorize mifare_*_get_tags() / mifare_*_free_tags() as freefare_get_tags() and freefare_free_tags();
  - Add a new freefare_get_tag_type() function to get a tag type;
  - Update regression test suite;
  - Update example.

While this is a major change that basically change all the API, programs using libfreefare should be easily modified by replacing any Mifare*Tag variable by a generic MifareTag one, adding a few lines of code to check the target's type using freefare_get_tag_type(), and changing any call to mifare_*_get_tags() / mifare_*_free_tags() by the generic freefare_get_tags() and freefare_free_tags() functions.
2010-02-19 14:50:18 +00:00
Romain Tartiere
2fd329e530 Do not make regression tests fail: spamming my shell is enouth to reminf me to fix this. 2010-02-19 14:40:28 +00:00
Romain Tartiere
d76da4697b Update files headers and Ids. 2010-02-19 10:43:06 +00:00
Romain Tartiere
1b6d7ab210 Fix MIFARE UltraLight UID length.
Okay, either I lost some code somewhere, or I am really mad _AND_ fu**ing good at writing C code 'cause I am pretty sure I already fixed that at the very beginning of the UltraLight tags support and only after wrote all these test I don't have to modify so they pass.
2010-02-18 18:32:53 +00:00
Romain Tartiere
4c2da817f0 Fix MIFARE UltraLight related code (C99 compliance). 2010-02-18 18:13:48 +00:00
Romain Tartiere
6d5224472c Fix MIFARE Classic unit tests default key.
According to the NXP documentation, default keys are 0xffffffffffff, not 0xa0a1a2a3a4a5 nor 0xd3f7d3f7d3f7.
2010-02-18 18:12:36 +00:00
Romain Tartiere
2380583ec6 fix the mifare_classic_transfer() function. 2010-02-18 18:09:34 +00:00
Romain Tartiere
acb00368c6 Mark test_mifare_classic_get_trailer_permission() as pending.
This test requires a valid MAD to be present on the MIFARE card which is not a requirement for testing MIFARE Classic tags but MAD.
2010-02-18 17:14:37 +00:00
Romain Tartiere
2f24959116 Fix default permissions. 2010-02-18 17:07:36 +00:00
Romain Tartiere
37c404b128 ilibfreefare: The transfer operation actually returns something. 2010-02-18 16:45:24 +00:00
Romain Tartiere
8903968ea3 Honor 'ISO C99 requires rest arguments to be used'. 2010-02-11 11:29:57 +00:00
Romain Tartiere
10b8b92eb9 Fix a brunch of warnings. 2010-01-22 16:06:26 +00:00
Romain Tartiere
ecdb1afb6e Use the new ASSERT_INACTIVE macro in mifare_classic.c. 2010-01-19 23:15:10 +00:00
Romain Tartiere
ef081454c7 Add support for MIFARE UltraLight Tags.
Many thanks to Johann Dantant from SpringCard for giving me UltraLight cards.

While here, fix a few other problems in the autostuff.
2010-01-19 23:14:25 +00:00
Romain Tartiere
cdf4404dd9 Fix wrong variable name. 2010-01-19 23:10:01 +00:00
Romain Tartiere
7f87a0180d Set _XOPEN_SOURCE to 600 for silencing gcc on GNU/Linux. 2010-01-13 13:53:45 +00:00
Romain Tartiere
0d1000e859 Fix regression tests build on FreeBSD.
While here, enhance error message when no MIFARE Classic tag can be found on the NFC device when running test_mifare_classic.la tests.
2010-01-12 15:38:56 +00:00
Romuald Conty
576801d5ff Fix build when cutter is not available. (make distcheck ok) 2010-01-11 20:25:28 +00:00
Romain Tartiere
c1bcb966ea Rework unit tests using cutter. 2010-01-11 20:14:30 +00:00
Romain Tartiere
935ab47c54 Update the mifare-classic-format example. 2010-01-10 14:24:26 +00:00
Romain Tartiere
d8b0a18752 Fix invalid memory access in CRC8 computation functions. 2010-01-09 02:55:42 +00:00
Romain Tartiere
1c62fc83e6 Handle the special case of sector #0 when formatting (sector is read-only). 2010-01-09 01:37:36 +00:00
Romain Tartiere
517eef97cf The mifare_classic_format_sector prototype was changed on changeset 88. Update unit test accordingly. 2010-01-09 01:36:24 +00:00
Romain Tartiere
7a68e0f6ce Fix MadAid field orders (transfer bytes order is big endian). 2010-01-08 22:44:33 +00:00
Romuald Conty
3e00c7899a mifare_classic_get_tags() now return NULL when on failure and a one-entry array set to NULL when no tag is available (tags[0] == NULL). 2010-01-08 21:00:57 +00:00
Romuald Conty
756dc74969 move ACLOCAL_AMFLAGS to top Makefile.am 2010-01-08 20:58:29 +00:00
Romuald Conty
24ef79eca4 fix mifare_classic_get_uid(). 2010-01-08 16:34:43 +00:00
Romuald Conty
75d7ba4adb fix include header in mad.c 2010-01-08 16:17:21 +00:00
Romain Tartiere
2b76328c78 Unbreak example and add autotool stuff to help building. 2010-01-08 13:40:39 +00:00
Romain Tartiere
0c0d8e77a3 Add Makefile.am forgotten in the previous commit. 2010-01-08 11:51:40 +00:00
Romain Tartiere
32e740ea6d Split out autojunk and actual code files. 2010-01-08 11:46:23 +00:00
Romain Tartiere
8a9d90210a Add MAD CRC support. 2010-01-08 11:24:30 +00:00
Romain Tartiere
54f4a84ead Fix Id svn:keywords (ECOPYPASTETOOFAST). 2010-01-08 09:40:52 +00:00
Romain Tartiere
7fd413789a Add error checking to mifare_classic_connect(), mifare_classic_disconnect().
Do not assume nfc_initiator_select_tag() and nfc_initiator_deselect_tag() will not return an error if the provided tag is supposed to be ready for the operation (it might have move out of the field), and let the error propagate through libfreefare to the application calling the functions.
2010-01-08 08:29:19 +00:00
Romuald Conty
76a8c8e8b1 add an example draft mifare-classic-format, a tool which can be usefull to debug :) 2010-01-06 23:44:17 +00:00
Romuald Conty
7d1495940f add an accessor to UID contained in MifareClassicTag 2010-01-06 23:42:06 +00:00
Romuald Conty
fc3c23502c add C++ compatibility. 2010-01-06 23:40:30 +00:00
Romain Tartiere
4582bfbf11 add freefare.h forgotten in previous commit. 2010-01-03 19:53:58 +00:00
Romain Tartiere
073b67be48 merge all includes into a single freefare.h header.
libmad already has a mad.h file libfreefare would conflict with.
2009-12-26 18:16:22 +00:00
Romuald Conty
3c4d6ff095 Tag is no more active if authentication failed. 2009-12-26 03:37:20 +00:00
Romuald Conty
a5dd66f77d put MifareSectorNumber type in a new mifare_common.h header.
API changed: mifare_classic_format_sector() now takes a MifareSectorNumber in argument.
2009-12-23 15:26:57 +00:00