dcerpc-netlogon: all netr_LogonControl[2[Ex]] calls have the same reply values
[wireshark-sm.git] / wsutil / crc32.h
blobc6891730e0ca9dfe77e4201be349276b09880e3b
1 /** @file
2 * Declaration of CRC-32 routine and table
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
11 #ifndef __CRC32_H__
12 #define __CRC32_H__
14 #include <wireshark.h>
16 #ifdef __cplusplus
17 extern "C" {
18 #endif /* __cplusplus */
20 #define CRC32_CCITT_SEED 0xFFFFFFFF
21 #define CRC32C_PRELOAD 0xffffffff
22 #define CRC32_MPEG2_SEED 0xFFFFFFFF
25 * Byte swap fix contributed by Dave Wysochanski <davidw@netapp.com>.
27 #define CRC32C_SWAP(crc32c_value) \
28 (((crc32c_value & 0xff000000) >> 24) | \
29 ((crc32c_value & 0x00ff0000) >> 8) | \
30 ((crc32c_value & 0x0000ff00) << 8) | \
31 ((crc32c_value & 0x000000ff) << 24))
33 /** Lookup the crc value in the crc32_ccitt_table
34 @param pos Position in the table. */
35 WS_DLL_PUBLIC uint32_t crc32_ccitt_table_lookup (unsigned char pos);
37 /** Lookup the crc value in the crc32c_table
38 @param pos Position in the table. */
39 WS_DLL_PUBLIC uint32_t crc32c_table_lookup (unsigned char pos);
41 /** Compute CRC32C checksum of a buffer of data.
42 @param buf The buffer containing the data.
43 @param len The number of bytes to include in the computation.
44 @param crc The preload value for the CRC32C computation.
45 @return The CRC32C checksum. */
46 WS_DLL_PUBLIC uint32_t crc32c_calculate(const void *buf, int len, uint32_t crc);
48 /** Compute CRC32C checksum of a buffer of data without swapping seed crc
49 or completed checksum
50 @param buf The buffer containing the data.
51 @param len The number of bytes to include in the computation.
52 @param crc The preload value for the CRC32C computation.
53 @return The CRC32C checksum. */
54 WS_DLL_PUBLIC uint32_t crc32c_calculate_no_swap(const void *buf, int len, uint32_t crc);
56 /** Compute CRC32 CCITT checksum of a buffer of data.
57 @param buf The buffer containing the data.
58 @param len The number of bytes to include in the computation.
59 @return The CRC32 CCITT checksum. */
60 WS_DLL_PUBLIC uint32_t crc32_ccitt(const uint8_t *buf, unsigned len);
62 /** Compute CRC32 CCITT checksum of a buffer of data. If computing the
63 * checksum over multiple buffers and you want to feed the partial CRC32
64 * back in, remember to take the 1's complement of the partial CRC32 first.
65 @param buf The buffer containing the data.
66 @param len The number of bytes to include in the computation.
67 @param seed The seed to use.
68 @return The CRC32 CCITT checksum (using the given seed). */
69 WS_DLL_PUBLIC uint32_t crc32_ccitt_seed(const uint8_t *buf, unsigned len, uint32_t seed);
71 /** Compute MPEG-2 CRC32 checksum of a buffer of data.
72 @param buf The buffer containing the data.
73 @param len The number of bytes to include in the computation.
74 @param seed The seed to use.
75 @return The CRC32 MPEG-2 checksum (using the given seed). */
76 WS_DLL_PUBLIC uint32_t crc32_mpeg2_seed(const uint8_t *buf, unsigned len, uint32_t seed);
78 /** Computes CRC32 checksum for the given data with the polynom 0x0AA725CF using
79 * precompiled CRC table
80 * @param buf a pointer to a buffer of the given length
81 * @param len the length of the given buffer
82 * @param seed The seed to use.
83 * @return the CRC32 checksum for the buffer
85 WS_DLL_PUBLIC uint32_t crc32_0x0AA725CF_seed(const uint8_t *buf, unsigned len, uint32_t seed);
87 /** Computes CRC32 checksum for the given data with the polynom 0x5D6DCB using
88 * precompiled CRC table
89 * @param buf a pointer to a buffer of the given length
90 * @param len the length of the given buffer
91 * @param seed The seed to use.
92 * @return the CRC32 checksum for the buffer
94 WS_DLL_PUBLIC uint32_t crc32_0x5D6DCB_seed(const uint8_t *buf, unsigned len, uint32_t seed);
96 WS_DLL_PUBLIC int Dot11DecryptWepDecrypt(
97 const unsigned char *seed,
98 const size_t seed_len,
99 unsigned char *cypher_text,
100 const size_t data_len);
102 #ifdef __cplusplus
104 #endif /* __cplusplus */
106 #endif /* crc32.h */