Commit graph

48 commits

Author SHA1 Message Date
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
Philippe Teuwen
c72a55993b Return EACCES when authentication to a MIFARE Classic tag fails 2014-03-14 22:31:48 +01:00
Jan Engelhardt
089b6006b1 libfreefare: resolve compiler warning on breakage of strict aliasing
gcc warns:
mifare_classic.c:353:45: warning: dereferencing type-punned pointer
will break strict-aliasing rules [-Wstrict-aliasing]

There is another problem with this code: "data", being a 16-byte
array, may not be suitably aligned for the other types in the union.
This patch resolves this.
2013-06-05 19:37:32 +02:00
Philippe Teuwen
2d3cff48e7 Add support for 7-byte UID MIFARE Classic cards 2013-01-29 23:26:32 +01:00
Romuald Conty
dd1315321d Update to current libnfc devel API.
libnfc changed its nfc_initiator_transceive_bytes(): it now takes a const size_t used as maximal allowed rx bytes.
libnfc now checks if rx buffer is large enough to get the full response, so libfreefare should take care about whole size of its buffers.
2012-06-01 21:26:01 +00:00
Audrey Diacre
4f0227ddcb update to use libnfc's trunk 2012-01-25 09:58:16 +00:00
Romain Tartiere
0a7ce855b8 Sync w/ libnfc-1.5.1. 2011-09-22 13:05:07 +00:00
Romain Tartiere
7c8c818a08 Fix mifare_classic_transfer() with some readers. 2011-02-13 12:50:41 +00:00
Audrey Diacre
5133491c2c replace deprecated bzero function by memset. 2010-12-10 17:10:12 +00:00
Romain Tartiere
688d083f63 Fix build with recent libnfc API breakage. 2010-10-15 12:58:29 +00:00
Romain Tartiere
cf4942b510 Remove debugging line that should not have been committed in r535. 2010-09-07 13:38:48 +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
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
8f645fbe62 Attempt to fix Mifare Classic support after r543. 2010-08-31 14:48:47 +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
e68ae59c5e Rename mad_application_(read|write) to mifare_application_(read|write).
Fixes issue 40.
2010-08-24 10:51:58 +00:00
Romain Tartiere
02897e1b69 Add debug capabilities for Mifare Classic and Mifare UltraLight targets. 2010-07-29 08:14:16 +00:00
Romuald Conty
8026f33170 Add NFC Forum public key for MIFARE Classic. 2010-07-28 10:06:42 +00:00
Romain Tartiere
f5a95b1c57 Rename MC_STORE to MC_RESTORE.
It's easy now that the macro is defined in the libfreefare's code and not the libnfc's one.
2010-07-27 08:17:48 +00:00
Romain Tartiere
5779d6f945 Merge the freefare-desfire branch into trunk. 2010-07-26 21:48:18 +00:00
Romain Tartiere
5d62cee7d7 Merge r489 from the libfreefare-desfire branch. 2010-07-26 14:12:32 +00:00
Romain Tartiere
d186bfbaa3 Update after libnfc API change. 2010-07-21 11:41:58 +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
Romuald Conty
ed69f90056 add MIFARE Classic 4K documentation reference. 2010-06-29 14:45:55 +00:00
Romain Tartiere
5027d69b7e Silent down gcc44 -Wextra warnings. 2010-06-26 13:48:25 +00:00
Romain Tartiere
a7a561d330 Also fix the code after changeset r360.
Pointy hat to:	me
2010-06-22 21:57:16 +00:00
Romain Tartiere
92f96f0be2 Fix comment: c(321)=001 -> Key B can be written using Key B. 2010-06-22 21:52:38 +00:00
Romain Tartiere
2feb65ed04 Copy MIFARE Classic commands codes from the old libnfc source to the libfreefare's one. 2010-06-22 14:01:00 +00:00
Romuald Conty
e68904d48a attempt to build under OpenBSD. 2010-04-07 14:06:04 +00:00
Romain Tartiere
e5fbfbe6b7 Replace UTF-8 what-seems-to-be-an "em dash" with a basic ASCII dash: ANSI C says source code should be written in ASCII. 2010-04-01 12:04:53 +00:00
Romain Tartiere
aacddc7aae Add missing htole32() call in mifare_classic_init_value(). Fix Mifare Classic support on big-endian machines. 2010-03-31 22:46:13 +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
3b737a11e8 Add access bit macros to ease-up writing code using the library. 2010-03-19 09:00:06 +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
ffcc3174b2 Add missing block_number <- block that prevented full cache hits. 2010-02-23 02:00:04 +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
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
2380583ec6 fix the mifare_classic_transfer() function. 2010-02-18 18:09:34 +00:00
Romain Tartiere
37c404b128 ilibfreefare: The transfer operation actually returns something. 2010-02-18 16:45:24 +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
1c62fc83e6 Handle the special case of sector #0 when formatting (sector is read-only). 2010-01-09 01:37:36 +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
24ef79eca4 fix mifare_classic_get_uid(). 2010-01-08 16:34:43 +00:00
Romain Tartiere
32e740ea6d Split out autojunk and actual code files. 2010-01-08 11:46:23 +00:00
Renamed from mifare_classic.c (Browse further)