Wireshark-dev: Re: [Wireshark-dev] Calculating CRC5 of 11-bit data
From: Tomasz Moń <desowin@xxxxxxxxx>
Date: Sat, 20 Jul 2019 05:37:40 +0200
On Sat, Jul 20, 2019 at 2:35 AM Guy Harris <guy@xxxxxxxxxxxx> wrote:
> On Jul 19, 2019, at 9:26 AM, Tomasz Moń <desowin@xxxxxxxxx> wrote:
> > 1. Compute the CRC5 bitwise on the 11 bits of data, or
> > 2. Compute the CRC5 with table-based algorithm on 2 bytes (11 bits
> > data + 5 bits CRC) and relying on the CRC properties expect fixed
> > output.
>
> Meaning that if you run the CRC on the entire Link Control Word, including the 5-bit CRC and the remaining 11 bits, the result should be a fixed value?  (Is that what "The residual of CRC-5 shall be 01100b." is referring to?)

Yes, the CRC residue is what you should get after computing CRC over
the message *and* its message's CRC.
In case of CRC-5/USB the residual is decimal 6 (which matches the
value 01100b from your quote if it is lsb first).

> If the goal is just to check the CRC, approach 2) seems as if it's as good as approach 1), and may involve a simpler implementation.

The advantage of 1) over 2) is the ability to be able, if the CRC is
incorrect, to tell what the correct CRC should have been.
Approach 2) allows only to veify if the CRC is correct - but at the
advantage of being able to take full bytes as input.