From 269b61e1289e0d0d31c3cc70c4dbfee364d226ae Mon Sep 17 00:00:00 2001 From: Polle Vanhoof Date: Mon, 3 Aug 2020 20:40:03 +0200 Subject: [PATCH 1/3] Implemented best-effor case to use Key B for reading --- src/mfoc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mfoc.c b/src/mfoc.c index e2545be..a86ccb6 100644 --- a/src/mfoc.c +++ b/src/mfoc.c @@ -684,7 +684,9 @@ int main(int argc, char *const argv[]) failure = false; } else { // Error, now try read() with B key - if (res != NFC_ERFTRANS) { + if (res != NFC_EMFCAUTHFAIL) { + fprintf(stdout, "Failed reading with Key A after successfully testing Key A. This is unusual, but continuing anyway in case Key B succeeds..."); + } else if (res != NFC_ERFTRANS) { nfc_perror(r.pdi, "nfc_initiator_mifare_cmd"); goto error; } From f4cfd01b6be6cc93ea0a25c8e2d23133b0bc2972 Mon Sep 17 00:00:00 2001 From: Polle Vanhoof Date: Mon, 3 Aug 2020 20:45:37 +0200 Subject: [PATCH 2/3] Fix stupid mistake. I should learn to test before I commit --- src/mfoc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mfoc.c b/src/mfoc.c index a86ccb6..672a297 100644 --- a/src/mfoc.c +++ b/src/mfoc.c @@ -684,7 +684,7 @@ int main(int argc, char *const argv[]) failure = false; } else { // Error, now try read() with B key - if (res != NFC_EMFCAUTHFAIL) { + if (res == NFC_EMFCAUTHFAIL) { fprintf(stdout, "Failed reading with Key A after successfully testing Key A. This is unusual, but continuing anyway in case Key B succeeds..."); } else if (res != NFC_ERFTRANS) { nfc_perror(r.pdi, "nfc_initiator_mifare_cmd"); From 9ba2686acec0d261dad168dc62aded502e81c6b0 Mon Sep 17 00:00:00 2001 From: Polle Vanhoof Date: Tue, 4 Aug 2020 09:54:29 +0200 Subject: [PATCH 3/3] Clean up with newline --- src/mfoc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mfoc.c b/src/mfoc.c index 672a297..006109d 100644 --- a/src/mfoc.c +++ b/src/mfoc.c @@ -685,7 +685,7 @@ int main(int argc, char *const argv[]) } else { // Error, now try read() with B key if (res == NFC_EMFCAUTHFAIL) { - fprintf(stdout, "Failed reading with Key A after successfully testing Key A. This is unusual, but continuing anyway in case Key B succeeds..."); + fprintf(stdout, "Failed reading with Key A after successfully testing Key A. This is unusual, but continuing anyway in case Key B succeeds...\n"); } else if (res != NFC_ERFTRANS) { nfc_perror(r.pdi, "nfc_initiator_mifare_cmd"); goto error;