I can extend coreutils cksum if you like, what are your thoughts on adding some parameters to the commandline? Even if it's just an extra flag for --rfc1952 or --gzip to change all the parameters just between these two variants?
On Thu, Oct 31, 2024, 17:41 Sam Russell <sam.h.russ...@gmail.com> wrote: > These are all solvable: > > Polynomial: technically the same but one could argue it's the reversed > version (we reverse the polynomial so we can read LSB first). We now > generate the tables at compile time so this could be a parameter to table > generation > Initial/final value: easy enough to configure at runtime or compile-time; > gnulib exports the inner functions (without inner/final xor values) so > these can be called directly > Reverse data: easy enough to make a compile-time function, but given we're > also looking up the tables by byte so no byte swapping needs to happen, we > can just map different offsets (so instead of data[0>, data[1] we can count > the other direction, or reverse the order of the lookup tables at compile > time) > Reverse CRC: easy to have as a run-time parameter. > > The pclmul is a little trickier, the intel paper covers the reversed > polynomial case though. We use different parameters (from the paper), and > iirc we swap taking hiword instead of loword and vice versa. > > On Thu, Oct 31, 2024, 17:12 Pádraig Brady <p...@draigbrady.com> wrote: > >> On 31/10/2024 12:18, Simon Josefsson via Gnulib discussion list wrote: >> > I merged this now, thank you! >> >> FYI, I looked at using this from coreutils cksum, >> but unfortunately that uses a different CRC-32 variant. >> >> For my reference... >> >> coreutils cksum parameters: >> ------------------------ >> Polynomial: 04C11DB7 >> Initial Value: 00000000 >> Final XOR Value: 00000000 >> Reverse data: no >> Reverse crc (before xor): no >> >> gnulib crc32 parameters (equivalent): >> ------------------------ >> Polynomial: 04C11DB7 >> Initial Value: FFFFFFFF >> Final XOR Value: FFFFFFFF >> Reverse data: yes >> Reverse crc (before xor): yes >> >> https://github.com/Michaelangel007/crc32 >> http://www.zorc.breitbandkatze.de/crc.html >> >> cheers, >> Pádraig >> >