2 * Implementation of the Skein block functions.
3 * Source code author: Doug Whiting, 2008.
4 * This algorithm and source code is released to the public domain.
5 * Compile-time switches:
6 * SKEIN_USE_ASM -- set bits (256/512/1024) to select which
7 * versions use ASM code for block processing
8 * [default: use C for all block sizes]
10 /* Copyright 2013 Doug Whiting. This code is released to the public domain. */
12 #include <sys/skein.h>
13 #include "skein_impl.h"
14 #include <sys/isa_defs.h> /* for _ILP32 */
17 #define SKEIN_USE_ASM (0) /* default is all C code (no ASM) */
22 * The low-level checksum routines use a lot of stack space. On systems where
23 * small stacks frame are enforced (like 32-bit kernel builds), do not unroll
24 * checksum calculations to save stack space.
26 * Even with no loops unrolled, we still can exceed the 1k stack frame limit
27 * in Skein1024_Process_Block() (it hits 1272 bytes on ARM32). We can
28 * safely ignore it though, since that the checksum functions will be called
29 * from a worker thread that won't be using much stack. That's why we have
30 * the #pragma here to ignore the warning.
32 #if defined(_ILP32) || defined(__powerpc) /* Assume small stack */
33 #if defined(__GNUC__) && !defined(__clang__)
34 #pragma GCC diagnostic ignored "-Wframe-larger-than="
37 * We're running on 32-bit, don't unroll loops to save stack frame space
39 * Due to the ways the calculations on SKEIN_LOOP are done in
40 * Skein_*_Process_Block(), a value of 111 disables unrolling loops
41 * in any of those functions.
43 #define SKEIN_LOOP 111
45 /* We're compiling with large stacks */
46 #define SKEIN_LOOP 001 /* default: unroll 256 and 512, but not 1024 */
50 /* some useful definitions for code here */
51 #define BLK_BITS (WCNT*64)
52 #define KW_TWK_BASE (0)
53 #define KW_KEY_BASE (3)
54 #define ks (kw + KW_KEY_BASE)
55 #define ts (kw + KW_TWK_BASE)
57 /* no debugging in Illumos version */
58 #define DebugSaveTweak(ctx)
61 #if !(SKEIN_USE_ASM & 256)
63 Skein_256_Process_Block(Skein_256_Ctxt_t
*ctx
, const uint8_t *blkPtr
,
64 size_t blkCnt
, size_t byteCntAdd
)
67 WCNT
= SKEIN_256_STATE_WORDS
70 #define RCNT (SKEIN_256_ROUNDS_TOTAL / 8)
72 #ifdef SKEIN_LOOP /* configure how much to unroll the loop */
73 #define SKEIN_UNROLL_256 (((SKEIN_LOOP) / 100) % 10)
75 #define SKEIN_UNROLL_256 (0)
79 #if (RCNT % SKEIN_UNROLL_256)
80 #error "Invalid SKEIN_UNROLL_256" /* sanity check on unroll count */
83 /* key schedule words : chaining vars + tweak + "rotation" */
84 uint64_t kw
[WCNT
+ 4 + RCNT
* 2];
86 uint64_t kw
[WCNT
+ 4]; /* key schedule words : chaining vars + tweak */
88 /* local copy of context vars, for speed */
89 uint64_t X0
, X1
, X2
, X3
;
90 uint64_t w
[WCNT
]; /* local copy of input block */
92 /* use for debugging (help compiler put Xn in registers) */
93 const uint64_t *Xptr
[4];
99 Skein_assert(blkCnt
!= 0); /* never call with blkCnt == 0! */
104 * this implementation only supports 2**64 input bytes
105 * (no carry out here)
107 ts
[0] += byteCntAdd
; /* update processed length */
109 /* precompute the key schedule for this block */
114 ks
[4] = ks
[0] ^ ks
[1] ^ ks
[2] ^ ks
[3] ^ SKEIN_KS_PARITY
;
116 ts
[2] = ts
[0] ^ ts
[1];
118 /* get input block in little-endian format */
119 Skein_Get64_LSB_First(w
, blkPtr
, WCNT
);
121 Skein_Show_Block(BLK_BITS
, &ctx
->h
, ctx
->X
, blkPtr
, w
, ks
, ts
);
123 X0
= w
[0] + ks
[0]; /* do the first full key injection */
124 X1
= w
[1] + ks
[1] + ts
[0];
125 X2
= w
[2] + ks
[2] + ts
[1];
128 Skein_Show_R_Ptr(BLK_BITS
, &ctx
->h
, SKEIN_RND_KEY_INITIAL
,
129 Xptr
); /* show starting state values */
131 blkPtr
+= SKEIN_256_BLOCK_BYTES
;
135 #define Round256(p0, p1, p2, p3, ROT, rNum) \
136 X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \
137 X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \
139 #if SKEIN_UNROLL_256 == 0
140 #define R256(p0, p1, p2, p3, ROT, rNum) /* fully unrolled */ \
141 Round256(p0, p1, p2, p3, ROT, rNum) \
142 Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr);
145 X0 += ks[((R) + 1) % 5]; /* inject the key schedule value */ \
146 X1 += ks[((R) + 2) % 5] + ts[((R) + 1) % 3]; \
147 X2 += ks[((R) + 3) % 5] + ts[((R) + 2) % 3]; \
148 X3 += ks[((R) + 4) % 5] + (R) + 1; \
149 Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr);
150 #else /* looping version */
151 #define R256(p0, p1, p2, p3, ROT, rNum) \
152 Round256(p0, p1, p2, p3, ROT, rNum) \
153 Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr);
156 X0 += ks[r + (R) + 0]; /* inject the key schedule value */ \
157 X1 += ks[r + (R) + 1] + ts[r + (R) + 0]; \
158 X2 += ks[r + (R) + 2] + ts[r + (R) + 1]; \
159 X3 += ks[r + (R) + 3] + r + (R); \
160 ks[r + (R) + 4] = ks[r + (R) - 1]; /* rotate key schedule */ \
161 ts[r + (R) + 2] = ts[r + (R) - 1]; \
162 Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr);
164 /* loop through it */
165 for (r
= 1; r
< 2 * RCNT
; r
+= 2 * SKEIN_UNROLL_256
)
168 #define R256_8_rounds(R) \
169 R256(0, 1, 2, 3, R_256_0, 8 * (R) + 1); \
170 R256(0, 3, 2, 1, R_256_1, 8 * (R) + 2); \
171 R256(0, 1, 2, 3, R_256_2, 8 * (R) + 3); \
172 R256(0, 3, 2, 1, R_256_3, 8 * (R) + 4); \
174 R256(0, 1, 2, 3, R_256_4, 8 * (R) + 5); \
175 R256(0, 3, 2, 1, R_256_5, 8 * (R) + 6); \
176 R256(0, 1, 2, 3, R_256_6, 8 * (R) + 7); \
177 R256(0, 3, 2, 1, R_256_7, 8 * (R) + 8); \
182 #define R256_Unroll_R(NN) \
183 ((SKEIN_UNROLL_256 == 0 && SKEIN_256_ROUNDS_TOTAL / 8 > (NN)) || \
184 (SKEIN_UNROLL_256 > (NN)))
213 #if R256_Unroll_R(10)
216 #if R256_Unroll_R(11)
219 #if R256_Unroll_R(12)
222 #if R256_Unroll_R(13)
225 #if R256_Unroll_R(14)
228 #if (SKEIN_UNROLL_256 > 14)
229 #error "need more unrolling in Skein_256_Process_Block"
233 * do the final "feedforward" xor, update context chaining vars
235 ctx
->X
[0] = X0
^ w
[0];
236 ctx
->X
[1] = X1
^ w
[1];
237 ctx
->X
[2] = X2
^ w
[2];
238 ctx
->X
[3] = X3
^ w
[3];
240 Skein_Show_Round(BLK_BITS
, &ctx
->h
, SKEIN_RND_FEED_FWD
, ctx
->X
);
242 ts
[1] &= ~SKEIN_T1_FLAG_FIRST
;
248 #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF)
250 Skein_256_Process_Block_CodeSize(void)
252 return ((uint8_t *)Skein_256_Process_Block_CodeSize
) -
253 ((uint8_t *)Skein_256_Process_Block
);
257 Skein_256_Unroll_Cnt(void)
259 return (SKEIN_UNROLL_256
);
265 #if !(SKEIN_USE_ASM & 512)
267 Skein_512_Process_Block(Skein_512_Ctxt_t
*ctx
, const uint8_t *blkPtr
,
268 size_t blkCnt
, size_t byteCntAdd
)
271 WCNT
= SKEIN_512_STATE_WORDS
274 #define RCNT (SKEIN_512_ROUNDS_TOTAL / 8)
276 #ifdef SKEIN_LOOP /* configure how much to unroll the loop */
277 #define SKEIN_UNROLL_512 (((SKEIN_LOOP) / 10) % 10)
279 #define SKEIN_UNROLL_512 (0)
283 #if (RCNT % SKEIN_UNROLL_512)
284 #error "Invalid SKEIN_UNROLL_512" /* sanity check on unroll count */
287 /* key schedule words : chaining vars + tweak + "rotation" */
288 uint64_t kw
[WCNT
+ 4 + RCNT
* 2];
290 uint64_t kw
[WCNT
+ 4]; /* key schedule words : chaining vars + tweak */
292 /* local copy of vars, for speed */
293 uint64_t X0
, X1
, X2
, X3
, X4
, X5
, X6
, X7
;
294 uint64_t w
[WCNT
]; /* local copy of input block */
296 /* use for debugging (help compiler put Xn in registers) */
297 const uint64_t *Xptr
[8];
308 Skein_assert(blkCnt
!= 0); /* never call with blkCnt == 0! */
313 * this implementation only supports 2**64 input bytes
314 * (no carry out here)
316 ts
[0] += byteCntAdd
; /* update processed length */
318 /* precompute the key schedule for this block */
327 ks
[8] = ks
[0] ^ ks
[1] ^ ks
[2] ^ ks
[3] ^
328 ks
[4] ^ ks
[5] ^ ks
[6] ^ ks
[7] ^ SKEIN_KS_PARITY
;
330 ts
[2] = ts
[0] ^ ts
[1];
332 /* get input block in little-endian format */
333 Skein_Get64_LSB_First(w
, blkPtr
, WCNT
);
335 Skein_Show_Block(BLK_BITS
, &ctx
->h
, ctx
->X
, blkPtr
, w
, ks
, ts
);
337 X0
= w
[0] + ks
[0]; /* do the first full key injection */
342 X5
= w
[5] + ks
[5] + ts
[0];
343 X6
= w
[6] + ks
[6] + ts
[1];
346 blkPtr
+= SKEIN_512_BLOCK_BYTES
;
348 Skein_Show_R_Ptr(BLK_BITS
, &ctx
->h
, SKEIN_RND_KEY_INITIAL
,
351 #define Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \
352 X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0;\
353 X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2;\
354 X##p4 += X##p5; X##p5 = RotL_64(X##p5, ROT##_2); X##p5 ^= X##p4;\
355 X##p6 += X##p7; X##p7 = RotL_64(X##p7, ROT##_3); X##p7 ^= X##p6;
357 #if SKEIN_UNROLL_512 == 0
358 #define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) /* unrolled */ \
359 Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \
360 Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr);
363 X0 += ks[((R) + 1) % 9]; /* inject the key schedule value */\
364 X1 += ks[((R) + 2) % 9]; \
365 X2 += ks[((R) + 3) % 9]; \
366 X3 += ks[((R) + 4) % 9]; \
367 X4 += ks[((R) + 5) % 9]; \
368 X5 += ks[((R) + 6) % 9] + ts[((R) + 1) % 3]; \
369 X6 += ks[((R) + 7) % 9] + ts[((R) + 2) % 3]; \
370 X7 += ks[((R) + 8) % 9] + (R) + 1; \
371 Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr);
372 #else /* looping version */
373 #define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \
374 Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \
375 Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr);
378 X0 += ks[r + (R) + 0]; /* inject the key schedule value */ \
379 X1 += ks[r + (R) + 1]; \
380 X2 += ks[r + (R) + 2]; \
381 X3 += ks[r + (R) + 3]; \
382 X4 += ks[r + (R) + 4]; \
383 X5 += ks[r + (R) + 5] + ts[r + (R) + 0]; \
384 X6 += ks[r + (R) + 6] + ts[r + (R) + 1]; \
385 X7 += ks[r + (R) + 7] + r + (R); \
386 ks[r + (R)+8] = ks[r + (R) - 1]; /* rotate key schedule */\
387 ts[r + (R)+2] = ts[r + (R) - 1]; \
388 Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr);
390 /* loop through it */
391 for (r
= 1; r
< 2 * RCNT
; r
+= 2 * SKEIN_UNROLL_512
)
392 #endif /* end of looped code definitions */
394 #define R512_8_rounds(R) /* do 8 full rounds */ \
395 R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_0, 8 * (R) + 1); \
396 R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_1, 8 * (R) + 2); \
397 R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_2, 8 * (R) + 3); \
398 R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_3, 8 * (R) + 4); \
400 R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_4, 8 * (R) + 5); \
401 R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_5, 8 * (R) + 6); \
402 R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_6, 8 * (R) + 7); \
403 R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_7, 8 * (R) + 8); \
404 I512(2*(R) + 1); /* and key injection */
408 #define R512_Unroll_R(NN) \
409 ((SKEIN_UNROLL_512 == 0 && SKEIN_512_ROUNDS_TOTAL / 8 > (NN)) || \
410 (SKEIN_UNROLL_512 > (NN)))
439 #if R512_Unroll_R(10)
442 #if R512_Unroll_R(11)
445 #if R512_Unroll_R(12)
448 #if R512_Unroll_R(13)
451 #if R512_Unroll_R(14)
454 #if (SKEIN_UNROLL_512 > 14)
455 #error "need more unrolling in Skein_512_Process_Block"
460 * do the final "feedforward" xor, update context chaining vars
462 ctx
->X
[0] = X0
^ w
[0];
463 ctx
->X
[1] = X1
^ w
[1];
464 ctx
->X
[2] = X2
^ w
[2];
465 ctx
->X
[3] = X3
^ w
[3];
466 ctx
->X
[4] = X4
^ w
[4];
467 ctx
->X
[5] = X5
^ w
[5];
468 ctx
->X
[6] = X6
^ w
[6];
469 ctx
->X
[7] = X7
^ w
[7];
470 Skein_Show_Round(BLK_BITS
, &ctx
->h
, SKEIN_RND_FEED_FWD
, ctx
->X
);
472 ts
[1] &= ~SKEIN_T1_FLAG_FIRST
;
478 #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF)
480 Skein_512_Process_Block_CodeSize(void)
482 return ((uint8_t *)Skein_512_Process_Block_CodeSize
) -
483 ((uint8_t *)Skein_512_Process_Block
);
487 Skein_512_Unroll_Cnt(void)
489 return (SKEIN_UNROLL_512
);
495 #if !(SKEIN_USE_ASM & 1024)
497 Skein1024_Process_Block(Skein1024_Ctxt_t
*ctx
, const uint8_t *blkPtr
,
498 size_t blkCnt
, size_t byteCntAdd
)
500 /* do it in C, always looping (unrolled is bigger AND slower!) */
502 WCNT
= SKEIN1024_STATE_WORDS
505 #define RCNT (SKEIN1024_ROUNDS_TOTAL/8)
507 #ifdef SKEIN_LOOP /* configure how much to unroll the loop */
508 #define SKEIN_UNROLL_1024 ((SKEIN_LOOP)%10)
510 #define SKEIN_UNROLL_1024 (0)
513 #if (SKEIN_UNROLL_1024 != 0)
514 #if (RCNT % SKEIN_UNROLL_1024)
515 #error "Invalid SKEIN_UNROLL_1024" /* sanity check on unroll count */
518 /* key schedule words : chaining vars + tweak + "rotation" */
519 uint64_t kw
[WCNT
+ 4 + RCNT
* 2];
521 uint64_t kw
[WCNT
+ 4]; /* key schedule words : chaining vars + tweak */
524 /* local copy of vars, for speed */
525 uint64_t X00
, X01
, X02
, X03
, X04
, X05
, X06
, X07
, X08
, X09
, X10
, X11
,
527 uint64_t w
[WCNT
]; /* local copy of input block */
529 /* use for debugging (help compiler put Xn in registers) */
530 const uint64_t *Xptr
[16];
549 Skein_assert(blkCnt
!= 0); /* never call with blkCnt == 0! */
554 * this implementation only supports 2**64 input bytes
555 * (no carry out here)
557 ts
[0] += byteCntAdd
; /* update processed length */
559 /* precompute the key schedule for this block */
576 ks
[16] = ks
[0] ^ ks
[1] ^ ks
[2] ^ ks
[3] ^
577 ks
[4] ^ ks
[5] ^ ks
[6] ^ ks
[7] ^
578 ks
[8] ^ ks
[9] ^ ks
[10] ^ ks
[11] ^
579 ks
[12] ^ ks
[13] ^ ks
[14] ^ ks
[15] ^ SKEIN_KS_PARITY
;
581 ts
[2] = ts
[0] ^ ts
[1];
583 /* get input block in little-endian format */
584 Skein_Get64_LSB_First(w
, blkPtr
, WCNT
);
586 Skein_Show_Block(BLK_BITS
, &ctx
->h
, ctx
->X
, blkPtr
, w
, ks
, ts
);
588 X00
= w
[0] + ks
[0]; /* do the first full key injection */
598 X10
= w
[10] + ks
[10];
599 X11
= w
[11] + ks
[11];
600 X12
= w
[12] + ks
[12];
601 X13
= w
[13] + ks
[13] + ts
[0];
602 X14
= w
[14] + ks
[14] + ts
[1];
603 X15
= w
[15] + ks
[15];
605 Skein_Show_R_Ptr(BLK_BITS
, &ctx
->h
, SKEIN_RND_KEY_INITIAL
,
608 #define Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, \
609 pD, pE, pF, ROT, rNum) \
610 X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0;\
611 X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2;\
612 X##p4 += X##p5; X##p5 = RotL_64(X##p5, ROT##_2); X##p5 ^= X##p4;\
613 X##p6 += X##p7; X##p7 = RotL_64(X##p7, ROT##_3); X##p7 ^= X##p6;\
614 X##p8 += X##p9; X##p9 = RotL_64(X##p9, ROT##_4); X##p9 ^= X##p8;\
615 X##pA += X##pB; X##pB = RotL_64(X##pB, ROT##_5); X##pB ^= X##pA;\
616 X##pC += X##pD; X##pD = RotL_64(X##pD, ROT##_6); X##pD ^= X##pC;\
617 X##pE += X##pF; X##pF = RotL_64(X##pF, ROT##_7); X##pF ^= X##pE;
619 #if SKEIN_UNROLL_1024 == 0
620 #define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, \
622 Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, \
623 pD, pE, pF, ROT, rn) \
624 Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rn, Xptr);
627 X00 += ks[((R) + 1) % 17]; /* inject the key schedule value */\
628 X01 += ks[((R) + 2) % 17]; \
629 X02 += ks[((R) + 3) % 17]; \
630 X03 += ks[((R) + 4) % 17]; \
631 X04 += ks[((R) + 5) % 17]; \
632 X05 += ks[((R) + 6) % 17]; \
633 X06 += ks[((R) + 7) % 17]; \
634 X07 += ks[((R) + 8) % 17]; \
635 X08 += ks[((R) + 9) % 17]; \
636 X09 += ks[((R) + 10) % 17]; \
637 X10 += ks[((R) + 11) % 17]; \
638 X11 += ks[((R) + 12) % 17]; \
639 X12 += ks[((R) + 13) % 17]; \
640 X13 += ks[((R) + 14) % 17] + ts[((R) + 1) % 3]; \
641 X14 += ks[((R) + 15) % 17] + ts[((R) + 2) % 3]; \
642 X15 += ks[((R) + 16) % 17] + (R) +1; \
643 Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr);
644 #else /* looping version */
645 #define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, \
647 Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, \
648 pD, pE, pF, ROT, rn) \
649 Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rn, Xptr);
652 X00 += ks[r + (R) + 0]; /* inject the key schedule value */ \
653 X01 += ks[r + (R) + 1]; \
654 X02 += ks[r + (R) + 2]; \
655 X03 += ks[r + (R) + 3]; \
656 X04 += ks[r + (R) + 4]; \
657 X05 += ks[r + (R) + 5]; \
658 X06 += ks[r + (R) + 6]; \
659 X07 += ks[r + (R) + 7]; \
660 X08 += ks[r + (R) + 8]; \
661 X09 += ks[r + (R) + 9]; \
662 X10 += ks[r + (R) + 10]; \
663 X11 += ks[r + (R) + 11]; \
664 X12 += ks[r + (R) + 12]; \
665 X13 += ks[r + (R) + 13] + ts[r + (R) + 0]; \
666 X14 += ks[r + (R) + 14] + ts[r + (R) + 1]; \
667 X15 += ks[r + (R) + 15] + r + (R); \
668 ks[r + (R) + 16] = ks[r + (R) - 1]; /* rotate key schedule */\
669 ts[r + (R) + 2] = ts[r + (R) - 1]; \
670 Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr);
672 /* loop through it */
673 for (r
= 1; r
<= 2 * RCNT
; r
+= 2 * SKEIN_UNROLL_1024
)
676 #define R1024_8_rounds(R) /* do 8 full rounds */ \
677 R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, \
678 14, 15, R1024_0, 8 * (R) + 1); \
679 R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, \
680 08, 01, R1024_1, 8 * (R) + 2); \
681 R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, \
682 10, 09, R1024_2, 8 * (R) + 3); \
683 R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, \
684 12, 07, R1024_3, 8 * (R) + 4); \
686 R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, \
687 14, 15, R1024_4, 8 * (R) + 5); \
688 R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, \
689 08, 01, R1024_5, 8 * (R) + 6); \
690 R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, \
691 10, 09, R1024_6, 8 * (R) + 7); \
692 R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, \
693 12, 07, R1024_7, 8 * (R) + 8); \
698 #define R1024_Unroll_R(NN) \
699 ((SKEIN_UNROLL_1024 == 0 && SKEIN1024_ROUNDS_TOTAL/8 > (NN)) || \
700 (SKEIN_UNROLL_1024 > (NN)))
702 #if R1024_Unroll_R(1)
705 #if R1024_Unroll_R(2)
708 #if R1024_Unroll_R(3)
711 #if R1024_Unroll_R(4)
714 #if R1024_Unroll_R(5)
717 #if R1024_Unroll_R(6)
720 #if R1024_Unroll_R(7)
723 #if R1024_Unroll_R(8)
726 #if R1024_Unroll_R(9)
729 #if R1024_Unroll_R(10)
732 #if R1024_Unroll_R(11)
735 #if R1024_Unroll_R(12)
738 #if R1024_Unroll_R(13)
741 #if R1024_Unroll_R(14)
744 #if (SKEIN_UNROLL_1024 > 14)
745 #error "need more unrolling in Skein_1024_Process_Block"
749 * do the final "feedforward" xor, update context chaining vars
752 ctx
->X
[0] = X00
^ w
[0];
753 ctx
->X
[1] = X01
^ w
[1];
754 ctx
->X
[2] = X02
^ w
[2];
755 ctx
->X
[3] = X03
^ w
[3];
756 ctx
->X
[4] = X04
^ w
[4];
757 ctx
->X
[5] = X05
^ w
[5];
758 ctx
->X
[6] = X06
^ w
[6];
759 ctx
->X
[7] = X07
^ w
[7];
760 ctx
->X
[8] = X08
^ w
[8];
761 ctx
->X
[9] = X09
^ w
[9];
762 ctx
->X
[10] = X10
^ w
[10];
763 ctx
->X
[11] = X11
^ w
[11];
764 ctx
->X
[12] = X12
^ w
[12];
765 ctx
->X
[13] = X13
^ w
[13];
766 ctx
->X
[14] = X14
^ w
[14];
767 ctx
->X
[15] = X15
^ w
[15];
769 Skein_Show_Round(BLK_BITS
, &ctx
->h
, SKEIN_RND_FEED_FWD
, ctx
->X
);
771 ts
[1] &= ~SKEIN_T1_FLAG_FIRST
;
772 blkPtr
+= SKEIN1024_BLOCK_BYTES
;
778 #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF)
780 Skein1024_Process_Block_CodeSize(void)
782 return ((uint8_t *)Skein1024_Process_Block_CodeSize
) -
783 ((uint8_t *)Skein1024_Process_Block
);
787 Skein1024_Unroll_Cnt(void)
789 return (SKEIN_UNROLL_1024
);