[NUT-devel] Incomplete description of checksum algorithm

Michael Niedermayer michaelni at gmx.at
Thu Feb 16 19:47:49 CET 2006


Hi

On Thu, Feb 16, 2006 at 12:12:11PM -0500, Rich Felker wrote:
> On Thu, Feb 16, 2006 at 04:44:02PM +0100, Michael Niedermayer wrote:
> > Hi
> > 
> > On Thu, Feb 16, 2006 at 01:47:32AM +0100, Alexander Strasser wrote:
> > [...]
> > > > crc32 checksum
> > > >     The checksum is choosen so that c(x) is a multiple of
> > > >     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 over GF(2)
> > > >     c(x) is the polynom coresponding to the block from and including the
> > > >     forward ptr and upto and including the checksum
> > > >     c(x)= (1&(d[0]>>8))*x^(n-1) + (1&(d[0]>>7))*x^(n- 2) + ...
> > > >         + (1&(d[1]>>8))*x^(n-9) + (1&(d[1]>>7))*x^(n-10) + ...
> > > >         + ...
> > > >         + ... + (1&(d[n/8-1]>>1))*x^1 + (1&(d[n/8-1]>>0))*x^0
> > > >     alternatively you can simply run
> > > >     crc=0;
> > > >     for(i=0; i<size; i++){
> > > >         crc ^= buf[i]<<24;
> > > >         for(j=0; j<8; j++)
> > > >             crc= (crc<<1) ^ (0x04C11DB7 & (crc>>31));
> > > >     }
> > > >     over the data  
> > > 
> > >   ok, while we are at it, should we use non zero initial value? if yes which?
> > 
> > personally i would simply include the forward ptr, so the all zero case would
> > naturally be gone, if the others are against this then we must either use a 
> 
> Is there an all-zero case? As far as I can tell, there's no NUT packet
> that's valid as all zeros, except possibly the very first
> syncpoint/header pair in the file.

maybe, but having all zero packets with always matching checksum is risky, 
we will have to check that no change we do might lead to legal all zero
packets, and its also more tricky on the demuxer side (search for a packet 
with matchig checksum vs. search for a packet we can parse with no errors 
and which has a matching checksum)

[...]

-- 
Michael




More information about the NUT-devel mailing list