Commit graph

138 commits

Author SHA1 Message Date
Romain Tartiere
d098bf623f Add support for authentication using 3K3DES.
Please note that according to the NXP documentation of the Mifare DESFire EV1,
the mifare_desfire_authenticate_iso() function can be used using either 3DES or
3K3DES keys.  The former has not been tested yet and is likely not to work. To
word it differently, this is a 3K3DES crypto support, not a ISO authentication
support...
2010-12-18 02:28:27 +00:00
Romain Tartiere
79f6cb20e5 Update CMAC code to handle 64 and 128 bit keys. 2010-12-18 01:45:38 +00:00
Romain Tartiere
8d74401e87 Enlarge another buffer to workaround the read_data() buffer overrun. 2010-12-18 01:44:20 +00:00
Romain Tartiere
a6e52db696 Workaround invalid write in read_data () (sic)
This has to be improved to some extend in the near future (hence the FIXME).
2010-12-18 01:05:35 +00:00
Romain Tartiere
c9680fd7c7 Fix key_macing_length() return value when nbytes is 0. 2010-12-17 22:53:40 +00:00
Romain Tartiere
ed028d720a Fix the fix introduced at r697.
Yes, this type I typed 'make' before committing...
2010-12-17 22:45:56 +00:00
Romain Tartiere
0119a43208 Fix freed memory usage. 2010-12-17 22:38:51 +00:00
Romain Tartiere
94bf8d83c6 Fix mifare_desfire_get_key_version() when authenticated with an AES key. 2010-12-15 13:34:15 +00:00
Romain Tartiere
42f9457d9f Add support for Mifare DESFire EV1 with AES encryption. 2010-12-15 12:43:31 +00:00
Audrey Diacre
5133491c2c replace deprecated bzero function by memset. 2010-12-10 17:10:12 +00:00
Romain Tartiere
193809f949 Don't build libtestcommon.la if we are not using cutter. 2010-11-24 00:07:47 +00:00
Romain Tartiere
12de6ea4c4 Add forgotten files. 2010-11-23 18:42:25 +00:00
Romain Tartiere
c6f4343276 Fix autotools fun.
Tribute to Justice!
2010-11-23 18:38:10 +00:00
Romain Tartiere
b7a45b4da4 Use mifare_desfire_auto_authenticate() for authentication. 2010-11-21 00:32:38 +00:00
Romain Tartiere
02c9d33ce1 Move master key detection and authentication in a convenience library.
The autohell hack sucks and should be fixed, but I was unable to find the magic
trick to prevent automake from building broken libtool rules which produce
warnings about portability :-/.
2010-11-21 00:10:04 +00:00
Romain Tartiere
b932c923d5 Improve the test_mifare_rol() test. 2010-10-29 13:02:55 +00:00
Romain Tartiere
678b71edb0 Rename some macros for consistency. 2010-10-29 13:01:55 +00:00
Romain Tartiere
356219e21b Require the ivect to be provided to mifare_cbc_des().
- Store ivect in the struct mifare_desfire_tag;
- Reset it before and after authentication;
- Reset before each crypto operation (for now).
2010-10-29 12:22:47 +00:00
Romain Tartiere
13f03a60bb Change rol8() to rol() to work with buffers of any length. 2010-10-29 12:01:57 +00:00
Romain Tartiere
8dac813e53 New API function mifare_desfire_aid_get_aid(). 2010-10-17 20:21:06 +00:00
Romain Tartiere
07709c2835 New API function mifare_desfire_last_picc_error(). 2010-10-17 19:32:59 +00:00
Romain Tartiere
cf9f8d5246 Add missing file header & Id. 2010-10-08 11:43:04 +00:00
Romain Tartiere
53462219f4 Remove unused file.
The test in this file is already in test_mifare_desfire_des.c.
2010-10-08 11:41:52 +00:00
Romain Tartiere
a216a05299 Include fixture.h in fixture.c. 2010-10-08 11:34:50 +00:00
Romain Tartiere
8a477773f7 Rework OpenSSL usage.
- Lookup for crypto functions in libcrypto instead of libssl.  Some systems
  (Mac OS) do not provide libssl, and the other have crypto functions in
  libcrypto but libssl is dynamically linked against libcrypto:
  % ldd /usr/lib/libssl.so
  /usr/lib/libssl.so:
         libcrypto.so.6 => /lib/libcrypto.so.6 (0x800c00000)
         libc.so.7 => /lib/libc.so.7 (0x800647000)
- Do not explicitly link against libssl (instead of libcrypto BTW): the
  autotools magic already does this at some point;
- Improve error message when headers cannot be found.
2010-09-04 10:47:07 +00:00
Romain Tartiere
7b9242e935 Reindent (2/2).
Align cases with switch statements.
Ça y est!  Le code est beau!
2010-09-03 18:04:12 +00:00
Romain Tartiere
af061a3c1a Reindent (1/2).
After trying to tweak gindent so that it does not mess-up my ASCII art, give
and read the help of Vim to setup 'cinoptions' according to my needs
(cino=t0(0).  This changeset reindent some bits that where not indented as they
should.  A future commit will reindent the switch/case according to my (bad)
taste now that I have setup cindent correctly on my system (cino=t0(0:0).
2010-09-03 18:01:02 +00:00
Romain Tartiere
d59e197ff9 Rename desfire_error_lookup() into mifare_desfire_error_lookup() for consistency with the rest of the code. 2010-09-03 11:24:25 +00:00
Romain Tartiere
a11d067d21 Free memory. 2010-09-03 11:13:29 +00:00
Romain Tartiere
087db1b298 New unit test to check Mifare DESFire AIDs containing a Mifare Classic AID. 2010-09-03 10:54:07 +00:00
Romuald Conty
1151ffdb7f fix test affected by r548. 2010-09-02 11:04:34 +00:00
Romain Tartiere
be45b25965 Remove Snappers workarounds: the bug is in the PN531 and has been fixed in r522. 2010-08-31 11:13:17 +00:00
Romain Tartiere
878af0e22a Remove extra semi-columns at end of macro definitions. 2010-08-31 10:08:40 +00:00
Romain Tartiere
e68ae59c5e Rename mad_application_(read|write) to mifare_application_(read|write).
Fixes issue 40.
2010-08-24 10:51:58 +00:00
Romain Tartiere
1f1db8692b Fix svn:keyword (I'll commit something to handle this automagically in ~2 commits). 2010-07-29 05:58:04 +00:00
Romain Tartiere
9872a1b087 Rename DESFIRE_4K to DESFIRE.
The code can work with virtually any size of DESFire (since the operating
system embedded in the card handle almost everything), so there is no need for
us to distinguish cards of different sizes.
2010-07-27 08:44:12 +00:00
Romain Tartiere
5779d6f945 Merge the freefare-desfire branch into trunk. 2010-07-26 21:48:18 +00:00
Romain Tartiere
dbd3682174 New API functions mad_application_read(), mad_application_write(). 2010-07-03 10:04:06 +00:00
Romain Tartiere
163df002f2 Rename MifareSectorNumber to MifareClassicSectorNumber. 2010-07-03 06:31:28 +00:00
Romain Tartiere
163ce56cc0 Refactoring Blocks vs. Sectors.
- mifare_classic_format_sector() now wants a sector instead of a block (the name was really disturbing);
  - New public API functions for Block <=> Sector conversions.
2010-07-01 23:19:45 +00:00
Romain Tartiere
cc5de33a56 Rename the test_mifare_classic_application unit test to test_mifare_application. 2010-07-01 21:57:49 +00:00
Romain Tartiere
f83918ee41 Fix MAD manipulation for Mifare Classic 4K.
- Allocate large blocks on Mifare Classic 4K in unit tests;
  - Constraints sector number in mad_set_aid();
  - Fix location of AID storage in mad_set_aid() (wrong variable name and offset, ECOPYPASTETOOFAST);
  - New API function mad_sector_reserved();
  - Use mad_sector_reserved() to avoid trying to use reserved sectors.
2010-07-01 21:44:40 +00:00
Romain Tartiere
541292505a Make mifare_application_alloc() accept size in bytes.
Fixes issue 31.
2010-07-01 17:05:44 +00:00
Romain Tartiere
92ae6036d2 Add unit tests for mad_read() and mad_write(). 2010-07-01 14:10:09 +00:00
Romain Tartiere
06e61a89d5 Remove clueless omitted test. 2010-07-01 11:00:25 +00:00
Romain Tartiere
829e28cfda Complete unit tests coverage of freefare.c.
The freefare_get_tag_friendly_name() function was not tested.  Call it from both supported cards unit tests suites.
2010-07-01 10:57:59 +00:00
Romain Tartiere
5a7a9391ae Move test_mifare_classic_sector_boundaries() in it's own file.
While here, sort out lines in test/Makefile.am.
2010-07-01 10:51:07 +00:00
Romain Tartiere
d5b91f9f3a Fix function name when reporting errors. 2010-07-01 10:44:03 +00:00
Romain Tartiere
a9c026e8f2 Workaround a FreeBSD-specific bug in cutter. 2010-06-26 13:45:46 +00:00
Romain Tartiere
335eef3e2f Various TLV enhancements:
- New API function: tlv_append();
  - Added unit tests for tlv_append();
  - New internal functions: tlv_record_length(), tlv_next(), tlv_sequence_length();
  - Rework tlv_decode() to use new internal functions.
2010-06-25 00:27:14 +00:00
Romain Tartiere
a235dbd0a9 Fix TLV terminator. 0xFE is part of TLV, not NDEF. 2010-06-23 23:21:47 +00:00
Romain Tartiere
b8049f110d Add support for TLV streams.
- New API functions: tlv_encode(), tlv_decode();
  - Documentation (man page);
  - Unit tests.
2010-06-23 02:03:13 +00:00
Romain Tartiere
1f8589f2ae Don't use deprecated cutter API. 2010-04-26 09:11:28 +00:00
Romain Tartiere
c9df81d96c Use cut_omit() in tests setup() fixtures (requires cutter>=1.1.2). 2010-04-08 12:10:42 +00:00
Romain Tartiere
73c50a544a Remove deprecated API mifare_ultralight_get_uid(), mifare_classic_get_uid(). 2010-03-30 16:24:37 +00:00
Romain Tartiere
574b068b3f New API function freefare_get_tag_uid().
- Deprecates mifare_classic_get_uid() and mifare_ultralight_get_uid().
2010-03-30 16:18:58 +00:00
Romain Tartiere
feb240ee73 Fix MAD CRC algorithm.
The CRC algorithm is not a standard CRC algorithm so rename it to nxp_crc() and adjust all related code.
2010-03-18 21:03:07 +00:00
Romain Tartiere
8a62a843ac Fix the test_mifare_classic_format unit test. 2010-02-23 14:22:23 +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
0f8ec71198 Add a unit test for mifare_classic_get_uid(). 2010-02-22 17:30:50 +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
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
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
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
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
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
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
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
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
Romain Tartiere
58d83ae20a Enforce unit tests name consistency. 2009-12-21 13:58:53 +00:00
Romain Tartiere
3cab1523eb Introduce MAD application management functions. 2009-12-21 13:54:27 +00:00
Romain Tartiere
c7b8574e23 Make MAD Application Identifiers (AID) structure public as MadAid.
- Changed mad_get_aid() and mad_set_aid() ABI;
  - Update unit test;
2009-12-21 03:02:15 +00:00
Romain Tartiere
89dd817a63 Rename mifare_application_directory.[ch] to mad.[ch]. 2009-12-21 00:40:07 +00:00
Romain Tartiere
9478706550 Add MIFARE Application Directory (MAD) version 1 & 2 support (modulo CRC). 2009-12-21 00:02:40 +00:00
Romain Tartiere
a317799f01 Don't crash when no MIFARE target is present when running the regression tests suite. 2009-12-20 23:42:58 +00:00
Romain Tartiere
253d49eef8 Add forgotten regression test for mifare_classic_trailer_block(). 2009-12-19 22:59:38 +00:00
Romain Tartiere
7ed4561f74 New API function: mifare_classic_trailer_block(). 2009-12-19 06:10:44 +00:00
Romain Tartiere
b97012ac05 Add regression test suite. 2009-12-19 02:06:21 +00:00