]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/mifarecmd.c
Revert changes in hardnested nonces collection. Sacrifice some speed in favor of...
[proxmark3-svn] / armsrc / mifarecmd.c
index fcfd7e8fddb80f9c1bac092def66cd5fbb1d23c0..3854b5899611e1f573352467dfeac34c6e278cd1 100644 (file)
@@ -20,6 +20,9 @@
 #include "parity.h"\r
 #include "crc.h"\r
 \r
+#define HARDNESTED_AUTHENTICATION_TIMEOUT 848                  // card times out 1ms after wrong authentication (according to NXP documentation)\r
+#define HARDNESTED_PRE_AUTHENTICATION_LEADTIME 400             // some (non standard) cards need a pause after select before they are ready for first authentication \r
+\r
 // the block number for the ISO14443-4 PCB\r
 static uint8_t pcb_blocknum = 0;\r
 // Deselect card by sending a s-block. the crc is precalced for speed\r
@@ -677,7 +680,7 @@ void MifareAcquireEncryptedNonces(uint32_t arg0, uint32_t arg1, uint32_t flags,
                }\r
 \r
                if (slow) {\r
-                       timeout = GetCountSspClk() + PRE_AUTHENTICATION_LEADTIME;\r
+                       timeout = GetCountSspClk() + HARDNESTED_PRE_AUTHENTICATION_LEADTIME;\r
                        while(GetCountSspClk() < timeout);\r
                }\r
 \r
@@ -694,10 +697,12 @@ void MifareAcquireEncryptedNonces(uint32_t arg0, uint32_t arg1, uint32_t flags,
                        continue;\r
                }\r
 \r
-               // send a dummy response in order to trigger the cards authentication failure timeout\r
-               uint8_t dummy_answer[8] = {0};\r
-               ReaderTransmit(dummy_answer, 8, NULL);\r
+               // send an incomplete dummy response in order to trigger the card's authentication failure timeout\r
+               uint8_t dummy_answer[1] = {0};\r
+               ReaderTransmit(dummy_answer, 1, NULL);\r
 \r
+               timeout = GetCountSspClk() + HARDNESTED_AUTHENTICATION_TIMEOUT;\r
+               \r
                num_nonces++;\r
                if (num_nonces % 2) {\r
                        memcpy(buf+i, receivedAnswer, 4);\r
@@ -709,6 +714,9 @@ void MifareAcquireEncryptedNonces(uint32_t arg0, uint32_t arg1, uint32_t flags,
                        i += 9;\r
                }\r
 \r
+               // wait for the card to become ready again\r
+               while(GetCountSspClk() < timeout);\r
+\r
        }\r
 \r
        LED_C_OFF();\r
Impressum, Datenschutz