crc table lookup not giving the same result as basic implementation

110 Views Asked by At

The basic implementation of CRC uses XOR and left-shift operations to find the remainder. While the index of the leftmost bit of the remainder is greater than the degree of the generator polynomial, the bits of the generator polynomial are left-shifted until the index of the leftmost bit of the remainder is aligned with the leftmost bit of the generator polynomial, then the remainder is XORed with the generator polynomial.

For example, using one of the most common CRC-32, whose generator is the following generator polynomial (0x04C11DB7): $$ x^{32} + x^{26} + x^{23} + x^{22} + x^{16} + x^{12} + x^{11} + x^{10} + x^{8} + x^{7} + x^{5} + x^{4} + x^{2} + x + 1 $$

Let's say the message is 101010 = 0x2A, then the remainder for this given message and generator polynomial would be:

101010 << 32

$\dfrac{101010 00000000000000000000000000000000}{100000 10011000001000111011011011100000}$

$\dfrac{001010 10011000001000111011011011100000}{001000 00100110000010001110110110111000}$

$\dfrac{000010 10111110001010110101101101011000}{000010 00001001100000100011101101101110}$

remainder = 1011 0111 1010 1001 0110 0000 0011 0110 = 0xB7A9 6036

Then if we go to https://crccalc.com/ and execute the CRC-32 algorithm on the same message, we get the result 0x09B9 265B.

Why are those two results differents? Is it normal that both algorithm do not return the same result? Am I missing something?