2.1.3.2 Calculate a CRC from a Given Array of Bytes
Given an initial value of the CRC field, as specified in section 2.1.3.1.1, or the value of the CRC field returned from a prior call (referred to in the following example as the crcValue field, which is a DWORD ([MS-DTYP])), the following is the algorithm for calculating the value of the CRC field for a given array of bytes (in pseudo-code). tablePosition is used as the index to get the value of crcTableValue from the CRC Lookup Table, as specified in section 2.1.2.2.1.
-
FOR each byte in the input array SET tablePosition to (crcValue XOR byte) BITWISE-AND 0xff SET intermediateValue to crcValue RIGHTSHIFTED by 8 bits SET crcValue to (crcTableValue at position tablePosition) XOR intermediateValue ENDFOR RETURN crcValue