aboutsummaryrefslogtreecommitdiffstats
path: root/libhashsum/internal.h
blob: e02a417fb7f3418fe7ebc2ff75801b71a2c11d3a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/* See LICENSE file for copyright and license details. */
#include <stdint.h>


#ifdef LIBHASHSUM_INCLUDE_LIBSHA1_STATE
# include <libsha1.h>
#endif
#ifdef LIBHASHSUM_INCLUDE_LIBSHA2_STATE
# include <libsha2.h>
#endif
#ifdef LIBHASHSUM_INCLUDE_LIBKECCAK_STATE
# include <libkeccak.h>
#endif
#ifdef LIBHASHSUM_INCLUDE_LIBBLAKE_STATE
# include <libblake.h>
#endif


/**
 * Hash state
 * 
 * For internal use
 */
union libhashsum_state {
	struct {
		unsigned char x[32];
		unsigned char mp[16];
		unsigned char mz[16];
		unsigned char sum[16];
		unsigned t;
	} md2; /* size = [82, 88] */

	struct {
		union {
			uint32_t h32[4];
			uint8_t sum[16];
		} h;
		union {
			uint32_t m32[16];
			uint8_t m8[64];
		} m;
		uint64_t count;
	} md4; /* size = 70 */

	struct {
		union {
			uint32_t h32[4];
			uint8_t sum[16];
		} h;
		uint8_t m[64];
		uint32_t w[16];
		uint64_t count;
	} md5; /* size = 152 */

	struct {
		union {
			uint32_t h32[4];
			uint8_t sum[16];
		} h;
		union {
			uint32_t m32[16];
			uint8_t m8[64];
		} m;
		uint64_t count;
	} ripemd_128; /* size = 88 */

	struct {
		union {
			uint32_t h32[5];
			uint8_t sum[20];
		} h;
		union {
			uint32_t m32[16];
			uint8_t m8[64];
		} m;
		uint32_t w1[5];
		uint32_t w2[5];
		uint64_t count;
	} ripemd_160; /* size = 132 */

	struct {
		union {
			uint32_t h32[8];
			uint8_t sum[32];
		} h;
		union {
			uint32_t m32[16];
			uint8_t m8[64];
		} m;
		uint64_t count;
	} ripemd_256; /* size = 104 */

	struct {
		union {
			uint32_t h32[10];
			uint8_t sum[40];
		} h;
		union {
			uint32_t m32[16];
			uint8_t m8[64];
		} m;
		uint32_t w1[5];
		uint32_t w2[5];
		uint64_t count;
	} ripemd_320; /* size = 152 */

#ifdef LIBHASHSUM_INCLUDE_LIBSHA1_STATE
	struct {
		struct libsha1_state s;
		uint8_t sum[20];
	} sha0, sha1; /* size = [432, 440] */
#endif

#ifdef LIBHASHSUM_INCLUDE_LIBSHA2_STATE
	struct {
		struct libsha2_state s;
		uint8_t sum[64];
	} sha2; /* size = [1612, 1624] */
#endif

#ifdef LIBHASHSUM_INCLUDE_LIBKECCAK_STATE
	struct {
		struct libkeccak_state s;
		union {
			uint8_t buf[512];
			uint8_t *dyn;
		} sum;
		const char *suffix;
		size_t squeezes;
		char algostr[256];
	} keccak; /* size = [1024, 1072] */
#endif

#ifdef LIBHASHSUM_INCLUDE_LIBBLAKE_STATE
	struct {
		struct libblake_blake224_state s;
		uint8_t buf[128];
		char algostr[49];
	} blake224; /* size = 233 */

	struct {
		struct libblake_blake256_state s;
		uint8_t buf[128];
		char algostr[49];
	} blake256; /* size = 233 */

	struct {
		struct libblake_blake384_state s;
		uint8_t buf[256];
		char algostr[81];
	} blake384; /* size = 449 */

	struct {
		struct libblake_blake512_state s;
		uint8_t buf[256];
		char algostr[81];
	} blake512; /* size = 449 */

	struct {
		struct libblake_blake2s_state s;
		char algostr[130];
		unsigned char buf[64];
		unsigned char keybytes;
	} blake2s; /* size = 243 */

	struct {
		struct libblake_blake2b_state s;
		char algostr[226];
		unsigned char buf[128];
		unsigned char keybytes;
	} blake2b; /* size = 451 */
#endif

	/* libblake: 144(2Xs), 276(2Xb) */

	char max_size[1648];
#define libhashsum_init_hasher libhashsum_init_hasher__1648
#define libhashsum_init_hasher_from_string libhashsum_init_hasher_from_string__1648
};