2 .TH crc32 3mLib "8 May 1999" "mLib"
4 crc32 \- calculate 32-bit CRC
7 .B "#include <mLib/crc32.h>"
9 .BI "int crc32(unsigned long " crc ", const void *" buf ", size_t " sz );
10 .BI CRC32( result ", " crc ", " buf ", " sz )
15 function calculates a 32-bit cyclic redundancy check of the data block
22 The function is restartable. For a first call, pass zero as the value
25 argument; for subsequent blocks, pass in the previous output. The final
26 answer is equal to the result you'd get from computing a CRC over the
27 concatenation of the individual blocks.
31 macro calculates a CRC inline. The calculated CRC value is placed in
34 Only use the macro version when efficiency is a major concern: it makes
35 the code rather harder to read.
37 Note that a CRC is not cryptographically strong: it's fairly easy for an
38 adversary to construct blocks of data with any desired CRC, or to modify
39 a given block in a way which doesn't change its (unknown) CRC.
41 The exact behaviour of the CRC is beyond the scope of this manual;
42 suffice to say that the result is, in some suitable representation, the
43 remainder after division in the finite field GF(2^32) of the block by a
44 carefully chosen polynomial of order 32.
46 The return value is the 32-bit CRC of the input block.
48 Mark Wooding, <mdw@nsict.org>