3 .\" Manual for CRC23 calculator
5 .\" (c) 1999--2001, 2003, 2005, 2009, 2024 Straylight/Edgeware
8 .\"----- Licensing notice ---------------------------------------------------
10 .\" This file is part of the mLib utilities library.
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.
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.
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,
27 .\"--------------------------------------------------------------------------
28 .so ../defs.man \" @@@PRE@@@
30 .\"--------------------------------------------------------------------------
31 .TH crc32 3mLib "8 May 1999" "Straylight/Edgeware" "mLib utilities library"
34 .\"--------------------------------------------------------------------------
36 crc32 \- calculate 32-bit CRC
38 .\"--------------------------------------------------------------------------
42 .B "#include <mLib/crc32.h>"
44 .BI "uint32 crc32(uint32 " crc ", const void *" buf ", size_t " sz );
45 .BI CRC32( result ", " crc ", " buf ", " sz )
48 .\"--------------------------------------------------------------------------
53 function calculates a 32-bit cyclic redundancy check of the data block
60 The function is restartable. For a first call, pass zero as the value
63 argument; for subsequent blocks, pass in the previous output. The final
64 answer is equal to the result you'd get from computing a CRC over the
65 concatenation of the individual blocks.
69 macro calculates a CRC inline. The calculated CRC value is placed in
72 Only use the macro version when efficiency is a major concern: it makes
73 the code rather harder to read.
75 Note that a CRC is not cryptographically strong: it's fairly easy for an
76 adversary to construct blocks of data with any desired CRC, or to modify
77 a given block in a way which doesn't change its (unknown) CRC.
79 The exact behaviour of the CRC is beyond the scope of this manual;
80 suffice to say that the result is, in some suitable representation, the
81 remainder after division by a degree-32 polynomial in GF(2)[x].
83 .\"--------------------------------------------------------------------------
85 The return value is the 32-bit CRC of the input block.
87 .\"--------------------------------------------------------------------------
93 .\"--------------------------------------------------------------------------
96 Mark Wooding, <mdw@distorted.org.uk>
98 .\"----- That's all, folks --------------------------------------------------