[ACCEPTED]-Verification of a CRC checksum against zero-crc16

Accepted answer
Score: 10

The issue is not that the CRC is 32 bit, but 26 that the CRC is post-complemented, xorout 25 = 0xffffffff. If you append the CRC (little 24 endian), to the message and then compute 23 the CRC again, if there are no errors, the 22 CRC will always be 0x2144DF1C. So in this 21 case you verify the CRC against 0x2144DF1C.

You 20 might find this online CRC calculator a 19 bit more informative, since it shows the 18 parameters: polynomial, xorin, xorout.


To 17 explain what is going on, normally if you 16 calculate and append a non-complemented 15 CRC to a message, then calculate the CRC 14 of the message + CRC, the resulting CRC 13 is zero (if there are no errors). Let CRC32X 12 = a custom CRC32 with initial value = 0 11 and xorout = 0. You can copy and paste the 10 data below with the online CRC calculator 9 I posted a link to.

CRC32X{0x31 0x32 0x33 0x34} = 0xBAA73FBF

appending the CRC and 8 calculating again:

CRC32X{0x31 0x32 0x33 0x34 0xBF 0x3F 0xA7 0xBA} = 0x00000000

Now consider a simpler 7 case:

CRC32X{0x00 0x00 0x00 0x00} = 0x00000000
CRC32X{0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00} = 0x00000000

Then to see the effect of complementing 6 the CRC and appending it:

CRC32X{0x00 0x00 0x00 0x00 0xFF 0xFF 0xFF 0xFF} = 0xDEBB20E3

and taking the 5 complement (using ~ for not):

~CRC32X{0x00 0x00 0x00 0x00 0xFF 0xFF 0xFF 0xFF} = ~0xDEBB20E3 = 0x2144DF1C

The initial 4 value is XOR'ed with the first 4 bytes of 3 the message. So for CRC32() with initial 2 value of 0xFFFFFFFF, and post complemented 1 CRC:

 CRC32(0x00 0x00 0x00 0x00) = 0x2144DF1C 
~CRC32X(0xFF 0xFF 0xFF 0xFF) = ~0xDEBB20E3 = 0x2144DF1C

More Related questions