Commit graph

209 commits

Author SHA1 Message Date
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
db0dd52339 Make the MAD read public key public (Rename it to insist on it's public nature). 2010-07-01 14:08:59 +00:00
Romain Tartiere
0e1aded982 Document the mifare_tag_type enum. 2010-07-01 12:32:03 +00:00
Romuald Conty
98e5b5a107 Fix mifare_application_alloc documentation: function takes "size" param in sectors unit. 2010-06-30 07:58:25 +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
ebeaf9ad35 Fix endian.h inclusion. 2010-06-26 11:56:57 +00:00
Romain Tartiere
9c9d270b7e Fix typo in comment. I may need to buy a few more fingers to count on. 2010-06-25 00:30:32 +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
a4793d7052 Fix mad_write(). 2010-06-24 00:06:33 +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
644a21ad9a Add missing section line in man page. 2010-06-23 00:36:40 +00:00
Romain Tartiere
1839e32df8 Fix documentation: a Mad is freed using mad_free() not free(3).
Actually, mad_free() only calls free(3) but for the sake of consistency, document the proper interface.
2010-06-22 22:50:01 +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
ef2c2e8168 Complete documentation for mad_new(). 2010-06-22 21:53:07 +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
a9f73f414d Fix wrong trailer block number for writing MAD v2. 2010-06-22 17:11:11 +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
Romain Tartiere
a0da16bf65 Update documentation.
Add a note about freefare_get_tags() invalidating previously found targets.
2010-04-26 11:09:04 +00:00
Romain Tartiere
1ea30f37bb Document the new freefare_free_tag() function.
Fixes issue 22.
2010-04-26 10:53:36 +00:00
Romain Tartiere
a2263b7ea8 Remove the freefare_duplicate_tag() function.
Update issue 22
Remove the freefare_duplicate_tag() function.
2010-04-26 10:34:27 +00:00
Romuald Conty
99b261d132 add freefare_free_tag() to free only one tag and add freefare_duplicate_tag() in order to copy a tag struct. 2010-04-20 15:17:17 +00:00
Romuald Conty
90fce89aee next try to build under OpenBSD. 2010-04-07 14:19:08 +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
85e7174a02 Fix weird UIDs for Mifare UltraLight (requires libnfc at r328) 2010-03-30 16:08:07 +00:00
Romain Tartiere
017029fbbe Do not require a Mifare UltraLight TAG to be connected to get it's UID.
Submitted by:	rosek86@gmail.com
2010-03-30 13:56:49 +00:00
Romain Tartiere
26aef03a48 Add man pages. 2010-03-30 12:54:49 +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
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
42692ccf54 Style. 2010-03-02 19:01:12 +00:00
Romain Tartiere
0f72871eb3 Instead of copying n fields, setup a pointer to the relevant supported_tag information in mifare_tag structures. 2010-03-01 14:19:48 +00:00
Romain Tartiere
0d4744001a Add support for friendly tag names. 2010-03-01 14:04:47 +00:00
Romain Tartiere
62ddf57c53 Rework byteswap.h inclusion.
This header is not available on e.g. FreeBSD so detect it's presence in configure.ac and only include it if appropriate.  Then, if byte order manipulation macros are not defined (old glibc like the one provided by Debian GNU/Linux) define them.
2010-02-25 18:02:54 +00:00
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
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
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
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
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