1 /* crc.h -- cyclic redundancy checks
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 /* Written by Simon Josefsson. */
25 # include <inttypes.h>
31 /* Compute CRC-32 value of LEN bytes long BUF, and return it. */
32 extern uint32_t crc32 (const char *buf, size_t len);
34 /* Incrementally update CRC-32 value CRC using LEN bytes long BUF. In
35 the first call, use 0 as the value for CRC. Return the updated
37 extern uint32_t crc32_update (uint32_t crc, const char *buf, size_t len);
39 /* Compute modified-CRC-32 value of LEN bytes long BUF, and return it.
40 The "modification" is to avoid the initial and final XOR operation.
41 Due to historic implementation errors, this variant is sometimes
42 used (i.e., in RFC 3961). */
43 extern uint32_t crc32_no_xor (const char *buf, size_t len);
45 /* Incrementally update modified-CRC-32 value CRC using LEN bytes long
46 BUF. In the first call, use 0 as the value for CRC. Return the
47 updated modified-CRC-32 value. The "modification" is to avoid the
48 initial and final XOR operation. Due to historic implementation
49 errors, this variant is sometimes used (i.e., in RFC 3961). */
51 crc32_update_no_xor (uint32_t crc, const char *buf, size_t len);