#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
}\r
\r
if (slow) {\r
- timeout = GetCountSspClk() + PRE_AUTHENTICATION_LEADTIME;\r
+ timeout = GetCountSspClk() + HARDNESTED_PRE_AUTHENTICATION_LEADTIME;\r
while(GetCountSspClk() < timeout);\r
}\r
\r
continue;\r
}\r
\r
- // send a dummy byte as reader response in order to trigger the cards authentication timeout\r
- uint8_t dummy_answer = 0;\r
- ReaderTransmit(&dummy_answer, 1, NULL);\r
- timeout = GetCountSspClk() + AUTHENTICATION_TIMEOUT;\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