Add MIFARE Application Directory (MAD) version 1 & 2 support (modulo CRC).
This commit is contained in:
parent
a317799f01
commit
9478706550
6 changed files with 439 additions and 4 deletions
|
|
@ -2,14 +2,15 @@ LMF_SRCDIR= ${.CURDIR}/..
|
|||
.PATH: ${LMF_SRCDIR}
|
||||
|
||||
#LMF_SRCS!= ${MAKE} -f ${LMF_SRCDIR}/Makefile -V SRCS
|
||||
LMF_SRCS= ../mifare_classic.c
|
||||
LMF_SRCS= ../mifare_classic.c ../mifare_application_directory.c
|
||||
|
||||
TESTS= test_read_sector_0.c \
|
||||
test_authenticate.c \
|
||||
test_value_block.c \
|
||||
test_access_bits.c \
|
||||
test_format.c \
|
||||
test_create_trailer_block.c
|
||||
test_create_trailer_block.c \
|
||||
test_mad.c
|
||||
|
||||
SRCS= ${LMF_SRCS} \
|
||||
${TESTS} \
|
||||
|
|
|
|||
|
|
@ -205,6 +205,7 @@ int read_open_memory2(struct archive *, void *, size_t, size_t);
|
|||
|
||||
#include <nfc/nfc.h>
|
||||
#include <mifare_classic.h>
|
||||
#include <mifare_application_directory.h>
|
||||
|
||||
int mifare_classic_test_setup (MifareClassicTag *tag);
|
||||
int mifare_classic_test_teardown (MifareClassicTag tag);
|
||||
|
|
|
|||
45
test/test_mad.c
Normal file
45
test/test_mad.c
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(mad)
|
||||
{
|
||||
int res;
|
||||
|
||||
do {
|
||||
Mad mad = mad_new (1);
|
||||
assert (mad != NULL);
|
||||
|
||||
if (mad) {
|
||||
assertEqualInt (mad_get_version (mad), 1);
|
||||
mad_set_version (mad, 2);
|
||||
assertEqualInt (mad_get_version (mad), 2);
|
||||
|
||||
assertEqualInt (0, mad_get_card_publisher_sector (mad));
|
||||
|
||||
res = mad_set_card_publisher_sector (mad, 13);
|
||||
assertEqualInt (res, 0);
|
||||
assertEqualInt (13, mad_get_card_publisher_sector (mad));
|
||||
|
||||
res = mad_set_card_publisher_sector (mad, 0xff);
|
||||
assertEqualInt (res, -1);
|
||||
assertEqualInt (13, mad_get_card_publisher_sector (mad));
|
||||
|
||||
uint8_t fcc, ac;
|
||||
res = mad_get_aid (mad, 3, &fcc, &ac);
|
||||
assertEqualInt (res, 0);
|
||||
assertEqualInt (fcc, 0);
|
||||
assertEqualInt (ac, 0);
|
||||
|
||||
res = mad_set_aid (mad, 3, 0xc0, 0x42);
|
||||
assertEqualInt (res, 0);
|
||||
|
||||
res = mad_get_aid (mad, 3, &fcc, &ac);
|
||||
assertEqualInt (res, 0);
|
||||
assertEqualInt (fcc, 0xc0);
|
||||
assertEqualInt (ac, 0x42);
|
||||
|
||||
mad_free (mad);
|
||||
}
|
||||
|
||||
} while (0);
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue