aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/check/check.h
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-06-18 18:02:10 +0300
committerLasse Collin <lasse.collin@tukaani.org>2008-06-18 18:02:10 +0300
commit7d17818cec8597f847b0a2537fde991bbc3d9e96 (patch)
tree9c41502e3eb96f103fe98e13456b382fbba7a292 /src/liblzma/check/check.h
parentUpdate the file format specification draft. The new one is (diff)
downloadxz-7d17818cec8597f847b0a2537fde991bbc3d9e96.tar.xz
Update the code to mostly match the new simpler file format
specification. Simplify things by removing most of the support for known uncompressed size in most places. There are some miscellaneous changes here and there too. The API of liblzma has got many changes and still some more will be done soon. While most of the code has been updated, some things are not fixed (the command line tool will choke with invalid filter chain, if nothing else). Subblock filter is somewhat broken for now. It will be updated once the encoded format of the Subblock filter has been decided.
Diffstat (limited to 'src/liblzma/check/check.h')
-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