sq krb_pa_supported_enctypes
[metze/wireshark/wip.git] / wsutil / crc16.h
1 /* crc16.h
2  * Declaration of CRC-16 routines and table
3  *
4  * 2004 Richard van der Hoff <richardv@mxtelecom.com>
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * SPDX-License-Identifier: GPL-2.0-or-later
11 */
12
13 #ifndef __CRC16_H__
14 #define __CRC16_H__
15
16 #include "ws_symbol_export.h"
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif /* __cplusplus */
21
22 /* Calculate the CCITT/ITU/CRC-16 16-bit CRC
23
24    (parameters for this CRC are:
25        Polynomial: x^16 + x^12 + x^5 + 1  (0x1021);
26        Start value 0xFFFF;
27        XOR result with 0xFFFF;
28        First bit is LSB)
29 */
30
31 /** Compute CRC16 CCITT checksum of a buffer of data.
32  @param buf The buffer containing the data.
33  @param len The number of bytes to include in the computation.
34  @return The CRC16 CCITT checksum. */
35 WS_DLL_PUBLIC guint16 crc16_ccitt(const guint8 *buf, guint len);
36
37 /** Compute CRC16 X.25 CCITT checksum of a buffer of data.
38  @param buf The buffer containing the data.
39  @param len The number of bytes to include in the computation.
40  @return The CRC16 X.25 CCITT checksum. */
41 WS_DLL_PUBLIC guint16 crc16_x25_ccitt_seed(const guint8 *buf, guint len, guint16 seed);
42
43 /** Compute CRC16 CCITT checksum of a buffer of data.  If computing the
44  *  checksum over multiple buffers and you want to feed the partial CRC16
45  *  back in, remember to take the 1's complement of the partial CRC16 first.
46  @param buf The buffer containing the data.
47  @param len The number of bytes to include in the computation.
48  @param seed The seed to use.
49  @return The CRC16 CCITT checksum (using the given seed). */
50 WS_DLL_PUBLIC guint16 crc16_ccitt_seed(const guint8 *buf, guint len, guint16 seed);
51
52 /** Compute the 16bit CRC_A value of a buffer as defined in ISO14443-3.
53  @param buf The buffer containing the data.
54  @param len The number of bytes to include in the computation.
55  @return the CRC16 checksum for the buffer */
56 WS_DLL_PUBLIC guint16 crc16_iso14443a(const guint8 *buf, guint len);
57
58 /** Calculates a CRC16 checksum for the given buffer with the polynom
59  *  0x5935 using a precompiled CRC table
60  * @param buf a pointer to a buffer of the given length
61  * @param len the length of the given buffer
62  * @param seed The seed to use.
63  * @return the CRC16 checksum for the buffer
64  */
65 WS_DLL_PUBLIC guint16 crc16_0x5935(const guint8 *buf, guint32 len, guint16 seed);
66
67 /** Calculates a CRC16 checksum for the given buffer with the polynom
68  *  0x755B using a precompiled CRC table
69  * @param buf a pointer to a buffer of the given length
70  * @param len the length of the given buffer
71  * @param seed The seed to use.
72  * @return the CRC16 checksum for the buffer
73  */
74 WS_DLL_PUBLIC guint16 crc16_0x755B(const guint8 *buf, guint32 len, guint16 seed);
75
76 /** Computes CRC16 checksum for the given data with the polynom 0x9949 using
77  *  precompiled CRC table
78  * @param buf a pointer to a buffer of the given length
79  * @param len the length of the given buffer
80  * @param seed The seed to use.
81  * @return the CRC16 checksum for the buffer
82  */
83 WS_DLL_PUBLIC guint16 crc16_0x9949_seed(const guint8 *buf, guint len, guint16 seed);
84
85 /** Computes CRC16 checksum for the given data with the polynom 0x3D65 using
86  *  precompiled CRC table
87  * @param buf a pointer to a buffer of the given length
88  * @param len the length of the given buffer
89  * @param seed The seed to use.
90  * @return the CRC16 checksum for the buffer
91  */
92 WS_DLL_PUBLIC guint16 crc16_0x3D65_seed(const guint8 *buf, guint len, guint16 seed);
93
94 /** Computes CRC16 checksum for the given data with the polynom 0x080F using
95  *  precompiled CRC table
96  * @param buf a pointer to a buffer of the given length
97  * @param len the length of the given buffer
98  * @param seed The seed to use.
99  * @return the CRC16 checksum for the buffer
100  */
101 WS_DLL_PUBLIC guint16 crc16_0x080F_seed(const guint8 *buf, guint len, guint16 seed);
102
103 #ifdef __cplusplus
104 }
105 #endif /* __cplusplus */
106
107 #endif /* crc16.h */