"Fossies" - the Fresh Open Source Software Archive

Member "src/Crypto/Rmd160.c" (10 Oct 2018, 16418 Bytes) of package /windows/misc/VeraCrypt_1.23-Hotfix-2_Source.zip:

As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Rmd160.c" see the Fossies "Dox" file reference documentation.

```    1 // RIPEMD-160 written and placed in the public domain by Wei Dai
2
3 /*
4  * This code implements the MD4 message-digest algorithm.
5  * The algorithm is due to Ron Rivest.  This code was
6  * written by Colin Plumb in 1993, no copyright is claimed.
7  * This code is in the public domain; do with it what you wish.
8  */
9
10 /* Adapted for TrueCrypt */
11 /* Adapted for VeraCrypt */
12 #if !defined(_UEFI)
13 #include <memory.h>
14 #endif // !defined(_UEFI)
15
16 #include "Common/Tcdefs.h"
17 #include "Common/Endian.h"
18 #include "Rmd160.h"
19
20 #define F(x, y, z)    (x ^ y ^ z)
21 #define G(x, y, z)    (z ^ (x & (y^z)))
22 #define H(x, y, z)    (z ^ (x | ~y))
23 #define I(x, y, z)    (y ^ (z & (x^y)))
24 #define J(x, y, z)    (x ^ (y | ~z))
25
26 #define PUT_64BIT_LE(cp, value) do {                                    \
27     (cp)[7] = (byte) ((value) >> 56);                                        \
28     (cp)[6] = (byte) ((value) >> 48);                                        \
29     (cp)[5] = (byte) ((value) >> 40);                                        \
30     (cp)[4] = (byte) ((value) >> 32);                                        \
31     (cp)[3] = (byte) ((value) >> 24);                                        \
32     (cp)[2] = (byte) ((value) >> 16);                                        \
33     (cp)[1] = (byte) ((value) >> 8);                                         \
34     (cp)[0] = (byte) (value); } while (0)
35
36 #define PUT_32BIT_LE(cp, value) do {                                    \
37     (cp)[3] = (byte) ((value) >> 24);                                        \
38     (cp)[2] = (byte) ((value) >> 16);                                        \
39     (cp)[1] = (byte) ((value) >> 8);                                         \
40     (cp)[0] = (byte) (value); } while (0)
41
42 #ifndef TC_MINIMIZE_CODE_SIZE
43
44 static byte PADDING[64] = hlOpen(44,1);{
45     0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
46     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
47     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
48 hlClose(1, 48);};
49
50 #else
51
53
54 #endif
55
56 void RMD160Init (RMD160_CTX *ctx)
57 hlOpen(57,1);{
58     ctx->count = 0;
59     ctx->state[0] = 0x67452301;
60     ctx->state[1] = 0xefcdab89;
62     ctx->state[3] = 0x10325476;
63     ctx->state[4] = 0xc3d2e1f0;
65 hlClose(2, 65);}
66
67 /*
68 * Update context to reflect the concatenation of another buffer full
69 * of bytes.
70 */
71 void RMD160Update (RMD160_CTX *ctx, const unsigned char *input, unsigned __int32 lenArg)
72 hlOpen(72,1);{
73 #ifndef TC_WINDOWS_BOOT
74     uint64 len = lenArg;
75 #else
76     uint32 len = lenArg;
77 #endif
78     unsigned int have, need;
79
80     /* Check how many bytes we already have and how many more we need. */
81     have = (unsigned int) ((ctx->count) & (RIPEMD160_BLOCK_LENGTH - 1));
82     need = RIPEMD160_BLOCK_LENGTH - have;
83
84     /* Update bitcount */
85     ctx->count += len;
86
87     if (len >= need) hlOpen(87,2);{
88         if (have != 0) hlOpen(88,3);{
89             memcpy (ctx->buffer + have, input, (size_t) need);
90             RMD160Transform ((uint32 *) ctx->state, (const uint32 *) ctx->buffer);
91             input += need;
92             len -= need;
93             have = 0;
94         hlClose(5, 94);}
95
96         /* Process data in RIPEMD160_BLOCK_LENGTH-byte chunks. */
97         while (len >= RIPEMD160_BLOCK_LENGTH) hlOpen(97,3);{
98             RMD160Transform ((uint32 *) ctx->state, (const uint32 *) input);
99             input += RIPEMD160_BLOCK_LENGTH;
100             len -= RIPEMD160_BLOCK_LENGTH;
101         hlClose(6, 101);}
102     hlClose(4, 102);}
103
104     /* Handle any remaining bytes of data. */
105     if (len != 0)
106         memcpy (ctx->buffer + have, input, (size_t) len);
107 hlClose(3, 107);}
108
109 /*
111 * 1 0* (64-bit count of bits processed, MSB-first)
112 */
114 hlOpen(114,1);{
115     byte count[8];
117
118     /* Convert count to 8 bytes in little endian order. */
119
120 #ifndef TC_WINDOWS_BOOT
121     uint64 bitcount = ctx->count << 3;
122     PUT_64BIT_LE(count, bitcount);
123 #else
124     *(uint32 *) (count + 4) = 0;
125     *(uint32 *) (count + 0) = ctx->count << 3;
126 #endif
127
128     /* Pad out to 56 mod 64. */
130         (uint32)((ctx->count) & (RIPEMD160_BLOCK_LENGTH - 1));
131     if (padlen < 1 + 8)
134     RMD160Update(ctx, count, 8);
135 hlClose(7, 135);}
136
137 /*
138 * Final wrapup--call RMD160Pad, fill in digest and zero out ctx.
139 */
140 void RMD160Final(unsigned char *digest, RMD160_CTX *ctx)
141 hlOpen(141,1);{
142     int i;
143
145     if (digest) hlOpen(145,2);{
146         for (i = 0; i < 5; i++)
147             PUT_32BIT_LE(digest + i * 4, ctx->state[i]);
148 #ifndef TC_WINDOWS_BOOT
149         burn (ctx, sizeof(*ctx));
150 #endif
151     hlClose(9, 151);}
152 hlClose(8, 152);}
153
154
155 #ifndef TC_MINIMIZE_CODE_SIZE
156
157 #define word32 unsigned __int32
158
159 #define k0 0
160 #define k1 0x5a827999UL
161 #define k2 0x6ed9eba1UL
162 #define k3 0x8f1bbcdcUL
163 #define k4 0xa953fd4eUL
164 #define k5 0x50a28be6UL
165 #define k6 0x5c4dd124UL
166 #define k7 0x6d703ef3UL
167 #define k8 0x7a6d76e9UL
168 #define k9 0
169
170 static word32 rotlFixed (word32 x, unsigned int y)
171 hlOpen(171,1);{
172     return (word32)((x<<y) | (x>>(sizeof(word32)*8-y)));
173 hlClose(10, 173);}
174
175 #define Subround(f, a, b, c, d, e, x, s, k)        \
176     a += f(b, c, d) + x + k;\
177     a = rotlFixed((word32)a, s) + e;\
178     c = rotlFixed((word32)c, 10U)
179
180 void RMD160Transform (unsigned __int32 *digest, const unsigned __int32 *data)
181 hlOpen(181,1);{
182 #if BYTE_ORDER == LITTLE_ENDIAN
183     const word32 *X = data;
184 #else
185     word32 X[16];
186     int i;
187 #endif
188
189     word32 a1, b1, c1, d1, e1, a2, b2, c2, d2, e2;
190     a1 = a2 = digest[0];
191     b1 = b2 = digest[1];
192     c1 = c2 = digest[2];
193     d1 = d2 = digest[3];
194     e1 = e2 = digest[4];
195
196 #if BYTE_ORDER == BIG_ENDIAN
197     for (i = 0; i < 16; i++)
198     hlOpen(198,2);{
199         X[i] = LE32 (data[i]);
200     hlClose(12, 200);}
201 #endif
202
203     Subround(F, a1, b1, c1, d1, e1, X[ 0], 11, k0);
204     Subround(F, e1, a1, b1, c1, d1, X[ 1], 14, k0);
205     Subround(F, d1, e1, a1, b1, c1, X[ 2], 15, k0);
206     Subround(F, c1, d1, e1, a1, b1, X[ 3], 12, k0);
207     Subround(F, b1, c1, d1, e1, a1, X[ 4],  5, k0);
208     Subround(F, a1, b1, c1, d1, e1, X[ 5],  8, k0);
209     Subround(F, e1, a1, b1, c1, d1, X[ 6],  7, k0);
210     Subround(F, d1, e1, a1, b1, c1, X[ 7],  9, k0);
211     Subround(F, c1, d1, e1, a1, b1, X[ 8], 11, k0);
212     Subround(F, b1, c1, d1, e1, a1, X[ 9], 13, k0);
213     Subround(F, a1, b1, c1, d1, e1, X[10], 14, k0);
214     Subround(F, e1, a1, b1, c1, d1, X[11], 15, k0);
215     Subround(F, d1, e1, a1, b1, c1, X[12],  6, k0);
216     Subround(F, c1, d1, e1, a1, b1, X[13],  7, k0);
217     Subround(F, b1, c1, d1, e1, a1, X[14],  9, k0);
218     Subround(F, a1, b1, c1, d1, e1, X[15],  8, k0);
219
220     Subround(G, e1, a1, b1, c1, d1, X[ 7],  7, k1);
221     Subround(G, d1, e1, a1, b1, c1, X[ 4],  6, k1);
222     Subround(G, c1, d1, e1, a1, b1, X[13],  8, k1);
223     Subround(G, b1, c1, d1, e1, a1, X[ 1], 13, k1);
224     Subround(G, a1, b1, c1, d1, e1, X[10], 11, k1);
225     Subround(G, e1, a1, b1, c1, d1, X[ 6],  9, k1);
226     Subround(G, d1, e1, a1, b1, c1, X[15],  7, k1);
227     Subround(G, c1, d1, e1, a1, b1, X[ 3], 15, k1);
228     Subround(G, b1, c1, d1, e1, a1, X[12],  7, k1);
229     Subround(G, a1, b1, c1, d1, e1, X[ 0], 12, k1);
230     Subround(G, e1, a1, b1, c1, d1, X[ 9], 15, k1);
231     Subround(G, d1, e1, a1, b1, c1, X[ 5],  9, k1);
232     Subround(G, c1, d1, e1, a1, b1, X[ 2], 11, k1);
233     Subround(G, b1, c1, d1, e1, a1, X[14],  7, k1);
234     Subround(G, a1, b1, c1, d1, e1, X[11], 13, k1);
235     Subround(G, e1, a1, b1, c1, d1, X[ 8], 12, k1);
236
237     Subround(H, d1, e1, a1, b1, c1, X[ 3], 11, k2);
238     Subround(H, c1, d1, e1, a1, b1, X[10], 13, k2);
239     Subround(H, b1, c1, d1, e1, a1, X[14],  6, k2);
240     Subround(H, a1, b1, c1, d1, e1, X[ 4],  7, k2);
241     Subround(H, e1, a1, b1, c1, d1, X[ 9], 14, k2);
242     Subround(H, d1, e1, a1, b1, c1, X[15],  9, k2);
243     Subround(H, c1, d1, e1, a1, b1, X[ 8], 13, k2);
244     Subround(H, b1, c1, d1, e1, a1, X[ 1], 15, k2);
245     Subround(H, a1, b1, c1, d1, e1, X[ 2], 14, k2);
246     Subround(H, e1, a1, b1, c1, d1, X[ 7],  8, k2);
247     Subround(H, d1, e1, a1, b1, c1, X[ 0], 13, k2);
248     Subround(H, c1, d1, e1, a1, b1, X[ 6],  6, k2);
249     Subround(H, b1, c1, d1, e1, a1, X[13],  5, k2);
250     Subround(H, a1, b1, c1, d1, e1, X[11], 12, k2);
251     Subround(H, e1, a1, b1, c1, d1, X[ 5],  7, k2);
252     Subround(H, d1, e1, a1, b1, c1, X[12],  5, k2);
253
254     Subround(I, c1, d1, e1, a1, b1, X[ 1], 11, k3);
255     Subround(I, b1, c1, d1, e1, a1, X[ 9], 12, k3);
256     Subround(I, a1, b1, c1, d1, e1, X[11], 14, k3);
257     Subround(I, e1, a1, b1, c1, d1, X[10], 15, k3);
258     Subround(I, d1, e1, a1, b1, c1, X[ 0], 14, k3);
259     Subround(I, c1, d1, e1, a1, b1, X[ 8], 15, k3);
260     Subround(I, b1, c1, d1, e1, a1, X[12],  9, k3);
261     Subround(I, a1, b1, c1, d1, e1, X[ 4],  8, k3);
262     Subround(I, e1, a1, b1, c1, d1, X[13],  9, k3);
263     Subround(I, d1, e1, a1, b1, c1, X[ 3], 14, k3);
264     Subround(I, c1, d1, e1, a1, b1, X[ 7],  5, k3);
265     Subround(I, b1, c1, d1, e1, a1, X[15],  6, k3);
266     Subround(I, a1, b1, c1, d1, e1, X[14],  8, k3);
267     Subround(I, e1, a1, b1, c1, d1, X[ 5],  6, k3);
268     Subround(I, d1, e1, a1, b1, c1, X[ 6],  5, k3);
269     Subround(I, c1, d1, e1, a1, b1, X[ 2], 12, k3);
270
271     Subround(J, b1, c1, d1, e1, a1, X[ 4],  9, k4);
272     Subround(J, a1, b1, c1, d1, e1, X[ 0], 15, k4);
273     Subround(J, e1, a1, b1, c1, d1, X[ 5],  5, k4);
274     Subround(J, d1, e1, a1, b1, c1, X[ 9], 11, k4);
275     Subround(J, c1, d1, e1, a1, b1, X[ 7],  6, k4);
276     Subround(J, b1, c1, d1, e1, a1, X[12],  8, k4);
277     Subround(J, a1, b1, c1, d1, e1, X[ 2], 13, k4);
278     Subround(J, e1, a1, b1, c1, d1, X[10], 12, k4);
279     Subround(J, d1, e1, a1, b1, c1, X[14],  5, k4);
280     Subround(J, c1, d1, e1, a1, b1, X[ 1], 12, k4);
281     Subround(J, b1, c1, d1, e1, a1, X[ 3], 13, k4);
282     Subround(J, a1, b1, c1, d1, e1, X[ 8], 14, k4);
283     Subround(J, e1, a1, b1, c1, d1, X[11], 11, k4);
284     Subround(J, d1, e1, a1, b1, c1, X[ 6],  8, k4);
285     Subround(J, c1, d1, e1, a1, b1, X[15],  5, k4);
286     Subround(J, b1, c1, d1, e1, a1, X[13],  6, k4);
287
288     Subround(J, a2, b2, c2, d2, e2, X[ 5],  8, k5);
289     Subround(J, e2, a2, b2, c2, d2, X[14],  9, k5);
290     Subround(J, d2, e2, a2, b2, c2, X[ 7],  9, k5);
291     Subround(J, c2, d2, e2, a2, b2, X[ 0], 11, k5);
292     Subround(J, b2, c2, d2, e2, a2, X[ 9], 13, k5);
293     Subround(J, a2, b2, c2, d2, e2, X[ 2], 15, k5);
294     Subround(J, e2, a2, b2, c2, d2, X[11], 15, k5);
295     Subround(J, d2, e2, a2, b2, c2, X[ 4],  5, k5);
296     Subround(J, c2, d2, e2, a2, b2, X[13],  7, k5);
297     Subround(J, b2, c2, d2, e2, a2, X[ 6],  7, k5);
298     Subround(J, a2, b2, c2, d2, e2, X[15],  8, k5);
299     Subround(J, e2, a2, b2, c2, d2, X[ 8], 11, k5);
300     Subround(J, d2, e2, a2, b2, c2, X[ 1], 14, k5);
301     Subround(J, c2, d2, e2, a2, b2, X[10], 14, k5);
302     Subround(J, b2, c2, d2, e2, a2, X[ 3], 12, k5);
303     Subround(J, a2, b2, c2, d2, e2, X[12],  6, k5);
304
305     Subround(I, e2, a2, b2, c2, d2, X[ 6],  9, k6);
306     Subround(I, d2, e2, a2, b2, c2, X[11], 13, k6);
307     Subround(I, c2, d2, e2, a2, b2, X[ 3], 15, k6);
308     Subround(I, b2, c2, d2, e2, a2, X[ 7],  7, k6);
309     Subround(I, a2, b2, c2, d2, e2, X[ 0], 12, k6);
310     Subround(I, e2, a2, b2, c2, d2, X[13],  8, k6);
311     Subround(I, d2, e2, a2, b2, c2, X[ 5],  9, k6);
312     Subround(I, c2, d2, e2, a2, b2, X[10], 11, k6);
313     Subround(I, b2, c2, d2, e2, a2, X[14],  7, k6);
314     Subround(I, a2, b2, c2, d2, e2, X[15],  7, k6);
315     Subround(I, e2, a2, b2, c2, d2, X[ 8], 12, k6);
316     Subround(I, d2, e2, a2, b2, c2, X[12],  7, k6);
317     Subround(I, c2, d2, e2, a2, b2, X[ 4],  6, k6);
318     Subround(I, b2, c2, d2, e2, a2, X[ 9], 15, k6);
319     Subround(I, a2, b2, c2, d2, e2, X[ 1], 13, k6);
320     Subround(I, e2, a2, b2, c2, d2, X[ 2], 11, k6);
321
322     Subround(H, d2, e2, a2, b2, c2, X[15],  9, k7);
323     Subround(H, c2, d2, e2, a2, b2, X[ 5],  7, k7);
324     Subround(H, b2, c2, d2, e2, a2, X[ 1], 15, k7);
325     Subround(H, a2, b2, c2, d2, e2, X[ 3], 11, k7);
326     Subround(H, e2, a2, b2, c2, d2, X[ 7],  8, k7);
327     Subround(H, d2, e2, a2, b2, c2, X[14],  6, k7);
328     Subround(H, c2, d2, e2, a2, b2, X[ 6],  6, k7);
329     Subround(H, b2, c2, d2, e2, a2, X[ 9], 14, k7);
330     Subround(H, a2, b2, c2, d2, e2, X[11], 12, k7);
331     Subround(H, e2, a2, b2, c2, d2, X[ 8], 13, k7);
332     Subround(H, d2, e2, a2, b2, c2, X[12],  5, k7);
333     Subround(H, c2, d2, e2, a2, b2, X[ 2], 14, k7);
334     Subround(H, b2, c2, d2, e2, a2, X[10], 13, k7);
335     Subround(H, a2, b2, c2, d2, e2, X[ 0], 13, k7);
336     Subround(H, e2, a2, b2, c2, d2, X[ 4],  7, k7);
337     Subround(H, d2, e2, a2, b2, c2, X[13],  5, k7);
338
339     Subround(G, c2, d2, e2, a2, b2, X[ 8], 15, k8);
340     Subround(G, b2, c2, d2, e2, a2, X[ 6],  5, k8);
341     Subround(G, a2, b2, c2, d2, e2, X[ 4],  8, k8);
342     Subround(G, e2, a2, b2, c2, d2, X[ 1], 11, k8);
343     Subround(G, d2, e2, a2, b2, c2, X[ 3], 14, k8);
344     Subround(G, c2, d2, e2, a2, b2, X[11], 14, k8);
345     Subround(G, b2, c2, d2, e2, a2, X[15],  6, k8);
346     Subround(G, a2, b2, c2, d2, e2, X[ 0], 14, k8);
347     Subround(G, e2, a2, b2, c2, d2, X[ 5],  6, k8);
348     Subround(G, d2, e2, a2, b2, c2, X[12],  9, k8);
349     Subround(G, c2, d2, e2, a2, b2, X[ 2], 12, k8);
350     Subround(G, b2, c2, d2, e2, a2, X[13],  9, k8);
351     Subround(G, a2, b2, c2, d2, e2, X[ 9], 12, k8);
352     Subround(G, e2, a2, b2, c2, d2, X[ 7],  5, k8);
353     Subround(G, d2, e2, a2, b2, c2, X[10], 15, k8);
354     Subround(G, c2, d2, e2, a2, b2, X[14],  8, k8);
355
356     Subround(F, b2, c2, d2, e2, a2, X[12],  8, k9);
357     Subround(F, a2, b2, c2, d2, e2, X[15],  5, k9);
358     Subround(F, e2, a2, b2, c2, d2, X[10], 12, k9);
359     Subround(F, d2, e2, a2, b2, c2, X[ 4],  9, k9);
360     Subround(F, c2, d2, e2, a2, b2, X[ 1], 12, k9);
361     Subround(F, b2, c2, d2, e2, a2, X[ 5],  5, k9);
362     Subround(F, a2, b2, c2, d2, e2, X[ 8], 14, k9);
363     Subround(F, e2, a2, b2, c2, d2, X[ 7],  6, k9);
364     Subround(F, d2, e2, a2, b2, c2, X[ 6],  8, k9);
365     Subround(F, c2, d2, e2, a2, b2, X[ 2], 13, k9);
366     Subround(F, b2, c2, d2, e2, a2, X[13],  6, k9);
367     Subround(F, a2, b2, c2, d2, e2, X[14],  5, k9);
368     Subround(F, e2, a2, b2, c2, d2, X[ 0], 15, k9);
369     Subround(F, d2, e2, a2, b2, c2, X[ 3], 13, k9);
370     Subround(F, c2, d2, e2, a2, b2, X[ 9], 11, k9);
371     Subround(F, b2, c2, d2, e2, a2, X[11], 11, k9);
372
373     c1        = digest[1] + c1 + d2;
374     digest[1] = digest[2] + d1 + e2;
375     digest[2] = digest[3] + e1 + a2;
376     digest[3] = digest[4] + a1 + b2;
377     digest[4] = digest[0] + b1 + c2;
378     digest[0] = c1;
379 hlClose(11, 379);}
380
381 #else // TC_MINIMIZE_CODE_SIZE
382
383 /*
384  Derived from source code of TrueCrypt 7.1a, which is
385  Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
386  by the TrueCrypt License 3.0.
387
388  Modifications and additions to the original source code (contained in this file)
389  and all other portions of this file are Copyright (c) 2013-2017 IDRIX
390  and are governed by the Apache License 2.0 the full text of which is
391  contained in the file License.txt included in VeraCrypt binary and source
392  code distribution packages.
393 */
394
395 #pragma optimize ("tl", on)
396
397 typedef unsigned __int32 uint32;
398 typedef unsigned __int8 byte;
399
400 #include <stdlib.h>
401 #pragma intrinsic (_lrotl)
402
403 static const byte OrderTab[] = hlOpen(403,1);{
404     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
405     7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
406     3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
407     1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
408     4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13,
409     5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
410     6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
411     15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
412     8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
413     12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
414 hlClose(13, 414);};
415
416 static const byte RolTab[] = hlOpen(416,1);{
417     11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
418     7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
419     11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
420     11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
421     9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6,
422     8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
423     9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
424     9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
425     15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
426     8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
427 hlClose(14, 427);};
428
429 static const uint32 KTab[] = hlOpen(429,1);{
430     0x00000000UL,
431     0x5A827999UL,
432     0x6ED9EBA1UL,
433     0x8F1BBCDCUL,
434     0xA953FD4EUL,
435     0x50A28BE6UL,
436     0x5C4DD124UL,
437     0x6D703EF3UL,
438     0x7A6D76E9UL,
439     0x00000000UL
440 hlClose(15, 440);};
441
442
443 void RMD160Transform (unsigned __int32 *state, const unsigned __int32 *data)
444 hlOpen(444,1);{
445     uint32 a, b, c, d, e;
446     uint32 a2, b2, c2, d2, e2;
447     byte pos;
448     uint32 tmp;
449
450     a = state[0];
451     b = state[1];
452     c = state[2];
453     d = state[3];
454     e = state[4];
455
456     for (pos = 0; pos < 160; ++pos)
457     hlOpen(457,2);{
458         tmp = a + data[OrderTab[pos]] + KTab[pos >> 4];
459
460         switch (pos >> 4)
461         hlOpen(461,3);{
462         case 0: case 9: tmp += F (b, c, d); break;
463         case 1: case 8: tmp += G (b, c, d); break;
464         case 2: case 7: tmp += H (b, c, d); break;
465         case 3: case 6: tmp += I (b, c, d); break;
466         case 4: case 5: tmp += J (b, c, d); break;
467         hlClose(18, 467);}
468
469         tmp = _lrotl (tmp, RolTab[pos]) + e;
470         a = e;
471         e = d;
472         d = _lrotl (c, 10);
473         c = b;
474         b = tmp;
475
476         if (pos == 79)
477         hlOpen(477,3);{
478             a2 = a;
479             b2 = b;
480             c2 = c;
481             d2 = d;
482             e2 = e;
483
484             a = state[0];
485             b = state[1];
486             c = state[2];
487             d = state[3];
488             e = state[4];
489         hlClose(19, 489);}
490     hlClose(17, 490);}
491
492     tmp = state[1] + c2 + d;
493     state[1] = state[2] + d2 + e;
494     state[2] = state[3] + e2 + a;
495     state[3] = state[4] + a2 + b;
496     state[4] = state[0] + b2 + c;
497     state[0] = tmp;
498 hlClose(16, 498);}
499
500 #endif // TC_MINIMIZE_CODE_SIZE
```