From 6121d816e783b23efa8674ea4bf7c7edccfe0c07 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 30 Dec 2019 12:50:44 +0100 Subject: [PATCH] Chg: faster authentication by lower timeout limit. (@pwpiwi) --- armsrc/mifareutil.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/armsrc/mifareutil.c b/armsrc/mifareutil.c index 3ccf25737..2e6ba8ade 100644 --- a/armsrc/mifareutil.c +++ b/armsrc/mifareutil.c @@ -127,7 +127,7 @@ int mifare_sendcmd_short(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, int mifare_classic_auth(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t keyType, uint64_t ui64Key, uint8_t isNested) { return mifare_classic_authex(pcs, uid, blockNo, keyType, ui64Key, isNested, NULL, NULL); } - + int mifare_classic_authex(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t keyType, uint64_t ui64Key, uint8_t isNested, uint32_t *ntptr, uint32_t *timing) { int len; uint32_t pos, nt, ntpp; // Supplied tag nonce @@ -190,8 +190,17 @@ int mifare_classic_authex(struct Crypto1State *pcs, uint32_t uid, uint8_t blockN // Transmit reader nonce and reader answer ReaderTransmitPar(mf_nr_ar, sizeof(mf_nr_ar), par, NULL); + // save standard timeout + uint32_t save_timeout = iso14a_get_timeout(); + + // set timeout for authentication response + iso14a_set_timeout(106); + // Receive 4 byte tag answer len = ReaderReceive(receivedAnswer, receivedAnswerPar); + + iso14a_set_timeout(save_timeout); + if (!len) { if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("Authentication failed. Card timeout."); return 2;