rmd160.c revision 1.3.8.2 1 1.3.8.2 joerg /* $NetBSD: rmd160.c,v 1.3.8.2 2007/07/18 13:57:55 joerg Exp $ */
2 1.3.8.2 joerg /* $KAME: rmd160.c,v 1.2 2003/07/25 09:37:55 itojun Exp $ */
3 1.3.8.2 joerg /* $OpenBSD: rmd160.c,v 1.3 2001/09/26 21:40:13 markus Exp $ */
4 1.3.8.2 joerg /*
5 1.3.8.2 joerg * Copyright (c) 2001 Markus Friedl. All rights reserved.
6 1.3.8.2 joerg *
7 1.3.8.2 joerg * Redistribution and use in source and binary forms, with or without
8 1.3.8.2 joerg * modification, are permitted provided that the following conditions
9 1.3.8.2 joerg * are met:
10 1.3.8.2 joerg * 1. Redistributions of source code must retain the above copyright
11 1.3.8.2 joerg * notice, this list of conditions and the following disclaimer.
12 1.3.8.2 joerg * 2. Redistributions in binary form must reproduce the above copyright
13 1.3.8.2 joerg * notice, this list of conditions and the following disclaimer in the
14 1.3.8.2 joerg * documentation and/or other materials provided with the distribution.
15 1.3.8.2 joerg *
16 1.3.8.2 joerg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.3.8.2 joerg * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.3.8.2 joerg * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 1.3.8.2 joerg * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 1.3.8.2 joerg * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 1.3.8.2 joerg * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 1.3.8.2 joerg * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 1.3.8.2 joerg * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 1.3.8.2 joerg * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 1.3.8.2 joerg * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 1.3.8.2 joerg */
27 1.3.8.2 joerg /*
28 1.3.8.2 joerg * Preneel, Bosselaers, Dobbertin, "The Cryptographic Hash Function RIPEMD-160",
29 1.3.8.2 joerg * RSA Laboratories, CryptoBytes, Volume 3, Number 2, Autumn 1997,
30 1.3.8.2 joerg * ftp://ftp.rsasecurity.com/pub/cryptobytes/crypto3n2.pdf
31 1.3.8.2 joerg */
32 1.3.8.2 joerg
33 1.3.8.2 joerg #include <sys/cdefs.h>
34 1.3.8.2 joerg
35 1.3.8.2 joerg #if defined(_KERNEL) || defined(_STANDALONE)
36 1.3.8.2 joerg __KERNEL_RCSID(0, "$NetBSD: rmd160.c,v 1.3.8.2 2007/07/18 13:57:55 joerg Exp $");
37 1.3.8.2 joerg
38 1.3.8.2 joerg #include <lib/libkern/libkern.h>
39 1.3.8.2 joerg
40 1.3.8.2 joerg #else
41 1.3.8.2 joerg
42 1.3.8.2 joerg #if defined(LIBC_SCCS) && !defined(lint)
43 1.3.8.2 joerg __RCSID("$NetBSD: rmd160.c,v 1.3.8.2 2007/07/18 13:57:55 joerg Exp $");
44 1.3.8.2 joerg #endif /* LIBC_SCCS and not lint */
45 1.3.8.2 joerg
46 1.3.8.2 joerg #include "namespace.h"
47 1.3.8.2 joerg #include <assert.h>
48 1.3.8.2 joerg #include <string.h>
49 1.3.8.2 joerg
50 1.3.8.2 joerg #endif
51 1.3.8.2 joerg
52 1.3.8.2 joerg #include <sys/types.h>
53 1.3.8.2 joerg #include <sys/param.h>
54 1.3.8.2 joerg #include <sys/rmd160.h>
55 1.3.8.2 joerg
56 1.3.8.2 joerg
57 1.3.8.2 joerg #define PUT_64BIT_LE(cp, value) do { \
58 1.3.8.2 joerg (cp)[7] = (u_char)((value) >> 56); \
59 1.3.8.2 joerg (cp)[6] = (u_char)((value) >> 48); \
60 1.3.8.2 joerg (cp)[5] = (u_char)((value) >> 40); \
61 1.3.8.2 joerg (cp)[4] = (u_char)((value) >> 32); \
62 1.3.8.2 joerg (cp)[3] = (u_char)((value) >> 24); \
63 1.3.8.2 joerg (cp)[2] = (u_char)((value) >> 16); \
64 1.3.8.2 joerg (cp)[1] = (u_char)((value) >> 8); \
65 1.3.8.2 joerg (cp)[0] = (u_char)((value)); } while (/*CONSTCOND*/0)
66 1.3.8.2 joerg
67 1.3.8.2 joerg #define PUT_32BIT_LE(cp, value) do { \
68 1.3.8.2 joerg (cp)[3] = (value) >> 24; \
69 1.3.8.2 joerg (cp)[2] = (value) >> 16; \
70 1.3.8.2 joerg (cp)[1] = (value) >> 8; \
71 1.3.8.2 joerg (cp)[0] = (value); } while (/*CONSTCOND*/0)
72 1.3.8.2 joerg
73 1.3.8.2 joerg #define H0 0x67452301U
74 1.3.8.2 joerg #define H1 0xEFCDAB89U
75 1.3.8.2 joerg #define H2 0x98BADCFEU
76 1.3.8.2 joerg #define H3 0x10325476U
77 1.3.8.2 joerg #define H4 0xC3D2E1F0U
78 1.3.8.2 joerg
79 1.3.8.2 joerg #define K0 0x00000000U
80 1.3.8.2 joerg #define K1 0x5A827999U
81 1.3.8.2 joerg #define K2 0x6ED9EBA1U
82 1.3.8.2 joerg #define K3 0x8F1BBCDCU
83 1.3.8.2 joerg #define K4 0xA953FD4EU
84 1.3.8.2 joerg
85 1.3.8.2 joerg #define KK0 0x50A28BE6U
86 1.3.8.2 joerg #define KK1 0x5C4DD124U
87 1.3.8.2 joerg #define KK2 0x6D703EF3U
88 1.3.8.2 joerg #define KK3 0x7A6D76E9U
89 1.3.8.2 joerg #define KK4 0x00000000U
90 1.3.8.2 joerg
91 1.3.8.2 joerg /* rotate x left n bits. */
92 1.3.8.2 joerg #define ROL(n, x) (((x) << (n)) | ((x) >> (32-(n))))
93 1.3.8.2 joerg
94 1.3.8.2 joerg #define F0(x, y, z) ((x) ^ (y) ^ (z))
95 1.3.8.2 joerg #define F1(x, y, z) (((x) & (y)) | ((~x) & (z)))
96 1.3.8.2 joerg #define F2(x, y, z) (((x) | (~y)) ^ (z))
97 1.3.8.2 joerg #define F3(x, y, z) (((x) & (z)) | ((y) & (~z)))
98 1.3.8.2 joerg #define F4(x, y, z) ((x) ^ ((y) | (~z)))
99 1.3.8.2 joerg
100 1.3.8.2 joerg #define R(a, b, c, d, e, Fj, Kj, sj, rj) \
101 1.3.8.2 joerg do { \
102 1.3.8.2 joerg a = ROL(sj, a + Fj(b,c,d) + X(rj) + Kj) + e; \
103 1.3.8.2 joerg c = ROL(10, c); \
104 1.3.8.2 joerg } while(/*CONSTCOND*/0)
105 1.3.8.2 joerg
106 1.3.8.2 joerg #define X(i) x[i]
107 1.3.8.2 joerg
108 1.3.8.2 joerg static const u_char PADDING[64] = {
109 1.3.8.2 joerg 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
110 1.3.8.2 joerg 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
111 1.3.8.2 joerg 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
112 1.3.8.2 joerg };
113 1.3.8.2 joerg
114 1.3.8.2 joerg #if !defined(_KERNEL) && defined(__weak_alias)
115 1.3.8.2 joerg __weak_alias(RMD160Init,_RMD160Init)
116 1.3.8.2 joerg __weak_alias(RMD160Update,_RMD160Update)
117 1.3.8.2 joerg __weak_alias(RMD160Final,_RMD160Final)
118 1.3.8.2 joerg __weak_alias(RMD160Transform,_RMD160Transform)
119 1.3.8.2 joerg #endif
120 1.3.8.2 joerg
121 1.3.8.2 joerg void
122 1.3.8.2 joerg RMD160Init(RMD160_CTX *ctx)
123 1.3.8.2 joerg {
124 1.3.8.2 joerg ctx->count = 0;
125 1.3.8.2 joerg ctx->state[0] = H0;
126 1.3.8.2 joerg ctx->state[1] = H1;
127 1.3.8.2 joerg ctx->state[2] = H2;
128 1.3.8.2 joerg ctx->state[3] = H3;
129 1.3.8.2 joerg ctx->state[4] = H4;
130 1.3.8.2 joerg }
131 1.3.8.2 joerg
132 1.3.8.2 joerg void
133 1.3.8.2 joerg RMD160Update(RMD160_CTX *ctx, const u_char *input, u_int32_t len)
134 1.3.8.2 joerg {
135 1.3.8.2 joerg u_int32_t have, off, need;
136 1.3.8.2 joerg
137 1.3.8.2 joerg have = (u_int32_t)((ctx->count/8) % 64);
138 1.3.8.2 joerg need = 64 - have;
139 1.3.8.2 joerg ctx->count += 8 * len;
140 1.3.8.2 joerg off = 0;
141 1.3.8.2 joerg
142 1.3.8.2 joerg if (len >= need) {
143 1.3.8.2 joerg if (have) {
144 1.3.8.2 joerg memcpy(ctx->buffer + have, input, (size_t)need);
145 1.3.8.2 joerg RMD160Transform(ctx->state, ctx->buffer);
146 1.3.8.2 joerg off = need;
147 1.3.8.2 joerg have = 0;
148 1.3.8.2 joerg }
149 1.3.8.2 joerg /* now the buffer is empty */
150 1.3.8.2 joerg while (off + 64 <= len) {
151 1.3.8.2 joerg RMD160Transform(ctx->state, input+off);
152 1.3.8.2 joerg off += 64;
153 1.3.8.2 joerg }
154 1.3.8.2 joerg }
155 1.3.8.2 joerg if (off < len)
156 1.3.8.2 joerg memcpy(ctx->buffer + have, input+off, (size_t)len-off);
157 1.3.8.2 joerg }
158 1.3.8.2 joerg
159 1.3.8.2 joerg void
160 1.3.8.2 joerg RMD160Final(u_char digest[20], RMD160_CTX *ctx)
161 1.3.8.2 joerg {
162 1.3.8.2 joerg int i;
163 1.3.8.2 joerg u_char size[8];
164 1.3.8.2 joerg u_int32_t padlen;
165 1.3.8.2 joerg
166 1.3.8.2 joerg PUT_64BIT_LE(size, ctx->count);
167 1.3.8.2 joerg
168 1.3.8.2 joerg /*
169 1.3.8.2 joerg * pad to 64 byte blocks, at least one byte from PADDING plus 8 bytes
170 1.3.8.2 joerg * for the size
171 1.3.8.2 joerg */
172 1.3.8.2 joerg padlen = (u_int32_t)(64 - ((ctx->count/8) % 64));
173 1.3.8.2 joerg if (padlen < 1 + 8)
174 1.3.8.2 joerg padlen += 64;
175 1.3.8.2 joerg RMD160Update(ctx, PADDING, padlen - 8); /* padlen - 8 <= 64 */
176 1.3.8.2 joerg RMD160Update(ctx, size, 8);
177 1.3.8.2 joerg
178 1.3.8.2 joerg if (digest != NULL)
179 1.3.8.2 joerg for (i = 0; i < 5; i++)
180 1.3.8.2 joerg PUT_32BIT_LE(digest + i*4, ctx->state[i]);
181 1.3.8.2 joerg
182 1.3.8.2 joerg memset(ctx, 0, sizeof (*ctx));
183 1.3.8.2 joerg }
184 1.3.8.2 joerg
185 1.3.8.2 joerg void
186 1.3.8.2 joerg RMD160Transform(u_int32_t state[5], const u_char block[64])
187 1.3.8.2 joerg {
188 1.3.8.2 joerg u_int32_t a, b, c, d, e, aa, bb, cc, dd, ee, t, x[16];
189 1.3.8.2 joerg
190 1.3.8.2 joerg #if BYTE_ORDER == LITTLE_ENDIAN
191 1.3.8.2 joerg memcpy(x, block, (size_t)64);
192 1.3.8.2 joerg #else
193 1.3.8.2 joerg int i;
194 1.3.8.2 joerg
195 1.3.8.2 joerg for (i = 0; i < 16; i++)
196 1.3.8.2 joerg x[i] = le32dec(block+i*4);
197 1.3.8.2 joerg #endif
198 1.3.8.2 joerg
199 1.3.8.2 joerg a = state[0];
200 1.3.8.2 joerg b = state[1];
201 1.3.8.2 joerg c = state[2];
202 1.3.8.2 joerg d = state[3];
203 1.3.8.2 joerg e = state[4];
204 1.3.8.2 joerg
205 1.3.8.2 joerg /* Round 1 */
206 1.3.8.2 joerg R(a, b, c, d, e, F0, K0, 11, 0);
207 1.3.8.2 joerg R(e, a, b, c, d, F0, K0, 14, 1);
208 1.3.8.2 joerg R(d, e, a, b, c, F0, K0, 15, 2);
209 1.3.8.2 joerg R(c, d, e, a, b, F0, K0, 12, 3);
210 1.3.8.2 joerg R(b, c, d, e, a, F0, K0, 5, 4);
211 1.3.8.2 joerg R(a, b, c, d, e, F0, K0, 8, 5);
212 1.3.8.2 joerg R(e, a, b, c, d, F0, K0, 7, 6);
213 1.3.8.2 joerg R(d, e, a, b, c, F0, K0, 9, 7);
214 1.3.8.2 joerg R(c, d, e, a, b, F0, K0, 11, 8);
215 1.3.8.2 joerg R(b, c, d, e, a, F0, K0, 13, 9);
216 1.3.8.2 joerg R(a, b, c, d, e, F0, K0, 14, 10);
217 1.3.8.2 joerg R(e, a, b, c, d, F0, K0, 15, 11);
218 1.3.8.2 joerg R(d, e, a, b, c, F0, K0, 6, 12);
219 1.3.8.2 joerg R(c, d, e, a, b, F0, K0, 7, 13);
220 1.3.8.2 joerg R(b, c, d, e, a, F0, K0, 9, 14);
221 1.3.8.2 joerg R(a, b, c, d, e, F0, K0, 8, 15); /* #15 */
222 1.3.8.2 joerg /* Round 2 */
223 1.3.8.2 joerg R(e, a, b, c, d, F1, K1, 7, 7);
224 1.3.8.2 joerg R(d, e, a, b, c, F1, K1, 6, 4);
225 1.3.8.2 joerg R(c, d, e, a, b, F1, K1, 8, 13);
226 1.3.8.2 joerg R(b, c, d, e, a, F1, K1, 13, 1);
227 1.3.8.2 joerg R(a, b, c, d, e, F1, K1, 11, 10);
228 1.3.8.2 joerg R(e, a, b, c, d, F1, K1, 9, 6);
229 1.3.8.2 joerg R(d, e, a, b, c, F1, K1, 7, 15);
230 1.3.8.2 joerg R(c, d, e, a, b, F1, K1, 15, 3);
231 1.3.8.2 joerg R(b, c, d, e, a, F1, K1, 7, 12);
232 1.3.8.2 joerg R(a, b, c, d, e, F1, K1, 12, 0);
233 1.3.8.2 joerg R(e, a, b, c, d, F1, K1, 15, 9);
234 1.3.8.2 joerg R(d, e, a, b, c, F1, K1, 9, 5);
235 1.3.8.2 joerg R(c, d, e, a, b, F1, K1, 11, 2);
236 1.3.8.2 joerg R(b, c, d, e, a, F1, K1, 7, 14);
237 1.3.8.2 joerg R(a, b, c, d, e, F1, K1, 13, 11);
238 1.3.8.2 joerg R(e, a, b, c, d, F1, K1, 12, 8); /* #31 */
239 1.3.8.2 joerg /* Round 3 */
240 1.3.8.2 joerg R(d, e, a, b, c, F2, K2, 11, 3);
241 1.3.8.2 joerg R(c, d, e, a, b, F2, K2, 13, 10);
242 1.3.8.2 joerg R(b, c, d, e, a, F2, K2, 6, 14);
243 1.3.8.2 joerg R(a, b, c, d, e, F2, K2, 7, 4);
244 1.3.8.2 joerg R(e, a, b, c, d, F2, K2, 14, 9);
245 1.3.8.2 joerg R(d, e, a, b, c, F2, K2, 9, 15);
246 1.3.8.2 joerg R(c, d, e, a, b, F2, K2, 13, 8);
247 1.3.8.2 joerg R(b, c, d, e, a, F2, K2, 15, 1);
248 1.3.8.2 joerg R(a, b, c, d, e, F2, K2, 14, 2);
249 1.3.8.2 joerg R(e, a, b, c, d, F2, K2, 8, 7);
250 1.3.8.2 joerg R(d, e, a, b, c, F2, K2, 13, 0);
251 1.3.8.2 joerg R(c, d, e, a, b, F2, K2, 6, 6);
252 1.3.8.2 joerg R(b, c, d, e, a, F2, K2, 5, 13);
253 1.3.8.2 joerg R(a, b, c, d, e, F2, K2, 12, 11);
254 1.3.8.2 joerg R(e, a, b, c, d, F2, K2, 7, 5);
255 1.3.8.2 joerg R(d, e, a, b, c, F2, K2, 5, 12); /* #47 */
256 1.3.8.2 joerg /* Round 4 */
257 1.3.8.2 joerg R(c, d, e, a, b, F3, K3, 11, 1);
258 1.3.8.2 joerg R(b, c, d, e, a, F3, K3, 12, 9);
259 1.3.8.2 joerg R(a, b, c, d, e, F3, K3, 14, 11);
260 1.3.8.2 joerg R(e, a, b, c, d, F3, K3, 15, 10);
261 1.3.8.2 joerg R(d, e, a, b, c, F3, K3, 14, 0);
262 1.3.8.2 joerg R(c, d, e, a, b, F3, K3, 15, 8);
263 1.3.8.2 joerg R(b, c, d, e, a, F3, K3, 9, 12);
264 1.3.8.2 joerg R(a, b, c, d, e, F3, K3, 8, 4);
265 1.3.8.2 joerg R(e, a, b, c, d, F3, K3, 9, 13);
266 1.3.8.2 joerg R(d, e, a, b, c, F3, K3, 14, 3);
267 1.3.8.2 joerg R(c, d, e, a, b, F3, K3, 5, 7);
268 1.3.8.2 joerg R(b, c, d, e, a, F3, K3, 6, 15);
269 1.3.8.2 joerg R(a, b, c, d, e, F3, K3, 8, 14);
270 1.3.8.2 joerg R(e, a, b, c, d, F3, K3, 6, 5);
271 1.3.8.2 joerg R(d, e, a, b, c, F3, K3, 5, 6);
272 1.3.8.2 joerg R(c, d, e, a, b, F3, K3, 12, 2); /* #63 */
273 1.3.8.2 joerg /* Round 5 */
274 1.3.8.2 joerg R(b, c, d, e, a, F4, K4, 9, 4);
275 1.3.8.2 joerg R(a, b, c, d, e, F4, K4, 15, 0);
276 1.3.8.2 joerg R(e, a, b, c, d, F4, K4, 5, 5);
277 1.3.8.2 joerg R(d, e, a, b, c, F4, K4, 11, 9);
278 1.3.8.2 joerg R(c, d, e, a, b, F4, K4, 6, 7);
279 1.3.8.2 joerg R(b, c, d, e, a, F4, K4, 8, 12);
280 1.3.8.2 joerg R(a, b, c, d, e, F4, K4, 13, 2);
281 1.3.8.2 joerg R(e, a, b, c, d, F4, K4, 12, 10);
282 1.3.8.2 joerg R(d, e, a, b, c, F4, K4, 5, 14);
283 1.3.8.2 joerg R(c, d, e, a, b, F4, K4, 12, 1);
284 1.3.8.2 joerg R(b, c, d, e, a, F4, K4, 13, 3);
285 1.3.8.2 joerg R(a, b, c, d, e, F4, K4, 14, 8);
286 1.3.8.2 joerg R(e, a, b, c, d, F4, K4, 11, 11);
287 1.3.8.2 joerg R(d, e, a, b, c, F4, K4, 8, 6);
288 1.3.8.2 joerg R(c, d, e, a, b, F4, K4, 5, 15);
289 1.3.8.2 joerg R(b, c, d, e, a, F4, K4, 6, 13); /* #79 */
290 1.3.8.2 joerg
291 1.3.8.2 joerg aa = a ; bb = b; cc = c; dd = d; ee = e;
292 1.3.8.2 joerg
293 1.3.8.2 joerg a = state[0];
294 1.3.8.2 joerg b = state[1];
295 1.3.8.2 joerg c = state[2];
296 1.3.8.2 joerg d = state[3];
297 1.3.8.2 joerg e = state[4];
298 1.3.8.2 joerg
299 1.3.8.2 joerg /* Parallel round 1 */
300 1.3.8.2 joerg R(a, b, c, d, e, F4, KK0, 8, 5);
301 1.3.8.2 joerg R(e, a, b, c, d, F4, KK0, 9, 14);
302 1.3.8.2 joerg R(d, e, a, b, c, F4, KK0, 9, 7);
303 1.3.8.2 joerg R(c, d, e, a, b, F4, KK0, 11, 0);
304 1.3.8.2 joerg R(b, c, d, e, a, F4, KK0, 13, 9);
305 1.3.8.2 joerg R(a, b, c, d, e, F4, KK0, 15, 2);
306 1.3.8.2 joerg R(e, a, b, c, d, F4, KK0, 15, 11);
307 1.3.8.2 joerg R(d, e, a, b, c, F4, KK0, 5, 4);
308 1.3.8.2 joerg R(c, d, e, a, b, F4, KK0, 7, 13);
309 1.3.8.2 joerg R(b, c, d, e, a, F4, KK0, 7, 6);
310 1.3.8.2 joerg R(a, b, c, d, e, F4, KK0, 8, 15);
311 1.3.8.2 joerg R(e, a, b, c, d, F4, KK0, 11, 8);
312 1.3.8.2 joerg R(d, e, a, b, c, F4, KK0, 14, 1);
313 1.3.8.2 joerg R(c, d, e, a, b, F4, KK0, 14, 10);
314 1.3.8.2 joerg R(b, c, d, e, a, F4, KK0, 12, 3);
315 1.3.8.2 joerg R(a, b, c, d, e, F4, KK0, 6, 12); /* #15 */
316 1.3.8.2 joerg /* Parallel round 2 */
317 1.3.8.2 joerg R(e, a, b, c, d, F3, KK1, 9, 6);
318 1.3.8.2 joerg R(d, e, a, b, c, F3, KK1, 13, 11);
319 1.3.8.2 joerg R(c, d, e, a, b, F3, KK1, 15, 3);
320 1.3.8.2 joerg R(b, c, d, e, a, F3, KK1, 7, 7);
321 1.3.8.2 joerg R(a, b, c, d, e, F3, KK1, 12, 0);
322 1.3.8.2 joerg R(e, a, b, c, d, F3, KK1, 8, 13);
323 1.3.8.2 joerg R(d, e, a, b, c, F3, KK1, 9, 5);
324 1.3.8.2 joerg R(c, d, e, a, b, F3, KK1, 11, 10);
325 1.3.8.2 joerg R(b, c, d, e, a, F3, KK1, 7, 14);
326 1.3.8.2 joerg R(a, b, c, d, e, F3, KK1, 7, 15);
327 1.3.8.2 joerg R(e, a, b, c, d, F3, KK1, 12, 8);
328 1.3.8.2 joerg R(d, e, a, b, c, F3, KK1, 7, 12);
329 1.3.8.2 joerg R(c, d, e, a, b, F3, KK1, 6, 4);
330 1.3.8.2 joerg R(b, c, d, e, a, F3, KK1, 15, 9);
331 1.3.8.2 joerg R(a, b, c, d, e, F3, KK1, 13, 1);
332 1.3.8.2 joerg R(e, a, b, c, d, F3, KK1, 11, 2); /* #31 */
333 1.3.8.2 joerg /* Parallel round 3 */
334 1.3.8.2 joerg R(d, e, a, b, c, F2, KK2, 9, 15);
335 1.3.8.2 joerg R(c, d, e, a, b, F2, KK2, 7, 5);
336 1.3.8.2 joerg R(b, c, d, e, a, F2, KK2, 15, 1);
337 1.3.8.2 joerg R(a, b, c, d, e, F2, KK2, 11, 3);
338 1.3.8.2 joerg R(e, a, b, c, d, F2, KK2, 8, 7);
339 1.3.8.2 joerg R(d, e, a, b, c, F2, KK2, 6, 14);
340 1.3.8.2 joerg R(c, d, e, a, b, F2, KK2, 6, 6);
341 1.3.8.2 joerg R(b, c, d, e, a, F2, KK2, 14, 9);
342 1.3.8.2 joerg R(a, b, c, d, e, F2, KK2, 12, 11);
343 1.3.8.2 joerg R(e, a, b, c, d, F2, KK2, 13, 8);
344 1.3.8.2 joerg R(d, e, a, b, c, F2, KK2, 5, 12);
345 1.3.8.2 joerg R(c, d, e, a, b, F2, KK2, 14, 2);
346 1.3.8.2 joerg R(b, c, d, e, a, F2, KK2, 13, 10);
347 1.3.8.2 joerg R(a, b, c, d, e, F2, KK2, 13, 0);
348 1.3.8.2 joerg R(e, a, b, c, d, F2, KK2, 7, 4);
349 1.3.8.2 joerg R(d, e, a, b, c, F2, KK2, 5, 13); /* #47 */
350 1.3.8.2 joerg /* Parallel round 4 */
351 1.3.8.2 joerg R(c, d, e, a, b, F1, KK3, 15, 8);
352 1.3.8.2 joerg R(b, c, d, e, a, F1, KK3, 5, 6);
353 1.3.8.2 joerg R(a, b, c, d, e, F1, KK3, 8, 4);
354 1.3.8.2 joerg R(e, a, b, c, d, F1, KK3, 11, 1);
355 1.3.8.2 joerg R(d, e, a, b, c, F1, KK3, 14, 3);
356 1.3.8.2 joerg R(c, d, e, a, b, F1, KK3, 14, 11);
357 1.3.8.2 joerg R(b, c, d, e, a, F1, KK3, 6, 15);
358 1.3.8.2 joerg R(a, b, c, d, e, F1, KK3, 14, 0);
359 1.3.8.2 joerg R(e, a, b, c, d, F1, KK3, 6, 5);
360 1.3.8.2 joerg R(d, e, a, b, c, F1, KK3, 9, 12);
361 1.3.8.2 joerg R(c, d, e, a, b, F1, KK3, 12, 2);
362 1.3.8.2 joerg R(b, c, d, e, a, F1, KK3, 9, 13);
363 1.3.8.2 joerg R(a, b, c, d, e, F1, KK3, 12, 9);
364 1.3.8.2 joerg R(e, a, b, c, d, F1, KK3, 5, 7);
365 1.3.8.2 joerg R(d, e, a, b, c, F1, KK3, 15, 10);
366 1.3.8.2 joerg R(c, d, e, a, b, F1, KK3, 8, 14); /* #63 */
367 1.3.8.2 joerg /* Parallel round 5 */
368 1.3.8.2 joerg R(b, c, d, e, a, F0, KK4, 8, 12);
369 1.3.8.2 joerg R(a, b, c, d, e, F0, KK4, 5, 15);
370 1.3.8.2 joerg R(e, a, b, c, d, F0, KK4, 12, 10);
371 1.3.8.2 joerg R(d, e, a, b, c, F0, KK4, 9, 4);
372 1.3.8.2 joerg R(c, d, e, a, b, F0, KK4, 12, 1);
373 1.3.8.2 joerg R(b, c, d, e, a, F0, KK4, 5, 5);
374 1.3.8.2 joerg R(a, b, c, d, e, F0, KK4, 14, 8);
375 1.3.8.2 joerg R(e, a, b, c, d, F0, KK4, 6, 7);
376 1.3.8.2 joerg R(d, e, a, b, c, F0, KK4, 8, 6);
377 1.3.8.2 joerg R(c, d, e, a, b, F0, KK4, 13, 2);
378 1.3.8.2 joerg R(b, c, d, e, a, F0, KK4, 6, 13);
379 1.3.8.2 joerg R(a, b, c, d, e, F0, KK4, 5, 14);
380 1.3.8.2 joerg R(e, a, b, c, d, F0, KK4, 15, 0);
381 1.3.8.2 joerg R(d, e, a, b, c, F0, KK4, 13, 3);
382 1.3.8.2 joerg R(c, d, e, a, b, F0, KK4, 11, 9);
383 1.3.8.2 joerg R(b, c, d, e, a, F0, KK4, 11, 11); /* #79 */
384 1.3.8.2 joerg
385 1.3.8.2 joerg t = state[1] + cc + d;
386 1.3.8.2 joerg state[1] = state[2] + dd + e;
387 1.3.8.2 joerg state[2] = state[3] + ee + a;
388 1.3.8.2 joerg state[3] = state[4] + aa + b;
389 1.3.8.2 joerg state[4] = state[0] + bb + c;
390 1.3.8.2 joerg state[0] = t;
391 1.3.8.2 joerg }
392