ADD: added some time debug statements to be able to measure execution time.
CHG: change the auth_ex method to send usb package faster, REM: removed some bucketsort changes.
This commit is contained in:
@@ -998,8 +998,6 @@ void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
||||
set_tracing(TRUE);
|
||||
|
||||
for (i = 0; i < keyCount; ++i) {
|
||||
if (mifare_classic_halt(pcs, cuid))
|
||||
if (MF_DBGLEVEL >= 1) Dbprintf("ChkKeys: Halt error");
|
||||
|
||||
if (!iso14443a_select_card(uid, NULL, &cuid, true, 0)) {
|
||||
if (OLD_MF_DBGLEVEL >= 1) Dbprintf("ChkKeys: Can't select card");
|
||||
@@ -1007,19 +1005,23 @@ void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
||||
}
|
||||
|
||||
ui64Key = bytes_to_num(datain + i * 6, 6);
|
||||
if (mifare_classic_auth(pcs, cuid, blockNo, keyType, ui64Key, AUTH_FIRST))
|
||||
if (mifare_classic_auth(pcs, cuid, blockNo, keyType, ui64Key, AUTH_FIRST)) {
|
||||
if (mifare_classic_halt(pcs, cuid))
|
||||
if (MF_DBGLEVEL >= 1) Dbprintf("ChkKeys: Halt error");
|
||||
continue;
|
||||
}
|
||||
|
||||
isOK = 1;
|
||||
break;
|
||||
}
|
||||
crypto1_destroy(pcs);
|
||||
|
||||
LED_B_ON();
|
||||
cmd_send(CMD_ACK,isOK,0,0,datain + i * 6,6);
|
||||
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LEDsoff();
|
||||
set_tracing(FALSE);
|
||||
crypto1_destroy(pcs);
|
||||
|
||||
// restore debug level
|
||||
MF_DBGLEVEL = OLD_MF_DBGLEVEL;
|
||||
|
||||
@@ -139,12 +139,11 @@ int mifare_classic_authex(struct Crypto1State *pcs, uint32_t uid, uint8_t blockN
|
||||
// variables
|
||||
int len;
|
||||
uint32_t pos;
|
||||
uint8_t tmp4[4] = {0x00};
|
||||
uint8_t par[1] = {0x00};
|
||||
|
||||
// "random" reader nonce:
|
||||
byte_t nr[4] = {0x55, 0x41, 0x49, 0x92};
|
||||
//byte_t nr[4] = {0x01, 0x01, 0x01, 0x01};
|
||||
//byte_t nr[4] = {0x55, 0x41, 0x49, 0x92};
|
||||
byte_t nr[4] = {0x01, 0x01, 0x01, 0x01};
|
||||
|
||||
uint32_t nt, ntpp; // Supplied tag nonce
|
||||
|
||||
@@ -210,10 +209,9 @@ int mifare_classic_authex(struct Crypto1State *pcs, uint32_t uid, uint8_t blockN
|
||||
return 2;
|
||||
}
|
||||
|
||||
memcpy(tmp4, receivedAnswer, 4);
|
||||
ntpp = prng_successor(nt, 32) ^ crypto1_word(pcs, 0,0);
|
||||
|
||||
if (ntpp != bytes_to_num(tmp4, 4)) {
|
||||
|
||||
if (ntpp != bytes_to_num(receivedAnswer, 4)) {
|
||||
if (MF_DBGLEVEL >= 1) Dbprintf("Authentication failed. Error card response.");
|
||||
return 3;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user