Debian Codegraph @

libdrgn/crc32.h

raw
1 // Copyright (c) Meta Platforms, Inc. and affiliates.
2 // SPDX-License-Identifier: LGPL-2.1-or-later
3
4 /**
5 * @file
6 *
7 * CRC-32 checksums.
8 *
9 * See @ref CRC32.
10 */
11
12 #ifndef DRGN_CRC32_H
13 #define DRGN_CRC32_H
14
15 #include <stddef.h>
16 #include <stdint.h>
17
18 /**
19 * @ingroup Internals
20 *
21 * @defgroup CRC32 CRC-32
22 *
23 * CRC-32 checksums.
24 *
25 * @{
26 */
27
28 /**
29 * Update a CRC-32 checksum with additional data.
30 *
31 * This uses the IEEE CRC-32 polynomial (<EM>x</EM><SUP>32</SUP> +
32 * <EM>x</EM><SUP>26</SUP> + <EM>x</EM><SUP>23</SUP> + <EM>x</EM><SUP>22</SUP> +
33 * <EM>x</EM><SUP>16</SUP> + <EM>x</EM><SUP>12</SUP> + <EM>x</EM><SUP>11</SUP> +
34 * <EM>x</EM><SUP>10</SUP> + <EM>x</EM><SUP>8</SUP> + <EM>x</EM><SUP>7</SUP> +
35 * <EM>x</EM><SUP>5</SUP> + <EM>x</EM><SUP>4</SUP> + <EM>x</EM><SUP>2</SUP> +
36 * <EM>x</EM> + 1).
37 *
38 * @param[in] crc Checksum to update. For the first call, this is the initial
39 * checksum value (often `0xffffffff`).
40 * @param[in] buf Data to checksum.
41 * @param[in] len Size of @p buf in bytes.
42 * @return Updated checksum. This is not bitwise negated as is often required
43 * for the final result.
44 */
45 uint32_t crc32_update(uint32_t crc, const void *buf, size_t len);
46
47 /** @} */
48
49 #endif /* DRGN_CRC32_H */