VirtualBox

source: vbox/trunk/include/iprt/crc.h@ 53370

Last change on this file since 53370 was 50526, checked in by vboxsync, 11 years ago

Storage/VHDX: Finally commit and enable CRC-32c checksum validation after finding the cause for the failing checksum computation. The whole 4KB space needs to get used for the checksum though the header is only 512 bytes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1/** @file
2 * IPRT - CRCs and Checksums.
3 */
4
5/*
6 * Copyright (C) 2006-2010 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___iprt_crc_h
27#define ___iprt_crc_h
28
29#include <iprt/cdefs.h>
30#include <iprt/types.h>
31
32
33RT_C_DECLS_BEGIN
34
35/** @defgroup grp_rt_crc RTCrc - Checksums and CRCs.
36 * @ingroup grp_rt
37 * @{
38 */
39
40
41/** @defgroup grp_rt_crc32 CRC-32
42 * @{ */
43/**
44 * Calculate CRC-32 for a memory block.
45 *
46 * @returns CRC-32 for the memory block.
47 * @param pv Pointer to the memory block.
48 * @param cb Size of the memory block in bytes.
49 */
50RTDECL(uint32_t) RTCrc32(const void *pv, size_t cb);
51
52/**
53 * Start a multiblock CRC-32 calculation.
54 *
55 * @returns Start CRC-32.
56 */
57RTDECL(uint32_t) RTCrc32Start(void);
58
59/**
60 * Processes a multiblock of a CRC-32 calculation.
61 *
62 * @returns Intermediate CRC-32 value.
63 * @param uCRC32 Current CRC-32 intermediate value.
64 * @param pv The data block to process.
65 * @param cb The size of the data block in bytes.
66 */
67RTDECL(uint32_t) RTCrc32Process(uint32_t uCRC32, const void *pv, size_t cb);
68
69/**
70 * Complete a multiblock CRC-32 calculation.
71 *
72 * @returns CRC-32 value.
73 * @param uCRC32 Current CRC-32 intermediate value.
74 */
75RTDECL(uint32_t) RTCrc32Finish(uint32_t uCRC32);
76/** @} */
77
78
79/** @defgroup grp_rt_crc64 CRC-64 Calculation
80 * @{ */
81/**
82 * Calculate CRC-64 for a memory block.
83 *
84 * @returns CRC-64 for the memory block.
85 * @param pv Pointer to the memory block.
86 * @param cb Size of the memory block in bytes.
87 */
88RTDECL(uint64_t) RTCrc64(const void *pv, size_t cb);
89
90/**
91 * Start a multiblock CRC-64 calculation.
92 *
93 * @returns Start CRC-64.
94 */
95RTDECL(uint64_t) RTCrc64Start(void);
96
97/**
98 * Processes a multiblock of a CRC-64 calculation.
99 *
100 * @returns Intermediate CRC-64 value.
101 * @param uCRC64 Current CRC-64 intermediate value.
102 * @param pv The data block to process.
103 * @param cb The size of the data block in bytes.
104 */
105RTDECL(uint64_t) RTCrc64Process(uint64_t uCRC64, const void *pv, size_t cb);
106
107/**
108 * Complete a multiblock CRC-64 calculation.
109 *
110 * @returns CRC-64 value.
111 * @param uCRC64 Current CRC-64 intermediate value.
112 */
113RTDECL(uint64_t) RTCrc64Finish(uint64_t uCRC64);
114/** @} */
115
116
117/** @defgroup grp_rt_crc_adler32 Adler-32
118 * @{ */
119/**
120 * Calculate Adler-32 for a memory block.
121 *
122 * @returns Adler-32 for the memory block.
123 * @param pv Pointer to the memory block.
124 * @param cb Size of the memory block in bytes.
125 */
126RTDECL(uint32_t) RTCrcAdler32(void const *pv, size_t cb);
127
128/**
129 * Start a multiblock Adler-32 calculation.
130 *
131 * @returns Start Adler-32.
132 */
133RTDECL(uint32_t) RTCrcAdler32Start(void);
134
135/**
136 * Processes a multiblock of a Adler-32 calculation.
137 *
138 * @returns Intermediate Adler-32 value.
139 * @param uCrc Current Adler-32 intermediate value.
140 * @param pv The data block to process.
141 * @param cb The size of the data block in bytes.
142 */
143RTDECL(uint32_t) RTCrcAdler32Process(uint32_t uCrc, void const *pv, size_t cb);
144
145/**
146 * Complete a multiblock Adler-32 calculation.
147 *
148 * @returns Adler-32 value.
149 * @param uCrc Current Adler-32 intermediate value.
150 */
151RTDECL(uint32_t) RTCrcAdler32Finish(uint32_t uCrc);
152
153/** @} */
154
155
156/** @defgroup grp_rt_crc32c CRC-32C
157 * @{ */
158/**
159 * Calculate CRC-32C for a memory block.
160 *
161 * @returns CRC-32C for the memory block.
162 * @param pv Pointer to the memory block.
163 * @param cb Size of the memory block in bytes.
164 */
165RTDECL(uint32_t) RTCrc32C(const void *pv, size_t cb);
166
167/**
168 * Start a multiblock CRC-32 calculation.
169 *
170 * @returns Start CRC-32.
171 */
172RTDECL(uint32_t) RTCrc32CStart(void);
173
174/**
175 * Processes a multiblock of a CRC-32C calculation.
176 *
177 * @returns Intermediate CRC-32C value.
178 * @param uCRC32C Current CRC-32C intermediate value.
179 * @param pv The data block to process.
180 * @param cb The size of the data block in bytes.
181 */
182RTDECL(uint32_t) RTCrc32CProcess(uint32_t uCRC32C, const void *pv, size_t cb);
183
184/**
185 * Complete a multiblock CRC-32 calculation.
186 *
187 * @returns CRC-32 value.
188 * @param uCRC32 Current CRC-32 intermediate value.
189 */
190RTDECL(uint32_t) RTCrc32CFinish(uint32_t uCRC32);
191
192/** @} */
193
194/** @} */
195
196RT_C_DECLS_END
197
198#endif
199
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette