Commit 6ffb1647 authored by Eric Rost's avatar Eric Rost Committed by Greg Kroah-Hartman

staging: skein: Whitespace cleanup

Pretties up multiline #defines and many other whitespace issues
Signed-off-by: default avatarEric Rost <eric.rost@mybabylon.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9246a4a9
......@@ -26,15 +26,18 @@
#define SKEIN_LOOP 001 /* default: unroll 256 and 512, but not 1024 */
#endif
#define BLK_BITS (WCNT*64) /* some useful definitions for code here */
#define BLK_BITS (WCNT * 64) /* some useful definitions for code here */
#define KW_TWK_BASE (0)
#define KW_KEY_BASE (3)
#define ks (kw + KW_KEY_BASE)
#define ts (kw + KW_TWK_BASE)
#ifdef SKEIN_DEBUG
#define debug_save_tweak(ctx) { \
ctx->h.tweak[0] = ts[0]; ctx->h.tweak[1] = ts[1]; }
#define debug_save_tweak(ctx) \
{ \
ctx->h.tweak[0] = ts[0]; \
ctx->h.tweak[1] = ts[1]; \
}
#else
#define debug_save_tweak(ctx)
#endif
......@@ -43,15 +46,15 @@
#if !(SKEIN_USE_ASM & 256)
void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr,
size_t blk_cnt, size_t byte_cnt_add)
{ /* do it in C */
{ /* do it in C */
enum {
WCNT = SKEIN_256_STATE_WORDS
};
#undef RCNT
#define RCNT (SKEIN_256_ROUNDS_TOTAL/8)
#define RCNT (SKEIN_256_ROUNDS_TOTAL / 8)
#ifdef SKEIN_LOOP /* configure how much to unroll the loop */
#define SKEIN_UNROLL_256 (((SKEIN_LOOP)/100)%10)
#define SKEIN_UNROLL_256 (((SKEIN_LOOP) / 100) % 10)
#else
#define SKEIN_UNROLL_256 (0)
#endif
......@@ -96,7 +99,8 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr,
debug_save_tweak(ctx);
skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, w, ks, ts);
X0 = w[0] + ks[0]; /* do the first full key injection */
/* do the first full key injection */
X0 = w[0] + ks[0];
X1 = w[1] + ks[1] + ts[0];
X2 = w[2] + ks[2] + ts[1];
X3 = w[3] + ks[3];
......@@ -111,8 +115,12 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr,
#define ROUND256(p0, p1, p2, p3, ROT, r_num) \
do { \
X##p0 += X##p1; X##p1 = rotl_64(X##p1, ROT##_0); X##p1 ^= X##p0; \
X##p2 += X##p3; X##p3 = rotl_64(X##p3, ROT##_1); X##p3 ^= X##p2; \
X##p0 += X##p1; \
X##p1 = rotl_64(X##p1, ROT##_0); \
X##p1 ^= X##p0; \
X##p2 += X##p3; \
X##p3 = rotl_64(X##p3, ROT##_1); \
X##p3 ^= X##p2; \
} while (0)
#if SKEIN_UNROLL_256 == 0
......@@ -125,13 +133,14 @@ do { \
#define I256(R) \
do { \
/* inject the key schedule value */ \
X0 += ks[((R)+1) % 5]; \
X1 += ks[((R)+2) % 5] + ts[((R)+1) % 3]; \
X2 += ks[((R)+3) % 5] + ts[((R)+2) % 3]; \
X3 += ks[((R)+4) % 5] + (R)+1; \
X0 += ks[((R) + 1) % 5]; \
X1 += ks[((R) + 2) % 5] + ts[((R) + 1) % 3]; \
X2 += ks[((R) + 3) % 5] + ts[((R) + 2) % 3]; \
X3 += ks[((R) + 4) % 5] + (R) + 1; \
skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \
} while (0)
#else /* looping version */
#else
/* looping version */
#define R256(p0, p1, p2, p3, ROT, r_num) \
do { \
ROUND256(p0, p1, p2, p3, ROT, r_num); \
......@@ -141,10 +150,10 @@ do { \
#define I256(R) \
do { \
/* inject the key schedule value */ \
X0 += ks[r+(R)+0]; \
X1 += ks[r+(R)+1] + ts[r+(R)+0]; \
X2 += ks[r+(R)+2] + ts[r+(R)+1]; \
X3 += ks[r+(R)+3] + r+(R); \
X0 += ks[r + (R) + 0]; \
X1 += ks[r + (R) + 1] + ts[r + (R) + 0]; \
X2 += ks[r + (R) + 2] + ts[r + (R) + 1]; \
X3 += ks[r + (R) + 3] + r + (R); \
/* rotate key schedule */ \
ks[r + (R) + 4] = ks[r + (R) - 1]; \
ts[r + (R) + 2] = ts[r + (R) - 1]; \
......@@ -172,54 +181,54 @@ do { \
#define R256_UNROLL_R(NN) \
((SKEIN_UNROLL_256 == 0 && \
SKEIN_256_ROUNDS_TOTAL/8 > (NN)) || \
SKEIN_256_ROUNDS_TOTAL / 8 > (NN)) || \
(SKEIN_UNROLL_256 > (NN)))
#if R256_UNROLL_R(1)
#if R256_UNROLL_R(1)
R256_8_ROUNDS(1);
#endif
#if R256_UNROLL_R(2)
#endif
#if R256_UNROLL_R(2)
R256_8_ROUNDS(2);
#endif
#if R256_UNROLL_R(3)
#endif
#if R256_UNROLL_R(3)
R256_8_ROUNDS(3);
#endif
#if R256_UNROLL_R(4)
#endif
#if R256_UNROLL_R(4)
R256_8_ROUNDS(4);
#endif
#if R256_UNROLL_R(5)
#endif
#if R256_UNROLL_R(5)
R256_8_ROUNDS(5);
#endif
#if R256_UNROLL_R(6)
#endif
#if R256_UNROLL_R(6)
R256_8_ROUNDS(6);
#endif
#if R256_UNROLL_R(7)
#endif
#if R256_UNROLL_R(7)
R256_8_ROUNDS(7);
#endif
#if R256_UNROLL_R(8)
#endif
#if R256_UNROLL_R(8)
R256_8_ROUNDS(8);
#endif
#if R256_UNROLL_R(9)
#endif
#if R256_UNROLL_R(9)
R256_8_ROUNDS(9);
#endif
#if R256_UNROLL_R(10)
#endif
#if R256_UNROLL_R(10)
R256_8_ROUNDS(10);
#endif
#if R256_UNROLL_R(11)
#endif
#if R256_UNROLL_R(11)
R256_8_ROUNDS(11);
#endif
#if R256_UNROLL_R(12)
#endif
#if R256_UNROLL_R(12)
R256_8_ROUNDS(12);
#endif
#if R256_UNROLL_R(13)
#endif
#if R256_UNROLL_R(13)
R256_8_ROUNDS(13);
#endif
#if R256_UNROLL_R(14)
#endif
#if R256_UNROLL_R(14)
R256_8_ROUNDS(14);
#endif
#if (SKEIN_UNROLL_256 > 14)
#endif
#if (SKEIN_UNROLL_256 > 14)
#error "need more unrolling in skein_256_process_block"
#endif
#endif
}
/* do the final "feedforward" xor, update context chaining */
ctx->x[0] = X0 ^ w[0];
......@@ -312,7 +321,8 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr,
debug_save_tweak(ctx);
skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, w, ks, ts);
X0 = w[0] + ks[0]; /* do the first full key injection */
/* do the first full key injection */
X0 = w[0] + ks[0];
X1 = w[1] + ks[1];
X2 = w[2] + ks[2];
X3 = w[3] + ks[3];
......@@ -328,10 +338,17 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr,
/* run the rounds */
#define ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \
do { \
X##p0 += X##p1; X##p1 = rotl_64(X##p1, ROT##_0); X##p1 ^= X##p0; \
X##p2 += X##p3; X##p3 = rotl_64(X##p3, ROT##_1); X##p3 ^= X##p2; \
X##p4 += X##p5; X##p5 = rotl_64(X##p5, ROT##_2); X##p5 ^= X##p4; \
X##p6 += X##p7; X##p7 = rotl_64(X##p7, ROT##_3); X##p7 ^= X##p6; \
X##p0 += X##p1; \
X##p1 = rotl_64(X##p1, ROT##_0); \
X##p1 ^= X##p0; \
X##p2 += X##p3; \
X##p3 = rotl_64(X##p3, ROT##_1); \
X##p3 ^= X##p2; \
X##p4 += X##p5; \
X##p5 = rotl_64(X##p5, ROT##_2); \
X##p5 ^= X##p4; \
X##p6 += X##p7; X##p7 = rotl_64(X##p7, ROT##_3); \
X##p7 ^= X##p6; \
} while (0)
#if SKEIN_UNROLL_512 == 0
......@@ -354,6 +371,7 @@ do { \
X7 += ks[((R) + 8) % 9] + (R) + 1; \
skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \
} while (0)
#else /* looping version */
#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \
do { \
......@@ -402,51 +420,51 @@ do { \
SKEIN_512_ROUNDS_TOTAL/8 > (NN)) || \
(SKEIN_UNROLL_512 > (NN)))
#if R512_UNROLL_R(1)
#if R512_UNROLL_R(1)
R512_8_ROUNDS(1);
#endif
#if R512_UNROLL_R(2)
#endif
#if R512_UNROLL_R(2)
R512_8_ROUNDS(2);
#endif
#if R512_UNROLL_R(3)
#endif
#if R512_UNROLL_R(3)
R512_8_ROUNDS(3);
#endif
#if R512_UNROLL_R(4)
#endif
#if R512_UNROLL_R(4)
R512_8_ROUNDS(4);
#endif
#if R512_UNROLL_R(5)
#endif
#if R512_UNROLL_R(5)
R512_8_ROUNDS(5);
#endif
#if R512_UNROLL_R(6)
#endif
#if R512_UNROLL_R(6)
R512_8_ROUNDS(6);
#endif
#if R512_UNROLL_R(7)
#endif
#if R512_UNROLL_R(7)
R512_8_ROUNDS(7);
#endif
#if R512_UNROLL_R(8)
#endif
#if R512_UNROLL_R(8)
R512_8_ROUNDS(8);
#endif
#if R512_UNROLL_R(9)
#endif
#if R512_UNROLL_R(9)
R512_8_ROUNDS(9);
#endif
#if R512_UNROLL_R(10)
#endif
#if R512_UNROLL_R(10)
R512_8_ROUNDS(10);
#endif
#if R512_UNROLL_R(11)
#endif
#if R512_UNROLL_R(11)
R512_8_ROUNDS(11);
#endif
#if R512_UNROLL_R(12)
#endif
#if R512_UNROLL_R(12)
R512_8_ROUNDS(12);
#endif
#if R512_UNROLL_R(13)
#endif
#if R512_UNROLL_R(13)
R512_8_ROUNDS(13);
#endif
#if R512_UNROLL_R(14)
#endif
#if R512_UNROLL_R(14)
R512_8_ROUNDS(14);
#endif
#if (SKEIN_UNROLL_512 > 14)
#endif
#if (SKEIN_UNROLL_512 > 14)
#error "need more unrolling in skein_512_process_block"
#endif
#endif
}
/* do the final "feedforward" xor, update context chaining */
......@@ -513,11 +531,21 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr,
#ifdef SKEIN_DEBUG
const u64 *X_ptr[16]; /* use for debugging (help cc put Xn in regs) */
X_ptr[0] = &X00; X_ptr[1] = &X01; X_ptr[2] = &X02;
X_ptr[3] = &X03; X_ptr[4] = &X04; X_ptr[5] = &X05;
X_ptr[6] = &X06; X_ptr[7] = &X07; X_ptr[8] = &X08;
X_ptr[9] = &X09; X_ptr[10] = &X10; X_ptr[11] = &X11;
X_ptr[12] = &X12; X_ptr[13] = &X13; X_ptr[14] = &X14;
X_ptr[0] = &X00;
X_ptr[1] = &X01;
X_ptr[2] = &X02;
X_ptr[3] = &X03;
X_ptr[4] = &X04;
X_ptr[5] = &X05;
X_ptr[6] = &X06;
X_ptr[7] = &X07;
X_ptr[8] = &X08;
X_ptr[9] = &X09;
X_ptr[10] = &X10;
X_ptr[11] = &X11;
X_ptr[12] = &X12;
X_ptr[13] = &X13;
X_ptr[14] = &X14;
X_ptr[15] = &X15;
#endif
......@@ -560,7 +588,8 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr,
debug_save_tweak(ctx);
skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, w, ks, ts);
X00 = w[0] + ks[0]; /* do the first full key injection */
/* do the first full key injection */
X00 = w[0] + ks[0];
X01 = w[1] + ks[1];
X02 = w[2] + ks[2];
X03 = w[3] + ks[3];
......@@ -583,14 +612,30 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr,
#define ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \
pF, ROT, r_num) \
do { \
X##p0 += X##p1; X##p1 = rotl_64(X##p1, ROT##_0); X##p1 ^= X##p0; \
X##p2 += X##p3; X##p3 = rotl_64(X##p3, ROT##_1); X##p3 ^= X##p2; \
X##p4 += X##p5; X##p5 = rotl_64(X##p5, ROT##_2); X##p5 ^= X##p4; \
X##p6 += X##p7; X##p7 = rotl_64(X##p7, ROT##_3); X##p7 ^= X##p6; \
X##p8 += X##p9; X##p9 = rotl_64(X##p9, ROT##_4); X##p9 ^= X##p8; \
X##pA += X##pB; X##pB = rotl_64(X##pB, ROT##_5); X##pB ^= X##pA; \
X##pC += X##pD; X##pD = rotl_64(X##pD, ROT##_6); X##pD ^= X##pC; \
X##pE += X##pF; X##pF = rotl_64(X##pF, ROT##_7); X##pF ^= X##pE; \
X##p0 += X##p1; \
X##p1 = rotl_64(X##p1, ROT##_0); \
X##p1 ^= X##p0; \
X##p2 += X##p3; \
X##p3 = rotl_64(X##p3, ROT##_1); \
X##p3 ^= X##p2; \
X##p4 += X##p5; \
X##p5 = rotl_64(X##p5, ROT##_2); \
X##p5 ^= X##p4; \
X##p6 += X##p7; \
X##p7 = rotl_64(X##p7, ROT##_3); \
X##p7 ^= X##p6; \
X##p8 += X##p9; \
X##p9 = rotl_64(X##p9, ROT##_4); \
X##p9 ^= X##p8; \
X##pA += X##pB; \
X##pB = rotl_64(X##pB, ROT##_5); \
X##pB ^= X##pA; \
X##pC += X##pD; \
X##pD = rotl_64(X##pD, ROT##_6); \
X##pD ^= X##pC; \
X##pE += X##pF; \
X##pF = rotl_64(X##pF, ROT##_7); \
X##pF ^= X##pE; \
} while (0)
#if SKEIN_UNROLL_1024 == 0
......@@ -689,48 +734,48 @@ do { \
SKEIN_1024_ROUNDS_TOTAL/8 > (NN)) || \
(SKEIN_UNROLL_1024 > (NN)))
#if R1024_UNROLL_R(1)
#if R1024_UNROLL_R(1)
R1024_8_ROUNDS(1);
#endif
#if R1024_UNROLL_R(2)
#endif
#if R1024_UNROLL_R(2)
R1024_8_ROUNDS(2);
#endif
#if R1024_UNROLL_R(3)
#endif
#if R1024_UNROLL_R(3)
R1024_8_ROUNDS(3);
#endif
#if R1024_UNROLL_R(4)
#endif
#if R1024_UNROLL_R(4)
R1024_8_ROUNDS(4);
#endif
#if R1024_UNROLL_R(5)
#endif
#if R1024_UNROLL_R(5)
R1024_8_ROUNDS(5);
#endif
#if R1024_UNROLL_R(6)
#endif
#if R1024_UNROLL_R(6)
R1024_8_ROUNDS(6);
#endif
#if R1024_UNROLL_R(7)
#endif
#if R1024_UNROLL_R(7)
R1024_8_ROUNDS(7);
#endif
#if R1024_UNROLL_R(8)
#endif
#if R1024_UNROLL_R(8)
R1024_8_ROUNDS(8);
#endif
#if R1024_UNROLL_R(9)
#endif
#if R1024_UNROLL_R(9)
R1024_8_ROUNDS(9);
#endif
#if R1024_UNROLL_R(10)
#endif
#if R1024_UNROLL_R(10)
R1024_8_ROUNDS(10);
#endif
#if R1024_UNROLL_R(11)
#endif
#if R1024_UNROLL_R(11)
R1024_8_ROUNDS(11);
#endif
#if R1024_UNROLL_R(12)
#endif
#if R1024_UNROLL_R(12)
R1024_8_ROUNDS(12);
#endif
#if R1024_UNROLL_R(13)
#endif
#if R1024_UNROLL_R(13)
R1024_8_ROUNDS(13);
#endif
#if R1024_UNROLL_R(14)
#endif
#if R1024_UNROLL_R(14)
R1024_8_ROUNDS(14);
#endif
#endif
#if (SKEIN_UNROLL_1024 > 14)
#error "need more unrolling in Skein_1024_Process_Block"
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment