Add support for 7-byte UID MIFARE Classic cards

This commit is contained in:
Philippe Teuwen 2013-01-29 23:26:32 +01:00
parent 42e731b492
commit 2d3cff48e7
2 changed files with 3 additions and 2 deletions

View file

@ -289,7 +289,8 @@ mifare_classic_authenticate (MifareTag tag, const MifareClassicBlockNumber block
BUFFER_APPEND(cmd, block); BUFFER_APPEND(cmd, block);
BUFFER_APPEND_BYTES (cmd, key, 6); 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); CLASSIC_TRANSCEIVE_EX (tag, cmd, res, 1);

View file

@ -361,7 +361,7 @@ test_mifare_classic_get_uid (void)
uid = freefare_get_tag_uid (tag); uid = freefare_get_tag_uid (tag);
cut_assert_not_null (uid, cut_message ("freefare_get_tag_uid() failed")); 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); free (uid);
} }