mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-07-12 00:06:09 -07:00
Merge pull request #515 from pwpiwi/fix_14atimeout
fix: hf mf hardnested failed with new WUPA timing
This commit is contained in:
commit
feb1bf4184
2 changed files with 9 additions and 12 deletions
|
@ -189,13 +189,14 @@ void iso14a_set_trigger(bool enable) {
|
||||||
|
|
||||||
|
|
||||||
void iso14a_set_timeout(uint32_t timeout) {
|
void iso14a_set_timeout(uint32_t timeout) {
|
||||||
iso14a_timeout = timeout - (DELAY_AIR2ARM_AS_READER + DELAY_ARM2AIR_AS_READER)/(16*8);
|
// adjust timeout by FPGA delays and 2 additional ssp_frames to detect SOF
|
||||||
|
iso14a_timeout = timeout + (DELAY_AIR2ARM_AS_READER + DELAY_ARM2AIR_AS_READER)/(16*8) + 2;
|
||||||
if(MF_DBGLEVEL >= 3) Dbprintf("ISO14443A Timeout set to %ld (%dms)", timeout, timeout / 106);
|
if(MF_DBGLEVEL >= 3) Dbprintf("ISO14443A Timeout set to %ld (%dms)", timeout, timeout / 106);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t iso14a_get_timeout(void) {
|
uint32_t iso14a_get_timeout(void) {
|
||||||
return iso14a_timeout + (DELAY_AIR2ARM_AS_READER + DELAY_ARM2AIR_AS_READER)/(16*8);
|
return iso14a_timeout - (DELAY_AIR2ARM_AS_READER + DELAY_ARM2AIR_AS_READER)/(16*8) - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -1955,9 +1956,9 @@ int iso14_apdu(uint8_t *cmd, uint16_t cmd_len, void *data) {
|
||||||
} else{
|
} else{
|
||||||
// S-Block WTX
|
// S-Block WTX
|
||||||
while((data_bytes[0] & 0xF2) == 0xF2) {
|
while((data_bytes[0] & 0xF2) == 0xF2) {
|
||||||
uint32_t save_iso14a_timeout = iso14a_timeout;
|
uint32_t save_iso14a_timeout = iso14a_get_timeout();
|
||||||
// temporarily increase timeout
|
// temporarily increase timeout
|
||||||
iso14a_timeout = MAX((data_bytes[1] & 0x3f) * iso14a_timeout, MAX_ISO14A_TIMEOUT);
|
iso14a_set_timeout(MAX((data_bytes[1] & 0x3f) * save_iso14a_timeout, MAX_ISO14A_TIMEOUT));
|
||||||
// Transmit WTX back
|
// Transmit WTX back
|
||||||
// byte1 - WTXM [1..59]. command FWT=FWT*WTXM
|
// byte1 - WTXM [1..59]. command FWT=FWT*WTXM
|
||||||
data_bytes[1] = data_bytes[1] & 0x3f; // 2 high bits mandatory set to 0b
|
data_bytes[1] = data_bytes[1] & 0x3f; // 2 high bits mandatory set to 0b
|
||||||
|
@ -1969,7 +1970,7 @@ int iso14_apdu(uint8_t *cmd, uint16_t cmd_len, void *data) {
|
||||||
len = ReaderReceive(data, parity);
|
len = ReaderReceive(data, parity);
|
||||||
data_bytes = data;
|
data_bytes = data;
|
||||||
// restore timeout
|
// restore timeout
|
||||||
iso14a_timeout = save_iso14a_timeout;
|
iso14a_set_timeout(save_iso14a_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we received an I- or R(ACK)-Block with a block number equal to the
|
// if we received an I- or R(ACK)-Block with a block number equal to the
|
||||||
|
|
|
@ -694,10 +694,9 @@ void MifareAcquireEncryptedNonces(uint32_t arg0, uint32_t arg1, uint32_t flags,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send a dummy byte as reader response in order to trigger the cards authentication timeout
|
// send a dummy response in order to trigger the cards authentication failure timeout
|
||||||
uint8_t dummy_answer = 0;
|
uint8_t dummy_answer[8] = {0};
|
||||||
ReaderTransmit(&dummy_answer, 1, NULL);
|
ReaderTransmit(dummy_answer, 8, NULL);
|
||||||
timeout = GetCountSspClk() + AUTHENTICATION_TIMEOUT;
|
|
||||||
|
|
||||||
num_nonces++;
|
num_nonces++;
|
||||||
if (num_nonces % 2) {
|
if (num_nonces % 2) {
|
||||||
|
@ -710,9 +709,6 @@ void MifareAcquireEncryptedNonces(uint32_t arg0, uint32_t arg1, uint32_t flags,
|
||||||
i += 9;
|
i += 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for the card to become ready again
|
|
||||||
while(GetCountSspClk() < timeout);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LED_C_OFF();
|
LED_C_OFF();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue