Rework tag allocation.

Split Mifare Classic 1 and 4K tag allocation.
Rely on new tasting functions.
This commit is contained in:
Romain Tartière 2016-01-18 16:55:47 +01:00
parent 0279361873
commit ee628f7ec5
11 changed files with 162 additions and 109 deletions

View file

@ -12,6 +12,7 @@ TESTS_ENVIRONMENT = NO_MAKE=yes CUTTER="$(CUTTER)"
cutter_unit_test_libs = \
test_felica.la \
test_freefare.la \
test_mad.la \
test_mifare_application.la \
test_mifare_classic.la \
@ -39,6 +40,9 @@ test_felica_la_SOURCES = test_felica.c \
felica_fixture.h
test_felica_la_LIBADD = $(top_builddir)/libfreefare/libfreefare.la
test_freefare_la_SOURCES = test_freefare.c
test_freefare_la_LIBADD = $(top_builddir)/libfreefare/libfreefare.la
test_mad_la_SOURCES = test_mad.c
test_mad_la_LIBADD = $(top_builddir)/libfreefare/libfreefare.la

26
test/test_freefare.c Normal file
View file

@ -0,0 +1,26 @@
#include <cutter.h>
#include <freefare.h>
#include "freefare_internal.h"
void
test_is_mifare_ultralight (void)
{
FreefareTag tag;
nfc_target target;
tag = mifare_ultralight_tag_new (NULL, target);
cut_assert_true (is_mifare_ultralight (tag));
mifare_ultralight_tag_free (tag);
}
void
test_is_mifare_ultralightc (void)
{
FreefareTag tag;
nfc_target target;
tag = mifare_ultralightc_tag_new (NULL, target);
cut_assert_true (is_mifare_ultralightc (tag));
mifare_ultralightc_tag_free (tag);
}

View file

@ -178,7 +178,7 @@ test_mifare_ultralightc_authenticate (void)
int res;
MifareDESFireKey key;
if (tag->tag_info->type == MIFARE_ULTRALIGHT_C) {
if (is_mifare_ultralightc (tag)) {
uint8_t key1_3des_data[16] = { 0x49, 0x45, 0x4D, 0x4B, 0x41, 0x45, 0x52, 0x42, 0x21, 0x4E, 0x41, 0x43, 0x55, 0x4F, 0x59, 0x46 };
key = mifare_desfire_3des_key_new (key1_3des_data);
res = mifare_ultralightc_authenticate (tag, key);