From 087db1b298f6f089af019715fe477feccccd2e39 Mon Sep 17 00:00:00 2001 From: Romain Tartiere Date: Fri, 3 Sep 2010 10:54:07 +0000 Subject: [PATCH] New unit test to check Mifare DESFire AIDs containing a Mifare Classic AID. --- test/Makefile.am | 4 ++++ test/test_mifare_desfire_aid.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 test/test_mifare_desfire_aid.c diff --git a/test/Makefile.am b/test/Makefile.am index e370f41..c2646b0 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -18,6 +18,7 @@ noinst_LTLIBRARIES = \ test_mifare_classic_create_trailer_block.la \ test_mifare_classic_sector_boundaries.la \ test_mifare_desfire.la \ + test_mifare_desfire_aid.la \ test_mifare_desfire_des.la \ test_mifare_desfire_key.la \ test_mifare_ultralight.la \ @@ -48,6 +49,9 @@ test_mifare_desfire_la_SOURCES = test_mifare_desfire.c \ mifare_desfire_fixture.h test_mifare_desfire_la_LIBADD = $(top_builddir)/libfreefare/libfreefare.la -lutil +test_mifare_desfire_aid_la_SOURCES = test_mifare_desfire_aid.c +test_mifare_desfire_aid_la_LIBADD = $(top_builddir)/libfreefare/libfreefare.la + test_mifare_desfire_des_la_SOURCES = test_mifare_desfire_des.c test_mifare_desfire_des_la_LIBADD = $(top_builddir)/libfreefare/libfreefare.la -lssl diff --git a/test/test_mifare_desfire_aid.c b/test/test_mifare_desfire_aid.c new file mode 100644 index 0000000..353b21d --- /dev/null +++ b/test/test_mifare_desfire_aid.c @@ -0,0 +1,28 @@ +#include +#include + +#include "freefare_internal.h" + +void +test_mifare_desfire_aid (void) +{ + /* + * <-- LSB MSB --> + * | MIFARE DESFire AID Byte 0 | MIFARE DESFire AID Byte 1 | MIFARE DESFire AID Byte 2 | + * | Nible 0 | Nible 1 | Nible 2 | Nible 3 | Nible 4 | Nible 5 | + * | 0xF | MIFARE Classic AID | 0x0...0xF | + * | Function-Cluster | Application code | + * <-- MSB LSB--> + * + * 0xF21438 -> 0x83412F + */ + MifareDESFireAID desfire_aid = mifare_desfire_aid_new (0x00f12ab8); + MadAid mad_aid = { + .function_cluster_code = 0x12, + .application_code = 0xab, + }; + MifareDESFireAID desfire_aid2 = mifare_desfire_aid_new_with_mad_aid (mad_aid, 8); + + cut_assert_equal_memory (desfire_aid->data,3, desfire_aid2->data, 3, cut_message ("wrong aid")); + +}