1
votes

I am trying to verify this statement from Wikipedia (http://en.wikipedia.org/wiki/Cyclic_redundancy_check):

Sometimes an implementation appends n 0-bits (n being the size of the CRC) to the bitstream to be checked before the polynomial division occurs. This has the convenience that the remainder of the original bitstream with the check value appended is exactly zero, so the CRC can be checked simply by performing the polynomial division on the received bitstream and comparing the remainder with zero.

I used a online CRC-32 calculator from http://www.lammertbies.nl/comm/info/crc-calculation.html

  1. The original message is 'test' or 0x74657374, its CRC-32 is 0xD87F7E0C.
  2. Then add 4 zero bytes so the message is 0x7465737400000000, its CRC-32 is 0x15521A21.
  3. Then replace the zeros with CRC-32 from step-2, the message is 0x7465737415521A21.
  4. CRC32 of 0x7465737415521A21 is 0xE1E9ADD7, shouldn't it be 0 here?

Can anyone point me to what went wrong?

1

1 Answers

3
votes

Actually, the CRC-32 algorithm has the following property:

  1. Suppose we have an arbitrary file x.
  2. Let y = crc32(x) in little endian.
  3. Then crc32(x append y) = 0x2144DF1C.