annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/lzma/check.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 /* SPDX-License-Identifier: 0BSD */
jpayne@69 2
jpayne@69 3 /**
jpayne@69 4 * \file lzma/check.h
jpayne@69 5 * \brief Integrity checks
jpayne@69 6 * \note Never include this file directly. Use <lzma.h> instead.
jpayne@69 7 */
jpayne@69 8
jpayne@69 9 /*
jpayne@69 10 * Author: Lasse Collin
jpayne@69 11 */
jpayne@69 12
jpayne@69 13 #ifndef LZMA_H_INTERNAL
jpayne@69 14 # error Never include this file directly. Use <lzma.h> instead.
jpayne@69 15 #endif
jpayne@69 16
jpayne@69 17
jpayne@69 18 /**
jpayne@69 19 * \brief Type of the integrity check (Check ID)
jpayne@69 20 *
jpayne@69 21 * The .xz format supports multiple types of checks that are calculated
jpayne@69 22 * from the uncompressed data. They vary in both speed and ability to
jpayne@69 23 * detect errors.
jpayne@69 24 */
jpayne@69 25 typedef enum {
jpayne@69 26 LZMA_CHECK_NONE = 0,
jpayne@69 27 /**<
jpayne@69 28 * No Check is calculated.
jpayne@69 29 *
jpayne@69 30 * Size of the Check field: 0 bytes
jpayne@69 31 */
jpayne@69 32
jpayne@69 33 LZMA_CHECK_CRC32 = 1,
jpayne@69 34 /**<
jpayne@69 35 * CRC32 using the polynomial from the IEEE 802.3 standard
jpayne@69 36 *
jpayne@69 37 * Size of the Check field: 4 bytes
jpayne@69 38 */
jpayne@69 39
jpayne@69 40 LZMA_CHECK_CRC64 = 4,
jpayne@69 41 /**<
jpayne@69 42 * CRC64 using the polynomial from the ECMA-182 standard
jpayne@69 43 *
jpayne@69 44 * Size of the Check field: 8 bytes
jpayne@69 45 */
jpayne@69 46
jpayne@69 47 LZMA_CHECK_SHA256 = 10
jpayne@69 48 /**<
jpayne@69 49 * SHA-256
jpayne@69 50 *
jpayne@69 51 * Size of the Check field: 32 bytes
jpayne@69 52 */
jpayne@69 53 } lzma_check;
jpayne@69 54
jpayne@69 55
jpayne@69 56 /**
jpayne@69 57 * \brief Maximum valid Check ID
jpayne@69 58 *
jpayne@69 59 * The .xz file format specification specifies 16 Check IDs (0-15). Some
jpayne@69 60 * of them are only reserved, that is, no actual Check algorithm has been
jpayne@69 61 * assigned. When decoding, liblzma still accepts unknown Check IDs for
jpayne@69 62 * future compatibility. If a valid but unsupported Check ID is detected,
jpayne@69 63 * liblzma can indicate a warning; see the flags LZMA_TELL_NO_CHECK,
jpayne@69 64 * LZMA_TELL_UNSUPPORTED_CHECK, and LZMA_TELL_ANY_CHECK in container.h.
jpayne@69 65 */
jpayne@69 66 #define LZMA_CHECK_ID_MAX 15
jpayne@69 67
jpayne@69 68
jpayne@69 69 /**
jpayne@69 70 * \brief Test if the given Check ID is supported
jpayne@69 71 *
jpayne@69 72 * LZMA_CHECK_NONE and LZMA_CHECK_CRC32 are always supported (even if
jpayne@69 73 * liblzma is built with limited features).
jpayne@69 74 *
jpayne@69 75 * \note It is safe to call this with a value that is not in the
jpayne@69 76 * range [0, 15]; in that case the return value is always false.
jpayne@69 77 *
jpayne@69 78 * \param check Check ID
jpayne@69 79 *
jpayne@69 80 * \return lzma_bool:
jpayne@69 81 * - true if Check ID is supported by this liblzma build.
jpayne@69 82 * - false otherwise.
jpayne@69 83 */
jpayne@69 84 extern LZMA_API(lzma_bool) lzma_check_is_supported(lzma_check check)
jpayne@69 85 lzma_nothrow lzma_attr_const;
jpayne@69 86
jpayne@69 87
jpayne@69 88 /**
jpayne@69 89 * \brief Get the size of the Check field with the given Check ID
jpayne@69 90 *
jpayne@69 91 * Although not all Check IDs have a check algorithm associated, the size of
jpayne@69 92 * every Check is already frozen. This function returns the size (in bytes) of
jpayne@69 93 * the Check field with the specified Check ID. The values are:
jpayne@69 94 * { 0, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64 }
jpayne@69 95 *
jpayne@69 96 * \param check Check ID
jpayne@69 97 *
jpayne@69 98 * \return Size of the Check field in bytes. If the argument is not in
jpayne@69 99 * the range [0, 15], UINT32_MAX is returned.
jpayne@69 100 */
jpayne@69 101 extern LZMA_API(uint32_t) lzma_check_size(lzma_check check)
jpayne@69 102 lzma_nothrow lzma_attr_const;
jpayne@69 103
jpayne@69 104
jpayne@69 105 /**
jpayne@69 106 * \brief Maximum size of a Check field
jpayne@69 107 */
jpayne@69 108 #define LZMA_CHECK_SIZE_MAX 64
jpayne@69 109
jpayne@69 110
jpayne@69 111 /**
jpayne@69 112 * \brief Calculate CRC32
jpayne@69 113 *
jpayne@69 114 * Calculate CRC32 using the polynomial from the IEEE 802.3 standard.
jpayne@69 115 *
jpayne@69 116 * \param buf Pointer to the input buffer
jpayne@69 117 * \param size Size of the input buffer
jpayne@69 118 * \param crc Previously returned CRC value. This is used to
jpayne@69 119 * calculate the CRC of a big buffer in smaller chunks.
jpayne@69 120 * Set to zero when starting a new calculation.
jpayne@69 121 *
jpayne@69 122 * \return Updated CRC value, which can be passed to this function
jpayne@69 123 * again to continue CRC calculation.
jpayne@69 124 */
jpayne@69 125 extern LZMA_API(uint32_t) lzma_crc32(
jpayne@69 126 const uint8_t *buf, size_t size, uint32_t crc)
jpayne@69 127 lzma_nothrow lzma_attr_pure;
jpayne@69 128
jpayne@69 129
jpayne@69 130 /**
jpayne@69 131 * \brief Calculate CRC64
jpayne@69 132 *
jpayne@69 133 * Calculate CRC64 using the polynomial from the ECMA-182 standard.
jpayne@69 134 *
jpayne@69 135 * This function is used similarly to lzma_crc32().
jpayne@69 136 *
jpayne@69 137 * \param buf Pointer to the input buffer
jpayne@69 138 * \param size Size of the input buffer
jpayne@69 139 * \param crc Previously returned CRC value. This is used to
jpayne@69 140 * calculate the CRC of a big buffer in smaller chunks.
jpayne@69 141 * Set to zero when starting a new calculation.
jpayne@69 142 *
jpayne@69 143 * \return Updated CRC value, which can be passed to this function
jpayne@69 144 * again to continue CRC calculation.
jpayne@69 145 */
jpayne@69 146 extern LZMA_API(uint64_t) lzma_crc64(
jpayne@69 147 const uint8_t *buf, size_t size, uint64_t crc)
jpayne@69 148 lzma_nothrow lzma_attr_pure;
jpayne@69 149
jpayne@69 150
jpayne@69 151 /**
jpayne@69 152 * \brief Get the type of the integrity check
jpayne@69 153 *
jpayne@69 154 * This function can be called only immediately after lzma_code() has
jpayne@69 155 * returned LZMA_NO_CHECK, LZMA_UNSUPPORTED_CHECK, or LZMA_GET_CHECK.
jpayne@69 156 * Calling this function in any other situation has undefined behavior.
jpayne@69 157 *
jpayne@69 158 * \param strm Pointer to lzma_stream meeting the above conditions.
jpayne@69 159 *
jpayne@69 160 * \return Check ID in the lzma_stream, or undefined if called improperly.
jpayne@69 161 */
jpayne@69 162 extern LZMA_API(lzma_check) lzma_get_check(const lzma_stream *strm)
jpayne@69 163 lzma_nothrow;