mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-04-02 02:19:57 +08:00
fix bug with false-positive crc16 and remove debug
This commit is contained in:
parent
77a66a024b
commit
08d8ac4f9f
1 changed files with 4 additions and 12 deletions
|
@ -117,21 +117,18 @@ size_t DesfireSearchCRCPos(uint8_t *data, size_t datalen, uint8_t respcode, uint
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
crcpos++; // crc may be 0x00000000 or 0x0000
|
crcpos++; // crc may be 0x00000000 or 0x0000
|
||||||
PrintAndLogEx(INFO, "crcpos: %d", crcpos);
|
|
||||||
if (crcpos < crclen) {
|
if (crcpos < crclen) {
|
||||||
PrintAndLogEx(WARNING, "No space for crc. pos: %d", crcpos);
|
PrintAndLogEx(WARNING, "No space for crc. pos: %d", crcpos);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t crcdata[1024] = {0};
|
uint8_t crcdata[1024] = {0};
|
||||||
bool crcok = false;
|
size_t crcposfound = 0;
|
||||||
for (int i = 0; i < crclen + 1; i++) {
|
for (int i = 0; i < crclen + 1; i++) {
|
||||||
PrintAndLogEx(INFO, "--crcpos: %d", crcpos - i);
|
|
||||||
if (crcpos - i == 0)
|
if (crcpos - i == 0)
|
||||||
break;
|
break;
|
||||||
if (crcpos - i + crclen > datalen)
|
if (crcpos - i + crclen > datalen)
|
||||||
continue;
|
continue;
|
||||||
PrintAndLogEx(INFO, "--crcposcheck: %d", crcpos - i);
|
|
||||||
|
|
||||||
memcpy(crcdata, data, crcpos - i);
|
memcpy(crcdata, data, crcpos - i);
|
||||||
crcdata[crcpos - i] = respcode;
|
crcdata[crcpos - i] = respcode;
|
||||||
|
@ -139,18 +136,13 @@ size_t DesfireSearchCRCPos(uint8_t *data, size_t datalen, uint8_t respcode, uint
|
||||||
if (crclen == 4)
|
if (crclen == 4)
|
||||||
res = desfire_crc32_check(crcdata, crcpos - i + 1, &data[crcpos - i]);
|
res = desfire_crc32_check(crcdata, crcpos - i + 1, &data[crcpos - i]);
|
||||||
else
|
else
|
||||||
res = iso14443a_crc_check(crcdata, crcpos - i + 1, &data[crcpos - i]);
|
res = iso14443a_crc_check(data, crcpos - i, &data[crcpos - i]);
|
||||||
if (res) {
|
if (res) {
|
||||||
PrintAndLogEx(INFO, "--crc OK pos: %d", crcpos - i);
|
crcposfound = crcpos - i;
|
||||||
crcpos -= i;
|
|
||||||
crcok = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!crcok)
|
|
||||||
crcpos = 0;
|
|
||||||
|
|
||||||
return crcpos;
|
return crcposfound;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DesfireCryptoEncDecSingleBlock(uint8_t *key, DesfireCryptoAlgorythm keyType, uint8_t *data, uint8_t *dstdata, uint8_t *ivect, bool dir_to_send, bool encode) {
|
static void DesfireCryptoEncDecSingleBlock(uint8_t *key, DesfireCryptoAlgorythm keyType, uint8_t *data, uint8_t *dstdata, uint8_t *ivect, bool dir_to_send, bool encode) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue