chiark / gitweb /
@@@ much mess, mostly manpages
[mLib] / hash / crc32.3.in
CommitLineData
c4ccbbf9
MW
1.\" -*-nroff-*-
2.\"
3.\" Manual for CRC23 calculator
4.\"
5.\" (c) 1999--2001, 2003, 2005, 2009, 2024 Straylight/Edgeware
6.\"
7.
8.\"----- Licensing notice ---------------------------------------------------
9.\"
10.\" This file is part of the mLib utilities library.
11.\"
12.\" mLib is free software: you can redistribute it and/or modify it under
13.\" the terms of the GNU Library General Public License as published by
14.\" the Free Software Foundation; either version 2 of the License, or (at
15.\" your option) any later version.
16.\"
17.\" mLib is distributed in the hope that it will be useful, but WITHOUT
18.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19.\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
20.\" License for more details.
21.\"
22.\" You should have received a copy of the GNU Library General Public
23.\" License along with mLib. If not, write to the Free Software
24.\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
25.\" USA.
26.
27.\"--------------------------------------------------------------------------
28.so ../defs.man \" @@@PRE@@@
29.
30.\"--------------------------------------------------------------------------
31.TH crc32 3mLib "8 May 1999" "Straylight/Edgeware" "mLib utilities library"
32.\" @crc32
33.
34.\"--------------------------------------------------------------------------
35.SH NAME
36crc32 \- calculate 32-bit CRC
37.
38.\"--------------------------------------------------------------------------
39.SH SYNOPSIS
40.
41.nf
42.B "#include <mLib/crc32.h>"
43.PP
44.BI "uint32 crc32(uint32 " crc ", const void *" buf ", size_t " sz );
45.BI CRC32( result ", " crc ", " buf ", " sz )
46.fi
47.
48.\"--------------------------------------------------------------------------
49.SH DESCRIPTION
50.
51The
52.B crc32
53function calculates a 32-bit cyclic redundancy check of the data block
54at address
55.I buf
56and size
57.I sz
58passed to it.
59.PP
60The function is restartable. For a first call, pass zero as the value
61of the
62.I crc
63argument; for subsequent blocks, pass in the previous output. The final
64answer is equal to the result you'd get from computing a CRC over the
65concatenation of the individual blocks.
66.PP
67The
68.B CRC32
69macro calculates a CRC inline. The calculated CRC value is placed in
70the variable named by
71.IR result .
72Only use the macro version when efficiency is a major concern: it makes
73the code rather harder to read.
74.PP
75Note that a CRC is not cryptographically strong: it's fairly easy for an
76adversary to construct blocks of data with any desired CRC, or to modify
77a given block in a way which doesn't change its (unknown) CRC.
78.PP
79The exact behaviour of the CRC is beyond the scope of this manual;
80suffice to say that the result is, in some suitable representation, the
81remainder after division by a degree-32 polynomial in GF(2)[x].
82.
83.\"--------------------------------------------------------------------------
84.SH "RETURN VALUE"
85The return value is the 32-bit CRC of the input block.
86.
87.\"--------------------------------------------------------------------------
88.SH "SEE ALSO"
89.
90.BR unihash (3),
91.BR mLib (3).
92.
93.\"--------------------------------------------------------------------------
94.SH AUTHOR
95.
96Mark Wooding, <mdw@distorted.org.uk>
97.
98.\"----- That's all, folks --------------------------------------------------