Introduce MAD application management functions.
This commit is contained in:
parent
0ae63092bd
commit
3cab1523eb
6 changed files with 225 additions and 4 deletions
|
|
@ -2,7 +2,7 @@ LMF_SRCDIR= ${.CURDIR}/..
|
|||
.PATH: ${LMF_SRCDIR}
|
||||
|
||||
#LMF_SRCS!= ${MAKE} -f ${LMF_SRCDIR}/Makefile -V SRCS
|
||||
LMF_SRCS= ../mifare_classic.c ../mad.c
|
||||
LMF_SRCS= ../mifare_classic.c ../mad.c ../mifare_application.c
|
||||
|
||||
TESTS= test_read_sector_0.c \
|
||||
test_authenticate.c \
|
||||
|
|
@ -10,7 +10,8 @@ TESTS= test_read_sector_0.c \
|
|||
test_access_bits.c \
|
||||
test_format.c \
|
||||
test_create_trailer_block.c \
|
||||
test_mad.c
|
||||
test_mad.c \
|
||||
test_mifare_application.c
|
||||
|
||||
SRCS= ${LMF_SRCS} \
|
||||
${TESTS} \
|
||||
|
|
|
|||
|
|
@ -206,6 +206,7 @@ int read_open_memory2(struct archive *, void *, size_t, size_t);
|
|||
#include <nfc/nfc.h>
|
||||
#include <mifare_classic.h>
|
||||
#include <mad.h>
|
||||
#include <mifare_application.h>
|
||||
|
||||
int mifare_classic_test_setup (MifareClassicTag *tag);
|
||||
int mifare_classic_test_teardown (MifareClassicTag tag);
|
||||
|
|
|
|||
37
test/test_mifare_application.c
Normal file
37
test/test_mifare_application.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_mifare_application)
|
||||
{
|
||||
do {
|
||||
|
||||
/* Card publisher part */
|
||||
|
||||
MadAid aid = { 0x22, 0x42 };
|
||||
Mad mad = mad_new (2);
|
||||
assert (NULL != mad);
|
||||
|
||||
MifareSectorNumber *s_alloc = mifare_application_alloc (mad, aid, 3);
|
||||
assert (NULL != s_alloc);
|
||||
|
||||
MifareSectorNumber *s_found = mifare_application_find (mad, aid);
|
||||
assert (NULL != s_found);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
assertEqualInt (s_alloc[i], s_found[i]);
|
||||
}
|
||||
|
||||
assertEqualInt (0, s_alloc[3]);
|
||||
assertEqualInt (0, s_found[3]);
|
||||
|
||||
mifare_application_free (mad, aid);
|
||||
|
||||
free (s_alloc);
|
||||
free (s_found);
|
||||
|
||||
s_found = mifare_application_find (mad, aid);
|
||||
assert (s_found == NULL);
|
||||
|
||||
mad_free (mad);
|
||||
|
||||
} while (0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue