Reply To: Mifare Classic MAD1 CRC8 Generation

Forum MIFARE SmartCard IC`s MIFARE Classic Mifare Classic MAD1 CRC8 Generation Reply To: Mifare Classic MAD1 CRC8 Generation

Re: Mifare Classic MAD1 CRC8 Generation

18. September 2018 at 10:11
Hi, it's some time ago, but maybe it will help somebody anyway. I use this code to calculate MAD CRC:

uint8_t CalculateCRC8_MAD(uint8_t *in_pData, uint8_t in_nDataLength)
{
if (in_pData == nullptr)
return 0;

if (in_nDataLength == 0)
return 0;

// init vector defined in MAD appnote is 0xE3. This didn't work, but bit-swapped value 0xC7 works
boost::crc_optimal crc8;

uint8_t *pStart = in_pData;
uint8_t *pEnd = in_pData + in_nDataLength;

crc8 = std::for_each(pStart, pEnd, crc8);

return crc8.checksum();
}


Regards
Jan
+ 0  |  - 0