Forum / MIFARE SmartCard IC`s / MIFARE Classic / Mifare Classic MAD1 CRC8 Generation
Tagged: CRC, MAD, MIFARE Classic
-
Hi,
I am trying to format first sector of Mifare Classic as MAD
and ran into a problem of generating correct CRC.
I many implementations of CRC I found on internet and followed datasheet on CRC generation
but every time I get different results from every try and that is not equal to value
that is in datasheet. http://www.nxp.com/documents/application_note/AN10787.pdf
Is there some solution which is tested for Mifare Classic CRC generation ?
There were some variables which wasn't covered in datasheet such as initial value of CRC and using table lookup
which I saw as options in some implementations.
I use Java.
+ 0 | - 0
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
The most important part in the previous post was cut (boost::crc_optimal), so I will try to post that line again without marking it as code (no idea how could I edit the post):
// init vector defined in MAD appnote is 0xE3. This didn't work, but bit-swapped value 0xC7 works
boost::crc_optimal crc8;
+ 0 | - 0
It looks that everything within angle brackets gets cut, so I will use normal brackets instead to declare crc8 variable from boost::crc_optimal template (I hope it will work finally :-) )
// init vector defined in MAD appnote is 0xE3. This didn't work, but bit-swapped value 0xC7 works
boost::crc_optimal(8, 0x1D, 0xC7, 0, false, false) crc8;
+ 0 | - 0
-
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.