1 ///////////////////////////////////////////////////////////////////////////////
4 /// \brief Internal API to different integrity check functions
6 // This code has been put into the public domain.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 ///////////////////////////////////////////////////////////////////////////////
20 // Index hashing needs the best possible hash function (preferably
21 // a cryptographic hash) for maximum reliability.
22 #if defined(HAVE_CHECK_SHA256)
23 # define LZMA_CHECK_BEST LZMA_CHECK_SHA256
24 #elif defined(HAVE_CHECK_CRC64)
25 # define LZMA_CHECK_BEST LZMA_CHECK_CRC64
27 # define LZMA_CHECK_BEST LZMA_CHECK_CRC32
31 /// \brief Structure to hold internal state of the check being calculated
33 /// \note This is not in the public API because this structure may
34 /// change in future if new integrity check algorithms are added.
36 /// Buffer to hold the final result and a temporary buffer for SHA256.
43 /// Check-specific data
52 /// Size of the message excluding padding
61 extern uint32_t lzma_crc32_table[8][256];
62 extern uint64_t lzma_crc64_table[4][256];
64 extern const uint32_t lzma_crc32_table[8][256];
65 extern const uint64_t lzma_crc64_table[4][256];
69 /// \brief Initializes *check depending on type
71 /// \return LZMA_OK on success. LZMA_UNSUPPORTED_CHECK if the type is not
72 /// supported by the current version or build of liblzma.
73 /// LZMA_PROG_ERROR if type > LZMA_CHECK_ID_MAX.
75 extern void lzma_check_init(lzma_check_state *check, lzma_check type);
78 /// \brief Updates *check
80 extern void lzma_check_update(lzma_check_state *check, lzma_check type,
81 const uint8_t *buf, size_t size);
84 /// \brief Finishes *check
86 extern void lzma_check_finish(lzma_check_state *check, lzma_check type);
89 extern void lzma_crc32_init(void);
92 extern void lzma_crc64_init(void);
95 extern void lzma_sha256_init(lzma_check_state *check);
97 extern void lzma_sha256_update(
98 const uint8_t *buf, size_t size, lzma_check_state *check);
100 extern void lzma_sha256_finish(lzma_check_state *check);