crc.h revision 5ae5011f5a5bce195e3f675803b667ec383d57ee
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** @file
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * IPRT - CRCs and Checksums.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/*
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Copyright (C) 2006-2009 Sun Microsystems, Inc.
5d39cab83ac9a6c6e4c5da4690ac53b4cfec73aavboxsync *
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * available from http://www.virtualbox.org. This file is free software;
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * you can redistribute it and/or modify it under the terms of the GNU
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * General Public License (GPL) as published by the Free Software
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync *
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * The contents of this file may alternatively be used under the terms
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * of the Common Development and Distribution License Version 1.0
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync * VirtualBox OSE distribution, in which case the provisions of the
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync * CDDL are applicable instead of those of the GPL.
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync *
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync * You may elect to license modified versions of this file under the
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync * terms and conditions of either the GPL or the CDDL or both.
1ce069685b24d243eb0464f46d4c56b250c64445vboxsync *
a55af63ead2dcca370bfc0dfe49771d9dcc61b93vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
e0778e583cb4a0bdc9bcc48f5957e00a01108388vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * additional information or have any questions.
a55af63ead2dcca370bfc0dfe49771d9dcc61b93vboxsync */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync#ifndef ___iprt_crc_h
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync#define ___iprt_crc_h
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync#include <iprt/cdefs.h>
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync#include <iprt/types.h>
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsyncRT_C_DECLS_BEGIN
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync/** @defgroup grp_rt_crc RTCrc - Checksums and CRCs.
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync * @ingroup grp_rt
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync * @{
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync */
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync/** @defgroup grp_rt_crc32 CRC-32
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync * @{ */
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync/**
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync * Calculate CRC-32 for a memory block.
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync *
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @returns CRC-32 for the memory block.
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync * @param pv Pointer to the memory block.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @param cb Size of the memory block in bytes.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRTDECL(uint32_t) RTCrc32(const void *pv, size_t cb);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/**
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Start a multiblock CRC-32 calculation.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync *
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @returns Start CRC-32.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRTDECL(uint32_t) RTCrc32Start(void);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/**
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Processes a multiblock of a CRC-32 calculation.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync *
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @returns Intermediate CRC-32 value.
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync * @param uCRC32 Current CRC-32 intermediate value.
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync * @param pv The data block to process.
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync * @param cb The size of the data block in bytes.
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync */
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsyncRTDECL(uint32_t) RTCrc32Process(uint32_t uCRC32, const void *pv, size_t cb);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/**
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Complete a multiblock CRC-32 calculation.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync *
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @returns CRC-32 value.
a2d9f81753c129b5e3bbe3769627dcd25a3724bdvboxsync * @param uCRC32 Current CRC-32 intermediate value.
a2d9f81753c129b5e3bbe3769627dcd25a3724bdvboxsync */
a2d9f81753c129b5e3bbe3769627dcd25a3724bdvboxsyncRTDECL(uint32_t) RTCrc32Finish(uint32_t uCRC32);
a2d9f81753c129b5e3bbe3769627dcd25a3724bdvboxsync/** @} */
a2d9f81753c129b5e3bbe3769627dcd25a3724bdvboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** @defgroup grp_rt_crc64 CRC-64 Calculation
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @{ */
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync/**
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Calculate CRC-64 for a memory block.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync *
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @returns CRC-64 for the memory block.
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync * @param pv Pointer to the memory block.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @param cb Size of the memory block in bytes.
a2d9f81753c129b5e3bbe3769627dcd25a3724bdvboxsync */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRTDECL(uint64_t) RTCrc64(const void *pv, size_t cb);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/**
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync * Start a multiblock CRC-64 calculation.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync *
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync * @returns Start CRC-64.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRTDECL(uint64_t) RTCrc64Start(void);
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync/**
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync * Processes a multiblock of a CRC-64 calculation.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync *
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @returns Intermediate CRC-64 value.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @param uCRC64 Current CRC-64 intermediate value.
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync * @param pv The data block to process.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync * @param cb The size of the data block in bytes.
7bf07b1592dfaab1a4fb6d497fd0ff1302fb7585vboxsync */
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsyncRTDECL(uint64_t) RTCrc64Process(uint64_t uCRC64, const void *pv, size_t cb);
7c1f498692cd2393f8ba68cb62be482495106f93vboxsync
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync/**
7c1f498692cd2393f8ba68cb62be482495106f93vboxsync * Complete a multiblock CRC-64 calculation.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync *
4c8907a420ed66a42f729eb08cddf9c1e57f25eavboxsync * @returns CRC-64 value.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync * @param uCRC64 Current CRC-64 intermediate value.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRTDECL(uint64_t) RTCrc64Finish(uint64_t uCRC64);
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync/** @} */
66b8ee000e49b0cc08a897451350cd6927d77b60vboxsync
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync/** @defgroup grp_rt_crc_adler32 Adler-32
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync * @{ */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/**
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Calculate Adler-32 for a memory block.
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync *
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync * @returns Adler-32 for the memory block.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync * @param pv Pointer to the memory block.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @param cb Size of the memory block in bytes.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync */
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsyncRTDECL(uint32_t) RTCrcAdler32(void const *pv, size_t cb);
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync/**
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Start a multiblock Adler-32 calculation.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync *
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync * @returns Start Adler-32.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync */
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsyncRTDECL(uint32_t) RTCrcAdler32Start(void);
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync
7e8d44e04156d78379666f20d5daa2a79e5cbf44vboxsync/**
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync * Processes a multiblock of a Adler-32 calculation.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync *
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @returns Intermediate Adler-32 value.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @param uCrc Current Adler-32 intermediate value.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @param pv The data block to process.
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync * @param cb The size of the data block in bytes.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync */
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsyncRTDECL(uint32_t) RTCrcAdler32Process(uint32_t uCrc, void const *pv, size_t cb);
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync/**
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync * Complete a multiblock Adler-32 calculation.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync *
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync * @returns Adler-32 value.
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * @param uCrc Current Adler-32 intermediate value.
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync */
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsyncRTDECL(uint32_t) RTCrcAdler32Finish(uint32_t uCrc);
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync/** @} */
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync/** @} */
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsyncRT_C_DECLS_END
85bc82f92f4d7a7b95e96d133c4847b2847703dfvboxsync
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync#endif
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync