1479fd71aSmarkus /*
2479fd71aSmarkus * Copyright (c) 2001 Markus Friedl. All rights reserved.
3780327d8Smillert *
4479fd71aSmarkus * Redistribution and use in source and binary forms, with or without
5479fd71aSmarkus * modification, are permitted provided that the following conditions
6479fd71aSmarkus * are met:
7479fd71aSmarkus * 1. Redistributions of source code must retain the above copyright
8479fd71aSmarkus * notice, this list of conditions and the following disclaimer.
9479fd71aSmarkus * 2. Redistributions in binary form must reproduce the above copyright
10479fd71aSmarkus * notice, this list of conditions and the following disclaimer in the
11479fd71aSmarkus * documentation and/or other materials provided with the distribution.
12780327d8Smillert *
13479fd71aSmarkus * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14479fd71aSmarkus * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15479fd71aSmarkus * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16479fd71aSmarkus * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17479fd71aSmarkus * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18479fd71aSmarkus * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19479fd71aSmarkus * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20479fd71aSmarkus * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21479fd71aSmarkus * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22479fd71aSmarkus * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23479fd71aSmarkus */
24479fd71aSmarkus /*
25479fd71aSmarkus * Preneel, Bosselaers, Dobbertin, "The Cryptographic Hash Function RIPEMD-160",
26479fd71aSmarkus * RSA Laboratories, CryptoBytes, Volume 3, Number 2, Autumn 1997,
27479fd71aSmarkus * ftp://ftp.rsasecurity.com/pub/cryptobytes/crypto3n2.pdf
28479fd71aSmarkus */
29b14a012fSmillert #include <sys/types.h>
30be9b7050Sguenther #include <endian.h>
31be9b7050Sguenther #include <string.h>
32780327d8Smillert #include <rmd160.h>
33780327d8Smillert
34479fd71aSmarkus #define PUT_64BIT_LE(cp, value) do { \
35479fd71aSmarkus (cp)[7] = (value) >> 56; \
36479fd71aSmarkus (cp)[6] = (value) >> 48; \
37479fd71aSmarkus (cp)[5] = (value) >> 40; \
38479fd71aSmarkus (cp)[4] = (value) >> 32; \
39479fd71aSmarkus (cp)[3] = (value) >> 24; \
40479fd71aSmarkus (cp)[2] = (value) >> 16; \
41479fd71aSmarkus (cp)[1] = (value) >> 8; \
42479fd71aSmarkus (cp)[0] = (value); } while (0)
43780327d8Smillert
44479fd71aSmarkus #define PUT_32BIT_LE(cp, value) do { \
45479fd71aSmarkus (cp)[3] = (value) >> 24; \
46479fd71aSmarkus (cp)[2] = (value) >> 16; \
47479fd71aSmarkus (cp)[1] = (value) >> 8; \
48479fd71aSmarkus (cp)[0] = (value); } while (0)
49780327d8Smillert
50479fd71aSmarkus #define H0 0x67452301U
51479fd71aSmarkus #define H1 0xEFCDAB89U
52479fd71aSmarkus #define H2 0x98BADCFEU
53479fd71aSmarkus #define H3 0x10325476U
54479fd71aSmarkus #define H4 0xC3D2E1F0U
55780327d8Smillert
56479fd71aSmarkus #define K0 0x00000000U
57479fd71aSmarkus #define K1 0x5A827999U
58479fd71aSmarkus #define K2 0x6ED9EBA1U
59479fd71aSmarkus #define K3 0x8F1BBCDCU
60479fd71aSmarkus #define K4 0xA953FD4EU
61780327d8Smillert
62479fd71aSmarkus #define KK0 0x50A28BE6U
63479fd71aSmarkus #define KK1 0x5C4DD124U
64479fd71aSmarkus #define KK2 0x6D703EF3U
65479fd71aSmarkus #define KK3 0x7A6D76E9U
66479fd71aSmarkus #define KK4 0x00000000U
67780327d8Smillert
68479fd71aSmarkus /* rotate x left n bits. */
69479fd71aSmarkus #define ROL(n, x) (((x) << (n)) | ((x) >> (32-(n))))
70479fd71aSmarkus
71479fd71aSmarkus #define F0(x, y, z) ((x) ^ (y) ^ (z))
72479fd71aSmarkus #define F1(x, y, z) (((x) & (y)) | ((~x) & (z)))
73479fd71aSmarkus #define F2(x, y, z) (((x) | (~y)) ^ (z))
74479fd71aSmarkus #define F3(x, y, z) (((x) & (z)) | ((y) & (~z)))
75479fd71aSmarkus #define F4(x, y, z) ((x) ^ ((y) | (~z)))
76479fd71aSmarkus
77479fd71aSmarkus #define R(a, b, c, d, e, Fj, Kj, sj, rj) \
78479fd71aSmarkus do { \
79479fd71aSmarkus a = ROL(sj, a + Fj(b,c,d) + X(rj) + Kj) + e; \
80479fd71aSmarkus c = ROL(10, c); \
81479fd71aSmarkus } while(0)
82479fd71aSmarkus
83479fd71aSmarkus #define X(i) x[i]
84479fd71aSmarkus
85*036a3c97Sguenther static const u_int8_t PADDING[RMD160_BLOCK_LENGTH] = {
86479fd71aSmarkus 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
87479fd71aSmarkus 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
88479fd71aSmarkus 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
89479fd71aSmarkus };
90780327d8Smillert
91b14a012fSmillert void
RMD160Init(RMD160_CTX * ctx)92479fd71aSmarkus RMD160Init(RMD160_CTX *ctx)
93780327d8Smillert {
94479fd71aSmarkus ctx->count = 0;
95479fd71aSmarkus ctx->state[0] = H0;
96479fd71aSmarkus ctx->state[1] = H1;
97479fd71aSmarkus ctx->state[2] = H2;
98479fd71aSmarkus ctx->state[3] = H3;
99479fd71aSmarkus ctx->state[4] = H4;
100780327d8Smillert }
10189db3a20Sguenther DEF_WEAK(RMD160Init);
102780327d8Smillert
103b14a012fSmillert void
RMD160Update(RMD160_CTX * ctx,const u_int8_t * input,size_t len)10418c901a1Smillert RMD160Update(RMD160_CTX *ctx, const u_int8_t *input, size_t len)
105780327d8Smillert {
1069dfc8d30Smillert size_t have, off, need;
107780327d8Smillert
108e5c6a985Smillert have = (ctx->count / 8) % RMD160_BLOCK_LENGTH;
109e5c6a985Smillert need = RMD160_BLOCK_LENGTH - have;
110479fd71aSmarkus ctx->count += 8 * len;
111479fd71aSmarkus off = 0;
112780327d8Smillert
113479fd71aSmarkus if (len >= need) {
114479fd71aSmarkus if (have) {
115479fd71aSmarkus memcpy(ctx->buffer + have, input, need);
116479fd71aSmarkus RMD160Transform(ctx->state, ctx->buffer);
117479fd71aSmarkus off = need;
118479fd71aSmarkus have = 0;
119780327d8Smillert }
120479fd71aSmarkus /* now the buffer is empty */
121e5c6a985Smillert while (off + RMD160_BLOCK_LENGTH <= len) {
122479fd71aSmarkus RMD160Transform(ctx->state, input+off);
123e5c6a985Smillert off += RMD160_BLOCK_LENGTH;
124479fd71aSmarkus }
125479fd71aSmarkus }
126479fd71aSmarkus if (off < len)
127479fd71aSmarkus memcpy(ctx->buffer + have, input+off, len-off);
128479fd71aSmarkus }
12989db3a20Sguenther DEF_WEAK(RMD160Update);
130780327d8Smillert
131b14a012fSmillert void
RMD160Pad(RMD160_CTX * ctx)1329dfc8d30Smillert RMD160Pad(RMD160_CTX *ctx)
133780327d8Smillert {
1349dfc8d30Smillert u_int8_t size[8];
1359dfc8d30Smillert size_t padlen;
136780327d8Smillert
137479fd71aSmarkus PUT_64BIT_LE(size, ctx->count);
138e7aec372Sjanjaap
139780327d8Smillert /*
140e5c6a985Smillert * pad to RMD160_BLOCK_LENGTH byte blocks, at least one byte from
141e5c6a985Smillert * PADDING plus 8 bytes for the size
142780327d8Smillert */
143e5c6a985Smillert padlen = RMD160_BLOCK_LENGTH - ((ctx->count / 8) % RMD160_BLOCK_LENGTH);
144479fd71aSmarkus if (padlen < 1 + 8)
145e5c6a985Smillert padlen += RMD160_BLOCK_LENGTH;
146479fd71aSmarkus RMD160Update(ctx, PADDING, padlen - 8); /* padlen - 8 <= 64 */
147479fd71aSmarkus RMD160Update(ctx, size, 8);
1489dfc8d30Smillert }
14989db3a20Sguenther DEF_WEAK(RMD160Pad);
150780327d8Smillert
1519dfc8d30Smillert void
RMD160Final(u_int8_t digest[RMD160_DIGEST_LENGTH],RMD160_CTX * ctx)15218c901a1Smillert RMD160Final(u_int8_t digest[RMD160_DIGEST_LENGTH], RMD160_CTX *ctx)
1539dfc8d30Smillert {
1549dfc8d30Smillert int i;
1559dfc8d30Smillert
1569dfc8d30Smillert RMD160Pad(ctx);
157479fd71aSmarkus for (i = 0; i < 5; i++)
158479fd71aSmarkus PUT_32BIT_LE(digest + i*4, ctx->state[i]);
159b4c10efeSmillert explicit_bzero(ctx, sizeof (*ctx));
160479fd71aSmarkus }
16189db3a20Sguenther DEF_WEAK(RMD160Final);
162780327d8Smillert
163b14a012fSmillert void
RMD160Transform(u_int32_t state[5],const u_int8_t block[RMD160_BLOCK_LENGTH])16418c901a1Smillert RMD160Transform(u_int32_t state[5], const u_int8_t block[RMD160_BLOCK_LENGTH])
165780327d8Smillert {
166479fd71aSmarkus u_int32_t a, b, c, d, e, aa, bb, cc, dd, ee, t, x[16];
167780327d8Smillert
168e7aec372Sjanjaap #if BYTE_ORDER == LITTLE_ENDIAN
169e5c6a985Smillert memcpy(x, block, RMD160_BLOCK_LENGTH);
170e7aec372Sjanjaap #else
171479fd71aSmarkus int i;
172479fd71aSmarkus
173479fd71aSmarkus for (i = 0; i < 16; i++)
174ae7178f8Smarkus x[i] = (u_int32_t)(
175ae7178f8Smarkus (u_int32_t)(block[i*4 + 0]) |
176ae7178f8Smarkus (u_int32_t)(block[i*4 + 1]) << 8 |
177ae7178f8Smarkus (u_int32_t)(block[i*4 + 2]) << 16 |
178ae7178f8Smarkus (u_int32_t)(block[i*4 + 3]) << 24);
179e7aec372Sjanjaap #endif
180780327d8Smillert
181479fd71aSmarkus a = state[0];
182479fd71aSmarkus b = state[1];
183479fd71aSmarkus c = state[2];
184479fd71aSmarkus d = state[3];
185479fd71aSmarkus e = state[4];
186780327d8Smillert
187479fd71aSmarkus /* Round 1 */
188479fd71aSmarkus R(a, b, c, d, e, F0, K0, 11, 0);
189479fd71aSmarkus R(e, a, b, c, d, F0, K0, 14, 1);
190479fd71aSmarkus R(d, e, a, b, c, F0, K0, 15, 2);
191479fd71aSmarkus R(c, d, e, a, b, F0, K0, 12, 3);
192479fd71aSmarkus R(b, c, d, e, a, F0, K0, 5, 4);
193479fd71aSmarkus R(a, b, c, d, e, F0, K0, 8, 5);
194479fd71aSmarkus R(e, a, b, c, d, F0, K0, 7, 6);
195479fd71aSmarkus R(d, e, a, b, c, F0, K0, 9, 7);
196479fd71aSmarkus R(c, d, e, a, b, F0, K0, 11, 8);
197479fd71aSmarkus R(b, c, d, e, a, F0, K0, 13, 9);
198479fd71aSmarkus R(a, b, c, d, e, F0, K0, 14, 10);
199479fd71aSmarkus R(e, a, b, c, d, F0, K0, 15, 11);
200479fd71aSmarkus R(d, e, a, b, c, F0, K0, 6, 12);
201479fd71aSmarkus R(c, d, e, a, b, F0, K0, 7, 13);
202479fd71aSmarkus R(b, c, d, e, a, F0, K0, 9, 14);
203479fd71aSmarkus R(a, b, c, d, e, F0, K0, 8, 15); /* #15 */
204479fd71aSmarkus /* Round 2 */
205479fd71aSmarkus R(e, a, b, c, d, F1, K1, 7, 7);
206479fd71aSmarkus R(d, e, a, b, c, F1, K1, 6, 4);
207479fd71aSmarkus R(c, d, e, a, b, F1, K1, 8, 13);
208479fd71aSmarkus R(b, c, d, e, a, F1, K1, 13, 1);
209479fd71aSmarkus R(a, b, c, d, e, F1, K1, 11, 10);
210479fd71aSmarkus R(e, a, b, c, d, F1, K1, 9, 6);
211479fd71aSmarkus R(d, e, a, b, c, F1, K1, 7, 15);
212479fd71aSmarkus R(c, d, e, a, b, F1, K1, 15, 3);
213479fd71aSmarkus R(b, c, d, e, a, F1, K1, 7, 12);
214479fd71aSmarkus R(a, b, c, d, e, F1, K1, 12, 0);
215479fd71aSmarkus R(e, a, b, c, d, F1, K1, 15, 9);
216479fd71aSmarkus R(d, e, a, b, c, F1, K1, 9, 5);
217479fd71aSmarkus R(c, d, e, a, b, F1, K1, 11, 2);
218479fd71aSmarkus R(b, c, d, e, a, F1, K1, 7, 14);
219479fd71aSmarkus R(a, b, c, d, e, F1, K1, 13, 11);
220479fd71aSmarkus R(e, a, b, c, d, F1, K1, 12, 8); /* #31 */
221479fd71aSmarkus /* Round 3 */
222479fd71aSmarkus R(d, e, a, b, c, F2, K2, 11, 3);
223479fd71aSmarkus R(c, d, e, a, b, F2, K2, 13, 10);
224479fd71aSmarkus R(b, c, d, e, a, F2, K2, 6, 14);
225479fd71aSmarkus R(a, b, c, d, e, F2, K2, 7, 4);
226479fd71aSmarkus R(e, a, b, c, d, F2, K2, 14, 9);
227479fd71aSmarkus R(d, e, a, b, c, F2, K2, 9, 15);
228479fd71aSmarkus R(c, d, e, a, b, F2, K2, 13, 8);
229479fd71aSmarkus R(b, c, d, e, a, F2, K2, 15, 1);
230479fd71aSmarkus R(a, b, c, d, e, F2, K2, 14, 2);
231479fd71aSmarkus R(e, a, b, c, d, F2, K2, 8, 7);
232479fd71aSmarkus R(d, e, a, b, c, F2, K2, 13, 0);
233479fd71aSmarkus R(c, d, e, a, b, F2, K2, 6, 6);
234479fd71aSmarkus R(b, c, d, e, a, F2, K2, 5, 13);
235479fd71aSmarkus R(a, b, c, d, e, F2, K2, 12, 11);
236479fd71aSmarkus R(e, a, b, c, d, F2, K2, 7, 5);
237479fd71aSmarkus R(d, e, a, b, c, F2, K2, 5, 12); /* #47 */
238479fd71aSmarkus /* Round 4 */
239479fd71aSmarkus R(c, d, e, a, b, F3, K3, 11, 1);
240479fd71aSmarkus R(b, c, d, e, a, F3, K3, 12, 9);
241479fd71aSmarkus R(a, b, c, d, e, F3, K3, 14, 11);
242479fd71aSmarkus R(e, a, b, c, d, F3, K3, 15, 10);
243479fd71aSmarkus R(d, e, a, b, c, F3, K3, 14, 0);
244479fd71aSmarkus R(c, d, e, a, b, F3, K3, 15, 8);
245479fd71aSmarkus R(b, c, d, e, a, F3, K3, 9, 12);
246479fd71aSmarkus R(a, b, c, d, e, F3, K3, 8, 4);
247479fd71aSmarkus R(e, a, b, c, d, F3, K3, 9, 13);
248479fd71aSmarkus R(d, e, a, b, c, F3, K3, 14, 3);
249479fd71aSmarkus R(c, d, e, a, b, F3, K3, 5, 7);
250479fd71aSmarkus R(b, c, d, e, a, F3, K3, 6, 15);
251479fd71aSmarkus R(a, b, c, d, e, F3, K3, 8, 14);
252479fd71aSmarkus R(e, a, b, c, d, F3, K3, 6, 5);
253479fd71aSmarkus R(d, e, a, b, c, F3, K3, 5, 6);
254479fd71aSmarkus R(c, d, e, a, b, F3, K3, 12, 2); /* #63 */
255479fd71aSmarkus /* Round 5 */
256479fd71aSmarkus R(b, c, d, e, a, F4, K4, 9, 4);
257479fd71aSmarkus R(a, b, c, d, e, F4, K4, 15, 0);
258479fd71aSmarkus R(e, a, b, c, d, F4, K4, 5, 5);
259479fd71aSmarkus R(d, e, a, b, c, F4, K4, 11, 9);
260479fd71aSmarkus R(c, d, e, a, b, F4, K4, 6, 7);
261479fd71aSmarkus R(b, c, d, e, a, F4, K4, 8, 12);
262479fd71aSmarkus R(a, b, c, d, e, F4, K4, 13, 2);
263479fd71aSmarkus R(e, a, b, c, d, F4, K4, 12, 10);
264479fd71aSmarkus R(d, e, a, b, c, F4, K4, 5, 14);
265479fd71aSmarkus R(c, d, e, a, b, F4, K4, 12, 1);
266479fd71aSmarkus R(b, c, d, e, a, F4, K4, 13, 3);
267479fd71aSmarkus R(a, b, c, d, e, F4, K4, 14, 8);
268479fd71aSmarkus R(e, a, b, c, d, F4, K4, 11, 11);
269479fd71aSmarkus R(d, e, a, b, c, F4, K4, 8, 6);
270479fd71aSmarkus R(c, d, e, a, b, F4, K4, 5, 15);
271479fd71aSmarkus R(b, c, d, e, a, F4, K4, 6, 13); /* #79 */
272780327d8Smillert
273479fd71aSmarkus aa = a ; bb = b; cc = c; dd = d; ee = e;
274479fd71aSmarkus
275479fd71aSmarkus a = state[0];
276479fd71aSmarkus b = state[1];
277479fd71aSmarkus c = state[2];
278479fd71aSmarkus d = state[3];
279479fd71aSmarkus e = state[4];
280479fd71aSmarkus
281479fd71aSmarkus /* Parallel round 1 */
282479fd71aSmarkus R(a, b, c, d, e, F4, KK0, 8, 5);
283479fd71aSmarkus R(e, a, b, c, d, F4, KK0, 9, 14);
284479fd71aSmarkus R(d, e, a, b, c, F4, KK0, 9, 7);
285479fd71aSmarkus R(c, d, e, a, b, F4, KK0, 11, 0);
286479fd71aSmarkus R(b, c, d, e, a, F4, KK0, 13, 9);
287479fd71aSmarkus R(a, b, c, d, e, F4, KK0, 15, 2);
288479fd71aSmarkus R(e, a, b, c, d, F4, KK0, 15, 11);
289479fd71aSmarkus R(d, e, a, b, c, F4, KK0, 5, 4);
290479fd71aSmarkus R(c, d, e, a, b, F4, KK0, 7, 13);
291479fd71aSmarkus R(b, c, d, e, a, F4, KK0, 7, 6);
292479fd71aSmarkus R(a, b, c, d, e, F4, KK0, 8, 15);
293479fd71aSmarkus R(e, a, b, c, d, F4, KK0, 11, 8);
294479fd71aSmarkus R(d, e, a, b, c, F4, KK0, 14, 1);
295479fd71aSmarkus R(c, d, e, a, b, F4, KK0, 14, 10);
296479fd71aSmarkus R(b, c, d, e, a, F4, KK0, 12, 3);
297479fd71aSmarkus R(a, b, c, d, e, F4, KK0, 6, 12); /* #15 */
298479fd71aSmarkus /* Parallel round 2 */
299479fd71aSmarkus R(e, a, b, c, d, F3, KK1, 9, 6);
300479fd71aSmarkus R(d, e, a, b, c, F3, KK1, 13, 11);
301479fd71aSmarkus R(c, d, e, a, b, F3, KK1, 15, 3);
302479fd71aSmarkus R(b, c, d, e, a, F3, KK1, 7, 7);
303479fd71aSmarkus R(a, b, c, d, e, F3, KK1, 12, 0);
304479fd71aSmarkus R(e, a, b, c, d, F3, KK1, 8, 13);
305479fd71aSmarkus R(d, e, a, b, c, F3, KK1, 9, 5);
306479fd71aSmarkus R(c, d, e, a, b, F3, KK1, 11, 10);
307479fd71aSmarkus R(b, c, d, e, a, F3, KK1, 7, 14);
308479fd71aSmarkus R(a, b, c, d, e, F3, KK1, 7, 15);
309479fd71aSmarkus R(e, a, b, c, d, F3, KK1, 12, 8);
310479fd71aSmarkus R(d, e, a, b, c, F3, KK1, 7, 12);
311479fd71aSmarkus R(c, d, e, a, b, F3, KK1, 6, 4);
312479fd71aSmarkus R(b, c, d, e, a, F3, KK1, 15, 9);
313479fd71aSmarkus R(a, b, c, d, e, F3, KK1, 13, 1);
314479fd71aSmarkus R(e, a, b, c, d, F3, KK1, 11, 2); /* #31 */
315479fd71aSmarkus /* Parallel round 3 */
316479fd71aSmarkus R(d, e, a, b, c, F2, KK2, 9, 15);
317479fd71aSmarkus R(c, d, e, a, b, F2, KK2, 7, 5);
318479fd71aSmarkus R(b, c, d, e, a, F2, KK2, 15, 1);
319479fd71aSmarkus R(a, b, c, d, e, F2, KK2, 11, 3);
320479fd71aSmarkus R(e, a, b, c, d, F2, KK2, 8, 7);
321479fd71aSmarkus R(d, e, a, b, c, F2, KK2, 6, 14);
322479fd71aSmarkus R(c, d, e, a, b, F2, KK2, 6, 6);
323479fd71aSmarkus R(b, c, d, e, a, F2, KK2, 14, 9);
324479fd71aSmarkus R(a, b, c, d, e, F2, KK2, 12, 11);
325479fd71aSmarkus R(e, a, b, c, d, F2, KK2, 13, 8);
326479fd71aSmarkus R(d, e, a, b, c, F2, KK2, 5, 12);
327479fd71aSmarkus R(c, d, e, a, b, F2, KK2, 14, 2);
328479fd71aSmarkus R(b, c, d, e, a, F2, KK2, 13, 10);
329479fd71aSmarkus R(a, b, c, d, e, F2, KK2, 13, 0);
330479fd71aSmarkus R(e, a, b, c, d, F2, KK2, 7, 4);
331479fd71aSmarkus R(d, e, a, b, c, F2, KK2, 5, 13); /* #47 */
332479fd71aSmarkus /* Parallel round 4 */
333479fd71aSmarkus R(c, d, e, a, b, F1, KK3, 15, 8);
334479fd71aSmarkus R(b, c, d, e, a, F1, KK3, 5, 6);
335479fd71aSmarkus R(a, b, c, d, e, F1, KK3, 8, 4);
336479fd71aSmarkus R(e, a, b, c, d, F1, KK3, 11, 1);
337479fd71aSmarkus R(d, e, a, b, c, F1, KK3, 14, 3);
338479fd71aSmarkus R(c, d, e, a, b, F1, KK3, 14, 11);
339479fd71aSmarkus R(b, c, d, e, a, F1, KK3, 6, 15);
340479fd71aSmarkus R(a, b, c, d, e, F1, KK3, 14, 0);
341479fd71aSmarkus R(e, a, b, c, d, F1, KK3, 6, 5);
342479fd71aSmarkus R(d, e, a, b, c, F1, KK3, 9, 12);
343479fd71aSmarkus R(c, d, e, a, b, F1, KK3, 12, 2);
344479fd71aSmarkus R(b, c, d, e, a, F1, KK3, 9, 13);
345479fd71aSmarkus R(a, b, c, d, e, F1, KK3, 12, 9);
346479fd71aSmarkus R(e, a, b, c, d, F1, KK3, 5, 7);
347479fd71aSmarkus R(d, e, a, b, c, F1, KK3, 15, 10);
348479fd71aSmarkus R(c, d, e, a, b, F1, KK3, 8, 14); /* #63 */
349479fd71aSmarkus /* Parallel round 5 */
350479fd71aSmarkus R(b, c, d, e, a, F0, KK4, 8, 12);
351479fd71aSmarkus R(a, b, c, d, e, F0, KK4, 5, 15);
352479fd71aSmarkus R(e, a, b, c, d, F0, KK4, 12, 10);
353479fd71aSmarkus R(d, e, a, b, c, F0, KK4, 9, 4);
354479fd71aSmarkus R(c, d, e, a, b, F0, KK4, 12, 1);
355479fd71aSmarkus R(b, c, d, e, a, F0, KK4, 5, 5);
356479fd71aSmarkus R(a, b, c, d, e, F0, KK4, 14, 8);
357479fd71aSmarkus R(e, a, b, c, d, F0, KK4, 6, 7);
358479fd71aSmarkus R(d, e, a, b, c, F0, KK4, 8, 6);
359479fd71aSmarkus R(c, d, e, a, b, F0, KK4, 13, 2);
360479fd71aSmarkus R(b, c, d, e, a, F0, KK4, 6, 13);
361479fd71aSmarkus R(a, b, c, d, e, F0, KK4, 5, 14);
362479fd71aSmarkus R(e, a, b, c, d, F0, KK4, 15, 0);
363479fd71aSmarkus R(d, e, a, b, c, F0, KK4, 13, 3);
364479fd71aSmarkus R(c, d, e, a, b, F0, KK4, 11, 9);
365479fd71aSmarkus R(b, c, d, e, a, F0, KK4, 11, 11); /* #79 */
366479fd71aSmarkus
367479fd71aSmarkus t = state[1] + cc + d;
368479fd71aSmarkus state[1] = state[2] + dd + e;
369479fd71aSmarkus state[2] = state[3] + ee + a;
370479fd71aSmarkus state[3] = state[4] + aa + b;
371479fd71aSmarkus state[4] = state[0] + bb + c;
372479fd71aSmarkus state[0] = t;
373479fd71aSmarkus }
37489db3a20Sguenther DEF_WEAK(RMD160Transform);
375