Commit graph

214 commits

Author SHA1 Message Date
Romuald Conty
53f21706da bump libnfc needed version. 2010-09-06 09:28:14 +00:00
Romain Tartiere
b6a4982102 Attempt to detect and use CoreFoundation's headers for endianness conversions on Mac OS X.
PR:		Issue 21
Submitted by:	MathewMcBride47
2010-09-04 11:06:14 +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
05bd15b1d3 Explicitly enable auto ISO14443-4 mode.
We may be unable to locate Mifare DESFire otherwise.
2010-09-04 10:25:07 +00:00
Romain Tartiere
a260754627 Add missing include <sys/types.h> (required for some endianness magic). 2010-09-04 09:47:15 +00:00
Romain Tartiere
0db66925e1 Add some endianness macro aliases for OpenBSD. 2010-09-04 09:42:12 +00:00
Romain Tartiere
11794763b1 Complete external document reference in comment. 2010-09-04 09:16:42 +00:00
Romain Tartiere
274dfdefd2 Update the HACKING file and give some indentation sugars. 2010-09-03 18:08:18 +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
036d2956f4 Update nfc_initiator_transceive_bytes() vs. nfc_initiator_transceive_dep_bytes().
nfc_initiator_transceive_dep_bytes() was removed, and
nfc_initiator_transceive_bytes() is now configured to behave like the one or
the other of the original functions.  For details, see:
http://code.google.com/p/libnfc/source/detail?r=592
2010-09-03 16:13:46 +00:00
Romain Tartiere
70f2fe2685 Do not freeze the card Master Key in mifare-desfire-write-ndef.
Since it is irreversible, the card cannot be used for e.g. running the
regression tests suite.
2010-09-03 15:56:37 +00:00
Romain Tartiere
717e18f810 Display Master Key settings in mifare-desfire-info. 2010-09-03 15:54:58 +00:00
Romain Tartiere
9396e0010e Fix a function name I forgot to change. 2010-09-03 15:51:53 +00:00
Audrey Diacre
487bc621a9 add a new example "mifare-desfire-write-ndef" that put a simple NDEF content on DESFire. 2010-09-03 14:36:17 +00:00
Romain Tartiere
03bd356bd4 Minor tweaks.
- Improve code lisibility;
- Add reference document link.
2010-09-03 13:18:08 +00:00
Romuald Conty
bb840dccaf minor cosmetic enhancements. 2010-09-03 12:51:45 +00:00
Romain Tartiere
4c519ff9d0 Add some missing mifare_desfire_error.3 man page. 2010-09-03 11:26:41 +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
ff7f136fbe Add some missing man pages. 2010-09-03 11:16:18 +00:00
Romain Tartiere
a11d067d21 Free memory. 2010-09-03 11:13:29 +00:00
Romain Tartiere
5b1d51bd55 Enhance Mifare DESFire AID code.
- Fix endianness problems;
- Enforce AID validity;
- Simplify code.
2010-09-03 10:55:57 +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
Romuald Conty
02d09e58f7 Dirty patch to be able to create "real" MifareDESFareAID. 2010-08-31 16:03:08 +00:00
Romain Tartiere
8f645fbe62 Attempt to fix Mifare Classic support after r543. 2010-08-31 14:48:47 +00:00
Romain Tartiere
5aafbc9a48 Indent after last commit. 2010-08-31 12:00:56 +00:00
Romain Tartiere
7ba83f79ed Enhance the mifare-classic-write-ndef example.
- Only format the PICC if no MAD is present;
- Do not overwrite an existing MAD.
2010-08-31 12:00:02 +00:00
Romain Tartiere
a5f1a80447 Check Mifare Classic command return values.
Many command return 1 byte, and my documentation does not tell what it's
supposed to be. However, this byte is always 0 when running the regression test
suite.  It's likely to be an error code with value 0 being a no-error code.
Assume this and check that the returned byte is always 0.
2010-08-31 11:29:29 +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
4abbb46515 Implement file settings caching.
For the regression test-suite test_mifare_desfire, it's a ~11% performance
boost, with 206 cache hits out of 488 calls to
mifare_desfire_get_file_settings().
2010-08-31 11:08:33 +00:00
Romain Tartiere
8171dd3960 Remove an irrelevant FIXME.
The check is already done by the PICC and we may not have access to the
required information to do the check from the library. Additionally, the
mifare_desfire_change_key() would require different keys to operate if we
detected an error, so no recovery of any kind is possible.
2010-08-31 10:20:24 +00:00
Romain Tartiere
878af0e22a Remove extra semi-columns at end of macro definitions. 2010-08-31 10:08:40 +00:00
Romain Tartiere
f7c4d99868 Enhance communication settings detection failures detection. 2010-08-31 10:06:55 +00:00
Romain Tartiere
2fc0d76044 Split-out freefare_tag_new() from freefare_get_tags().
Fixes issue 39.
2010-08-24 11:41:33 +00:00
Romain Tartiere
53550cb5ed Do not call directly nfc_initiator_select_passive_target() but rather nfc_initiator_list_passive_targets() in freefare_get_tags(). 2010-08-24 11:15:42 +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
890c6e3c2e Enforce target type identification with manufacturer code comparison. 2010-08-04 16:18:12 +00:00
Romain Tartiere
3aee8b560e Do not specify Mifare DESFire target size in it's friendly name: all work the same way. 2010-08-04 16:12:18 +00:00
Romain Tartiere
03da46df65 Enforce target type identification with ATS comparison. 2010-08-04 16:11:09 +00:00
Romain Tartiere
f0e03b99fb Don't check the ATQA to determine tags type, it should not be used. 2010-08-04 12:51:34 +00:00
Romain Tartiere
bef4ec342f Don't keep unsupported tags selected.
Currently, when the libfreefare finds a NFC target, it checks whether it's a
supported one looking at it's ATQA.

If the target's ATQA is not in the supported ATQA list, the target was not
deselected.  While this is buggy, it allowed to detect 2 tags with colliding
ATQA on a single NFC device and still have the ATQA of each tag (on ATQA
collision, the ATQA is set to 0x0000 by the NFC chip, but as the tag is not
deselected, it will have a second chance to tell it's ATQA when it will be idle
again):

 computer             PCD                   PICC1   PICC2
    |                  |             ATQA:  0x1234  0x6789
    |                  |                      |       |
    |- InListTargets ->|                      |       |
    |                  |------ REQA ----->(===============)
    |                  |<---- ATQA 1234 ------|       |      } Both reply
    |                  |<---- ATQA 6789 --------------|      } simultaneously
    |                  |                      S       |
    |                  | // Collision detected PICC1 only is selected because
    |                  | // only a single tag was wanted.  It's ATQA is set
    |                  | // to 0x0000.
    |<-- ATQA 0x0000 --|                      S       |
    | // Unsuported ATQA, skipped             S       |
    |                  |                      S       |
    | // DESELECT IS MISSING HERE!            S       |
    |                  |                      S       |
    |- InListTargets ->|                      S       |
    |                  |------ REQA ----->(===============)
    |                  |<---- ATQA 6789 --------------S // PICC1 won't reply
    |<-- ATQA 0x6789 --|                      |       S // it is still selected
    | // Supported, deselect it               |       S
    |--- InDeselect -->|                      |       S
    |                  |-------- HALT --------------->X
    |                  |                      |       X
    |- InListTargets ->|                      |       X
    |                  |------ REQA ----->(===============)
    |                  |<---- ATQA 1234 ------S       X // PICC2 won't reply
    |<-- ATQA 0x1234 --|                      S       X // it is deselected
    | // Supported, deselect it               S       X
    |--- InDeselect -->|                      S       X
    |                  |-------- HALT ------->X       X
    |                  |                      X       X
    |--- InDeselect -->|                      X       X
    |                  |------ REQA ----->(===============)
    |                  |                      X       X // No reply
    |                  |                      X       X

                                          Tag timeline legend:
                                            | - Target idle
                                            S - Target selected
                                            X - Target deselected

Since PN53x devices can only known about 2 tags simultaneously, presenting 3
targets to the NFC device caused an infinite loop.

This commit prevents this infinite loop to occur, and will be completed later
by another commit for not relying on the ATQA to determine targets type.
2010-08-04 12:08:38 +00:00
Romain Tartiere
88a4cbbe53 Use a lower-level communication with Mifare DESFire targets.
Instead of uting nfc_initiator_transceive_dep_bytes() to transmit commands,
prepend an ISO-14443-4 header to it and send it using
nfc_initiator_transceive_bytes().  In case of WTX reply, handle it, and then
extract relevant information from the data returned by the PICC.

This prevents failure that happen with ISO-14443-4 compliant targets when using
a PN531-based NFC-device, and allows using the libfreefare with Mifare DESFire
targets on such devices.
2010-07-29 09:48:08 +00:00
Romain Tartiere
02897e1b69 Add debug capabilities for Mifare Classic and Mifare UltraLight targets. 2010-07-29 08:14:16 +00:00
Romain Tartiere
28b6ab7196 Move buffer macros to freefare_internal.h.
While here, tweak <libutil.h> include.
2010-07-29 07:58:25 +00:00
Romain Tartiere
b7d8f0e790 Add my Vim snippets as contrib. 2010-07-29 07:14:11 +00:00
Romain Tartiere
2ac6527164 Always define -DWITH_DEBUG if compiling WITH_DEBUG. 2010-07-29 06:31:37 +00:00
Romain Tartiere
cc50ebc4df Fix $Id$ vcs keywords.
- Add a new svn-keywords target to fix missing properties;
  - Add a new svn-keywords-check target to locate files lacking $Id$ statement.
2010-07-29 06:25:57 +00:00
Romain Tartiere
61a5ff4e4a Reintroduce the possibility to hexdump(3) PCD <=> PICC transmissions.
Not a hack this time:
  - Use the hexdump(3) function of the system if it exists;
  - Build the subpart of FreeBSD's libutil if not (contrib);
  - Do this only if configured --with-debug.

The Mifare Classic / Ultralight code will be eventually changed to also provide this functionality.
2010-07-29 06:11:27 +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