]> icculus.org git repositories - icculus/xz.git/blob - src/liblzma/check/check.h
Imported to git.
[icculus/xz.git] / src / liblzma / check / check.h
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file       check.h
4 /// \brief      Prototypes for different check functions
5 //
6 //  This code has been put into the public domain.
7 //
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.
11 //
12 ///////////////////////////////////////////////////////////////////////////////
13
14 #ifndef LZMA_CHECK_H
15 #define LZMA_CHECK_H
16
17 #include "common.h"
18
19
20 typedef struct {
21         /// Internal state
22         uint32_t state[8];
23
24         /// Temporary 8-byte aligned buffer to hold incomplete chunk.
25         /// After lzma_check_finish(), the first 32 bytes will contain
26         /// the final digest in big endian byte order.
27         uint8_t buffer[64];
28
29         /// Size of the message excluding padding
30         uint64_t size;
31
32 } lzma_sha256;
33
34
35 /// \note       This is not in the public API because this structure will
36 ///             change in future.
37 typedef union {
38         uint32_t crc32;
39         uint64_t crc64;
40         lzma_sha256 sha256;
41 } lzma_check;
42
43
44 #ifdef HAVE_SMALL
45 extern uint32_t lzma_crc32_table[8][256];
46 extern uint64_t lzma_crc64_table[4][256];
47 #else
48 extern const uint32_t lzma_crc32_table[8][256];
49 extern const uint64_t lzma_crc64_table[4][256];
50 #endif
51
52 // Generic
53
54 /// \brief      Initializes *check depending on type
55 ///
56 /// \return     LZMA_OK on success. LZMA_UNSUPPORTED_CHECK if the type is not
57 ///             supported by the current version or build of liblzma.
58 ///             LZMA_PROG_ERROR if type > LZMA_CHECK_ID_MAX.
59 ///
60 extern lzma_ret lzma_check_init(lzma_check *check, lzma_check_type type);
61
62 /// \brief      Updates *check
63 ///
64 extern void lzma_check_update(lzma_check *check, lzma_check_type type,
65                 const uint8_t *buf, size_t size);
66
67 /// \brief      Finishes *check
68 ///
69 extern void lzma_check_finish(lzma_check *check, lzma_check_type type);
70
71
72 /*
73 /// \brief      Compare two checks
74 ///
75 /// \return     false if the checks are identical; true if they differ.
76 ///
77 extern bool lzma_check_compare(
78                 lzma_check *check1, lzma_check *check2, lzma_check_type type);
79 */
80
81
82 // CRC32
83
84 extern void lzma_crc32_init(void);
85
86
87 // CRC64
88
89 extern void lzma_crc64_init(void);
90
91
92 // SHA256
93
94 extern void lzma_sha256_init(lzma_sha256 *sha256);
95
96 extern void lzma_sha256_update(
97                 const uint8_t *buf, size_t size, lzma_sha256 *sha256);
98
99 extern void lzma_sha256_finish(lzma_sha256 *sha256);
100
101
102 #endif