From efe5bbad9ec33b02067b276984906d83e80535da Mon Sep 17 00:00:00 2001 From: Romain Tartiere Date: Thu, 24 Jun 2010 00:19:05 +0000 Subject: [PATCH] Force disconnect to avoid failure when the same key is usable as key A and key B. --- examples/mifare-classic-write-ndef.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/mifare-classic-write-ndef.c b/examples/mifare-classic-write-ndef.c index 793845c..8728799 100644 --- a/examples/mifare-classic-write-ndef.c +++ b/examples/mifare-classic-write-ndef.c @@ -68,6 +68,7 @@ search_sector_key (MifareTag tag, MifareClassicBlockNumber block, MifareClassicK return 1; } } + mifare_classic_disconnect (tag); if ((0 == mifare_classic_connect (tag)) && (0 == mifare_classic_authenticate (tag, block, default_keys[i], MFC_KEY_B))) { if (((block == 0) || (1 == mifare_classic_get_data_block_permission (tag, block + 0, MCAB_W, MFC_KEY_B))) && @@ -81,6 +82,7 @@ search_sector_key (MifareTag tag, MifareClassicBlockNumber block, MifareClassicK return 1; } } + mifare_classic_disconnect (tag); } warnx ("No known authentication key for block %d", block);