fix mad2 crc8 check

This commit is contained in:
merlokk 2019-03-01 19:13:59 +02:00
parent 979aa678ad
commit 3a98c9fcd3

View file

@ -109,13 +109,19 @@ static const char *GetAIDDescription(uint16_t AID) {
int madCRCCheck(uint8_t *sector, bool verbose, int MADver) {
if (MADver == 1) {
uint8_t crc = CRC8Mad(&sector[16 + 1], 31);
uint8_t crc = CRC8Mad(&sector[16 + 1], 15 + 16);
if (crc != sector[16]) {
if (verbose)
PrintAndLogEx(ERR, "Wrong MAD%d CRC. Calculated: 0x%02x, from card: 0x%02x", MADver, crc, sector[16]);
return 3;
};
} else {
uint8_t crc = CRC8Mad(&sector[1], 15 + 16 + 16);
if (crc != sector[0]) {
if (verbose)
PrintAndLogEx(ERR, "Wrong MAD%d CRC. Calculated: 0x%02x, from card: 0x%02x", MADver, crc, sector[16]);
return 3;
};
}
return 0;
@ -191,6 +197,9 @@ int MAD2DecodeAndPrint(uint8_t *sector, bool verbose) {
if (res)
return res;
if (verbose)
PrintAndLogEx(NORMAL, "CRC8-MAD OK.");
uint8_t InfoByte = sector[1] & 0x3f;
PrintAndLogEx(NORMAL, "MAD2 Card publisher sector: 0x%02x", InfoByte);