CRC32 calculation for reconciliation factor

50 Views Asked by At

unsigned int buffer[] ={
0xffff, 0x1d24, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0, 0x0, 0x0, 0x0, 0x0}

1

There are 1 best solutions below

0
On

Assuming the buffer data is unsigned short, then try the buffer shown below, which should be the same CRC as the original buffer if using a left shifting CRC32.

unsigned short bfrx[] = {0xffff, 0x1d24, 0xffff, 0xffff, 
                         0xffff, 0xffff, 0xffff, 0xffff,
                         0xffff, 0xffff, 0xffff, 0xffff,
                         0xffff, 0xffff, 0xffff, 0xffff,
                         0xffff, 0xffff, 0xffff, 0xffff,
                         0x0000, 0x0000, 0x0000, 0x463f,
                         0x2dac};

What the question show is replacing 0xffff with 0x1d24, which is the same a xor'ing 0xffff with 0xe2db. Since there are 4 bytes of zeroes at the end of the buffer a simple approach would be to generate the CRC for a buffer with 4 less bytes:

unsigned short bfrz[] = {0x0000, 0xe2db, 0x0000, 0x0000,
                         0x0000, 0x0000, 0x0000, 0x0000,
                         0x0000, 0x0000, 0x0000, 0x0000,
                         0x0000, 0x0000, 0x0000, 0x0000,
                         0x0000, 0x0000, 0x0000, 0x0000,
                         0x0000, 0x0000, 0x0000};

Then store the CRC into the last 4 bytes of bfrx.

There is a more generic approach (reverse cycling and|or multiplying by power of 2), but I'm guessing on what the question is actually asking, so unless there is feedback, I can't offer a good explanation.