aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/check/check.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/liblzma/check/check.h47
1 files changed, 35 insertions, 12 deletions
diff --git a/src/liblzma/check/check.h b/src/liblzma/check/check.h
index 74279ceb..45ca25e9 100644
--- a/src/liblzma/check/check.h
+++ b/src/liblzma/check/check.h
@@ -17,15 +17,21 @@
#include "common.h"
+// Index hashing used to verify the Index with O(1) memory usage needs
+// a good hash function.
+#if defined(HAVE_CHECK_SHA256)
+# define LZMA_CHECK_BEST LZMA_CHECK_SHA256
+#elif defined(HAVE_CHECK_CRC64)
+# define LZMA_CHECK_BEST LZMA_CHECK_CRC64
+#else
+# define LZMA_CHECK_BEST LZMA_CHECK_CRC32
+#endif
+
+
typedef struct {
/// Internal state
uint32_t state[8];
- /// Temporary 8-byte aligned buffer to hold incomplete chunk.
- /// After lzma_check_finish(), the first 32 bytes will contain
- /// the final digest in big endian byte order.
- uint8_t buffer[64];
-
/// Size of the message excluding padding
uint64_t size;
@@ -34,10 +40,27 @@ typedef struct {
/// \note This is not in the public API because this structure will
/// change in future.
-typedef union {
- uint32_t crc32;
- uint64_t crc64;
- lzma_sha256 sha256;
+typedef struct {
+ // FIXME Guarantee 8-byte alignment
+
+ /// Buffer to hold the final result; this is also used as a temporary
+ /// buffer in SHA256. Note that this buffer must be 8-byte aligned.
+ uint8_t buffer[64];
+
+ /// Check-specific data
+ union {
+ uint32_t crc32;
+ uint64_t crc64;
+
+ struct {
+ /// Internal state
+ uint32_t state[8];
+
+ /// Size of the message excluding padding
+ uint64_t size;
+ } sha256;
+ } state;
+
} lzma_check;
@@ -91,12 +114,12 @@ extern void lzma_crc64_init(void);
// SHA256
-extern void lzma_sha256_init(lzma_sha256 *sha256);
+extern void lzma_sha256_init(lzma_check *check);
extern void lzma_sha256_update(
- const uint8_t *buf, size_t size, lzma_sha256 *sha256);
+ const uint8_t *buf, size_t size, lzma_check *check);
-extern void lzma_sha256_finish(lzma_sha256 *sha256);
+extern void lzma_sha256_finish(lzma_check *check);
#endif