Path: blob/master/Utilities/cmliblzma/liblzma/api/lzma/check.h
3158 views
/* SPDX-License-Identifier: 0BSD */12/**3* \file lzma/check.h4* \brief Integrity checks5* \note Never include this file directly. Use <lzma.h> instead.6*/78/*9* Author: Lasse Collin10*/1112#ifndef LZMA_H_INTERNAL13# error Never include this file directly. Use <lzma.h> instead.14#endif151617/**18* \brief Type of the integrity check (Check ID)19*20* The .xz format supports multiple types of checks that are calculated21* from the uncompressed data. They vary in both speed and ability to22* detect errors.23*/24typedef enum {25LZMA_CHECK_NONE = 0,26/**<27* No Check is calculated.28*29* Size of the Check field: 0 bytes30*/3132LZMA_CHECK_CRC32 = 1,33/**<34* CRC32 using the polynomial from the IEEE 802.3 standard35*36* Size of the Check field: 4 bytes37*/3839LZMA_CHECK_CRC64 = 4,40/**<41* CRC64 using the polynomial from the ECMA-182 standard42*43* Size of the Check field: 8 bytes44*/4546LZMA_CHECK_SHA256 = 1047/**<48* SHA-25649*50* Size of the Check field: 32 bytes51*/52} lzma_check;535455/**56* \brief Maximum valid Check ID57*58* The .xz file format specification specifies 16 Check IDs (0-15). Some59* of them are only reserved, that is, no actual Check algorithm has been60* assigned. When decoding, liblzma still accepts unknown Check IDs for61* future compatibility. If a valid but unsupported Check ID is detected,62* liblzma can indicate a warning; see the flags LZMA_TELL_NO_CHECK,63* LZMA_TELL_UNSUPPORTED_CHECK, and LZMA_TELL_ANY_CHECK in container.h.64*/65#define LZMA_CHECK_ID_MAX 15666768/**69* \brief Test if the given Check ID is supported70*71* LZMA_CHECK_NONE and LZMA_CHECK_CRC32 are always supported (even if72* liblzma is built with limited features).73*74* \note It is safe to call this with a value that is not in the75* range [0, 15]; in that case the return value is always false.76*77* \param check Check ID78*79* \return lzma_bool:80* - true if Check ID is supported by this liblzma build.81* - false otherwise.82*/83extern LZMA_API(lzma_bool) lzma_check_is_supported(lzma_check check)84lzma_nothrow lzma_attr_const;858687/**88* \brief Get the size of the Check field with the given Check ID89*90* Although not all Check IDs have a check algorithm associated, the size of91* every Check is already frozen. This function returns the size (in bytes) of92* the Check field with the specified Check ID. The values are:93* { 0, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64 }94*95* \param check Check ID96*97* \return Size of the Check field in bytes. If the argument is not in98* the range [0, 15], UINT32_MAX is returned.99*/100extern LZMA_API(uint32_t) lzma_check_size(lzma_check check)101lzma_nothrow lzma_attr_const;102103104/**105* \brief Maximum size of a Check field106*/107#define LZMA_CHECK_SIZE_MAX 64108109110/**111* \brief Calculate CRC32112*113* Calculate CRC32 using the polynomial from the IEEE 802.3 standard.114*115* \param buf Pointer to the input buffer116* \param size Size of the input buffer117* \param crc Previously returned CRC value. This is used to118* calculate the CRC of a big buffer in smaller chunks.119* Set to zero when starting a new calculation.120*121* \return Updated CRC value, which can be passed to this function122* again to continue CRC calculation.123*/124extern LZMA_API(uint32_t) lzma_crc32(125const uint8_t *buf, size_t size, uint32_t crc)126lzma_nothrow lzma_attr_pure;127128129/**130* \brief Calculate CRC64131*132* Calculate CRC64 using the polynomial from the ECMA-182 standard.133*134* This function is used similarly to lzma_crc32().135*136* \param buf Pointer to the input buffer137* \param size Size of the input buffer138* \param crc Previously returned CRC value. This is used to139* calculate the CRC of a big buffer in smaller chunks.140* Set to zero when starting a new calculation.141*142* \return Updated CRC value, which can be passed to this function143* again to continue CRC calculation.144*/145extern LZMA_API(uint64_t) lzma_crc64(146const uint8_t *buf, size_t size, uint64_t crc)147lzma_nothrow lzma_attr_pure;148149150/**151* \brief Get the type of the integrity check152*153* This function can be called only immediately after lzma_code() has154* returned LZMA_NO_CHECK, LZMA_UNSUPPORTED_CHECK, or LZMA_GET_CHECK.155* Calling this function in any other situation has undefined behavior.156*157* \param strm Pointer to lzma_stream meeting the above conditions.158*159* \return Check ID in the lzma_stream, or undefined if called improperly.160*/161extern LZMA_API(lzma_check) lzma_get_check(const lzma_stream *strm)162lzma_nothrow;163164165