3 * \brief Integrity checks
9 * This file has been put into the public domain.
10 * You can do whatever you want with this file.
12 * See ../lzma.h for information about liblzma as a whole.
15 #ifndef LZMA_H_INTERNAL
16 # error Never include this file directly. Use <lzma.h> instead.
21 * \brief Type of the integrity check (Check ID)
23 * The .xz format supports multiple types of checks that are calculated
24 * from the uncompressed data. They vary in both speed and ability to
30 * No Check is calculated.
32 * Size of the Check field: 0 bytes
37 * CRC32 using the polynomial from the IEEE 802.3 standard
39 * Size of the Check field: 4 bytes
44 * CRC64 using the polynomial from the ECMA-182 standard
46 * Size of the Check field: 8 bytes
49 LZMA_CHECK_SHA256 = 10
53 * Size of the Check field: 32 bytes
59 * \brief Maximum valid Check ID
61 * The .xz file format specification specifies 16 Check IDs (0-15). Some
62 * of them are only reserved, that is, no actual Check algorithm has been
63 * assigned. When decoding, liblzma still accepts unknown Check IDs for
64 * future compatibility. If a valid but unsupported Check ID is detected,
65 * liblzma can indicate a warning; see the flags LZMA_TELL_NO_CHECK,
66 * LZMA_TELL_UNSUPPORTED_CHECK, and LZMA_TELL_ANY_CHECK in container.h.
68 #define LZMA_CHECK_ID_MAX 15
72 * \brief Test if the given Check ID is supported
74 * Return true if the given Check ID is supported by this liblzma build.
75 * Otherwise false is returned. It is safe to call this with a value that
76 * is not in the range [0, 15]; in that case the return value is always false.
78 * You can assume that LZMA_CHECK_NONE and LZMA_CHECK_CRC32 are always
79 * supported (even if liblzma is built with limited features).
81 extern LZMA_API(lzma_bool) lzma_check_is_supported(lzma_check check)
82 lzma_nothrow lzma_attr_const;
86 * \brief Get the size of the Check field with the given Check ID
88 * Although not all Check IDs have a check algorithm associated, the size of
89 * every Check is already frozen. This function returns the size (in bytes) of
90 * the Check field with the specified Check ID. The values are:
91 * { 0, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64 }
93 * If the argument is not in the range [0, 15], UINT32_MAX is returned.
95 extern LZMA_API(uint32_t) lzma_check_size(lzma_check check)
96 lzma_nothrow lzma_attr_const;
100 * \brief Maximum size of a Check field
102 #define LZMA_CHECK_SIZE_MAX 64
106 * \brief Calculate CRC32
108 * Calculate CRC32 using the polynomial from the IEEE 802.3 standard.
110 * \param buf Pointer to the input buffer
111 * \param size Size of the input buffer
112 * \param crc Previously returned CRC value. This is used to
113 * calculate the CRC of a big buffer in smaller chunks.
114 * Set to zero when starting a new calculation.
116 * \return Updated CRC value, which can be passed to this function
117 * again to continue CRC calculation.
119 extern LZMA_API(uint32_t) lzma_crc32(
120 const uint8_t *buf, size_t size, uint32_t crc)
121 lzma_nothrow lzma_attr_pure;
125 * \brief Calculate CRC64
127 * Calculate CRC64 using the polynomial from the ECMA-182 standard.
129 * This function is used similarly to lzma_crc32(). See its documentation.
131 extern LZMA_API(uint64_t) lzma_crc64(
132 const uint8_t *buf, size_t size, uint64_t crc)
133 lzma_nothrow lzma_attr_pure;
137 * SHA-256 functions are currently not exported to public API.
138 * Contact Lasse Collin if you think it should be.
143 * \brief Get the type of the integrity check
145 * This function can be called only immediately after lzma_code() has
146 * returned LZMA_NO_CHECK, LZMA_UNSUPPORTED_CHECK, or LZMA_GET_CHECK.
147 * Calling this function in any other situation has undefined behavior.
149 extern LZMA_API(lzma_check) lzma_get_check(const lzma_stream *strm)