Skip to content

Commit

Permalink
Add support for 7-byte UID MIFARE Classic cards
Browse files Browse the repository at this point in the history
  • Loading branch information
doegox committed Jan 29, 2013
1 parent 42e731b commit 2d3cff4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion libfreefare/mifare_classic.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ mifare_classic_authenticate (MifareTag tag, const MifareClassicBlockNumber block

BUFFER_APPEND(cmd, block);
BUFFER_APPEND_BYTES (cmd, key, 6);
BUFFER_APPEND_BYTES (cmd, tag->info.abtUid, 4);
// To support both 4-byte & 7-byte UID cards:
BUFFER_APPEND_BYTES (cmd, tag->info.abtUid + tag->info.szUidLen - 4, 4);

CLASSIC_TRANSCEIVE_EX (tag, cmd, res, 1);

Expand Down
2 changes: 1 addition & 1 deletion test/test_mifare_classic.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ test_mifare_classic_get_uid (void)
uid = freefare_get_tag_uid (tag);

cut_assert_not_null (uid, cut_message ("freefare_get_tag_uid() failed"));
cut_assert_equal_int (8, strlen (uid), cut_message ("Wrong UID length"));
cut_assert (((strlen (uid) == 8)||(strlen (uid) == 14)), cut_message ("Wrong UID length"));

free (uid);
}
Expand Down

0 comments on commit 2d3cff4

Please sign in to comment.