Commit 78930e7c authored by Manu Kumar's avatar Manu Kumar Committed by Greg Kroah-Hartman

staging: skein: cleanup: add operator white space

Added white space between operators and operands. Because this sometimes
maxed out the column width, some expressions were broken up into multiple
lines, and comments were moved appropriately.
Signed-off-by: default avatarManu Kumar <maraku@gmx.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 60b3109e
...@@ -58,7 +58,7 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len) ...@@ -58,7 +58,7 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len)
cfg.w[1] = skein_swap64(hash_bit_len); cfg.w[1] = skein_swap64(hash_bit_len);
cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL);
/* zero pad config block */ /* zero pad config block */
memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); memset(&cfg.w[3], 0, sizeof(cfg) - 3 * sizeof(cfg.w[0]));
/* compute the initial chaining values from config block */ /* compute the initial chaining values from config block */
/* zero the chaining variables */ /* zero the chaining variables */
...@@ -98,7 +98,7 @@ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, ...@@ -98,7 +98,7 @@ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len,
skein_assert(sizeof(cfg.b) >= sizeof(ctx->x)); skein_assert(sizeof(cfg.b) >= sizeof(ctx->x));
/* do a mini-Init right here */ /* do a mini-Init right here */
/* set output hash bit count = state size */ /* set output hash bit count = state size */
ctx->h.hash_bit_len = 8*sizeof(ctx->x); ctx->h.hash_bit_len = 8 * sizeof(ctx->x);
/* set tweaks: T0 = 0; T1 = KEY type */ /* set tweaks: T0 = 0; T1 = KEY type */
skein_start_new_type(ctx, KEY); skein_start_new_type(ctx, KEY);
/* zero the initial chaining variables */ /* zero the initial chaining variables */
...@@ -171,7 +171,7 @@ int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, ...@@ -171,7 +171,7 @@ int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg,
*/ */
if (msg_byte_cnt > SKEIN_256_BLOCK_BYTES) { if (msg_byte_cnt > SKEIN_256_BLOCK_BYTES) {
/* number of full blocks to process */ /* number of full blocks to process */
n = (msg_byte_cnt-1) / SKEIN_256_BLOCK_BYTES; n = (msg_byte_cnt - 1) / SKEIN_256_BLOCK_BYTES;
skein_256_process_block(ctx, msg, n, skein_256_process_block(ctx, msg, n,
SKEIN_256_BLOCK_BYTES); SKEIN_256_BLOCK_BYTES);
msg_byte_cnt -= n * SKEIN_256_BLOCK_BYTES; msg_byte_cnt -= n * SKEIN_256_BLOCK_BYTES;
...@@ -219,19 +219,19 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val) ...@@ -219,19 +219,19 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val)
memset(ctx->b, 0, sizeof(ctx->b)); memset(ctx->b, 0, sizeof(ctx->b));
/* keep a local copy of counter mode "key" */ /* keep a local copy of counter mode "key" */
memcpy(x, ctx->x, sizeof(x)); memcpy(x, ctx->x, sizeof(x));
for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) { for (i = 0; i * SKEIN_256_BLOCK_BYTES < byte_cnt; i++) {
/* build the counter block */ /* build the counter block */
((u64 *)ctx->b)[0] = skein_swap64((u64) i); ((u64 *)ctx->b)[0] = skein_swap64((u64) i);
skein_start_new_type(ctx, OUT_FINAL); skein_start_new_type(ctx, OUT_FINAL);
/* run "counter mode" */ /* run "counter mode" */
skein_256_process_block(ctx, ctx->b, 1, sizeof(u64)); skein_256_process_block(ctx, ctx->b, 1, sizeof(u64));
/* number of output bytes left to go */ /* number of output bytes left to go */
n = byte_cnt - i*SKEIN_256_BLOCK_BYTES; n = byte_cnt - i * SKEIN_256_BLOCK_BYTES;
if (n >= SKEIN_256_BLOCK_BYTES) if (n >= SKEIN_256_BLOCK_BYTES)
n = SKEIN_256_BLOCK_BYTES; n = SKEIN_256_BLOCK_BYTES;
/* "output" the ctr mode bytes */ /* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x, skein_put64_lsb_first(hash_val + i * SKEIN_256_BLOCK_BYTES,
n); ctx->x, n);
/* restore the counter mode key for next time */ /* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x)); memcpy(ctx->x, x, sizeof(x));
} }
...@@ -282,7 +282,7 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len) ...@@ -282,7 +282,7 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len)
cfg.w[1] = skein_swap64(hash_bit_len); cfg.w[1] = skein_swap64(hash_bit_len);
cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL);
/* zero pad config block */ /* zero pad config block */
memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); memset(&cfg.w[3], 0, sizeof(cfg) - 3 * sizeof(cfg.w[0]));
/* compute the initial chaining values from config block */ /* compute the initial chaining values from config block */
/* zero the chaining variables */ /* zero the chaining variables */
...@@ -326,7 +326,7 @@ int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, ...@@ -326,7 +326,7 @@ int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len,
skein_assert(sizeof(cfg.b) >= sizeof(ctx->x)); skein_assert(sizeof(cfg.b) >= sizeof(ctx->x));
/* do a mini-Init right here */ /* do a mini-Init right here */
/* set output hash bit count = state size */ /* set output hash bit count = state size */
ctx->h.hash_bit_len = 8*sizeof(ctx->x); ctx->h.hash_bit_len = 8 * sizeof(ctx->x);
/* set tweaks: T0 = 0; T1 = KEY type */ /* set tweaks: T0 = 0; T1 = KEY type */
skein_start_new_type(ctx, KEY); skein_start_new_type(ctx, KEY);
/* zero the initial chaining variables */ /* zero the initial chaining variables */
...@@ -398,7 +398,7 @@ int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, ...@@ -398,7 +398,7 @@ int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg,
*/ */
if (msg_byte_cnt > SKEIN_512_BLOCK_BYTES) { if (msg_byte_cnt > SKEIN_512_BLOCK_BYTES) {
/* number of full blocks to process */ /* number of full blocks to process */
n = (msg_byte_cnt-1) / SKEIN_512_BLOCK_BYTES; n = (msg_byte_cnt - 1) / SKEIN_512_BLOCK_BYTES;
skein_512_process_block(ctx, msg, n, skein_512_process_block(ctx, msg, n,
SKEIN_512_BLOCK_BYTES); SKEIN_512_BLOCK_BYTES);
msg_byte_cnt -= n * SKEIN_512_BLOCK_BYTES; msg_byte_cnt -= n * SKEIN_512_BLOCK_BYTES;
...@@ -446,19 +446,19 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val) ...@@ -446,19 +446,19 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val)
memset(ctx->b, 0, sizeof(ctx->b)); memset(ctx->b, 0, sizeof(ctx->b));
/* keep a local copy of counter mode "key" */ /* keep a local copy of counter mode "key" */
memcpy(x, ctx->x, sizeof(x)); memcpy(x, ctx->x, sizeof(x));
for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) { for (i = 0; i * SKEIN_512_BLOCK_BYTES < byte_cnt; i++) {
/* build the counter block */ /* build the counter block */
((u64 *)ctx->b)[0] = skein_swap64((u64) i); ((u64 *)ctx->b)[0] = skein_swap64((u64) i);
skein_start_new_type(ctx, OUT_FINAL); skein_start_new_type(ctx, OUT_FINAL);
/* run "counter mode" */ /* run "counter mode" */
skein_512_process_block(ctx, ctx->b, 1, sizeof(u64)); skein_512_process_block(ctx, ctx->b, 1, sizeof(u64));
/* number of output bytes left to go */ /* number of output bytes left to go */
n = byte_cnt - i*SKEIN_512_BLOCK_BYTES; n = byte_cnt - i * SKEIN_512_BLOCK_BYTES;
if (n >= SKEIN_512_BLOCK_BYTES) if (n >= SKEIN_512_BLOCK_BYTES)
n = SKEIN_512_BLOCK_BYTES; n = SKEIN_512_BLOCK_BYTES;
/* "output" the ctr mode bytes */ /* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x, skein_put64_lsb_first(hash_val + i * SKEIN_512_BLOCK_BYTES,
n); ctx->x, n);
/* restore the counter mode key for next time */ /* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x)); memcpy(ctx->x, x, sizeof(x));
} }
...@@ -506,7 +506,7 @@ int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len) ...@@ -506,7 +506,7 @@ int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len)
cfg.w[1] = skein_swap64(hash_bit_len); cfg.w[1] = skein_swap64(hash_bit_len);
cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL);
/* zero pad config block */ /* zero pad config block */
memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); memset(&cfg.w[3], 0, sizeof(cfg) - 3 * sizeof(cfg.w[0]));
/* compute the initial chaining values from config block */ /* compute the initial chaining values from config block */
/* zero the chaining variables */ /* zero the chaining variables */
...@@ -547,7 +547,7 @@ int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, ...@@ -547,7 +547,7 @@ int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len,
skein_assert(sizeof(cfg.b) >= sizeof(ctx->x)); skein_assert(sizeof(cfg.b) >= sizeof(ctx->x));
/* do a mini-Init right here */ /* do a mini-Init right here */
/* set output hash bit count = state size */ /* set output hash bit count = state size */
ctx->h.hash_bit_len = 8*sizeof(ctx->x); ctx->h.hash_bit_len = 8 * sizeof(ctx->x);
/* set tweaks: T0 = 0; T1 = KEY type */ /* set tweaks: T0 = 0; T1 = KEY type */
skein_start_new_type(ctx, KEY); skein_start_new_type(ctx, KEY);
/* zero the initial chaining variables */ /* zero the initial chaining variables */
...@@ -620,7 +620,7 @@ int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg, ...@@ -620,7 +620,7 @@ int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg,
*/ */
if (msg_byte_cnt > SKEIN_1024_BLOCK_BYTES) { if (msg_byte_cnt > SKEIN_1024_BLOCK_BYTES) {
/* number of full blocks to process */ /* number of full blocks to process */
n = (msg_byte_cnt-1) / SKEIN_1024_BLOCK_BYTES; n = (msg_byte_cnt - 1) / SKEIN_1024_BLOCK_BYTES;
skein_1024_process_block(ctx, msg, n, skein_1024_process_block(ctx, msg, n,
SKEIN_1024_BLOCK_BYTES); SKEIN_1024_BLOCK_BYTES);
msg_byte_cnt -= n * SKEIN_1024_BLOCK_BYTES; msg_byte_cnt -= n * SKEIN_1024_BLOCK_BYTES;
...@@ -668,19 +668,19 @@ int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val) ...@@ -668,19 +668,19 @@ int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val)
memset(ctx->b, 0, sizeof(ctx->b)); memset(ctx->b, 0, sizeof(ctx->b));
/* keep a local copy of counter mode "key" */ /* keep a local copy of counter mode "key" */
memcpy(x, ctx->x, sizeof(x)); memcpy(x, ctx->x, sizeof(x));
for (i = 0; i*SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) { for (i = 0; i * SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) {
/* build the counter block */ /* build the counter block */
((u64 *)ctx->b)[0] = skein_swap64((u64) i); ((u64 *)ctx->b)[0] = skein_swap64((u64) i);
skein_start_new_type(ctx, OUT_FINAL); skein_start_new_type(ctx, OUT_FINAL);
/* run "counter mode" */ /* run "counter mode" */
skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64)); skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64));
/* number of output bytes left to go */ /* number of output bytes left to go */
n = byte_cnt - i*SKEIN_1024_BLOCK_BYTES; n = byte_cnt - i * SKEIN_1024_BLOCK_BYTES;
if (n >= SKEIN_1024_BLOCK_BYTES) if (n >= SKEIN_1024_BLOCK_BYTES)
n = SKEIN_1024_BLOCK_BYTES; n = SKEIN_1024_BLOCK_BYTES;
/* "output" the ctr mode bytes */ /* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x, skein_put64_lsb_first(hash_val + i * SKEIN_1024_BLOCK_BYTES,
n); ctx->x, n);
/* restore the counter mode key for next time */ /* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x)); memcpy(ctx->x, x, sizeof(x));
} }
...@@ -775,19 +775,19 @@ int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val) ...@@ -775,19 +775,19 @@ int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val)
memset(ctx->b, 0, sizeof(ctx->b)); memset(ctx->b, 0, sizeof(ctx->b));
/* keep a local copy of counter mode "key" */ /* keep a local copy of counter mode "key" */
memcpy(x, ctx->x, sizeof(x)); memcpy(x, ctx->x, sizeof(x));
for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) { for (i = 0; i * SKEIN_256_BLOCK_BYTES < byte_cnt; i++) {
/* build the counter block */ /* build the counter block */
((u64 *)ctx->b)[0] = skein_swap64((u64) i); ((u64 *)ctx->b)[0] = skein_swap64((u64) i);
skein_start_new_type(ctx, OUT_FINAL); skein_start_new_type(ctx, OUT_FINAL);
/* run "counter mode" */ /* run "counter mode" */
skein_256_process_block(ctx, ctx->b, 1, sizeof(u64)); skein_256_process_block(ctx, ctx->b, 1, sizeof(u64));
/* number of output bytes left to go */ /* number of output bytes left to go */
n = byte_cnt - i*SKEIN_256_BLOCK_BYTES; n = byte_cnt - i * SKEIN_256_BLOCK_BYTES;
if (n >= SKEIN_256_BLOCK_BYTES) if (n >= SKEIN_256_BLOCK_BYTES)
n = SKEIN_256_BLOCK_BYTES; n = SKEIN_256_BLOCK_BYTES;
/* "output" the ctr mode bytes */ /* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x, skein_put64_lsb_first(hash_val + i * SKEIN_256_BLOCK_BYTES,
n); ctx->x, n);
/* restore the counter mode key for next time */ /* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x)); memcpy(ctx->x, x, sizeof(x));
} }
...@@ -812,19 +812,19 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) ...@@ -812,19 +812,19 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val)
memset(ctx->b, 0, sizeof(ctx->b)); memset(ctx->b, 0, sizeof(ctx->b));
/* keep a local copy of counter mode "key" */ /* keep a local copy of counter mode "key" */
memcpy(x, ctx->x, sizeof(x)); memcpy(x, ctx->x, sizeof(x));
for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) { for (i = 0; i * SKEIN_512_BLOCK_BYTES < byte_cnt; i++) {
/* build the counter block */ /* build the counter block */
((u64 *)ctx->b)[0] = skein_swap64((u64) i); ((u64 *)ctx->b)[0] = skein_swap64((u64) i);
skein_start_new_type(ctx, OUT_FINAL); skein_start_new_type(ctx, OUT_FINAL);
/* run "counter mode" */ /* run "counter mode" */
skein_512_process_block(ctx, ctx->b, 1, sizeof(u64)); skein_512_process_block(ctx, ctx->b, 1, sizeof(u64));
/* number of output bytes left to go */ /* number of output bytes left to go */
n = byte_cnt - i*SKEIN_512_BLOCK_BYTES; n = byte_cnt - i * SKEIN_512_BLOCK_BYTES;
if (n >= SKEIN_512_BLOCK_BYTES) if (n >= SKEIN_512_BLOCK_BYTES)
n = SKEIN_512_BLOCK_BYTES; n = SKEIN_512_BLOCK_BYTES;
/* "output" the ctr mode bytes */ /* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x, skein_put64_lsb_first(hash_val + i * SKEIN_512_BLOCK_BYTES,
n); ctx->x, n);
/* restore the counter mode key for next time */ /* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x)); memcpy(ctx->x, x, sizeof(x));
} }
...@@ -849,19 +849,19 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val) ...@@ -849,19 +849,19 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val)
memset(ctx->b, 0, sizeof(ctx->b)); memset(ctx->b, 0, sizeof(ctx->b));
/* keep a local copy of counter mode "key" */ /* keep a local copy of counter mode "key" */
memcpy(x, ctx->x, sizeof(x)); memcpy(x, ctx->x, sizeof(x));
for (i = 0; i*SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) { for (i = 0; i * SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) {
/* build the counter block */ /* build the counter block */
((u64 *)ctx->b)[0] = skein_swap64((u64) i); ((u64 *)ctx->b)[0] = skein_swap64((u64) i);
skein_start_new_type(ctx, OUT_FINAL); skein_start_new_type(ctx, OUT_FINAL);
/* run "counter mode" */ /* run "counter mode" */
skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64)); skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64));
/* number of output bytes left to go */ /* number of output bytes left to go */
n = byte_cnt - i*SKEIN_1024_BLOCK_BYTES; n = byte_cnt - i * SKEIN_1024_BLOCK_BYTES;
if (n >= SKEIN_1024_BLOCK_BYTES) if (n >= SKEIN_1024_BLOCK_BYTES)
n = SKEIN_1024_BLOCK_BYTES; n = SKEIN_1024_BLOCK_BYTES;
/* "output" the ctr mode bytes */ /* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x, skein_put64_lsb_first(hash_val + i * SKEIN_1024_BLOCK_BYTES,
n); ctx->x, n);
/* restore the counter mode key for next time */ /* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x)); memcpy(ctx->x, x, sizeof(x));
} }
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
/* below two prototype assume we are handed aligned data */ /* below two prototype assume we are handed aligned data */
#define skein_put64_lsb_first(dst08, src64, b_cnt) memcpy(dst08, src64, b_cnt) #define skein_put64_lsb_first(dst08, src64, b_cnt) memcpy(dst08, src64, b_cnt)
#define skein_get64_lsb_first(dst64, src08, w_cnt) \ #define skein_get64_lsb_first(dst64, src08, w_cnt) \
memcpy(dst64, src08, 8*(w_cnt)) memcpy(dst64, src08, 8 * (w_cnt))
#define skein_swap64(w64) (w64) #define skein_swap64(w64) (w64)
enum { enum {
...@@ -48,17 +48,17 @@ enum { ...@@ -48,17 +48,17 @@ enum {
#define SKEIN_1024_STATE_WORDS 16 #define SKEIN_1024_STATE_WORDS 16
#define SKEIN_MAX_STATE_WORDS 16 #define SKEIN_MAX_STATE_WORDS 16
#define SKEIN_256_STATE_BYTES (8*SKEIN_256_STATE_WORDS) #define SKEIN_256_STATE_BYTES (8 * SKEIN_256_STATE_WORDS)
#define SKEIN_512_STATE_BYTES (8*SKEIN_512_STATE_WORDS) #define SKEIN_512_STATE_BYTES (8 * SKEIN_512_STATE_WORDS)
#define SKEIN_1024_STATE_BYTES (8*SKEIN_1024_STATE_WORDS) #define SKEIN_1024_STATE_BYTES (8 * SKEIN_1024_STATE_WORDS)
#define SKEIN_256_STATE_BITS (64*SKEIN_256_STATE_WORDS) #define SKEIN_256_STATE_BITS (64 * SKEIN_256_STATE_WORDS)
#define SKEIN_512_STATE_BITS (64*SKEIN_512_STATE_WORDS) #define SKEIN_512_STATE_BITS (64 * SKEIN_512_STATE_WORDS)
#define SKEIN_1024_STATE_BITS (64*SKEIN_1024_STATE_WORDS) #define SKEIN_1024_STATE_BITS (64 * SKEIN_1024_STATE_WORDS)
#define SKEIN_256_BLOCK_BYTES (8*SKEIN_256_STATE_WORDS) #define SKEIN_256_BLOCK_BYTES (8 * SKEIN_256_STATE_WORDS)
#define SKEIN_512_BLOCK_BYTES (8*SKEIN_512_STATE_WORDS) #define SKEIN_512_BLOCK_BYTES (8 * SKEIN_512_STATE_WORDS)
#define SKEIN_1024_BLOCK_BYTES (8*SKEIN_1024_STATE_WORDS) #define SKEIN_1024_BLOCK_BYTES (8 * SKEIN_1024_STATE_WORDS)
struct skein_ctx_hdr { struct skein_ctx_hdr {
size_t hash_bit_len; /* size of hash result, in bits */ size_t hash_bit_len; /* size of hash result, in bits */
...@@ -203,7 +203,7 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); ...@@ -203,7 +203,7 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val);
#define SKEIN_SCHEMA_VER SKEIN_MK_64(SKEIN_VERSION, SKEIN_ID_STRING_LE) #define SKEIN_SCHEMA_VER SKEIN_MK_64(SKEIN_VERSION, SKEIN_ID_STRING_LE)
#define SKEIN_KS_PARITY SKEIN_MK_64(0x1BD11BDA, 0xA9FC1A22) #define SKEIN_KS_PARITY SKEIN_MK_64(0x1BD11BDA, 0xA9FC1A22)
#define SKEIN_CFG_STR_LEN (4*8) #define SKEIN_CFG_STR_LEN (4 * 8)
/* bit field definitions in config block tree_info word */ /* bit field definitions in config block tree_info word */
#define SKEIN_CFG_TREE_LEAF_SIZE_POS (0) #define SKEIN_CFG_TREE_LEAF_SIZE_POS (0)
...@@ -322,9 +322,9 @@ enum { ...@@ -322,9 +322,9 @@ enum {
#define SKEIN_512_ROUNDS_TOTAL (72) #define SKEIN_512_ROUNDS_TOTAL (72)
#define SKEIN_1024_ROUNDS_TOTAL (80) #define SKEIN_1024_ROUNDS_TOTAL (80)
#else /* allow command-line define in range 8*(5..14) */ #else /* allow command-line define in range 8*(5..14) */
#define SKEIN_256_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/100) + 5) % 10) + 5)) #define SKEIN_256_ROUNDS_TOTAL (8 * ((((SKEIN_ROUNDS / 100) + 5) % 10) + 5))
#define SKEIN_512_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/10) + 5) % 10) + 5)) #define SKEIN_512_ROUNDS_TOTAL (8 * ((((SKEIN_ROUNDS / 10) + 5) % 10) + 5))
#define SKEIN_1024_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS) + 5) % 10) + 5)) #define SKEIN_1024_ROUNDS_TOTAL (8 * ((((SKEIN_ROUNDS) + 5) % 10) + 5))
#endif #endif
#endif /* ifndef _SKEIN_H_ */ #endif /* ifndef _SKEIN_H_ */
...@@ -121,10 +121,10 @@ ...@@ -121,10 +121,10 @@
#if !(SKEIN_USE_ASM & 512) #if !(SKEIN_USE_ASM & 512)
#undef RCNT #undef RCNT
#define RCNT (SKEIN_512_ROUNDS_TOTAL/8) #define RCNT (SKEIN_512_ROUNDS_TOTAL / 8)
#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ #ifdef SKEIN_LOOP /* configure how much to unroll the loop */
#define SKEIN_UNROLL_512 (((SKEIN_LOOP)/10)%10) #define SKEIN_UNROLL_512 (((SKEIN_LOOP) / 10) % 10)
#else #else
#define SKEIN_UNROLL_512 (0) #define SKEIN_UNROLL_512 (0)
#endif #endif
...@@ -202,7 +202,7 @@ ...@@ -202,7 +202,7 @@
} while (0) } while (0)
#define R512_UNROLL_R(NN) \ #define R512_UNROLL_R(NN) \
((SKEIN_UNROLL_512 == 0 && \ ((SKEIN_UNROLL_512 == 0 && \
SKEIN_512_ROUNDS_TOTAL/8 > (NN)) || \ SKEIN_512_ROUNDS_TOTAL / 8 > (NN)) || \
(SKEIN_UNROLL_512 > (NN))) (SKEIN_UNROLL_512 > (NN)))
#if (SKEIN_UNROLL_512 > 14) #if (SKEIN_UNROLL_512 > 14)
...@@ -212,7 +212,7 @@ ...@@ -212,7 +212,7 @@
#if !(SKEIN_USE_ASM & 1024) #if !(SKEIN_USE_ASM & 1024)
#undef RCNT #undef RCNT
#define RCNT (SKEIN_1024_ROUNDS_TOTAL/8) #define RCNT (SKEIN_1024_ROUNDS_TOTAL / 8)
#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ #ifdef SKEIN_LOOP /* configure how much to unroll the loop */
#define SKEIN_UNROLL_1024 ((SKEIN_LOOP) % 10) #define SKEIN_UNROLL_1024 ((SKEIN_LOOP) % 10)
#else #else
...@@ -313,28 +313,28 @@ ...@@ -313,28 +313,28 @@
#define R1024_8_ROUNDS(R) \ #define R1024_8_ROUNDS(R) \
do { \ do { \
R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, \ R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, \
13, 14, 15, R1024_0, 8*(R) + 1); \ 13, 14, 15, R1024_0, 8 * (R) + 1); \
R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, \ R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, \
05, 08, 01, R1024_1, 8*(R) + 2); \ 05, 08, 01, R1024_1, 8 * (R) + 2); \
R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, \ R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, \
11, 10, 09, R1024_2, 8*(R) + 3); \ 11, 10, 09, R1024_2, 8 * (R) + 3); \
R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, \ R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, \
03, 12, 07, R1024_3, 8*(R) + 4); \ 03, 12, 07, R1024_3, 8 * (R) + 4); \
I1024(2*(R)); \ I1024(2 * (R)); \
R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, \ R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, \
13, 14, 15, R1024_4, 8*(R) + 5); \ 13, 14, 15, R1024_4, 8 * (R) + 5); \
R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, \ R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, \
05, 08, 01, R1024_5, 8*(R) + 6); \ 05, 08, 01, R1024_5, 8 * (R) + 6); \
R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, \ R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, \
11, 10, 09, R1024_6, 8*(R) + 7); \ 11, 10, 09, R1024_6, 8 * (R) + 7); \
R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, \ R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, \
03, 12, 07, R1024_7, 8*(R) + 8); \ 03, 12, 07, R1024_7, 8 * (R) + 8); \
I1024(2*(R)+1); \ I1024(2 * (R) + 1); \
} while (0) } while (0)
#define R1024_UNROLL_R(NN) \ #define R1024_UNROLL_R(NN) \
((SKEIN_UNROLL_1024 == 0 && \ ((SKEIN_UNROLL_1024 == 0 && \
SKEIN_1024_ROUNDS_TOTAL/8 > (NN)) || \ SKEIN_1024_ROUNDS_TOTAL / 8 > (NN)) || \
(SKEIN_UNROLL_1024 > (NN))) (SKEIN_UNROLL_1024 > (NN)))
#if (SKEIN_UNROLL_1024 > 14) #if (SKEIN_UNROLL_1024 > 14)
...@@ -353,10 +353,10 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, ...@@ -353,10 +353,10 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr,
size_t r; size_t r;
#if SKEIN_UNROLL_256 #if SKEIN_UNROLL_256
/* key schedule: chaining vars + tweak + "rot"*/ /* key schedule: chaining vars + tweak + "rot"*/
u64 kw[WCNT+4+RCNT*2]; u64 kw[WCNT + 4 + RCNT * 2];
#else #else
/* key schedule words : chaining vars + tweak */ /* key schedule words : chaining vars + tweak */
u64 kw[WCNT+4]; u64 kw[WCNT + 4];
#endif #endif
u64 X0, X1, X2, X3; /* local copy of context vars, for speed */ u64 X0, X1, X2, X3; /* local copy of context vars, for speed */
u64 w[WCNT]; /* local copy of input block */ u64 w[WCNT]; /* local copy of input block */
...@@ -482,9 +482,11 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, ...@@ -482,9 +482,11 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr,
}; };
size_t r; size_t r;
#if SKEIN_UNROLL_512 #if SKEIN_UNROLL_512
u64 kw[WCNT+4+RCNT*2]; /* key sched: chaining vars + tweak + "rot"*/ /* key sched: chaining vars + tweak + "rot"*/
u64 kw[WCNT + 4 + RCNT * 2];
#else #else
u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ /* key schedule words : chaining vars + tweak */
u64 kw[WCNT + 4];
#endif #endif
u64 X0, X1, X2, X3, X4, X5, X6, X7; /* local copies, for speed */ u64 X0, X1, X2, X3, X4, X5, X6, X7; /* local copies, for speed */
u64 w[WCNT]; /* local copy of input block */ u64 w[WCNT]; /* local copy of input block */
...@@ -631,9 +633,11 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, ...@@ -631,9 +633,11 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr,
}; };
size_t r; size_t r;
#if (SKEIN_UNROLL_1024 != 0) #if (SKEIN_UNROLL_1024 != 0)
u64 kw[WCNT+4+RCNT*2]; /* key sched: chaining vars + tweak + "rot" */ /* key sched: chaining vars + tweak + "rot" */
u64 kw[WCNT + 4 + RCNT * 2];
#else #else
u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ /* key schedule words : chaining vars + tweak */
u64 kw[WCNT + 4];
#endif #endif
/* local copy of vars, for speed */ /* local copy of vars, for speed */
......
...@@ -52,7 +52,7 @@ enum threefish_size { ...@@ -52,7 +52,7 @@ enum threefish_size {
*/ */
struct threefish_key { struct threefish_key {
u64 state_size; u64 state_size;
u64 key[SKEIN_MAX_STATE_WORDS+1]; /* max number of key words*/ u64 key[SKEIN_MAX_STATE_WORDS + 1]; /* max number of key words*/
u64 tweak[3]; u64 tweak[3];
}; };
......
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