chiark / gitweb /
Add a slew of manual pages.
[mLib] / man / crc32.3
... / ...
CommitLineData
1.\" -*-nroff-*-
2.TH crc32 3mLib "8 May 1999" "mLib"
3.SH NAME
4crc32 \- calculate 32-bit CRC
5.SH SYNOPSIS
6.nf
7.B "#include <mLib/crc32.h>"
8
9.BI "int crc32(unsigned long " crc ", const void *" buf ", size_t " sz );
10.BI CRC32( result ", " crc ", " buf ", " sz )
11.fi
12.SH DESCRIPTION
13The
14.B crc32
15function calculates a 32-bit cyclic redundancy check of the data block
16at address
17.I buf
18and size
19.I sz
20passed to it.
21.PP
22The function is restartable. For a first call, pass zero as the value
23of the
24.I crc
25argument; for subsequent blocks, pass in the previous output. The final
26answer is equal to the result you'd get from computing a CRC over the
27concatenation of the individual blocks.
28.PP
29The
30.B CRC32
31macro calculates a CRC inline. The calculated CRC value is placed in
32the variable named by
33.IR result .
34Only use the macro version when efficiency is a major concern: it makes
35the code rather harder to read.
36.PP
37Note that a CRC is not cryptographically strong: it's fairly easy for an
38adversary to construct blocks of data with any desired CRC, or to modify
39a given block in a way which doesn't change its (unknown) CRC.
40.PP
41The exact behaviour of the CRC is beyond the scope of this manual;
42suffice to say that the result is, in some suitable representation, the
43remainder after division in the finite field GF(2^32) of the block by a
44carefully chosen polynomial of order 32.
45.SH "RETURN VALUE"
46The return value is the 32-bit CRC of the input block.
47.SH AUTHOR
48Mark Wooding, <mdw@nsict.org>