Re: [PATCH v3 1/1] staging: skein: Removes skein_debug include

2014-10-29 Thread Eric Rost
On Wed, 2014-10-29 at 19:12 -0500, Eric Rost wrote:
> Removes skein_debug.h include since skein_debug.h is nonexistent.
> Removes unneeded debug empty macro defines and their uses.
> 
> Signed-off-by: Eric Rost 
> ---

Jason,

I wanted you to take one last look at this before I put reviewed-by on
it, as I snipped one more piece of SKEIN_DEBUG that I found in the
middle of skein_block.c

thx,
Eric


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 1/1] staging: skein: Removes skein_debug include

2014-10-29 Thread Eric Rost
Removes skein_debug.h include since skein_debug.h is nonexistent.
Removes unneeded debug empty macro defines and their uses.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_base.c  | 18 -
 drivers/staging/skein/skein_base.h  | 17 -
 drivers/staging/skein/skein_block.c | 51 +
 3 files changed, 1 insertion(+), 85 deletions(-)

diff --git a/drivers/staging/skein/skein_base.c 
b/drivers/staging/skein/skein_base.c
index ebc436a..7e700a6 100644
--- a/drivers/staging/skein/skein_base.c
+++ b/drivers/staging/skein/skein_base.c
@@ -124,8 +124,6 @@ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t 
hash_bit_len,
/* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
cfg.w[2] = skein_swap64(tree_info);
 
-   skein_show_key(256, >h, key, key_bytes);
-
/* compute the initial chaining values from config block */
skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
 
@@ -232,8 +230,6 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val)
/* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x,
  n);
-   skein_show_final(256, >h, n,
-hash_val+i*SKEIN_256_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x));
}
@@ -353,8 +349,6 @@ int skein_512_init_ext(struct skein_512_ctx *ctx, size_t 
hash_bit_len,
/* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
cfg.w[2] = skein_swap64(tree_info);
 
-   skein_show_key(512, >h, key, key_bytes);
-
/* compute the initial chaining values from config block */
skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
 
@@ -461,8 +455,6 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val)
/* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x,
  n);
-   skein_show_final(512, >h, n,
-hash_val+i*SKEIN_512_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x));
}
@@ -577,8 +569,6 @@ int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t 
hash_bit_len,
/* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
cfg.w[2] = skein_swap64(tree_info);
 
-   skein_show_key(1024, >h, key, key_bytes);
-
/* compute the initial chaining values from config block */
skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
 
@@ -685,8 +675,6 @@ int skein_1024_final(struct skein_1024_ctx *ctx, u8 
*hash_val)
/* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x,
  n);
-   skein_show_final(1024, >h, n,
-hash_val+i*SKEIN_1024_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x));
}
@@ -794,8 +782,6 @@ int skein_256_output(struct skein_256_ctx *ctx, u8 
*hash_val)
/* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x,
  n);
-   skein_show_final(256, >h, n,
-hash_val+i*SKEIN_256_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x));
}
@@ -833,8 +819,6 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 
*hash_val)
/* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x,
  n);
-   skein_show_final(256, >h, n,
-hash_val+i*SKEIN_512_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x));
}
@@ -872,8 +856,6 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 
*hash_val)
/* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x,
  n);
-   skein_show_final(256, >h, n,
-hash_val+i*SKEIN_1024_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x));
}
diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index 0111fa4..993b951 100644
--- a/drivers/staging/skei

[PATCH v3 1/1] staging: skein: Removes skein_debug include

2014-10-29 Thread Eric Rost
Removes skein_debug.h include since skein_debug.h is nonexistent.
Removes unneeded debug empty macro defines and their uses.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/skein_base.c  | 18 -
 drivers/staging/skein/skein_base.h  | 17 -
 drivers/staging/skein/skein_block.c | 51 +
 3 files changed, 1 insertion(+), 85 deletions(-)

diff --git a/drivers/staging/skein/skein_base.c 
b/drivers/staging/skein/skein_base.c
index ebc436a..7e700a6 100644
--- a/drivers/staging/skein/skein_base.c
+++ b/drivers/staging/skein/skein_base.c
@@ -124,8 +124,6 @@ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t 
hash_bit_len,
/* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
cfg.w[2] = skein_swap64(tree_info);
 
-   skein_show_key(256, ctx-h, key, key_bytes);
-
/* compute the initial chaining values from config block */
skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
 
@@ -232,8 +230,6 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val)
/* output the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx-x,
  n);
-   skein_show_final(256, ctx-h, n,
-hash_val+i*SKEIN_256_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx-x, x, sizeof(x));
}
@@ -353,8 +349,6 @@ int skein_512_init_ext(struct skein_512_ctx *ctx, size_t 
hash_bit_len,
/* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
cfg.w[2] = skein_swap64(tree_info);
 
-   skein_show_key(512, ctx-h, key, key_bytes);
-
/* compute the initial chaining values from config block */
skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
 
@@ -461,8 +455,6 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val)
/* output the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx-x,
  n);
-   skein_show_final(512, ctx-h, n,
-hash_val+i*SKEIN_512_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx-x, x, sizeof(x));
}
@@ -577,8 +569,6 @@ int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t 
hash_bit_len,
/* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
cfg.w[2] = skein_swap64(tree_info);
 
-   skein_show_key(1024, ctx-h, key, key_bytes);
-
/* compute the initial chaining values from config block */
skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
 
@@ -685,8 +675,6 @@ int skein_1024_final(struct skein_1024_ctx *ctx, u8 
*hash_val)
/* output the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx-x,
  n);
-   skein_show_final(1024, ctx-h, n,
-hash_val+i*SKEIN_1024_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx-x, x, sizeof(x));
}
@@ -794,8 +782,6 @@ int skein_256_output(struct skein_256_ctx *ctx, u8 
*hash_val)
/* output the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx-x,
  n);
-   skein_show_final(256, ctx-h, n,
-hash_val+i*SKEIN_256_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx-x, x, sizeof(x));
}
@@ -833,8 +819,6 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 
*hash_val)
/* output the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx-x,
  n);
-   skein_show_final(256, ctx-h, n,
-hash_val+i*SKEIN_512_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx-x, x, sizeof(x));
}
@@ -872,8 +856,6 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 
*hash_val)
/* output the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx-x,
  n);
-   skein_show_final(256, ctx-h, n,
-hash_val+i*SKEIN_1024_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx-x, x, sizeof(x));
}
diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index 0111fa4..993b951 100644
--- a/drivers/staging/skein/skein_base.h
+++ b/drivers/staging/skein/skein_base.h
@@ -15,10 +15,6 @@
 **
 ** The default

Re: [PATCH v3 1/1] staging: skein: Removes skein_debug include

2014-10-29 Thread Eric Rost
On Wed, 2014-10-29 at 19:12 -0500, Eric Rost wrote:
 Removes skein_debug.h include since skein_debug.h is nonexistent.
 Removes unneeded debug empty macro defines and their uses.
 
 Signed-off-by: Eric Rost eric.r...@mybabylon.net
 ---

Jason,

I wanted you to take one last look at this before I put reviewed-by on
it, as I snipped one more piece of SKEIN_DEBUG that I found in the
middle of skein_block.c

thx,
Eric


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 1/1] staging: skein: Removes skein_debug include

2014-10-28 Thread Eric Rost
Removes skein_debug.h include since skein_debug.h is nonexistent.
Removes unneeded debug empty macro defines and their uses.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_base.c  | 18 --
 drivers/staging/skein/skein_base.h  | 17 -
 drivers/staging/skein/skein_block.c | 30 +-
 3 files changed, 1 insertion(+), 64 deletions(-)

diff --git a/drivers/staging/skein/skein_base.c 
b/drivers/staging/skein/skein_base.c
index ebc436a..7e700a6 100644
--- a/drivers/staging/skein/skein_base.c
+++ b/drivers/staging/skein/skein_base.c
@@ -124,8 +124,6 @@ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t 
hash_bit_len,
/* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
cfg.w[2] = skein_swap64(tree_info);
 
-   skein_show_key(256, >h, key, key_bytes);
-
/* compute the initial chaining values from config block */
skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
 
@@ -232,8 +230,6 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val)
/* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x,
  n);
-   skein_show_final(256, >h, n,
-hash_val+i*SKEIN_256_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x));
}
@@ -353,8 +349,6 @@ int skein_512_init_ext(struct skein_512_ctx *ctx, size_t 
hash_bit_len,
/* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
cfg.w[2] = skein_swap64(tree_info);
 
-   skein_show_key(512, >h, key, key_bytes);
-
/* compute the initial chaining values from config block */
skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
 
@@ -461,8 +455,6 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val)
/* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x,
  n);
-   skein_show_final(512, >h, n,
-hash_val+i*SKEIN_512_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x));
}
@@ -577,8 +569,6 @@ int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t 
hash_bit_len,
/* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
cfg.w[2] = skein_swap64(tree_info);
 
-   skein_show_key(1024, >h, key, key_bytes);
-
/* compute the initial chaining values from config block */
skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
 
@@ -685,8 +675,6 @@ int skein_1024_final(struct skein_1024_ctx *ctx, u8 
*hash_val)
/* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x,
  n);
-   skein_show_final(1024, >h, n,
-hash_val+i*SKEIN_1024_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x));
}
@@ -794,8 +782,6 @@ int skein_256_output(struct skein_256_ctx *ctx, u8 
*hash_val)
/* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x,
  n);
-   skein_show_final(256, >h, n,
-hash_val+i*SKEIN_256_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x));
}
@@ -833,8 +819,6 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 
*hash_val)
/* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x,
  n);
-   skein_show_final(256, >h, n,
-hash_val+i*SKEIN_512_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x));
}
@@ -872,8 +856,6 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 
*hash_val)
/* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x,
  n);
-   skein_show_final(256, >h, n,
-hash_val+i*SKEIN_1024_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x));
}
diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index 0111fa4..993b951 100644
--- a/drivers/stag

[PATCH v2 1/1] staging: skein: Removes skein_debug include

2014-10-28 Thread Eric Rost
Removes skein_debug.h include since skein_debug.h is nonexistent.
Removes unneeded debug empty macro defines and their uses.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/skein_base.c  | 18 --
 drivers/staging/skein/skein_base.h  | 17 -
 drivers/staging/skein/skein_block.c | 30 +-
 3 files changed, 1 insertion(+), 64 deletions(-)

diff --git a/drivers/staging/skein/skein_base.c 
b/drivers/staging/skein/skein_base.c
index ebc436a..7e700a6 100644
--- a/drivers/staging/skein/skein_base.c
+++ b/drivers/staging/skein/skein_base.c
@@ -124,8 +124,6 @@ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t 
hash_bit_len,
/* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
cfg.w[2] = skein_swap64(tree_info);
 
-   skein_show_key(256, ctx-h, key, key_bytes);
-
/* compute the initial chaining values from config block */
skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
 
@@ -232,8 +230,6 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val)
/* output the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx-x,
  n);
-   skein_show_final(256, ctx-h, n,
-hash_val+i*SKEIN_256_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx-x, x, sizeof(x));
}
@@ -353,8 +349,6 @@ int skein_512_init_ext(struct skein_512_ctx *ctx, size_t 
hash_bit_len,
/* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
cfg.w[2] = skein_swap64(tree_info);
 
-   skein_show_key(512, ctx-h, key, key_bytes);
-
/* compute the initial chaining values from config block */
skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
 
@@ -461,8 +455,6 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val)
/* output the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx-x,
  n);
-   skein_show_final(512, ctx-h, n,
-hash_val+i*SKEIN_512_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx-x, x, sizeof(x));
}
@@ -577,8 +569,6 @@ int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t 
hash_bit_len,
/* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
cfg.w[2] = skein_swap64(tree_info);
 
-   skein_show_key(1024, ctx-h, key, key_bytes);
-
/* compute the initial chaining values from config block */
skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
 
@@ -685,8 +675,6 @@ int skein_1024_final(struct skein_1024_ctx *ctx, u8 
*hash_val)
/* output the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx-x,
  n);
-   skein_show_final(1024, ctx-h, n,
-hash_val+i*SKEIN_1024_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx-x, x, sizeof(x));
}
@@ -794,8 +782,6 @@ int skein_256_output(struct skein_256_ctx *ctx, u8 
*hash_val)
/* output the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx-x,
  n);
-   skein_show_final(256, ctx-h, n,
-hash_val+i*SKEIN_256_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx-x, x, sizeof(x));
}
@@ -833,8 +819,6 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 
*hash_val)
/* output the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx-x,
  n);
-   skein_show_final(256, ctx-h, n,
-hash_val+i*SKEIN_512_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx-x, x, sizeof(x));
}
@@ -872,8 +856,6 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 
*hash_val)
/* output the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx-x,
  n);
-   skein_show_final(256, ctx-h, n,
-hash_val+i*SKEIN_1024_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx-x, x, sizeof(x));
}
diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index 0111fa4..993b951 100644
--- a/drivers/staging/skein/skein_base.h
+++ b/drivers/staging/skein/skein_base.h
@@ -15,10 +15,6 @@
 **
 ** The default

[PATCH v6 7/7] staging: skein: Removes skein_debug include

2014-10-24 Thread Eric Rost
Removes skein_debug.h include since skein_debug.h is nonexistent.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_base.h | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index 0111fa4..5b69e5a 100644
--- a/drivers/staging/skein/skein_base.h
+++ b/drivers/staging/skein/skein_base.h
@@ -15,10 +15,6 @@
 **
 ** The "default" note explains what happens when the switch is not defined.
 **
-**  SKEIN_DEBUG-- make callouts from inside Skein code
-**to examine/display intermediate values.
-**[default: no callouts (no overhead)]
-**
 **  SKEIN_ERR_CHECK-- how error checking is handled inside Skein
 **code. If not defined, most error checking
 **is disabled (for performance). Otherwise,
@@ -282,15 +278,12 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 
*hash_val);
 /*
 ** "Internal" Skein definitions for debugging and error checking
 **/
-#ifdef SKEIN_DEBUG /* examine/display intermediate values? */
-#include "skein_debug.h"
-#else   /* default is no callouts */
 #define skein_show_block(bits, ctx, x, blk_ptr, w_ptr, ks_event_ptr, 
ks_odd_ptr)
 #define skein_show_round(bits, ctx, r, x)
 #define skein_show_r_ptr(bits, ctx, r, x_ptr)
 #define skein_show_final(bits, ctx, cnt, out_ptr)
 #define skein_show_key(bits, ctx, key, key_bytes)
-#endif
+
 
 /* ignore all asserts, for performance */
 #define skein_assert_ret(x, ret_code)
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 6/7] staging: skein: Removes unneeded #define

2014-10-24 Thread Eric Rost
Removes unneeded #define SKEIN_PORT_CODE since skein_port.h is
nonexistent.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_base.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/skein/skein_base.c 
b/drivers/staging/skein/skein_base.c
index e0994ea..ebc436a 100644
--- a/drivers/staging/skein/skein_base.c
+++ b/drivers/staging/skein/skein_base.c
@@ -8,8 +8,6 @@
 **
 /
 
-#define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
-
 #include/* get the memcpy/memset functions */
 #include 
 #include "skein_base.h" /* get the Skein API definitions   */
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 4/7] staging: skein: Adds Loadable Module Support

2014-10-24 Thread Eric Rost
Adds loadable module support to the Skein Hashing Algorithm driver.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Kconfig |  2 +-
 drivers/staging/skein/Makefile| 13 +++--
 drivers/staging/skein/skein_generic.c | 19 ++-
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index de8bdd7..012a823 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,5 +1,5 @@
 config CRYPTO_SKEIN
-   bool "Skein digest algorithm"
+   tristate "Skein digest algorithm"
depends on (X86 || UML_X86) && 64BIT && CRYPTO
select CRYPTO_HASH
select CRYPTO_ALGAPI
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index d8177cc..b7f947f 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,9 +1,10 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \
- skein_api.o \
- skein_block.o \
- threefish_block.o \
- threefish_api.o \
- skein_generic.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein.o
+skein-y := skein_base.o \
+  skein_api.o \
+  skein_block.o \
+  threefish_block.o \
+  threefish_api.o \
+  skein_generic.o
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
index f2d6dfb..60d16b6 100644
--- a/drivers/staging/skein/skein_generic.c
+++ b/drivers/staging/skein/skein_generic.c
@@ -16,6 +16,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include "skein_base.h"
 
@@ -139,6 +140,7 @@ static struct shash_alg alg256 = {
.cra_driver_name=   "skein",
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_256_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -156,6 +158,7 @@ static struct shash_alg alg512 = {
.cra_driver_name=   "skein",
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_512_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -173,6 +176,7 @@ static struct shash_alg alg1024 = {
.cra_driver_name=   "skein",
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_1024_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -196,4 +200,17 @@ out:
return -1;
 }
 
-device_initcall(skein_generic_init);
+static void __exit skein_generic_fini(void)
+{
+   crypto_unregister_shash();
+   crypto_unregister_shash();
+   crypto_unregister_shash();
+}
+
+module_init(skein_generic_init);
+module_exit(skein_generic_fini);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Skein Hash Algorithm");
+
+MODULE_ALIAS("skein");
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 5/7] staging: skein: Inlines rotl_64

2014-10-24 Thread Eric Rost
Inlines the rotl_64 macro.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_base.h | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index 9f10af9..0111fa4 100644
--- a/drivers/staging/skein/skein_base.h
+++ b/drivers/staging/skein/skein_base.h
@@ -33,10 +33,6 @@
 #define SKEIN512_DIGEST_BIT_SIZE 512
 #define SKEIN1024_DIGEST_BIT_SIZE 1024
 
-#ifndef rotl_64
-#define rotl_64(x, N)(((x) << (N)) | ((x) >> (64-(N
-#endif
-
 /* 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_get64_lsb_first(dst64, src08, w_cnt) \
@@ -49,12 +45,12 @@ enum {
SKEIN_BAD_HASHLEN =  2
 };
 
-#define  SKEIN_MODIFIER_WORDS   (2) /* number of modifier (tweak) words */
+#define  SKEIN_MODIFIER_WORDS   2 /* number of modifier (tweak) words */
 
-#define  SKEIN_256_STATE_WORDS  (4)
-#define  SKEIN_512_STATE_WORDS  (8)
-#define  SKEIN_1024_STATE_WORDS (16)
-#define  SKEIN_MAX_STATE_WORDS (16)
+#define  SKEIN_256_STATE_WORDS  4
+#define  SKEIN_512_STATE_WORDS  8
+#define  SKEIN_1024_STATE_WORDS 16
+#define  SKEIN_MAX_STATE_WORDS 16
 
 #define  SKEIN_256_STATE_BYTES  (8*SKEIN_256_STATE_WORDS)
 #define  SKEIN_512_STATE_BYTES  (8*SKEIN_512_STATE_WORDS)
@@ -92,6 +88,11 @@ struct skein_1024_ctx { /* 1024-bit Skein hash context 
structure */
u8 b[SKEIN_1024_BLOCK_BYTES];   /* partial block buf (8-byte aligned) */
 };
 
+static inline int rotl_64(int x, int N)
+{
+   return (x << N) | (x >> (64 - N));
+}
+
 /* Skein APIs for (incremental) "straight hashing" */
 int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len);
 int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len);
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 3/7] staging: skein: Adds CryptoAPI Support

2014-10-24 Thread Eric Rost
Adds CryptoAPI support to the Skein Hashing Algorithm driver.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Makefile|   3 +-
 drivers/staging/skein/skein_base.h|   5 +
 drivers/staging/skein/skein_generic.c | 199 ++
 3 files changed, 206 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/skein/skein_generic.c

diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index ca746a9..d8177cc 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -5,4 +5,5 @@ obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \
  skein_api.o \
  skein_block.o \
  threefish_block.o \
- threefish_api.o
+ threefish_api.o \
+ skein_generic.o
diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index e6669f1..9f10af9 100644
--- a/drivers/staging/skein/skein_base.h
+++ b/drivers/staging/skein/skein_base.h
@@ -28,6 +28,11 @@
 **
 ***/
 
+/*Skein digest sizes for crypto api*/
+#define SKEIN256_DIGEST_BIT_SIZE 256
+#define SKEIN512_DIGEST_BIT_SIZE 512
+#define SKEIN1024_DIGEST_BIT_SIZE 1024
+
 #ifndef rotl_64
 #define rotl_64(x, N)(((x) << (N)) | ((x) >> (64-(N
 #endif
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
new file mode 100644
index 000..f2d6dfb
--- /dev/null
+++ b/drivers/staging/skein/skein_generic.c
@@ -0,0 +1,199 @@
+/*
+ * Cryptographic API.
+ *
+ * Skein256 Hash Algorithm.
+ *
+ * Derived from cryptoapi implementation, adapted for in-place
+ * scatterlist interface.
+ *
+ * Copyright (c) Eric Rost 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#include 
+#include 
+#include 
+#include "skein_base.h"
+
+
+static int skein256_init(struct shash_desc *desc)
+{
+   return skein_256_init((struct skein_256_ctx *) shash_desc_ctx(desc),
+   SKEIN256_DIGEST_BIT_SIZE);
+}
+
+int skein256_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   return skein_256_update((struct skein_256_ctx *)shash_desc_ctx(desc),
+   data, len);
+}
+
+static int skein256_final(struct shash_desc *desc, u8 *out)
+{
+   return skein_256_final((struct skein_256_ctx *)shash_desc_ctx(desc),
+   out);
+}
+
+static int skein256_export(struct shash_desc *desc, void *out)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein256_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
+static int skein512_init(struct shash_desc *desc)
+{
+   return skein_512_init((struct skein_512_ctx *)shash_desc_ctx(desc),
+   SKEIN512_DIGEST_BIT_SIZE);
+}
+
+int skein512_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   return skein_512_update((struct skein_512_ctx *)shash_desc_ctx(desc),
+   data, len);
+}
+
+static int skein512_final(struct shash_desc *desc, u8 *out)
+{
+   return skein_512_final((struct skein_512_ctx *)shash_desc_ctx(desc),
+   out);
+}
+
+static int skein512_export(struct shash_desc *desc, void *out)
+{
+   struct skein_512_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein512_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_512_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
+static int skein1024_init(struct shash_desc *desc)
+{
+   return skein_1024_init((struct skein_1024_ctx *)shash_desc_ctx(desc),
+   SKEIN1024_DIGEST_BIT_SIZE);
+}
+
+int skein1024_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   return skein_1024_update((struct skein_1024_ctx *)shash_desc_ctx(desc),
+   data, len);
+}
+
+static int skein1024_final(struct shash_desc *desc, u8 *out)
+{
+   return skein_1024_final((struct skein_1024_ctx *)shash_desc_ctx(desc),
+   out);
+}
+
+static int skein1024_export(struct shash_desc *desc, void *out)
+{
+   struct skein_1024_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   retu

[PATCH v6 2/7] staging: skein: Renames skein to skein_base

2014-10-24 Thread Eric Rost
Renames skein.c to skein_base.c and skein.h to skein_base.h in
preparation for naming loadable module skein.ko

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Makefile  | 2 +-
 drivers/staging/skein/skein_api.h   | 2 +-
 drivers/staging/skein/{skein.c => skein_base.c} | 3 ++-
 drivers/staging/skein/{skein.h => skein_base.h} | 0
 drivers/staging/skein/skein_block.c | 2 +-
 drivers/staging/skein/skein_block.h | 2 +-
 drivers/staging/skein/skein_iv.h| 2 +-
 drivers/staging/skein/threefish_api.h   | 2 +-
 8 files changed, 8 insertions(+), 7 deletions(-)
 rename drivers/staging/skein/{skein.c => skein_base.c} (99%)
 rename drivers/staging/skein/{skein.h => skein_base.h} (100%)

diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index 4b60171..ca746a9 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,7 +1,7 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \
+obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \
  skein_api.o \
  skein_block.o \
  threefish_block.o \
diff --git a/drivers/staging/skein/skein_api.h 
b/drivers/staging/skein/skein_api.h
index e02fa19..171b875 100644
--- a/drivers/staging/skein/skein_api.h
+++ b/drivers/staging/skein/skein_api.h
@@ -79,7 +79,7 @@ OTHER DEALINGS IN THE SOFTWARE.
  */
 
 #include 
-#include "skein.h"
+#include "skein_base.h"
 
 /**
  * Which Skein size to use
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein_base.c
similarity index 99%
rename from drivers/staging/skein/skein.c
rename to drivers/staging/skein/skein_base.c
index 8cc8358..e0994ea 100644
--- a/drivers/staging/skein/skein.c
+++ b/drivers/staging/skein/skein_base.c
@@ -11,7 +11,8 @@
 #define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
 
 #include/* get the memcpy/memset functions */
-#include "skein.h" /* get the Skein API definitions   */
+#include 
+#include "skein_base.h" /* get the Skein API definitions   */
 #include "skein_iv.h"/* get precomputed IVs */
 #include "skein_block.h"
 
diff --git a/drivers/staging/skein/skein.h b/drivers/staging/skein/skein_base.h
similarity index 100%
rename from drivers/staging/skein/skein.h
rename to drivers/staging/skein/skein_base.h
diff --git a/drivers/staging/skein/skein_block.c 
b/drivers/staging/skein/skein_block.c
index 88bc718..36b0b40 100644
--- a/drivers/staging/skein/skein_block.c
+++ b/drivers/staging/skein/skein_block.c
@@ -15,7 +15,7 @@
 /
 
 #include 
-#include "skein.h"
+#include "skein_base.h"
 #include "skein_block.h"
 
 #ifndef SKEIN_USE_ASM
diff --git a/drivers/staging/skein/skein_block.h 
b/drivers/staging/skein/skein_block.h
index bd7bdc3..9d40f4a 100644
--- a/drivers/staging/skein/skein_block.h
+++ b/drivers/staging/skein/skein_block.h
@@ -10,7 +10,7 @@
 #ifndef _SKEIN_BLOCK_H_
 #define _SKEIN_BLOCK_H_
 
-#include "skein.h" /* get the Skein API definitions   */
+#include "skein_base.h" /* get the Skein API definitions   */
 
 void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr,
 size_t blk_cnt, size_t byte_cnt_add);
diff --git a/drivers/staging/skein/skein_iv.h b/drivers/staging/skein/skein_iv.h
index d9dc1d5..8a06314 100644
--- a/drivers/staging/skein/skein_iv.h
+++ b/drivers/staging/skein/skein_iv.h
@@ -1,7 +1,7 @@
 #ifndef _SKEIN_IV_H_
 #define _SKEIN_IV_H_
 
-#include "skein.h"/* get Skein macros and types */
+#include "skein_base.h"/* get Skein macros and types */
 
 /*
 * Pre-computed Skein IVs ***
diff --git a/drivers/staging/skein/threefish_api.h 
b/drivers/staging/skein/threefish_api.h
index 8d5ddf8..8e0a0b7 100644
--- a/drivers/staging/skein/threefish_api.h
+++ b/drivers/staging/skein/threefish_api.h
@@ -29,7 +29,7 @@
  */
 
 #include 
-#include "skein.h"
+#include "skein_base.h"
 
 #define KEY_SCHEDULE_CONST 0x1BD11BDAA9FC1A22L
 
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 0/7] staging: skein: CryptoAPI and Module Support

2014-10-24 Thread Eric Rost
Adds CryptoAPI and loadable module support to the Skein Hashing
Algorithm. Collapses threefish module into skein module. Renames skein.c
and skein.h to skein_base.c and skein_base.h so module can be named
skein.ko. Inlines rotl_64 macro. Removes unneeded #define and
skein_debug.h include.

Eric Rost (7):
  staging: skein: Collapses threefish module
  staging: skein: Renames skein to skein_base
  staging: skein: Adds CryptoAPI Support
  staging: skein: Adds Loadable Module Support
  staging: skein: Inlines rotl_64
  staging: skein: Removes unneeded #define
  staging: skein: Removes skein_debug include

 drivers/staging/skein/Kconfig   |  24 +--
 drivers/staging/skein/Makefile  |  13 +-
 drivers/staging/skein/skein_api.h   |   2 +-
 drivers/staging/skein/{skein.c => skein_base.c} |   5 +-
 drivers/staging/skein/{skein.h => skein_base.h} |  31 ++--
 drivers/staging/skein/skein_block.c |   2 +-
 drivers/staging/skein/skein_block.h |   2 +-
 drivers/staging/skein/skein_generic.c   | 216 
 drivers/staging/skein/skein_iv.h|   2 +-
 drivers/staging/skein/threefish_api.h   |   2 +-
 10 files changed, 249 insertions(+), 50 deletions(-)
 rename drivers/staging/skein/{skein.c => skein_base.c} (99%)
 rename drivers/staging/skein/{skein.h => skein_base.h} (95%)
 create mode 100644 drivers/staging/skein/skein_generic.c

-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 1/7] staging: skein: Collapses threefish module

2014-10-24 Thread Eric Rost
Collapses threefish module into skein module.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Kconfig  | 22 +++---
 drivers/staging/skein/Makefile | 11 +--
 2 files changed, 8 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index b9172bf..de8bdd7 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,8 +1,8 @@
 config CRYPTO_SKEIN
bool "Skein digest algorithm"
depends on (X86 || UML_X86) && 64BIT && CRYPTO
-   select CRYPTO_THREEFISH
select CRYPTO_HASH
+   select CRYPTO_ALGAPI
help
  Skein secure hash algorithm is one of 5 finalists from the NIST SHA3
  competition.
@@ -12,21 +12,5 @@ config CRYPTO_SKEIN
 
  http://www.skein-hash.info/sites/default/files/skein1.3.pdf
 
- for more information.  This module depends on the threefish block
- cipher module.
-
-config CRYPTO_THREEFISH
-   bool "Threefish tweakable block cipher"
-   depends on (X86 || UML_X86) && 64BIT && CRYPTO
-   select CRYPTO_ALGAPI
-   help
- Threefish cipher algorithm is the tweakable block cipher underneath
- the Skein family of secure hash algorithms.  Skein is one of 5
- finalists from the NIST SHA3 competition.
-
- Skein is optimized for modern, 64bit processors and is highly
- customizable.  See:
-
- http://www.skein-hash.info/sites/default/files/skein1.3.pdf
-
- for more information.
+ for more information. This module also contains the threefish block
+ cipher algorithm.
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index a14aadd..4b60171 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,9 +1,8 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
-   skein_api.o \
-   skein_block.o
-
-obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
- threefish_api.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \
+ skein_api.o \
+ skein_block.o \
+ threefish_block.o \
+ threefish_api.o
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 7/7] staging: skein: Removes skein_debug include

2014-10-24 Thread Eric Rost
Removes skein_debug.h include since skein_debug.h is nonexistent.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_base.h | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index 0111fa4..5b69e5a 100644
--- a/drivers/staging/skein/skein_base.h
+++ b/drivers/staging/skein/skein_base.h
@@ -15,10 +15,6 @@
 **
 ** The "default" note explains what happens when the switch is not defined.
 **
-**  SKEIN_DEBUG-- make callouts from inside Skein code
-**to examine/display intermediate values.
-**[default: no callouts (no overhead)]
-**
 **  SKEIN_ERR_CHECK-- how error checking is handled inside Skein
 **code. If not defined, most error checking
 **is disabled (for performance). Otherwise,
@@ -282,15 +278,12 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 
*hash_val);
 /*
 ** "Internal" Skein definitions for debugging and error checking
 **/
-#ifdef SKEIN_DEBUG /* examine/display intermediate values? */
-#include "skein_debug.h"
-#else   /* default is no callouts */
 #define skein_show_block(bits, ctx, x, blk_ptr, w_ptr, ks_event_ptr, 
ks_odd_ptr)
 #define skein_show_round(bits, ctx, r, x)
 #define skein_show_r_ptr(bits, ctx, r, x_ptr)
 #define skein_show_final(bits, ctx, cnt, out_ptr)
 #define skein_show_key(bits, ctx, key, key_bytes)
-#endif
+
 
 /* ignore all asserts, for performance */
 #define skein_assert_ret(x, ret_code)
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 6/7] staging: skein: Removes unneeded #define

2014-10-24 Thread Eric Rost
Removes unneeded #define SKEIN_PORT_CODE since skein_port.h is
nonexistent.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_base.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/skein/skein_base.c 
b/drivers/staging/skein/skein_base.c
index e0994ea..ebc436a 100644
--- a/drivers/staging/skein/skein_base.c
+++ b/drivers/staging/skein/skein_base.c
@@ -8,8 +8,6 @@
 **
 /
 
-#define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
-
 #include/* get the memcpy/memset functions */
 #include 
 #include "skein_base.h" /* get the Skein API definitions   */
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 5/7] staging: skein: Inlines rotl_64

2014-10-24 Thread Eric Rost
Inlines the rotl_64 macro.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_base.h | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index 9f10af9..0111fa4 100644
--- a/drivers/staging/skein/skein_base.h
+++ b/drivers/staging/skein/skein_base.h
@@ -33,10 +33,6 @@
 #define SKEIN512_DIGEST_BIT_SIZE 512
 #define SKEIN1024_DIGEST_BIT_SIZE 1024
 
-#ifndef rotl_64
-#define rotl_64(x, N)(((x) << (N)) | ((x) >> (64-(N
-#endif
-
 /* 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_get64_lsb_first(dst64, src08, w_cnt) \
@@ -49,12 +45,12 @@ enum {
SKEIN_BAD_HASHLEN =  2
 };
 
-#define  SKEIN_MODIFIER_WORDS   (2) /* number of modifier (tweak) words */
+#define  SKEIN_MODIFIER_WORDS   2 /* number of modifier (tweak) words */
 
-#define  SKEIN_256_STATE_WORDS  (4)
-#define  SKEIN_512_STATE_WORDS  (8)
-#define  SKEIN_1024_STATE_WORDS (16)
-#define  SKEIN_MAX_STATE_WORDS (16)
+#define  SKEIN_256_STATE_WORDS  4
+#define  SKEIN_512_STATE_WORDS  8
+#define  SKEIN_1024_STATE_WORDS 16
+#define  SKEIN_MAX_STATE_WORDS 16
 
 #define  SKEIN_256_STATE_BYTES  (8*SKEIN_256_STATE_WORDS)
 #define  SKEIN_512_STATE_BYTES  (8*SKEIN_512_STATE_WORDS)
@@ -92,6 +88,11 @@ struct skein_1024_ctx { /* 1024-bit Skein hash context 
structure */
u8 b[SKEIN_1024_BLOCK_BYTES];   /* partial block buf (8-byte aligned) */
 };
 
+static inline int rotl_64(int x, int N)
+{
+   return (x << N) | (x >> (64 - N));
+}
+
 /* Skein APIs for (incremental) "straight hashing" */
 int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len);
 int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len);
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 3/7] staging: skein: Adds CryptoAPI Support

2014-10-24 Thread Eric Rost
Adds CryptoAPI support to the Skein Hashing Algorithm driver.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Makefile|   3 +-
 drivers/staging/skein/skein_generic.c | 191 ++
 2 files changed, 193 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/skein/skein_generic.c

diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index ca746a9..d8177cc 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -5,4 +5,5 @@ obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \
  skein_api.o \
  skein_block.o \
  threefish_block.o \
- threefish_api.o
+ threefish_api.o \
+ skein_generic.o
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
new file mode 100644
index 000..39332e8
--- /dev/null
+++ b/drivers/staging/skein/skein_generic.c
@@ -0,0 +1,191 @@
+/*
+ * Cryptographic API.
+ *
+ * Skein256 Hash Algorithm.
+ *
+ * Derived from cryptoapi implementation, adapted for in-place
+ * scatterlist interface.
+ *
+ * Copyright (c) Eric Rost 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#include 
+#include 
+#include 
+#include "skein_base.h"
+
+
+static int skein256_init(struct shash_desc *desc)
+{
+   return skein_256_init((struct skein_256_ctx *) shash_desc_ctx(desc),
+   SKEIN256_DIGEST_BIT_SIZE);
+}
+
+int skein256_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   return skein_256_update((struct skein_256_ctx *)shash_desc_ctx(desc),
+   data, len);
+}
+
+static int skein256_final(struct shash_desc *desc, u8 *out)
+{
+   return skein_256_final((struct skein_256_ctx *)shash_desc_ctx(desc),
+   out);
+}
+
+static int skein256_export(struct shash_desc *desc, void *out)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein256_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
+static int skein512_init(struct shash_desc *desc)
+{
+   return skein_512_init((struct skein_512_ctx *)shash_desc_ctx(desc),
+   SKEIN512_DIGEST_BIT_SIZE);
+}
+
+int skein512_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   return skein_512_update((struct skein_512_ctx *)shash_desc_ctx(desc),
+   data, len);
+}
+
+static int skein512_final(struct shash_desc *desc, u8 *out)
+{
+   return skein_512_final((struct skein_512_ctx *)shash_desc_ctx(desc),
+   out);
+}
+
+static int skein512_export(struct shash_desc *desc, void *out)
+{
+   struct skein_512_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein512_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_512_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
+static int skein1024_init(struct shash_desc *desc)
+{
+   return skein_1024_init((struct skein_1024_ctx *)shash_desc_ctx(desc),
+   SKEIN1024_DIGEST_BIT_SIZE);
+}
+
+int skein1024_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   return skein_1024_update((struct skein_1024_ctx *)shash_desc_ctx(desc),
+   data, len);
+}
+
+static int skein1024_final(struct shash_desc *desc, u8 *out)
+{
+   return skein_1024_final((struct skein_1024_ctx *)shash_desc_ctx(desc),
+   out);
+}
+
+static int skein1024_export(struct shash_desc *desc, void *out)
+{
+   struct skein_1024_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein1024_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_1024_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
+static struct shash_alg alg256 = {
+   .digestsize =   (SKEIN256_DIGEST_BIT_SIZE / 8),
+   .init   =   skein256_init,
+   .update =   skein256_update,
+   .final  =   skein256_final,
+   .export =   skein256_export,
+   .import =   skein256_import,
+   .descsize   =   sizeof(struct ske

[PATCH v5 4/7] staging: skein: Adds Loadable Module Support

2014-10-24 Thread Eric Rost
Adds loadable module support to the Skein Hashing Algorithm driver.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Kconfig |  2 +-
 drivers/staging/skein/Makefile| 13 +++--
 drivers/staging/skein/skein_generic.c | 19 ++-
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index de8bdd7..012a823 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,5 +1,5 @@
 config CRYPTO_SKEIN
-   bool "Skein digest algorithm"
+   tristate "Skein digest algorithm"
depends on (X86 || UML_X86) && 64BIT && CRYPTO
select CRYPTO_HASH
select CRYPTO_ALGAPI
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index d8177cc..b7f947f 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,9 +1,10 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \
- skein_api.o \
- skein_block.o \
- threefish_block.o \
- threefish_api.o \
- skein_generic.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein.o
+skein-y := skein_base.o \
+  skein_api.o \
+  skein_block.o \
+  threefish_block.o \
+  threefish_api.o \
+  skein_generic.o
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
index 39332e8..46466d0 100644
--- a/drivers/staging/skein/skein_generic.c
+++ b/drivers/staging/skein/skein_generic.c
@@ -16,6 +16,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include "skein_base.h"
 
@@ -139,6 +140,7 @@ static struct shash_alg alg256 = {
.cra_driver_name=   "skein",
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_256_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -156,6 +158,7 @@ static struct shash_alg alg512 = {
.cra_driver_name=   "skein",
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_512_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -173,6 +176,7 @@ static struct shash_alg alg1024 = {
.cra_driver_name=   "skein",
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_1024_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -188,4 +192,17 @@ static int __init skein_generic_init(void)
return 0;
 }
 
-device_initcall(skein_generic_init);
+static void __exit skein_generic_fini(void)
+{
+   crypto_unregister_shash();
+   crypto_unregister_shash();
+   crypto_unregister_shash();
+}
+
+module_init(skein_generic_init);
+module_exit(skein_generic_fini);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Skein Hash Algorithm");
+
+MODULE_ALIAS("skein");
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 1/7] staging: skein: Collapses threefish module

2014-10-24 Thread Eric Rost
Collapses threefish module into skein module.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Kconfig  | 22 +++---
 drivers/staging/skein/Makefile | 11 +--
 2 files changed, 8 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index b9172bf..de8bdd7 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,8 +1,8 @@
 config CRYPTO_SKEIN
bool "Skein digest algorithm"
depends on (X86 || UML_X86) && 64BIT && CRYPTO
-   select CRYPTO_THREEFISH
select CRYPTO_HASH
+   select CRYPTO_ALGAPI
help
  Skein secure hash algorithm is one of 5 finalists from the NIST SHA3
  competition.
@@ -12,21 +12,5 @@ config CRYPTO_SKEIN
 
  http://www.skein-hash.info/sites/default/files/skein1.3.pdf
 
- for more information.  This module depends on the threefish block
- cipher module.
-
-config CRYPTO_THREEFISH
-   bool "Threefish tweakable block cipher"
-   depends on (X86 || UML_X86) && 64BIT && CRYPTO
-   select CRYPTO_ALGAPI
-   help
- Threefish cipher algorithm is the tweakable block cipher underneath
- the Skein family of secure hash algorithms.  Skein is one of 5
- finalists from the NIST SHA3 competition.
-
- Skein is optimized for modern, 64bit processors and is highly
- customizable.  See:
-
- http://www.skein-hash.info/sites/default/files/skein1.3.pdf
-
- for more information.
+ for more information. This module also contains the threefish block
+ cipher algorithm.
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index a14aadd..4b60171 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,9 +1,8 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
-   skein_api.o \
-   skein_block.o
-
-obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
- threefish_api.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \
+ skein_api.o \
+ skein_block.o \
+ threefish_block.o \
+ threefish_api.o
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 2/7] staging: skein: Renames skein to skein_base

2014-10-24 Thread Eric Rost
Renames skein.c to skein_base.c and skein.h to skein_base.h

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Makefile|   2 +-
 drivers/staging/skein/skein.c | 883 -
 drivers/staging/skein/skein.h | 346 -
 drivers/staging/skein/skein_api.h |   2 +-
 drivers/staging/skein/skein_base.c| 884 ++
 drivers/staging/skein/skein_base.h| 351 ++
 drivers/staging/skein/skein_block.c   |   2 +-
 drivers/staging/skein/skein_block.h   |   2 +-
 drivers/staging/skein/skein_iv.h  |   2 +-
 drivers/staging/skein/threefish_api.h |   2 +-
 10 files changed, 1241 insertions(+), 1235 deletions(-)
 delete mode 100644 drivers/staging/skein/skein.c
 delete mode 100644 drivers/staging/skein/skein.h
 create mode 100644 drivers/staging/skein/skein_base.c
 create mode 100644 drivers/staging/skein/skein_base.h

diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index 4b60171..ca746a9 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,7 +1,7 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \
+obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \
  skein_api.o \
  skein_block.o \
  threefish_block.o \
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
deleted file mode 100644
index 8cc8358..000
--- a/drivers/staging/skein/skein.c
+++ /dev/null
@@ -1,883 +0,0 @@
-/***
-**
-** Implementation of the Skein hash function.
-**
-** Source code author: Doug Whiting, 2008.
-**
-** This algorithm and source code is released to the public domain.
-**
-/
-
-#define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
-
-#include/* get the memcpy/memset functions */
-#include "skein.h" /* get the Skein API definitions   */
-#include "skein_iv.h"/* get precomputed IVs */
-#include "skein_block.h"
-
-/*/
-/* 256-bit Skein */
-/*/
-
-/**/
-/* init the context for a straight hashing operation  */
-int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len)
-{
-   union {
-   u8 b[SKEIN_256_STATE_BYTES];
-   u64 w[SKEIN_256_STATE_WORDS];
-   } cfg;  /* config block */
-
-   skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
-   ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */
-
-   switch (hash_bit_len) { /* use pre-computed values, where available */
-   case  256:
-   memcpy(ctx->x, SKEIN_256_IV_256, sizeof(ctx->x));
-   break;
-   case  224:
-   memcpy(ctx->x, SKEIN_256_IV_224, sizeof(ctx->x));
-   break;
-   case  160:
-   memcpy(ctx->x, SKEIN_256_IV_160, sizeof(ctx->x));
-   break;
-   case  128:
-   memcpy(ctx->x, SKEIN_256_IV_128, sizeof(ctx->x));
-   break;
-   default:
-   /* here if there is no precomputed IV value available */
-   /*
-* build/process the config block, type == CONFIG (could be
-* precomputed)
-*/
-   /* set tweaks: T0=0; T1=CFG | FINAL */
-   skein_start_new_type(ctx, CFG_FINAL);
-
-   /* set the schema, version */
-   cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER);
-   /* hash result length in bits */
-   cfg.w[1] = skein_swap64(hash_bit_len);
-   cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL);
-   /* zero pad config block */
-   memset([3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0]));
-
-   /* compute the initial chaining values from config block */
-   /* zero the chaining variables */
-   memset(ctx->x, 0, sizeof(ctx->x));
-   skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
-   break;
-   }
-   /* The chaining vars ctx->x are now initialized for hash_bit_len. */
-   /* Set up to process the data message portion of the hash (default) */
-   skein_start_new_type(ctx, MSG);  /* T0=0, T1= MSG type */
-
-   return SKEIN_SUCCESS;
-}
-
-/**/
-/* init the context for a MAC and/or tree hash operation */
-/* [identical to skein_256_init() when key_bytes == 0 && \
- * t

[PATCH v5 0/7] staging: skein: CryptoAPI and Module Support

2014-10-24 Thread Eric Rost
Adds CryptoAPI and Module support to Skein Hash Algorithm. Also inlines
rotl_64 macro, and removes nonexistent header references.

Eric Rost (7):
  staging: skein: Collapses threefish module
  staging: skein: Renames skein to skein_base
  staging: skein: Adds CryptoAPI Support
  staging: skein: Adds Loadable Module Support
  staging: skein: Inlines rotl_64
  staging: skein: Removes unneeded #define
  staging: skein: Removes skein_debug include

 drivers/staging/skein/Kconfig |  24 +-
 drivers/staging/skein/Makefile|  13 +-
 drivers/staging/skein/skein.c | 883 --
 drivers/staging/skein/skein.h | 346 -
 drivers/staging/skein/skein_api.h |   2 +-
 drivers/staging/skein/skein_base.c| 882 +
 drivers/staging/skein/skein_base.h| 345 +
 drivers/staging/skein/skein_block.c   |   2 +-
 drivers/staging/skein/skein_block.h   |   2 +-
 drivers/staging/skein/skein_generic.c | 208 
 drivers/staging/skein/skein_iv.h  |   2 +-
 drivers/staging/skein/threefish_api.h |   2 +-
 12 files changed, 1451 insertions(+), 1260 deletions(-)
 delete mode 100644 drivers/staging/skein/skein.c
 delete mode 100644 drivers/staging/skein/skein.h
 create mode 100644 drivers/staging/skein/skein_base.c
 create mode 100644 drivers/staging/skein/skein_base.h
 create mode 100644 drivers/staging/skein/skein_generic.c

-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 0/7] staging: skein: CryptoAPI and Module Support

2014-10-24 Thread Eric Rost
On Fri, 2014-10-24 at 06:16 -0500, Eric Rost wrote:
> Adds CryptoAPI and Module support to Skein Hash Algorithm. Also inlines
> rotl_64 macro, and removes nonexistent header references.

This should be [PATCH v5], sorry.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 7/7] staging: skein: Removes skein_debug include

2014-10-24 Thread Eric Rost
Removes skein_debug.h include since skein_debug.h is nonexistent.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_base.h | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index 0111fa4..5b69e5a 100644
--- a/drivers/staging/skein/skein_base.h
+++ b/drivers/staging/skein/skein_base.h
@@ -15,10 +15,6 @@
 **
 ** The "default" note explains what happens when the switch is not defined.
 **
-**  SKEIN_DEBUG-- make callouts from inside Skein code
-**to examine/display intermediate values.
-**[default: no callouts (no overhead)]
-**
 **  SKEIN_ERR_CHECK-- how error checking is handled inside Skein
 **code. If not defined, most error checking
 **is disabled (for performance). Otherwise,
@@ -282,15 +278,12 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 
*hash_val);
 /*
 ** "Internal" Skein definitions for debugging and error checking
 **/
-#ifdef SKEIN_DEBUG /* examine/display intermediate values? */
-#include "skein_debug.h"
-#else   /* default is no callouts */
 #define skein_show_block(bits, ctx, x, blk_ptr, w_ptr, ks_event_ptr, 
ks_odd_ptr)
 #define skein_show_round(bits, ctx, r, x)
 #define skein_show_r_ptr(bits, ctx, r, x_ptr)
 #define skein_show_final(bits, ctx, cnt, out_ptr)
 #define skein_show_key(bits, ctx, key, key_bytes)
-#endif
+
 
 /* ignore all asserts, for performance */
 #define skein_assert_ret(x, ret_code)
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 6/7] staging: skein: Removes unneeded #define

2014-10-24 Thread Eric Rost
Removes unneeded #define SKEIN_PORT_CODE since skein_port.h is
nonexistent.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_base.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/skein/skein_base.c 
b/drivers/staging/skein/skein_base.c
index e0994ea..ebc436a 100644
--- a/drivers/staging/skein/skein_base.c
+++ b/drivers/staging/skein/skein_base.c
@@ -8,8 +8,6 @@
 **
 /
 
-#define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
-
 #include/* get the memcpy/memset functions */
 #include 
 #include "skein_base.h" /* get the Skein API definitions   */
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 5/7] staging: skein: Inlines rotl_64

2014-10-24 Thread Eric Rost
Inlines the rotl_64 macro.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_base.h | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index 9f10af9..0111fa4 100644
--- a/drivers/staging/skein/skein_base.h
+++ b/drivers/staging/skein/skein_base.h
@@ -33,10 +33,6 @@
 #define SKEIN512_DIGEST_BIT_SIZE 512
 #define SKEIN1024_DIGEST_BIT_SIZE 1024
 
-#ifndef rotl_64
-#define rotl_64(x, N)(((x) << (N)) | ((x) >> (64-(N
-#endif
-
 /* 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_get64_lsb_first(dst64, src08, w_cnt) \
@@ -49,12 +45,12 @@ enum {
SKEIN_BAD_HASHLEN =  2
 };
 
-#define  SKEIN_MODIFIER_WORDS   (2) /* number of modifier (tweak) words */
+#define  SKEIN_MODIFIER_WORDS   2 /* number of modifier (tweak) words */
 
-#define  SKEIN_256_STATE_WORDS  (4)
-#define  SKEIN_512_STATE_WORDS  (8)
-#define  SKEIN_1024_STATE_WORDS (16)
-#define  SKEIN_MAX_STATE_WORDS (16)
+#define  SKEIN_256_STATE_WORDS  4
+#define  SKEIN_512_STATE_WORDS  8
+#define  SKEIN_1024_STATE_WORDS 16
+#define  SKEIN_MAX_STATE_WORDS 16
 
 #define  SKEIN_256_STATE_BYTES  (8*SKEIN_256_STATE_WORDS)
 #define  SKEIN_512_STATE_BYTES  (8*SKEIN_512_STATE_WORDS)
@@ -92,6 +88,11 @@ struct skein_1024_ctx { /* 1024-bit Skein hash context 
structure */
u8 b[SKEIN_1024_BLOCK_BYTES];   /* partial block buf (8-byte aligned) */
 };
 
+static inline int rotl_64(int x, int N)
+{
+   return (x << N) | (x >> (64 - N));
+}
+
 /* Skein APIs for (incremental) "straight hashing" */
 int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len);
 int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len);
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 4/7] staging: skein: Adds Loadable Module Support

2014-10-24 Thread Eric Rost
Adds loadable module support to the Skein Hashing Algorithm driver.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Kconfig |  2 +-
 drivers/staging/skein/Makefile| 13 +++--
 drivers/staging/skein/skein_generic.c | 19 ++-
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index de8bdd7..012a823 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,5 +1,5 @@
 config CRYPTO_SKEIN
-   bool "Skein digest algorithm"
+   tristate "Skein digest algorithm"
depends on (X86 || UML_X86) && 64BIT && CRYPTO
select CRYPTO_HASH
select CRYPTO_ALGAPI
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index d8177cc..b7f947f 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,9 +1,10 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \
- skein_api.o \
- skein_block.o \
- threefish_block.o \
- threefish_api.o \
- skein_generic.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein.o
+skein-y := skein_base.o \
+  skein_api.o \
+  skein_block.o \
+  threefish_block.o \
+  threefish_api.o \
+  skein_generic.o
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
index 39332e8..46466d0 100644
--- a/drivers/staging/skein/skein_generic.c
+++ b/drivers/staging/skein/skein_generic.c
@@ -16,6 +16,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include "skein_base.h"
 
@@ -139,6 +140,7 @@ static struct shash_alg alg256 = {
.cra_driver_name=   "skein",
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_256_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -156,6 +158,7 @@ static struct shash_alg alg512 = {
.cra_driver_name=   "skein",
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_512_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -173,6 +176,7 @@ static struct shash_alg alg1024 = {
.cra_driver_name=   "skein",
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_1024_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -188,4 +192,17 @@ static int __init skein_generic_init(void)
return 0;
 }
 
-device_initcall(skein_generic_init);
+static void __exit skein_generic_fini(void)
+{
+   crypto_unregister_shash();
+   crypto_unregister_shash();
+   crypto_unregister_shash();
+}
+
+module_init(skein_generic_init);
+module_exit(skein_generic_fini);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Skein Hash Algorithm");
+
+MODULE_ALIAS("skein");
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 3/7] staging: skein: Adds CryptoAPI Support

2014-10-24 Thread Eric Rost
Adds CryptoAPI support to the Skein Hashing Algorithm driver.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Makefile|   3 +-
 drivers/staging/skein/skein_generic.c | 191 ++
 2 files changed, 193 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/skein/skein_generic.c

diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index ca746a9..d8177cc 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -5,4 +5,5 @@ obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \
  skein_api.o \
  skein_block.o \
  threefish_block.o \
- threefish_api.o
+ threefish_api.o \
+ skein_generic.o
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
new file mode 100644
index 000..39332e8
--- /dev/null
+++ b/drivers/staging/skein/skein_generic.c
@@ -0,0 +1,191 @@
+/*
+ * Cryptographic API.
+ *
+ * Skein256 Hash Algorithm.
+ *
+ * Derived from cryptoapi implementation, adapted for in-place
+ * scatterlist interface.
+ *
+ * Copyright (c) Eric Rost 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#include 
+#include 
+#include 
+#include "skein_base.h"
+
+
+static int skein256_init(struct shash_desc *desc)
+{
+   return skein_256_init((struct skein_256_ctx *) shash_desc_ctx(desc),
+   SKEIN256_DIGEST_BIT_SIZE);
+}
+
+int skein256_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   return skein_256_update((struct skein_256_ctx *)shash_desc_ctx(desc),
+   data, len);
+}
+
+static int skein256_final(struct shash_desc *desc, u8 *out)
+{
+   return skein_256_final((struct skein_256_ctx *)shash_desc_ctx(desc),
+   out);
+}
+
+static int skein256_export(struct shash_desc *desc, void *out)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein256_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
+static int skein512_init(struct shash_desc *desc)
+{
+   return skein_512_init((struct skein_512_ctx *)shash_desc_ctx(desc),
+   SKEIN512_DIGEST_BIT_SIZE);
+}
+
+int skein512_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   return skein_512_update((struct skein_512_ctx *)shash_desc_ctx(desc),
+   data, len);
+}
+
+static int skein512_final(struct shash_desc *desc, u8 *out)
+{
+   return skein_512_final((struct skein_512_ctx *)shash_desc_ctx(desc),
+   out);
+}
+
+static int skein512_export(struct shash_desc *desc, void *out)
+{
+   struct skein_512_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein512_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_512_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
+static int skein1024_init(struct shash_desc *desc)
+{
+   return skein_1024_init((struct skein_1024_ctx *)shash_desc_ctx(desc),
+   SKEIN1024_DIGEST_BIT_SIZE);
+}
+
+int skein1024_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   return skein_1024_update((struct skein_1024_ctx *)shash_desc_ctx(desc),
+   data, len);
+}
+
+static int skein1024_final(struct shash_desc *desc, u8 *out)
+{
+   return skein_1024_final((struct skein_1024_ctx *)shash_desc_ctx(desc),
+   out);
+}
+
+static int skein1024_export(struct shash_desc *desc, void *out)
+{
+   struct skein_1024_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein1024_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_1024_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
+static struct shash_alg alg256 = {
+   .digestsize =   (SKEIN256_DIGEST_BIT_SIZE / 8),
+   .init   =   skein256_init,
+   .update =   skein256_update,
+   .final  =   skein256_final,
+   .export =   skein256_export,
+   .import =   skein256_import,
+   .descsize   =   sizeof(struct ske

[PATCH v4 2/7] staging: skein: Renames skein to skein_base

2014-10-24 Thread Eric Rost
Renames skein.c to skein_base.c and skein.h to skein_base.h

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Makefile|   2 +-
 drivers/staging/skein/skein.c | 883 -
 drivers/staging/skein/skein.h | 346 -
 drivers/staging/skein/skein_api.h |   2 +-
 drivers/staging/skein/skein_base.c| 884 ++
 drivers/staging/skein/skein_base.h| 351 ++
 drivers/staging/skein/skein_block.c   |   2 +-
 drivers/staging/skein/skein_block.h   |   2 +-
 drivers/staging/skein/skein_iv.h  |   2 +-
 drivers/staging/skein/threefish_api.h |   2 +-
 10 files changed, 1241 insertions(+), 1235 deletions(-)
 delete mode 100644 drivers/staging/skein/skein.c
 delete mode 100644 drivers/staging/skein/skein.h
 create mode 100644 drivers/staging/skein/skein_base.c
 create mode 100644 drivers/staging/skein/skein_base.h

diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index 4b60171..ca746a9 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,7 +1,7 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \
+obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \
  skein_api.o \
  skein_block.o \
  threefish_block.o \
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
deleted file mode 100644
index 8cc8358..000
--- a/drivers/staging/skein/skein.c
+++ /dev/null
@@ -1,883 +0,0 @@
-/***
-**
-** Implementation of the Skein hash function.
-**
-** Source code author: Doug Whiting, 2008.
-**
-** This algorithm and source code is released to the public domain.
-**
-/
-
-#define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
-
-#include/* get the memcpy/memset functions */
-#include "skein.h" /* get the Skein API definitions   */
-#include "skein_iv.h"/* get precomputed IVs */
-#include "skein_block.h"
-
-/*/
-/* 256-bit Skein */
-/*/
-
-/**/
-/* init the context for a straight hashing operation  */
-int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len)
-{
-   union {
-   u8 b[SKEIN_256_STATE_BYTES];
-   u64 w[SKEIN_256_STATE_WORDS];
-   } cfg;  /* config block */
-
-   skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
-   ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */
-
-   switch (hash_bit_len) { /* use pre-computed values, where available */
-   case  256:
-   memcpy(ctx->x, SKEIN_256_IV_256, sizeof(ctx->x));
-   break;
-   case  224:
-   memcpy(ctx->x, SKEIN_256_IV_224, sizeof(ctx->x));
-   break;
-   case  160:
-   memcpy(ctx->x, SKEIN_256_IV_160, sizeof(ctx->x));
-   break;
-   case  128:
-   memcpy(ctx->x, SKEIN_256_IV_128, sizeof(ctx->x));
-   break;
-   default:
-   /* here if there is no precomputed IV value available */
-   /*
-* build/process the config block, type == CONFIG (could be
-* precomputed)
-*/
-   /* set tweaks: T0=0; T1=CFG | FINAL */
-   skein_start_new_type(ctx, CFG_FINAL);
-
-   /* set the schema, version */
-   cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER);
-   /* hash result length in bits */
-   cfg.w[1] = skein_swap64(hash_bit_len);
-   cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL);
-   /* zero pad config block */
-   memset([3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0]));
-
-   /* compute the initial chaining values from config block */
-   /* zero the chaining variables */
-   memset(ctx->x, 0, sizeof(ctx->x));
-   skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
-   break;
-   }
-   /* The chaining vars ctx->x are now initialized for hash_bit_len. */
-   /* Set up to process the data message portion of the hash (default) */
-   skein_start_new_type(ctx, MSG);  /* T0=0, T1= MSG type */
-
-   return SKEIN_SUCCESS;
-}
-
-/**/
-/* init the context for a MAC and/or tree hash operation */
-/* [identical to skein_256_init() when key_bytes == 0 && \
- * t

[PATCH v4 1/7] staging: skein: Collapses threefish module

2014-10-24 Thread Eric Rost
Collapses threefish module into skein module.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Kconfig  | 22 +++---
 drivers/staging/skein/Makefile | 11 +--
 2 files changed, 8 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index b9172bf..de8bdd7 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,8 +1,8 @@
 config CRYPTO_SKEIN
bool "Skein digest algorithm"
depends on (X86 || UML_X86) && 64BIT && CRYPTO
-   select CRYPTO_THREEFISH
select CRYPTO_HASH
+   select CRYPTO_ALGAPI
help
  Skein secure hash algorithm is one of 5 finalists from the NIST SHA3
  competition.
@@ -12,21 +12,5 @@ config CRYPTO_SKEIN
 
  http://www.skein-hash.info/sites/default/files/skein1.3.pdf
 
- for more information.  This module depends on the threefish block
- cipher module.
-
-config CRYPTO_THREEFISH
-   bool "Threefish tweakable block cipher"
-   depends on (X86 || UML_X86) && 64BIT && CRYPTO
-   select CRYPTO_ALGAPI
-   help
- Threefish cipher algorithm is the tweakable block cipher underneath
- the Skein family of secure hash algorithms.  Skein is one of 5
- finalists from the NIST SHA3 competition.
-
- Skein is optimized for modern, 64bit processors and is highly
- customizable.  See:
-
- http://www.skein-hash.info/sites/default/files/skein1.3.pdf
-
- for more information.
+ for more information. This module also contains the threefish block
+ cipher algorithm.
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index a14aadd..4b60171 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,9 +1,8 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
-   skein_api.o \
-   skein_block.o
-
-obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
- threefish_api.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \
+ skein_api.o \
+ skein_block.o \
+ threefish_block.o \
+ threefish_api.o
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 0/7] staging: skein: CryptoAPI and Module Support

2014-10-24 Thread Eric Rost
Adds CryptoAPI and Module support to Skein Hash Algorithm. Also inlines
rotl_64 macro, and removes nonexistent header references.

Eric Rost (7):
  staging: skein: Collapses threefish module
  staging: skein: Renames skein to skein_base
  staging: skein: Adds CryptoAPI Support
  staging: skein: Adds Loadable Module Support
  staging: skein: Inlines rotl_64
  staging: skein: Removes unneeded #define
  staging: skein: Removes skein_debug include

 drivers/staging/skein/Kconfig |  24 +-
 drivers/staging/skein/Makefile|  13 +-
 drivers/staging/skein/skein.c | 883 --
 drivers/staging/skein/skein.h | 346 -
 drivers/staging/skein/skein_api.h |   2 +-
 drivers/staging/skein/skein_base.c| 882 +
 drivers/staging/skein/skein_base.h| 345 +
 drivers/staging/skein/skein_block.c   |   2 +-
 drivers/staging/skein/skein_block.h   |   2 +-
 drivers/staging/skein/skein_generic.c | 208 
 drivers/staging/skein/skein_iv.h  |   2 +-
 drivers/staging/skein/threefish_api.h |   2 +-
 12 files changed, 1451 insertions(+), 1260 deletions(-)
 delete mode 100644 drivers/staging/skein/skein.c
 delete mode 100644 drivers/staging/skein/skein.h
 create mode 100644 drivers/staging/skein/skein_base.c
 create mode 100644 drivers/staging/skein/skein_base.h
 create mode 100644 drivers/staging/skein/skein_generic.c

-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 0/7] staging: skein: CryptoAPI and Module Support

2014-10-24 Thread Eric Rost
Adds CryptoAPI and Module support to Skein Hash Algorithm. Also inlines
rotl_64 macro, and removes nonexistent header references.

Eric Rost (7):
  staging: skein: Collapses threefish module
  staging: skein: Renames skein to skein_base
  staging: skein: Adds CryptoAPI Support
  staging: skein: Adds Loadable Module Support
  staging: skein: Inlines rotl_64
  staging: skein: Removes unneeded #define
  staging: skein: Removes skein_debug include

 drivers/staging/skein/Kconfig |  24 +-
 drivers/staging/skein/Makefile|  13 +-
 drivers/staging/skein/skein.c | 883 --
 drivers/staging/skein/skein.h | 346 -
 drivers/staging/skein/skein_api.h |   2 +-
 drivers/staging/skein/skein_base.c| 882 +
 drivers/staging/skein/skein_base.h| 345 +
 drivers/staging/skein/skein_block.c   |   2 +-
 drivers/staging/skein/skein_block.h   |   2 +-
 drivers/staging/skein/skein_generic.c | 208 
 drivers/staging/skein/skein_iv.h  |   2 +-
 drivers/staging/skein/threefish_api.h |   2 +-
 12 files changed, 1451 insertions(+), 1260 deletions(-)
 delete mode 100644 drivers/staging/skein/skein.c
 delete mode 100644 drivers/staging/skein/skein.h
 create mode 100644 drivers/staging/skein/skein_base.c
 create mode 100644 drivers/staging/skein/skein_base.h
 create mode 100644 drivers/staging/skein/skein_generic.c

-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 1/7] staging: skein: Collapses threefish module

2014-10-24 Thread Eric Rost
Collapses threefish module into skein module.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Kconfig  | 22 +++---
 drivers/staging/skein/Makefile | 11 +--
 2 files changed, 8 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index b9172bf..de8bdd7 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,8 +1,8 @@
 config CRYPTO_SKEIN
bool Skein digest algorithm
depends on (X86 || UML_X86)  64BIT  CRYPTO
-   select CRYPTO_THREEFISH
select CRYPTO_HASH
+   select CRYPTO_ALGAPI
help
  Skein secure hash algorithm is one of 5 finalists from the NIST SHA3
  competition.
@@ -12,21 +12,5 @@ config CRYPTO_SKEIN
 
  http://www.skein-hash.info/sites/default/files/skein1.3.pdf
 
- for more information.  This module depends on the threefish block
- cipher module.
-
-config CRYPTO_THREEFISH
-   bool Threefish tweakable block cipher
-   depends on (X86 || UML_X86)  64BIT  CRYPTO
-   select CRYPTO_ALGAPI
-   help
- Threefish cipher algorithm is the tweakable block cipher underneath
- the Skein family of secure hash algorithms.  Skein is one of 5
- finalists from the NIST SHA3 competition.
-
- Skein is optimized for modern, 64bit processors and is highly
- customizable.  See:
-
- http://www.skein-hash.info/sites/default/files/skein1.3.pdf
-
- for more information.
+ for more information. This module also contains the threefish block
+ cipher algorithm.
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index a14aadd..4b60171 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,9 +1,8 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
-   skein_api.o \
-   skein_block.o
-
-obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
- threefish_api.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \
+ skein_api.o \
+ skein_block.o \
+ threefish_block.o \
+ threefish_api.o
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 2/7] staging: skein: Renames skein to skein_base

2014-10-24 Thread Eric Rost
Renames skein.c to skein_base.c and skein.h to skein_base.h

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Makefile|   2 +-
 drivers/staging/skein/skein.c | 883 -
 drivers/staging/skein/skein.h | 346 -
 drivers/staging/skein/skein_api.h |   2 +-
 drivers/staging/skein/skein_base.c| 884 ++
 drivers/staging/skein/skein_base.h| 351 ++
 drivers/staging/skein/skein_block.c   |   2 +-
 drivers/staging/skein/skein_block.h   |   2 +-
 drivers/staging/skein/skein_iv.h  |   2 +-
 drivers/staging/skein/threefish_api.h |   2 +-
 10 files changed, 1241 insertions(+), 1235 deletions(-)
 delete mode 100644 drivers/staging/skein/skein.c
 delete mode 100644 drivers/staging/skein/skein.h
 create mode 100644 drivers/staging/skein/skein_base.c
 create mode 100644 drivers/staging/skein/skein_base.h

diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index 4b60171..ca746a9 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,7 +1,7 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \
+obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \
  skein_api.o \
  skein_block.o \
  threefish_block.o \
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
deleted file mode 100644
index 8cc8358..000
--- a/drivers/staging/skein/skein.c
+++ /dev/null
@@ -1,883 +0,0 @@
-/***
-**
-** Implementation of the Skein hash function.
-**
-** Source code author: Doug Whiting, 2008.
-**
-** This algorithm and source code is released to the public domain.
-**
-/
-
-#define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
-
-#include linux/string.h   /* get the memcpy/memset functions */
-#include skein.h /* get the Skein API definitions   */
-#include skein_iv.h/* get precomputed IVs */
-#include skein_block.h
-
-/*/
-/* 256-bit Skein */
-/*/
-
-/**/
-/* init the context for a straight hashing operation  */
-int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len)
-{
-   union {
-   u8 b[SKEIN_256_STATE_BYTES];
-   u64 w[SKEIN_256_STATE_WORDS];
-   } cfg;  /* config block */
-
-   skein_assert_ret(hash_bit_len  0, SKEIN_BAD_HASHLEN);
-   ctx-h.hash_bit_len = hash_bit_len; /* output hash bit count */
-
-   switch (hash_bit_len) { /* use pre-computed values, where available */
-   case  256:
-   memcpy(ctx-x, SKEIN_256_IV_256, sizeof(ctx-x));
-   break;
-   case  224:
-   memcpy(ctx-x, SKEIN_256_IV_224, sizeof(ctx-x));
-   break;
-   case  160:
-   memcpy(ctx-x, SKEIN_256_IV_160, sizeof(ctx-x));
-   break;
-   case  128:
-   memcpy(ctx-x, SKEIN_256_IV_128, sizeof(ctx-x));
-   break;
-   default:
-   /* here if there is no precomputed IV value available */
-   /*
-* build/process the config block, type == CONFIG (could be
-* precomputed)
-*/
-   /* set tweaks: T0=0; T1=CFG | FINAL */
-   skein_start_new_type(ctx, CFG_FINAL);
-
-   /* set the schema, version */
-   cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER);
-   /* hash result length in bits */
-   cfg.w[1] = skein_swap64(hash_bit_len);
-   cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL);
-   /* zero pad config block */
-   memset(cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0]));
-
-   /* compute the initial chaining values from config block */
-   /* zero the chaining variables */
-   memset(ctx-x, 0, sizeof(ctx-x));
-   skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
-   break;
-   }
-   /* The chaining vars ctx-x are now initialized for hash_bit_len. */
-   /* Set up to process the data message portion of the hash (default) */
-   skein_start_new_type(ctx, MSG);  /* T0=0, T1= MSG type */
-
-   return SKEIN_SUCCESS;
-}
-
-/**/
-/* init the context for a MAC and/or tree hash operation */
-/* [identical to skein_256_init() when key_bytes == 0  \
- * tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
-int

[PATCH v4 3/7] staging: skein: Adds CryptoAPI Support

2014-10-24 Thread Eric Rost
Adds CryptoAPI support to the Skein Hashing Algorithm driver.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Makefile|   3 +-
 drivers/staging/skein/skein_generic.c | 191 ++
 2 files changed, 193 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/skein/skein_generic.c

diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index ca746a9..d8177cc 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -5,4 +5,5 @@ obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \
  skein_api.o \
  skein_block.o \
  threefish_block.o \
- threefish_api.o
+ threefish_api.o \
+ skein_generic.o
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
new file mode 100644
index 000..39332e8
--- /dev/null
+++ b/drivers/staging/skein/skein_generic.c
@@ -0,0 +1,191 @@
+/*
+ * Cryptographic API.
+ *
+ * Skein256 Hash Algorithm.
+ *
+ * Derived from cryptoapi implementation, adapted for in-place
+ * scatterlist interface.
+ *
+ * Copyright (c) Eric Rost eric.r...@mybabylon.net
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#include linux/types.h
+#include linux/init.h
+#include crypto/internal/hash.h
+#include skein_base.h
+
+
+static int skein256_init(struct shash_desc *desc)
+{
+   return skein_256_init((struct skein_256_ctx *) shash_desc_ctx(desc),
+   SKEIN256_DIGEST_BIT_SIZE);
+}
+
+int skein256_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   return skein_256_update((struct skein_256_ctx *)shash_desc_ctx(desc),
+   data, len);
+}
+
+static int skein256_final(struct shash_desc *desc, u8 *out)
+{
+   return skein_256_final((struct skein_256_ctx *)shash_desc_ctx(desc),
+   out);
+}
+
+static int skein256_export(struct shash_desc *desc, void *out)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein256_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
+static int skein512_init(struct shash_desc *desc)
+{
+   return skein_512_init((struct skein_512_ctx *)shash_desc_ctx(desc),
+   SKEIN512_DIGEST_BIT_SIZE);
+}
+
+int skein512_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   return skein_512_update((struct skein_512_ctx *)shash_desc_ctx(desc),
+   data, len);
+}
+
+static int skein512_final(struct shash_desc *desc, u8 *out)
+{
+   return skein_512_final((struct skein_512_ctx *)shash_desc_ctx(desc),
+   out);
+}
+
+static int skein512_export(struct shash_desc *desc, void *out)
+{
+   struct skein_512_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein512_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_512_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
+static int skein1024_init(struct shash_desc *desc)
+{
+   return skein_1024_init((struct skein_1024_ctx *)shash_desc_ctx(desc),
+   SKEIN1024_DIGEST_BIT_SIZE);
+}
+
+int skein1024_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   return skein_1024_update((struct skein_1024_ctx *)shash_desc_ctx(desc),
+   data, len);
+}
+
+static int skein1024_final(struct shash_desc *desc, u8 *out)
+{
+   return skein_1024_final((struct skein_1024_ctx *)shash_desc_ctx(desc),
+   out);
+}
+
+static int skein1024_export(struct shash_desc *desc, void *out)
+{
+   struct skein_1024_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein1024_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_1024_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
+static struct shash_alg alg256 = {
+   .digestsize =   (SKEIN256_DIGEST_BIT_SIZE / 8),
+   .init   =   skein256_init,
+   .update =   skein256_update,
+   .final  =   skein256_final,
+   .export =   skein256_export,
+   .import

[PATCH v4 5/7] staging: skein: Inlines rotl_64

2014-10-24 Thread Eric Rost
Inlines the rotl_64 macro.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/skein_base.h | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index 9f10af9..0111fa4 100644
--- a/drivers/staging/skein/skein_base.h
+++ b/drivers/staging/skein/skein_base.h
@@ -33,10 +33,6 @@
 #define SKEIN512_DIGEST_BIT_SIZE 512
 #define SKEIN1024_DIGEST_BIT_SIZE 1024
 
-#ifndef rotl_64
-#define rotl_64(x, N)(((x)  (N)) | ((x)  (64-(N
-#endif
-
 /* 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_get64_lsb_first(dst64, src08, w_cnt) \
@@ -49,12 +45,12 @@ enum {
SKEIN_BAD_HASHLEN =  2
 };
 
-#define  SKEIN_MODIFIER_WORDS   (2) /* number of modifier (tweak) words */
+#define  SKEIN_MODIFIER_WORDS   2 /* number of modifier (tweak) words */
 
-#define  SKEIN_256_STATE_WORDS  (4)
-#define  SKEIN_512_STATE_WORDS  (8)
-#define  SKEIN_1024_STATE_WORDS (16)
-#define  SKEIN_MAX_STATE_WORDS (16)
+#define  SKEIN_256_STATE_WORDS  4
+#define  SKEIN_512_STATE_WORDS  8
+#define  SKEIN_1024_STATE_WORDS 16
+#define  SKEIN_MAX_STATE_WORDS 16
 
 #define  SKEIN_256_STATE_BYTES  (8*SKEIN_256_STATE_WORDS)
 #define  SKEIN_512_STATE_BYTES  (8*SKEIN_512_STATE_WORDS)
@@ -92,6 +88,11 @@ struct skein_1024_ctx { /* 1024-bit Skein hash context 
structure */
u8 b[SKEIN_1024_BLOCK_BYTES];   /* partial block buf (8-byte aligned) */
 };
 
+static inline int rotl_64(int x, int N)
+{
+   return (x  N) | (x  (64 - N));
+}
+
 /* Skein APIs for (incremental) straight hashing */
 int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len);
 int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len);
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 4/7] staging: skein: Adds Loadable Module Support

2014-10-24 Thread Eric Rost
Adds loadable module support to the Skein Hashing Algorithm driver.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Kconfig |  2 +-
 drivers/staging/skein/Makefile| 13 +++--
 drivers/staging/skein/skein_generic.c | 19 ++-
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index de8bdd7..012a823 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,5 +1,5 @@
 config CRYPTO_SKEIN
-   bool Skein digest algorithm
+   tristate Skein digest algorithm
depends on (X86 || UML_X86)  64BIT  CRYPTO
select CRYPTO_HASH
select CRYPTO_ALGAPI
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index d8177cc..b7f947f 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,9 +1,10 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \
- skein_api.o \
- skein_block.o \
- threefish_block.o \
- threefish_api.o \
- skein_generic.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein.o
+skein-y := skein_base.o \
+  skein_api.o \
+  skein_block.o \
+  threefish_block.o \
+  threefish_api.o \
+  skein_generic.o
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
index 39332e8..46466d0 100644
--- a/drivers/staging/skein/skein_generic.c
+++ b/drivers/staging/skein/skein_generic.c
@@ -16,6 +16,7 @@
  */
 #include linux/types.h
 #include linux/init.h
+#include linux/module.h
 #include crypto/internal/hash.h
 #include skein_base.h
 
@@ -139,6 +140,7 @@ static struct shash_alg alg256 = {
.cra_driver_name=   skein,
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_256_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -156,6 +158,7 @@ static struct shash_alg alg512 = {
.cra_driver_name=   skein,
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_512_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -173,6 +176,7 @@ static struct shash_alg alg1024 = {
.cra_driver_name=   skein,
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_1024_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -188,4 +192,17 @@ static int __init skein_generic_init(void)
return 0;
 }
 
-device_initcall(skein_generic_init);
+static void __exit skein_generic_fini(void)
+{
+   crypto_unregister_shash(alg256);
+   crypto_unregister_shash(alg512);
+   crypto_unregister_shash(alg1024);
+}
+
+module_init(skein_generic_init);
+module_exit(skein_generic_fini);
+
+MODULE_LICENSE(GPL);
+MODULE_DESCRIPTION(Skein Hash Algorithm);
+
+MODULE_ALIAS(skein);
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 6/7] staging: skein: Removes unneeded #define

2014-10-24 Thread Eric Rost
Removes unneeded #define SKEIN_PORT_CODE since skein_port.h is
nonexistent.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/skein_base.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/skein/skein_base.c 
b/drivers/staging/skein/skein_base.c
index e0994ea..ebc436a 100644
--- a/drivers/staging/skein/skein_base.c
+++ b/drivers/staging/skein/skein_base.c
@@ -8,8 +8,6 @@
 **
 /
 
-#define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
-
 #include linux/string.h   /* get the memcpy/memset functions */
 #include linux/export.h
 #include skein_base.h /* get the Skein API definitions   */
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 7/7] staging: skein: Removes skein_debug include

2014-10-24 Thread Eric Rost
Removes skein_debug.h include since skein_debug.h is nonexistent.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/skein_base.h | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index 0111fa4..5b69e5a 100644
--- a/drivers/staging/skein/skein_base.h
+++ b/drivers/staging/skein/skein_base.h
@@ -15,10 +15,6 @@
 **
 ** The default note explains what happens when the switch is not defined.
 **
-**  SKEIN_DEBUG-- make callouts from inside Skein code
-**to examine/display intermediate values.
-**[default: no callouts (no overhead)]
-**
 **  SKEIN_ERR_CHECK-- how error checking is handled inside Skein
 **code. If not defined, most error checking
 **is disabled (for performance). Otherwise,
@@ -282,15 +278,12 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 
*hash_val);
 /*
 ** Internal Skein definitions for debugging and error checking
 **/
-#ifdef SKEIN_DEBUG /* examine/display intermediate values? */
-#include skein_debug.h
-#else   /* default is no callouts */
 #define skein_show_block(bits, ctx, x, blk_ptr, w_ptr, ks_event_ptr, 
ks_odd_ptr)
 #define skein_show_round(bits, ctx, r, x)
 #define skein_show_r_ptr(bits, ctx, r, x_ptr)
 #define skein_show_final(bits, ctx, cnt, out_ptr)
 #define skein_show_key(bits, ctx, key, key_bytes)
-#endif
+
 
 /* ignore all asserts, for performance */
 #define skein_assert_ret(x, ret_code)
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 0/7] staging: skein: CryptoAPI and Module Support

2014-10-24 Thread Eric Rost
On Fri, 2014-10-24 at 06:16 -0500, Eric Rost wrote:
 Adds CryptoAPI and Module support to Skein Hash Algorithm. Also inlines
 rotl_64 macro, and removes nonexistent header references.

This should be [PATCH v5], sorry.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 0/7] staging: skein: CryptoAPI and Module Support

2014-10-24 Thread Eric Rost
Adds CryptoAPI and Module support to Skein Hash Algorithm. Also inlines
rotl_64 macro, and removes nonexistent header references.

Eric Rost (7):
  staging: skein: Collapses threefish module
  staging: skein: Renames skein to skein_base
  staging: skein: Adds CryptoAPI Support
  staging: skein: Adds Loadable Module Support
  staging: skein: Inlines rotl_64
  staging: skein: Removes unneeded #define
  staging: skein: Removes skein_debug include

 drivers/staging/skein/Kconfig |  24 +-
 drivers/staging/skein/Makefile|  13 +-
 drivers/staging/skein/skein.c | 883 --
 drivers/staging/skein/skein.h | 346 -
 drivers/staging/skein/skein_api.h |   2 +-
 drivers/staging/skein/skein_base.c| 882 +
 drivers/staging/skein/skein_base.h| 345 +
 drivers/staging/skein/skein_block.c   |   2 +-
 drivers/staging/skein/skein_block.h   |   2 +-
 drivers/staging/skein/skein_generic.c | 208 
 drivers/staging/skein/skein_iv.h  |   2 +-
 drivers/staging/skein/threefish_api.h |   2 +-
 12 files changed, 1451 insertions(+), 1260 deletions(-)
 delete mode 100644 drivers/staging/skein/skein.c
 delete mode 100644 drivers/staging/skein/skein.h
 create mode 100644 drivers/staging/skein/skein_base.c
 create mode 100644 drivers/staging/skein/skein_base.h
 create mode 100644 drivers/staging/skein/skein_generic.c

-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 1/7] staging: skein: Collapses threefish module

2014-10-24 Thread Eric Rost
Collapses threefish module into skein module.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Kconfig  | 22 +++---
 drivers/staging/skein/Makefile | 11 +--
 2 files changed, 8 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index b9172bf..de8bdd7 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,8 +1,8 @@
 config CRYPTO_SKEIN
bool Skein digest algorithm
depends on (X86 || UML_X86)  64BIT  CRYPTO
-   select CRYPTO_THREEFISH
select CRYPTO_HASH
+   select CRYPTO_ALGAPI
help
  Skein secure hash algorithm is one of 5 finalists from the NIST SHA3
  competition.
@@ -12,21 +12,5 @@ config CRYPTO_SKEIN
 
  http://www.skein-hash.info/sites/default/files/skein1.3.pdf
 
- for more information.  This module depends on the threefish block
- cipher module.
-
-config CRYPTO_THREEFISH
-   bool Threefish tweakable block cipher
-   depends on (X86 || UML_X86)  64BIT  CRYPTO
-   select CRYPTO_ALGAPI
-   help
- Threefish cipher algorithm is the tweakable block cipher underneath
- the Skein family of secure hash algorithms.  Skein is one of 5
- finalists from the NIST SHA3 competition.
-
- Skein is optimized for modern, 64bit processors and is highly
- customizable.  See:
-
- http://www.skein-hash.info/sites/default/files/skein1.3.pdf
-
- for more information.
+ for more information. This module also contains the threefish block
+ cipher algorithm.
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index a14aadd..4b60171 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,9 +1,8 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
-   skein_api.o \
-   skein_block.o
-
-obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
- threefish_api.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \
+ skein_api.o \
+ skein_block.o \
+ threefish_block.o \
+ threefish_api.o
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 2/7] staging: skein: Renames skein to skein_base

2014-10-24 Thread Eric Rost
Renames skein.c to skein_base.c and skein.h to skein_base.h

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Makefile|   2 +-
 drivers/staging/skein/skein.c | 883 -
 drivers/staging/skein/skein.h | 346 -
 drivers/staging/skein/skein_api.h |   2 +-
 drivers/staging/skein/skein_base.c| 884 ++
 drivers/staging/skein/skein_base.h| 351 ++
 drivers/staging/skein/skein_block.c   |   2 +-
 drivers/staging/skein/skein_block.h   |   2 +-
 drivers/staging/skein/skein_iv.h  |   2 +-
 drivers/staging/skein/threefish_api.h |   2 +-
 10 files changed, 1241 insertions(+), 1235 deletions(-)
 delete mode 100644 drivers/staging/skein/skein.c
 delete mode 100644 drivers/staging/skein/skein.h
 create mode 100644 drivers/staging/skein/skein_base.c
 create mode 100644 drivers/staging/skein/skein_base.h

diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index 4b60171..ca746a9 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,7 +1,7 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \
+obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \
  skein_api.o \
  skein_block.o \
  threefish_block.o \
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
deleted file mode 100644
index 8cc8358..000
--- a/drivers/staging/skein/skein.c
+++ /dev/null
@@ -1,883 +0,0 @@
-/***
-**
-** Implementation of the Skein hash function.
-**
-** Source code author: Doug Whiting, 2008.
-**
-** This algorithm and source code is released to the public domain.
-**
-/
-
-#define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
-
-#include linux/string.h   /* get the memcpy/memset functions */
-#include skein.h /* get the Skein API definitions   */
-#include skein_iv.h/* get precomputed IVs */
-#include skein_block.h
-
-/*/
-/* 256-bit Skein */
-/*/
-
-/**/
-/* init the context for a straight hashing operation  */
-int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len)
-{
-   union {
-   u8 b[SKEIN_256_STATE_BYTES];
-   u64 w[SKEIN_256_STATE_WORDS];
-   } cfg;  /* config block */
-
-   skein_assert_ret(hash_bit_len  0, SKEIN_BAD_HASHLEN);
-   ctx-h.hash_bit_len = hash_bit_len; /* output hash bit count */
-
-   switch (hash_bit_len) { /* use pre-computed values, where available */
-   case  256:
-   memcpy(ctx-x, SKEIN_256_IV_256, sizeof(ctx-x));
-   break;
-   case  224:
-   memcpy(ctx-x, SKEIN_256_IV_224, sizeof(ctx-x));
-   break;
-   case  160:
-   memcpy(ctx-x, SKEIN_256_IV_160, sizeof(ctx-x));
-   break;
-   case  128:
-   memcpy(ctx-x, SKEIN_256_IV_128, sizeof(ctx-x));
-   break;
-   default:
-   /* here if there is no precomputed IV value available */
-   /*
-* build/process the config block, type == CONFIG (could be
-* precomputed)
-*/
-   /* set tweaks: T0=0; T1=CFG | FINAL */
-   skein_start_new_type(ctx, CFG_FINAL);
-
-   /* set the schema, version */
-   cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER);
-   /* hash result length in bits */
-   cfg.w[1] = skein_swap64(hash_bit_len);
-   cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL);
-   /* zero pad config block */
-   memset(cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0]));
-
-   /* compute the initial chaining values from config block */
-   /* zero the chaining variables */
-   memset(ctx-x, 0, sizeof(ctx-x));
-   skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
-   break;
-   }
-   /* The chaining vars ctx-x are now initialized for hash_bit_len. */
-   /* Set up to process the data message portion of the hash (default) */
-   skein_start_new_type(ctx, MSG);  /* T0=0, T1= MSG type */
-
-   return SKEIN_SUCCESS;
-}
-
-/**/
-/* init the context for a MAC and/or tree hash operation */
-/* [identical to skein_256_init() when key_bytes == 0  \
- * tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
-int

[PATCH v5 4/7] staging: skein: Adds Loadable Module Support

2014-10-24 Thread Eric Rost
Adds loadable module support to the Skein Hashing Algorithm driver.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Kconfig |  2 +-
 drivers/staging/skein/Makefile| 13 +++--
 drivers/staging/skein/skein_generic.c | 19 ++-
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index de8bdd7..012a823 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,5 +1,5 @@
 config CRYPTO_SKEIN
-   bool Skein digest algorithm
+   tristate Skein digest algorithm
depends on (X86 || UML_X86)  64BIT  CRYPTO
select CRYPTO_HASH
select CRYPTO_ALGAPI
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index d8177cc..b7f947f 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,9 +1,10 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \
- skein_api.o \
- skein_block.o \
- threefish_block.o \
- threefish_api.o \
- skein_generic.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein.o
+skein-y := skein_base.o \
+  skein_api.o \
+  skein_block.o \
+  threefish_block.o \
+  threefish_api.o \
+  skein_generic.o
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
index 39332e8..46466d0 100644
--- a/drivers/staging/skein/skein_generic.c
+++ b/drivers/staging/skein/skein_generic.c
@@ -16,6 +16,7 @@
  */
 #include linux/types.h
 #include linux/init.h
+#include linux/module.h
 #include crypto/internal/hash.h
 #include skein_base.h
 
@@ -139,6 +140,7 @@ static struct shash_alg alg256 = {
.cra_driver_name=   skein,
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_256_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -156,6 +158,7 @@ static struct shash_alg alg512 = {
.cra_driver_name=   skein,
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_512_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -173,6 +176,7 @@ static struct shash_alg alg1024 = {
.cra_driver_name=   skein,
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_1024_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -188,4 +192,17 @@ static int __init skein_generic_init(void)
return 0;
 }
 
-device_initcall(skein_generic_init);
+static void __exit skein_generic_fini(void)
+{
+   crypto_unregister_shash(alg256);
+   crypto_unregister_shash(alg512);
+   crypto_unregister_shash(alg1024);
+}
+
+module_init(skein_generic_init);
+module_exit(skein_generic_fini);
+
+MODULE_LICENSE(GPL);
+MODULE_DESCRIPTION(Skein Hash Algorithm);
+
+MODULE_ALIAS(skein);
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 3/7] staging: skein: Adds CryptoAPI Support

2014-10-24 Thread Eric Rost
Adds CryptoAPI support to the Skein Hashing Algorithm driver.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Makefile|   3 +-
 drivers/staging/skein/skein_generic.c | 191 ++
 2 files changed, 193 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/skein/skein_generic.c

diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index ca746a9..d8177cc 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -5,4 +5,5 @@ obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \
  skein_api.o \
  skein_block.o \
  threefish_block.o \
- threefish_api.o
+ threefish_api.o \
+ skein_generic.o
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
new file mode 100644
index 000..39332e8
--- /dev/null
+++ b/drivers/staging/skein/skein_generic.c
@@ -0,0 +1,191 @@
+/*
+ * Cryptographic API.
+ *
+ * Skein256 Hash Algorithm.
+ *
+ * Derived from cryptoapi implementation, adapted for in-place
+ * scatterlist interface.
+ *
+ * Copyright (c) Eric Rost eric.r...@mybabylon.net
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#include linux/types.h
+#include linux/init.h
+#include crypto/internal/hash.h
+#include skein_base.h
+
+
+static int skein256_init(struct shash_desc *desc)
+{
+   return skein_256_init((struct skein_256_ctx *) shash_desc_ctx(desc),
+   SKEIN256_DIGEST_BIT_SIZE);
+}
+
+int skein256_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   return skein_256_update((struct skein_256_ctx *)shash_desc_ctx(desc),
+   data, len);
+}
+
+static int skein256_final(struct shash_desc *desc, u8 *out)
+{
+   return skein_256_final((struct skein_256_ctx *)shash_desc_ctx(desc),
+   out);
+}
+
+static int skein256_export(struct shash_desc *desc, void *out)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein256_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
+static int skein512_init(struct shash_desc *desc)
+{
+   return skein_512_init((struct skein_512_ctx *)shash_desc_ctx(desc),
+   SKEIN512_DIGEST_BIT_SIZE);
+}
+
+int skein512_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   return skein_512_update((struct skein_512_ctx *)shash_desc_ctx(desc),
+   data, len);
+}
+
+static int skein512_final(struct shash_desc *desc, u8 *out)
+{
+   return skein_512_final((struct skein_512_ctx *)shash_desc_ctx(desc),
+   out);
+}
+
+static int skein512_export(struct shash_desc *desc, void *out)
+{
+   struct skein_512_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein512_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_512_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
+static int skein1024_init(struct shash_desc *desc)
+{
+   return skein_1024_init((struct skein_1024_ctx *)shash_desc_ctx(desc),
+   SKEIN1024_DIGEST_BIT_SIZE);
+}
+
+int skein1024_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   return skein_1024_update((struct skein_1024_ctx *)shash_desc_ctx(desc),
+   data, len);
+}
+
+static int skein1024_final(struct shash_desc *desc, u8 *out)
+{
+   return skein_1024_final((struct skein_1024_ctx *)shash_desc_ctx(desc),
+   out);
+}
+
+static int skein1024_export(struct shash_desc *desc, void *out)
+{
+   struct skein_1024_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein1024_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_1024_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
+static struct shash_alg alg256 = {
+   .digestsize =   (SKEIN256_DIGEST_BIT_SIZE / 8),
+   .init   =   skein256_init,
+   .update =   skein256_update,
+   .final  =   skein256_final,
+   .export =   skein256_export,
+   .import

[PATCH v5 5/7] staging: skein: Inlines rotl_64

2014-10-24 Thread Eric Rost
Inlines the rotl_64 macro.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/skein_base.h | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index 9f10af9..0111fa4 100644
--- a/drivers/staging/skein/skein_base.h
+++ b/drivers/staging/skein/skein_base.h
@@ -33,10 +33,6 @@
 #define SKEIN512_DIGEST_BIT_SIZE 512
 #define SKEIN1024_DIGEST_BIT_SIZE 1024
 
-#ifndef rotl_64
-#define rotl_64(x, N)(((x)  (N)) | ((x)  (64-(N
-#endif
-
 /* 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_get64_lsb_first(dst64, src08, w_cnt) \
@@ -49,12 +45,12 @@ enum {
SKEIN_BAD_HASHLEN =  2
 };
 
-#define  SKEIN_MODIFIER_WORDS   (2) /* number of modifier (tweak) words */
+#define  SKEIN_MODIFIER_WORDS   2 /* number of modifier (tweak) words */
 
-#define  SKEIN_256_STATE_WORDS  (4)
-#define  SKEIN_512_STATE_WORDS  (8)
-#define  SKEIN_1024_STATE_WORDS (16)
-#define  SKEIN_MAX_STATE_WORDS (16)
+#define  SKEIN_256_STATE_WORDS  4
+#define  SKEIN_512_STATE_WORDS  8
+#define  SKEIN_1024_STATE_WORDS 16
+#define  SKEIN_MAX_STATE_WORDS 16
 
 #define  SKEIN_256_STATE_BYTES  (8*SKEIN_256_STATE_WORDS)
 #define  SKEIN_512_STATE_BYTES  (8*SKEIN_512_STATE_WORDS)
@@ -92,6 +88,11 @@ struct skein_1024_ctx { /* 1024-bit Skein hash context 
structure */
u8 b[SKEIN_1024_BLOCK_BYTES];   /* partial block buf (8-byte aligned) */
 };
 
+static inline int rotl_64(int x, int N)
+{
+   return (x  N) | (x  (64 - N));
+}
+
 /* Skein APIs for (incremental) straight hashing */
 int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len);
 int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len);
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 7/7] staging: skein: Removes skein_debug include

2014-10-24 Thread Eric Rost
Removes skein_debug.h include since skein_debug.h is nonexistent.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/skein_base.h | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index 0111fa4..5b69e5a 100644
--- a/drivers/staging/skein/skein_base.h
+++ b/drivers/staging/skein/skein_base.h
@@ -15,10 +15,6 @@
 **
 ** The default note explains what happens when the switch is not defined.
 **
-**  SKEIN_DEBUG-- make callouts from inside Skein code
-**to examine/display intermediate values.
-**[default: no callouts (no overhead)]
-**
 **  SKEIN_ERR_CHECK-- how error checking is handled inside Skein
 **code. If not defined, most error checking
 **is disabled (for performance). Otherwise,
@@ -282,15 +278,12 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 
*hash_val);
 /*
 ** Internal Skein definitions for debugging and error checking
 **/
-#ifdef SKEIN_DEBUG /* examine/display intermediate values? */
-#include skein_debug.h
-#else   /* default is no callouts */
 #define skein_show_block(bits, ctx, x, blk_ptr, w_ptr, ks_event_ptr, 
ks_odd_ptr)
 #define skein_show_round(bits, ctx, r, x)
 #define skein_show_r_ptr(bits, ctx, r, x_ptr)
 #define skein_show_final(bits, ctx, cnt, out_ptr)
 #define skein_show_key(bits, ctx, key, key_bytes)
-#endif
+
 
 /* ignore all asserts, for performance */
 #define skein_assert_ret(x, ret_code)
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 6/7] staging: skein: Removes unneeded #define

2014-10-24 Thread Eric Rost
Removes unneeded #define SKEIN_PORT_CODE since skein_port.h is
nonexistent.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/skein_base.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/skein/skein_base.c 
b/drivers/staging/skein/skein_base.c
index e0994ea..ebc436a 100644
--- a/drivers/staging/skein/skein_base.c
+++ b/drivers/staging/skein/skein_base.c
@@ -8,8 +8,6 @@
 **
 /
 
-#define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
-
 #include linux/string.h   /* get the memcpy/memset functions */
 #include linux/export.h
 #include skein_base.h /* get the Skein API definitions   */
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 1/7] staging: skein: Collapses threefish module

2014-10-24 Thread Eric Rost
Collapses threefish module into skein module.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Kconfig  | 22 +++---
 drivers/staging/skein/Makefile | 11 +--
 2 files changed, 8 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index b9172bf..de8bdd7 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,8 +1,8 @@
 config CRYPTO_SKEIN
bool Skein digest algorithm
depends on (X86 || UML_X86)  64BIT  CRYPTO
-   select CRYPTO_THREEFISH
select CRYPTO_HASH
+   select CRYPTO_ALGAPI
help
  Skein secure hash algorithm is one of 5 finalists from the NIST SHA3
  competition.
@@ -12,21 +12,5 @@ config CRYPTO_SKEIN
 
  http://www.skein-hash.info/sites/default/files/skein1.3.pdf
 
- for more information.  This module depends on the threefish block
- cipher module.
-
-config CRYPTO_THREEFISH
-   bool Threefish tweakable block cipher
-   depends on (X86 || UML_X86)  64BIT  CRYPTO
-   select CRYPTO_ALGAPI
-   help
- Threefish cipher algorithm is the tweakable block cipher underneath
- the Skein family of secure hash algorithms.  Skein is one of 5
- finalists from the NIST SHA3 competition.
-
- Skein is optimized for modern, 64bit processors and is highly
- customizable.  See:
-
- http://www.skein-hash.info/sites/default/files/skein1.3.pdf
-
- for more information.
+ for more information. This module also contains the threefish block
+ cipher algorithm.
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index a14aadd..4b60171 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,9 +1,8 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
-   skein_api.o \
-   skein_block.o
-
-obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
- threefish_api.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \
+ skein_api.o \
+ skein_block.o \
+ threefish_block.o \
+ threefish_api.o
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 0/7] staging: skein: CryptoAPI and Module Support

2014-10-24 Thread Eric Rost
Adds CryptoAPI and loadable module support to the Skein Hashing
Algorithm. Collapses threefish module into skein module. Renames skein.c
and skein.h to skein_base.c and skein_base.h so module can be named
skein.ko. Inlines rotl_64 macro. Removes unneeded #define and
skein_debug.h include.

Eric Rost (7):
  staging: skein: Collapses threefish module
  staging: skein: Renames skein to skein_base
  staging: skein: Adds CryptoAPI Support
  staging: skein: Adds Loadable Module Support
  staging: skein: Inlines rotl_64
  staging: skein: Removes unneeded #define
  staging: skein: Removes skein_debug include

 drivers/staging/skein/Kconfig   |  24 +--
 drivers/staging/skein/Makefile  |  13 +-
 drivers/staging/skein/skein_api.h   |   2 +-
 drivers/staging/skein/{skein.c = skein_base.c} |   5 +-
 drivers/staging/skein/{skein.h = skein_base.h} |  31 ++--
 drivers/staging/skein/skein_block.c |   2 +-
 drivers/staging/skein/skein_block.h |   2 +-
 drivers/staging/skein/skein_generic.c   | 216 
 drivers/staging/skein/skein_iv.h|   2 +-
 drivers/staging/skein/threefish_api.h   |   2 +-
 10 files changed, 249 insertions(+), 50 deletions(-)
 rename drivers/staging/skein/{skein.c = skein_base.c} (99%)
 rename drivers/staging/skein/{skein.h = skein_base.h} (95%)
 create mode 100644 drivers/staging/skein/skein_generic.c

-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 2/7] staging: skein: Renames skein to skein_base

2014-10-24 Thread Eric Rost
Renames skein.c to skein_base.c and skein.h to skein_base.h in
preparation for naming loadable module skein.ko

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Makefile  | 2 +-
 drivers/staging/skein/skein_api.h   | 2 +-
 drivers/staging/skein/{skein.c = skein_base.c} | 3 ++-
 drivers/staging/skein/{skein.h = skein_base.h} | 0
 drivers/staging/skein/skein_block.c | 2 +-
 drivers/staging/skein/skein_block.h | 2 +-
 drivers/staging/skein/skein_iv.h| 2 +-
 drivers/staging/skein/threefish_api.h   | 2 +-
 8 files changed, 8 insertions(+), 7 deletions(-)
 rename drivers/staging/skein/{skein.c = skein_base.c} (99%)
 rename drivers/staging/skein/{skein.h = skein_base.h} (100%)

diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index 4b60171..ca746a9 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,7 +1,7 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \
+obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \
  skein_api.o \
  skein_block.o \
  threefish_block.o \
diff --git a/drivers/staging/skein/skein_api.h 
b/drivers/staging/skein/skein_api.h
index e02fa19..171b875 100644
--- a/drivers/staging/skein/skein_api.h
+++ b/drivers/staging/skein/skein_api.h
@@ -79,7 +79,7 @@ OTHER DEALINGS IN THE SOFTWARE.
  */
 
 #include linux/types.h
-#include skein.h
+#include skein_base.h
 
 /**
  * Which Skein size to use
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein_base.c
similarity index 99%
rename from drivers/staging/skein/skein.c
rename to drivers/staging/skein/skein_base.c
index 8cc8358..e0994ea 100644
--- a/drivers/staging/skein/skein.c
+++ b/drivers/staging/skein/skein_base.c
@@ -11,7 +11,8 @@
 #define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
 
 #include linux/string.h   /* get the memcpy/memset functions */
-#include skein.h /* get the Skein API definitions   */
+#include linux/export.h
+#include skein_base.h /* get the Skein API definitions   */
 #include skein_iv.h/* get precomputed IVs */
 #include skein_block.h
 
diff --git a/drivers/staging/skein/skein.h b/drivers/staging/skein/skein_base.h
similarity index 100%
rename from drivers/staging/skein/skein.h
rename to drivers/staging/skein/skein_base.h
diff --git a/drivers/staging/skein/skein_block.c 
b/drivers/staging/skein/skein_block.c
index 88bc718..36b0b40 100644
--- a/drivers/staging/skein/skein_block.c
+++ b/drivers/staging/skein/skein_block.c
@@ -15,7 +15,7 @@
 /
 
 #include linux/string.h
-#include skein.h
+#include skein_base.h
 #include skein_block.h
 
 #ifndef SKEIN_USE_ASM
diff --git a/drivers/staging/skein/skein_block.h 
b/drivers/staging/skein/skein_block.h
index bd7bdc3..9d40f4a 100644
--- a/drivers/staging/skein/skein_block.h
+++ b/drivers/staging/skein/skein_block.h
@@ -10,7 +10,7 @@
 #ifndef _SKEIN_BLOCK_H_
 #define _SKEIN_BLOCK_H_
 
-#include skein.h /* get the Skein API definitions   */
+#include skein_base.h /* get the Skein API definitions   */
 
 void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr,
 size_t blk_cnt, size_t byte_cnt_add);
diff --git a/drivers/staging/skein/skein_iv.h b/drivers/staging/skein/skein_iv.h
index d9dc1d5..8a06314 100644
--- a/drivers/staging/skein/skein_iv.h
+++ b/drivers/staging/skein/skein_iv.h
@@ -1,7 +1,7 @@
 #ifndef _SKEIN_IV_H_
 #define _SKEIN_IV_H_
 
-#include skein.h/* get Skein macros and types */
+#include skein_base.h/* get Skein macros and types */
 
 /*
 * Pre-computed Skein IVs ***
diff --git a/drivers/staging/skein/threefish_api.h 
b/drivers/staging/skein/threefish_api.h
index 8d5ddf8..8e0a0b7 100644
--- a/drivers/staging/skein/threefish_api.h
+++ b/drivers/staging/skein/threefish_api.h
@@ -29,7 +29,7 @@
  */
 
 #include linux/types.h
-#include skein.h
+#include skein_base.h
 
 #define KEY_SCHEDULE_CONST 0x1BD11BDAA9FC1A22L
 
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 3/7] staging: skein: Adds CryptoAPI Support

2014-10-24 Thread Eric Rost
Adds CryptoAPI support to the Skein Hashing Algorithm driver.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Makefile|   3 +-
 drivers/staging/skein/skein_base.h|   5 +
 drivers/staging/skein/skein_generic.c | 199 ++
 3 files changed, 206 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/skein/skein_generic.c

diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index ca746a9..d8177cc 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -5,4 +5,5 @@ obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \
  skein_api.o \
  skein_block.o \
  threefish_block.o \
- threefish_api.o
+ threefish_api.o \
+ skein_generic.o
diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index e6669f1..9f10af9 100644
--- a/drivers/staging/skein/skein_base.h
+++ b/drivers/staging/skein/skein_base.h
@@ -28,6 +28,11 @@
 **
 ***/
 
+/*Skein digest sizes for crypto api*/
+#define SKEIN256_DIGEST_BIT_SIZE 256
+#define SKEIN512_DIGEST_BIT_SIZE 512
+#define SKEIN1024_DIGEST_BIT_SIZE 1024
+
 #ifndef rotl_64
 #define rotl_64(x, N)(((x)  (N)) | ((x)  (64-(N
 #endif
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
new file mode 100644
index 000..f2d6dfb
--- /dev/null
+++ b/drivers/staging/skein/skein_generic.c
@@ -0,0 +1,199 @@
+/*
+ * Cryptographic API.
+ *
+ * Skein256 Hash Algorithm.
+ *
+ * Derived from cryptoapi implementation, adapted for in-place
+ * scatterlist interface.
+ *
+ * Copyright (c) Eric Rost eric.r...@mybabylon.net
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#include linux/types.h
+#include linux/init.h
+#include crypto/internal/hash.h
+#include skein_base.h
+
+
+static int skein256_init(struct shash_desc *desc)
+{
+   return skein_256_init((struct skein_256_ctx *) shash_desc_ctx(desc),
+   SKEIN256_DIGEST_BIT_SIZE);
+}
+
+int skein256_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   return skein_256_update((struct skein_256_ctx *)shash_desc_ctx(desc),
+   data, len);
+}
+
+static int skein256_final(struct shash_desc *desc, u8 *out)
+{
+   return skein_256_final((struct skein_256_ctx *)shash_desc_ctx(desc),
+   out);
+}
+
+static int skein256_export(struct shash_desc *desc, void *out)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein256_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
+static int skein512_init(struct shash_desc *desc)
+{
+   return skein_512_init((struct skein_512_ctx *)shash_desc_ctx(desc),
+   SKEIN512_DIGEST_BIT_SIZE);
+}
+
+int skein512_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   return skein_512_update((struct skein_512_ctx *)shash_desc_ctx(desc),
+   data, len);
+}
+
+static int skein512_final(struct shash_desc *desc, u8 *out)
+{
+   return skein_512_final((struct skein_512_ctx *)shash_desc_ctx(desc),
+   out);
+}
+
+static int skein512_export(struct shash_desc *desc, void *out)
+{
+   struct skein_512_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein512_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_512_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
+static int skein1024_init(struct shash_desc *desc)
+{
+   return skein_1024_init((struct skein_1024_ctx *)shash_desc_ctx(desc),
+   SKEIN1024_DIGEST_BIT_SIZE);
+}
+
+int skein1024_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   return skein_1024_update((struct skein_1024_ctx *)shash_desc_ctx(desc),
+   data, len);
+}
+
+static int skein1024_final(struct shash_desc *desc, u8 *out)
+{
+   return skein_1024_final((struct skein_1024_ctx *)shash_desc_ctx(desc),
+   out);
+}
+
+static int skein1024_export(struct shash_desc *desc, void *out)
+{
+   struct skein_1024_ctx *sctx = shash_desc_ctx(desc

[PATCH v6 5/7] staging: skein: Inlines rotl_64

2014-10-24 Thread Eric Rost
Inlines the rotl_64 macro.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/skein_base.h | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index 9f10af9..0111fa4 100644
--- a/drivers/staging/skein/skein_base.h
+++ b/drivers/staging/skein/skein_base.h
@@ -33,10 +33,6 @@
 #define SKEIN512_DIGEST_BIT_SIZE 512
 #define SKEIN1024_DIGEST_BIT_SIZE 1024
 
-#ifndef rotl_64
-#define rotl_64(x, N)(((x)  (N)) | ((x)  (64-(N
-#endif
-
 /* 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_get64_lsb_first(dst64, src08, w_cnt) \
@@ -49,12 +45,12 @@ enum {
SKEIN_BAD_HASHLEN =  2
 };
 
-#define  SKEIN_MODIFIER_WORDS   (2) /* number of modifier (tweak) words */
+#define  SKEIN_MODIFIER_WORDS   2 /* number of modifier (tweak) words */
 
-#define  SKEIN_256_STATE_WORDS  (4)
-#define  SKEIN_512_STATE_WORDS  (8)
-#define  SKEIN_1024_STATE_WORDS (16)
-#define  SKEIN_MAX_STATE_WORDS (16)
+#define  SKEIN_256_STATE_WORDS  4
+#define  SKEIN_512_STATE_WORDS  8
+#define  SKEIN_1024_STATE_WORDS 16
+#define  SKEIN_MAX_STATE_WORDS 16
 
 #define  SKEIN_256_STATE_BYTES  (8*SKEIN_256_STATE_WORDS)
 #define  SKEIN_512_STATE_BYTES  (8*SKEIN_512_STATE_WORDS)
@@ -92,6 +88,11 @@ struct skein_1024_ctx { /* 1024-bit Skein hash context 
structure */
u8 b[SKEIN_1024_BLOCK_BYTES];   /* partial block buf (8-byte aligned) */
 };
 
+static inline int rotl_64(int x, int N)
+{
+   return (x  N) | (x  (64 - N));
+}
+
 /* Skein APIs for (incremental) straight hashing */
 int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len);
 int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len);
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 4/7] staging: skein: Adds Loadable Module Support

2014-10-24 Thread Eric Rost
Adds loadable module support to the Skein Hashing Algorithm driver.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Kconfig |  2 +-
 drivers/staging/skein/Makefile| 13 +++--
 drivers/staging/skein/skein_generic.c | 19 ++-
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index de8bdd7..012a823 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,5 +1,5 @@
 config CRYPTO_SKEIN
-   bool Skein digest algorithm
+   tristate Skein digest algorithm
depends on (X86 || UML_X86)  64BIT  CRYPTO
select CRYPTO_HASH
select CRYPTO_ALGAPI
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index d8177cc..b7f947f 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,9 +1,10 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \
- skein_api.o \
- skein_block.o \
- threefish_block.o \
- threefish_api.o \
- skein_generic.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein.o
+skein-y := skein_base.o \
+  skein_api.o \
+  skein_block.o \
+  threefish_block.o \
+  threefish_api.o \
+  skein_generic.o
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
index f2d6dfb..60d16b6 100644
--- a/drivers/staging/skein/skein_generic.c
+++ b/drivers/staging/skein/skein_generic.c
@@ -16,6 +16,7 @@
  */
 #include linux/types.h
 #include linux/init.h
+#include linux/module.h
 #include crypto/internal/hash.h
 #include skein_base.h
 
@@ -139,6 +140,7 @@ static struct shash_alg alg256 = {
.cra_driver_name=   skein,
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_256_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -156,6 +158,7 @@ static struct shash_alg alg512 = {
.cra_driver_name=   skein,
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_512_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -173,6 +176,7 @@ static struct shash_alg alg1024 = {
.cra_driver_name=   skein,
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_1024_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -196,4 +200,17 @@ out:
return -1;
 }
 
-device_initcall(skein_generic_init);
+static void __exit skein_generic_fini(void)
+{
+   crypto_unregister_shash(alg256);
+   crypto_unregister_shash(alg512);
+   crypto_unregister_shash(alg1024);
+}
+
+module_init(skein_generic_init);
+module_exit(skein_generic_fini);
+
+MODULE_LICENSE(GPL);
+MODULE_DESCRIPTION(Skein Hash Algorithm);
+
+MODULE_ALIAS(skein);
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 6/7] staging: skein: Removes unneeded #define

2014-10-24 Thread Eric Rost
Removes unneeded #define SKEIN_PORT_CODE since skein_port.h is
nonexistent.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/skein_base.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/skein/skein_base.c 
b/drivers/staging/skein/skein_base.c
index e0994ea..ebc436a 100644
--- a/drivers/staging/skein/skein_base.c
+++ b/drivers/staging/skein/skein_base.c
@@ -8,8 +8,6 @@
 **
 /
 
-#define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
-
 #include linux/string.h   /* get the memcpy/memset functions */
 #include linux/export.h
 #include skein_base.h /* get the Skein API definitions   */
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 7/7] staging: skein: Removes skein_debug include

2014-10-24 Thread Eric Rost
Removes skein_debug.h include since skein_debug.h is nonexistent.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/skein_base.h | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index 0111fa4..5b69e5a 100644
--- a/drivers/staging/skein/skein_base.h
+++ b/drivers/staging/skein/skein_base.h
@@ -15,10 +15,6 @@
 **
 ** The default note explains what happens when the switch is not defined.
 **
-**  SKEIN_DEBUG-- make callouts from inside Skein code
-**to examine/display intermediate values.
-**[default: no callouts (no overhead)]
-**
 **  SKEIN_ERR_CHECK-- how error checking is handled inside Skein
 **code. If not defined, most error checking
 **is disabled (for performance). Otherwise,
@@ -282,15 +278,12 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 
*hash_val);
 /*
 ** Internal Skein definitions for debugging and error checking
 **/
-#ifdef SKEIN_DEBUG /* examine/display intermediate values? */
-#include skein_debug.h
-#else   /* default is no callouts */
 #define skein_show_block(bits, ctx, x, blk_ptr, w_ptr, ks_event_ptr, 
ks_odd_ptr)
 #define skein_show_round(bits, ctx, r, x)
 #define skein_show_r_ptr(bits, ctx, r, x_ptr)
 #define skein_show_final(bits, ctx, cnt, out_ptr)
 #define skein_show_key(bits, ctx, key, key_bytes)
-#endif
+
 
 /* ignore all asserts, for performance */
 #define skein_assert_ret(x, ret_code)
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 3/3] staging: skein: Inlines rotl_64

2014-10-23 Thread Eric Rost
Inlines the macro definition rotl_64 to avoid bugs.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_base.h | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index 9f10af9..769bcb4 100644
--- a/drivers/staging/skein/skein_base.h
+++ b/drivers/staging/skein/skein_base.h
@@ -33,10 +33,6 @@
 #define SKEIN512_DIGEST_BIT_SIZE 512
 #define SKEIN1024_DIGEST_BIT_SIZE 1024
 
-#ifndef rotl_64
-#define rotl_64(x, N)(((x) << (N)) | ((x) >> (64-(N
-#endif
-
 /* 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_get64_lsb_first(dst64, src08, w_cnt) \
@@ -92,6 +88,11 @@ struct skein_1024_ctx { /* 1024-bit Skein hash context 
structure */
u8 b[SKEIN_1024_BLOCK_BYTES];   /* partial block buf (8-byte aligned) */
 };
 
+static inline int rotl_64(int x, int N) 
+{
+   return (x << N) | (x >> (64 - N));
+}
+
 /* Skein APIs for (incremental) "straight hashing" */
 int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len);
 int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len);
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 2/3] staging: skein: Adds Loadable Module Support

2014-10-23 Thread Eric Rost
Adds loadable module support for the Skein Hashing Algorithm.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Kconfig |  2 +-
 drivers/staging/skein/skein_generic.c | 19 ++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index de8bdd7..012a823 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,5 +1,5 @@
 config CRYPTO_SKEIN
-   bool "Skein digest algorithm"
+   tristate "Skein digest algorithm"
depends on (X86 || UML_X86) && 64BIT && CRYPTO
select CRYPTO_HASH
select CRYPTO_ALGAPI
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
index 815f9a4..3c9c6d0 100644
--- a/drivers/staging/skein/skein_generic.c
+++ b/drivers/staging/skein/skein_generic.c
@@ -16,6 +16,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include "skein_base.h"
 
@@ -142,6 +143,7 @@ static struct shash_alg alg256 = {
.cra_driver_name=   "skein",
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_256_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -159,6 +161,7 @@ static struct shash_alg alg512 = {
.cra_driver_name=   "skein",
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_512_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -176,6 +179,7 @@ static struct shash_alg alg1024 = {
.cra_driver_name=   "skein",
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_1024_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -191,4 +195,17 @@ static int __init skein_generic_init(void)
return 0;
 }
 
-device_initcall(skein_generic_init);
+static void __exit skein_generic_fini(void)
+{
+   crypto_unregister_shash();
+   crypto_unregister_shash();
+   crypto_unregister_shash();
+}
+
+module_init(skein_generic_init);
+module_exit(skein_generic_fini);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Skein Hash Algorithm");
+
+MODULE_ALIAS("skein");
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 1/3] staging: skein: Adds CryptoAPI Support

2014-10-23 Thread Eric Rost
Adds CryptoAPI support for skein256, skein512, and skein1024
algorithms. Also collapses threefish algorithm into skein.o and removes
Kconfig option for Threefish.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Kconfig |  22 +-
 drivers/staging/skein/Makefile|  13 +-
 drivers/staging/skein/skein.c | 883 -
 drivers/staging/skein/skein.h | 346 -
 drivers/staging/skein/skein_api.h |   2 +-
 drivers/staging/skein/skein_base.c| 884 ++
 drivers/staging/skein/skein_base.h| 351 ++
 drivers/staging/skein/skein_block.c   |   2 +-
 drivers/staging/skein/skein_block.h   |   2 +-
 drivers/staging/skein/skein_generic.c | 194 
 drivers/staging/skein/skein_iv.h  |   2 +-
 drivers/staging/skein/threefish_api.h |   2 +-
 12 files changed, 1444 insertions(+), 1259 deletions(-)
 delete mode 100644 drivers/staging/skein/skein.c
 delete mode 100644 drivers/staging/skein/skein.h
 create mode 100644 drivers/staging/skein/skein_base.c
 create mode 100644 drivers/staging/skein/skein_base.h
 create mode 100644 drivers/staging/skein/skein_generic.c

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index b9172bf..de8bdd7 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,8 +1,8 @@
 config CRYPTO_SKEIN
bool "Skein digest algorithm"
depends on (X86 || UML_X86) && 64BIT && CRYPTO
-   select CRYPTO_THREEFISH
select CRYPTO_HASH
+   select CRYPTO_ALGAPI
help
  Skein secure hash algorithm is one of 5 finalists from the NIST SHA3
  competition.
@@ -12,21 +12,5 @@ config CRYPTO_SKEIN
 
  http://www.skein-hash.info/sites/default/files/skein1.3.pdf
 
- for more information.  This module depends on the threefish block
- cipher module.
-
-config CRYPTO_THREEFISH
-   bool "Threefish tweakable block cipher"
-   depends on (X86 || UML_X86) && 64BIT && CRYPTO
-   select CRYPTO_ALGAPI
-   help
- Threefish cipher algorithm is the tweakable block cipher underneath
- the Skein family of secure hash algorithms.  Skein is one of 5
- finalists from the NIST SHA3 competition.
-
- Skein is optimized for modern, 64bit processors and is highly
- customizable.  See:
-
- http://www.skein-hash.info/sites/default/files/skein1.3.pdf
-
- for more information.
+ for more information. This module also contains the threefish block
+ cipher algorithm.
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index a14aadd..66c8799 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,9 +1,10 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
-   skein_api.o \
-   skein_block.o
-
-obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
- threefish_api.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein.o
+skein-y := skein_base.o \
+   skein_api.o \
+   skein_block.o \
+   threefish_block.o \
+   threefish_api.o \
+   skein_generic.o
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
deleted file mode 100644
index 8cc8358..000
--- a/drivers/staging/skein/skein.c
+++ /dev/null
@@ -1,883 +0,0 @@
-/***
-**
-** Implementation of the Skein hash function.
-**
-** Source code author: Doug Whiting, 2008.
-**
-** This algorithm and source code is released to the public domain.
-**
-/
-
-#define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
-
-#include/* get the memcpy/memset functions */
-#include "skein.h" /* get the Skein API definitions   */
-#include "skein_iv.h"/* get precomputed IVs */
-#include "skein_block.h"
-
-/*/
-/* 256-bit Skein */
-/*/
-
-/**/
-/* init the context for a straight hashing operation  */
-int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len)
-{
-   union {
-   u8 b[SKEIN_256_STATE_BYTES];
-   u64 w[SKEIN_256_STATE_WORDS];
-   } cfg;  /* config block */
-
-   skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
-   ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */
-
-   switch (hash_bit_len) { /* use pre-computed values, where available */
-   case  256:
-   me

[PATCH v4 0/3] staging: skein: Adds CryptoAPI and Module Support

2014-10-23 Thread Eric Rost
Adds CryptoAPI and Loadable Module support to the Skein Hash Algorithm.
Also inlines the rotl_64 macro.

Eric Rost (3):
  staging: skein: Adds CryptoAPI Support
  staging: skein: Adds Loadable Module Support
  staging: skein: Inlines rotl_64

 drivers/staging/skein/Kconfig |  24 +-
 drivers/staging/skein/Makefile|  13 +-
 drivers/staging/skein/skein.c | 883 -
 drivers/staging/skein/skein.h | 346 -
 drivers/staging/skein/skein_api.h |   2 +-
 drivers/staging/skein/skein_base.c| 884 ++
 drivers/staging/skein/skein_base.h| 352 ++
 drivers/staging/skein/skein_block.c   |   2 +-
 drivers/staging/skein/skein_block.h   |   2 +-
 drivers/staging/skein/skein_generic.c | 211 
 drivers/staging/skein/skein_iv.h  |   2 +-
 drivers/staging/skein/threefish_api.h |   2 +-
 12 files changed, 1463 insertions(+), 1260 deletions(-)
 delete mode 100644 drivers/staging/skein/skein.c
 delete mode 100644 drivers/staging/skein/skein.h
 create mode 100644 drivers/staging/skein/skein_base.c
 create mode 100644 drivers/staging/skein/skein_base.h
 create mode 100644 drivers/staging/skein/skein_generic.c

-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 2/2] staging: skein: Adds Loadable Module Support

2014-10-23 Thread Eric Rost
Adds loadable module support for the Skein Hashing Algorithm.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Kconfig |  2 +-
 drivers/staging/skein/skein_generic.c | 19 ++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index de8bdd7..012a823 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,5 +1,5 @@
 config CRYPTO_SKEIN
-   bool "Skein digest algorithm"
+   tristate "Skein digest algorithm"
depends on (X86 || UML_X86) && 64BIT && CRYPTO
select CRYPTO_HASH
select CRYPTO_ALGAPI
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
index 815f9a4..3c9c6d0 100644
--- a/drivers/staging/skein/skein_generic.c
+++ b/drivers/staging/skein/skein_generic.c
@@ -16,6 +16,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include "skein_base.h"
 
@@ -142,6 +143,7 @@ static struct shash_alg alg256 = {
.cra_driver_name=   "skein",
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_256_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -159,6 +161,7 @@ static struct shash_alg alg512 = {
.cra_driver_name=   "skein",
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_512_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -176,6 +179,7 @@ static struct shash_alg alg1024 = {
.cra_driver_name=   "skein",
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_1024_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -191,4 +195,17 @@ static int __init skein_generic_init(void)
return 0;
 }
 
-device_initcall(skein_generic_init);
+static void __exit skein_generic_fini(void)
+{
+   crypto_unregister_shash();
+   crypto_unregister_shash();
+   crypto_unregister_shash();
+}
+
+module_init(skein_generic_init);
+module_exit(skein_generic_fini);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Skein Hash Algorithm");
+
+MODULE_ALIAS("skein");
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 1/2] staging: skein: Adds CryptoAPI Support

2014-10-23 Thread Eric Rost
Adds CryptoAPI support for skein256, skein512, and skein1024
algorithms. Also collapses threefish algorithm into skein.o and removes
Kconfig option for Threefish.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Kconfig |  22 +-
 drivers/staging/skein/Makefile|  13 +-
 drivers/staging/skein/skein.c | 883 -
 drivers/staging/skein/skein.h | 346 -
 drivers/staging/skein/skein_api.h |   2 +-
 drivers/staging/skein/skein_base.c| 884 ++
 drivers/staging/skein/skein_base.h| 351 ++
 drivers/staging/skein/skein_block.c   |   2 +-
 drivers/staging/skein/skein_block.h   |   2 +-
 drivers/staging/skein/skein_generic.c | 194 
 drivers/staging/skein/skein_iv.h  |   2 +-
 drivers/staging/skein/threefish_api.h |   2 +-
 12 files changed, 1444 insertions(+), 1259 deletions(-)
 delete mode 100644 drivers/staging/skein/skein.c
 delete mode 100644 drivers/staging/skein/skein.h
 create mode 100644 drivers/staging/skein/skein_base.c
 create mode 100644 drivers/staging/skein/skein_base.h
 create mode 100644 drivers/staging/skein/skein_generic.c

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index b9172bf..de8bdd7 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,8 +1,8 @@
 config CRYPTO_SKEIN
bool "Skein digest algorithm"
depends on (X86 || UML_X86) && 64BIT && CRYPTO
-   select CRYPTO_THREEFISH
select CRYPTO_HASH
+   select CRYPTO_ALGAPI
help
  Skein secure hash algorithm is one of 5 finalists from the NIST SHA3
  competition.
@@ -12,21 +12,5 @@ config CRYPTO_SKEIN
 
  http://www.skein-hash.info/sites/default/files/skein1.3.pdf
 
- for more information.  This module depends on the threefish block
- cipher module.
-
-config CRYPTO_THREEFISH
-   bool "Threefish tweakable block cipher"
-   depends on (X86 || UML_X86) && 64BIT && CRYPTO
-   select CRYPTO_ALGAPI
-   help
- Threefish cipher algorithm is the tweakable block cipher underneath
- the Skein family of secure hash algorithms.  Skein is one of 5
- finalists from the NIST SHA3 competition.
-
- Skein is optimized for modern, 64bit processors and is highly
- customizable.  See:
-
- http://www.skein-hash.info/sites/default/files/skein1.3.pdf
-
- for more information.
+ for more information. This module also contains the threefish block
+ cipher algorithm.
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index a14aadd..66c8799 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,9 +1,10 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
-   skein_api.o \
-   skein_block.o
-
-obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
- threefish_api.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein.o
+skein-y := skein_base.o \
+   skein_api.o \
+   skein_block.o \
+   threefish_block.o \
+   threefish_api.o \
+   skein_generic.o
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
deleted file mode 100644
index 8cc8358..000
--- a/drivers/staging/skein/skein.c
+++ /dev/null
@@ -1,883 +0,0 @@
-/***
-**
-** Implementation of the Skein hash function.
-**
-** Source code author: Doug Whiting, 2008.
-**
-** This algorithm and source code is released to the public domain.
-**
-/
-
-#define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
-
-#include/* get the memcpy/memset functions */
-#include "skein.h" /* get the Skein API definitions   */
-#include "skein_iv.h"/* get precomputed IVs */
-#include "skein_block.h"
-
-/*/
-/* 256-bit Skein */
-/*/
-
-/**/
-/* init the context for a straight hashing operation  */
-int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len)
-{
-   union {
-   u8 b[SKEIN_256_STATE_BYTES];
-   u64 w[SKEIN_256_STATE_WORDS];
-   } cfg;  /* config block */
-
-   skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
-   ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */
-
-   switch (hash_bit_len) { /* use pre-computed values, where available */
-   case  256:
-   me

[PATCH v3 0/2] staging: skein: Adds CryptoAPI and Module Support

2014-10-23 Thread Eric Rost
Adds CryptoAPI and Loadable Module support to the Skein Hashing
Algorithm.

Eric Rost (2):
  staging: skein: Adds CryptoAPI Support
  staging: skein: Adds Loadable Module Support

 drivers/staging/skein/Kconfig |  24 +-
 drivers/staging/skein/Makefile|  13 +-
 drivers/staging/skein/skein.c | 883 -
 drivers/staging/skein/skein.h | 346 -
 drivers/staging/skein/skein_api.h |   2 +-
 drivers/staging/skein/skein_base.c| 884 ++
 drivers/staging/skein/skein_base.h| 351 ++
 drivers/staging/skein/skein_block.c   |   2 +-
 drivers/staging/skein/skein_block.h   |   2 +-
 drivers/staging/skein/skein_generic.c | 211 
 drivers/staging/skein/skein_iv.h  |   2 +-
 drivers/staging/skein/threefish_api.h |   2 +-
 12 files changed, 1462 insertions(+), 1260 deletions(-)
 delete mode 100644 drivers/staging/skein/skein.c
 delete mode 100644 drivers/staging/skein/skein.h
 create mode 100644 drivers/staging/skein/skein_base.c
 create mode 100644 drivers/staging/skein/skein_base.h
 create mode 100644 drivers/staging/skein/skein_generic.c

-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 0/2] staging: skein: Adds CryptoAPI and Module Support

2014-10-23 Thread Eric Rost
Adds CryptoAPI and Loadable Module support to the Skein Hashing
Algorithm.

Eric Rost (2):
  staging: skein: Adds CryptoAPI Support
  staging: skein: Adds Loadable Module Support

 drivers/staging/skein/Kconfig |  24 +-
 drivers/staging/skein/Makefile|  13 +-
 drivers/staging/skein/skein.c | 883 -
 drivers/staging/skein/skein.h | 346 -
 drivers/staging/skein/skein_api.h |   2 +-
 drivers/staging/skein/skein_base.c| 884 ++
 drivers/staging/skein/skein_base.h| 351 ++
 drivers/staging/skein/skein_block.c   |   2 +-
 drivers/staging/skein/skein_block.h   |   2 +-
 drivers/staging/skein/skein_generic.c | 211 
 drivers/staging/skein/skein_iv.h  |   2 +-
 drivers/staging/skein/threefish_api.h |   2 +-
 12 files changed, 1462 insertions(+), 1260 deletions(-)
 delete mode 100644 drivers/staging/skein/skein.c
 delete mode 100644 drivers/staging/skein/skein.h
 create mode 100644 drivers/staging/skein/skein_base.c
 create mode 100644 drivers/staging/skein/skein_base.h
 create mode 100644 drivers/staging/skein/skein_generic.c

-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 1/2] staging: skein: Adds CryptoAPI Support

2014-10-23 Thread Eric Rost
Adds CryptoAPI support for skein256, skein512, and skein1024
algorithms. Also collapses threefish algorithm into skein.o and removes
Kconfig option for Threefish.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Kconfig |  22 +-
 drivers/staging/skein/Makefile|  13 +-
 drivers/staging/skein/skein.c | 883 -
 drivers/staging/skein/skein.h | 346 -
 drivers/staging/skein/skein_api.h |   2 +-
 drivers/staging/skein/skein_base.c| 884 ++
 drivers/staging/skein/skein_base.h| 351 ++
 drivers/staging/skein/skein_block.c   |   2 +-
 drivers/staging/skein/skein_block.h   |   2 +-
 drivers/staging/skein/skein_generic.c | 194 
 drivers/staging/skein/skein_iv.h  |   2 +-
 drivers/staging/skein/threefish_api.h |   2 +-
 12 files changed, 1444 insertions(+), 1259 deletions(-)
 delete mode 100644 drivers/staging/skein/skein.c
 delete mode 100644 drivers/staging/skein/skein.h
 create mode 100644 drivers/staging/skein/skein_base.c
 create mode 100644 drivers/staging/skein/skein_base.h
 create mode 100644 drivers/staging/skein/skein_generic.c

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index b9172bf..de8bdd7 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,8 +1,8 @@
 config CRYPTO_SKEIN
bool Skein digest algorithm
depends on (X86 || UML_X86)  64BIT  CRYPTO
-   select CRYPTO_THREEFISH
select CRYPTO_HASH
+   select CRYPTO_ALGAPI
help
  Skein secure hash algorithm is one of 5 finalists from the NIST SHA3
  competition.
@@ -12,21 +12,5 @@ config CRYPTO_SKEIN
 
  http://www.skein-hash.info/sites/default/files/skein1.3.pdf
 
- for more information.  This module depends on the threefish block
- cipher module.
-
-config CRYPTO_THREEFISH
-   bool Threefish tweakable block cipher
-   depends on (X86 || UML_X86)  64BIT  CRYPTO
-   select CRYPTO_ALGAPI
-   help
- Threefish cipher algorithm is the tweakable block cipher underneath
- the Skein family of secure hash algorithms.  Skein is one of 5
- finalists from the NIST SHA3 competition.
-
- Skein is optimized for modern, 64bit processors and is highly
- customizable.  See:
-
- http://www.skein-hash.info/sites/default/files/skein1.3.pdf
-
- for more information.
+ for more information. This module also contains the threefish block
+ cipher algorithm.
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index a14aadd..66c8799 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,9 +1,10 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
-   skein_api.o \
-   skein_block.o
-
-obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
- threefish_api.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein.o
+skein-y := skein_base.o \
+   skein_api.o \
+   skein_block.o \
+   threefish_block.o \
+   threefish_api.o \
+   skein_generic.o
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
deleted file mode 100644
index 8cc8358..000
--- a/drivers/staging/skein/skein.c
+++ /dev/null
@@ -1,883 +0,0 @@
-/***
-**
-** Implementation of the Skein hash function.
-**
-** Source code author: Doug Whiting, 2008.
-**
-** This algorithm and source code is released to the public domain.
-**
-/
-
-#define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
-
-#include linux/string.h   /* get the memcpy/memset functions */
-#include skein.h /* get the Skein API definitions   */
-#include skein_iv.h/* get precomputed IVs */
-#include skein_block.h
-
-/*/
-/* 256-bit Skein */
-/*/
-
-/**/
-/* init the context for a straight hashing operation  */
-int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len)
-{
-   union {
-   u8 b[SKEIN_256_STATE_BYTES];
-   u64 w[SKEIN_256_STATE_WORDS];
-   } cfg;  /* config block */
-
-   skein_assert_ret(hash_bit_len  0, SKEIN_BAD_HASHLEN);
-   ctx-h.hash_bit_len = hash_bit_len; /* output hash bit count */
-
-   switch (hash_bit_len) { /* use pre-computed values, where available */
-   case  256:
-   memcpy(ctx-x, SKEIN_256_IV_256, sizeof(ctx-x));
-   break

[PATCH v3 2/2] staging: skein: Adds Loadable Module Support

2014-10-23 Thread Eric Rost
Adds loadable module support for the Skein Hashing Algorithm.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Kconfig |  2 +-
 drivers/staging/skein/skein_generic.c | 19 ++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index de8bdd7..012a823 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,5 +1,5 @@
 config CRYPTO_SKEIN
-   bool Skein digest algorithm
+   tristate Skein digest algorithm
depends on (X86 || UML_X86)  64BIT  CRYPTO
select CRYPTO_HASH
select CRYPTO_ALGAPI
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
index 815f9a4..3c9c6d0 100644
--- a/drivers/staging/skein/skein_generic.c
+++ b/drivers/staging/skein/skein_generic.c
@@ -16,6 +16,7 @@
  */
 #include linux/types.h
 #include linux/init.h
+#include linux/module.h
 #include crypto/internal/hash.h
 #include skein_base.h
 
@@ -142,6 +143,7 @@ static struct shash_alg alg256 = {
.cra_driver_name=   skein,
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_256_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -159,6 +161,7 @@ static struct shash_alg alg512 = {
.cra_driver_name=   skein,
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_512_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -176,6 +179,7 @@ static struct shash_alg alg1024 = {
.cra_driver_name=   skein,
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_1024_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -191,4 +195,17 @@ static int __init skein_generic_init(void)
return 0;
 }
 
-device_initcall(skein_generic_init);
+static void __exit skein_generic_fini(void)
+{
+   crypto_unregister_shash(alg256);
+   crypto_unregister_shash(alg512);
+   crypto_unregister_shash(alg1024);
+}
+
+module_init(skein_generic_init);
+module_exit(skein_generic_fini);
+
+MODULE_LICENSE(GPL);
+MODULE_DESCRIPTION(Skein Hash Algorithm);
+
+MODULE_ALIAS(skein);
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 0/3] staging: skein: Adds CryptoAPI and Module Support

2014-10-23 Thread Eric Rost
Adds CryptoAPI and Loadable Module support to the Skein Hash Algorithm.
Also inlines the rotl_64 macro.

Eric Rost (3):
  staging: skein: Adds CryptoAPI Support
  staging: skein: Adds Loadable Module Support
  staging: skein: Inlines rotl_64

 drivers/staging/skein/Kconfig |  24 +-
 drivers/staging/skein/Makefile|  13 +-
 drivers/staging/skein/skein.c | 883 -
 drivers/staging/skein/skein.h | 346 -
 drivers/staging/skein/skein_api.h |   2 +-
 drivers/staging/skein/skein_base.c| 884 ++
 drivers/staging/skein/skein_base.h| 352 ++
 drivers/staging/skein/skein_block.c   |   2 +-
 drivers/staging/skein/skein_block.h   |   2 +-
 drivers/staging/skein/skein_generic.c | 211 
 drivers/staging/skein/skein_iv.h  |   2 +-
 drivers/staging/skein/threefish_api.h |   2 +-
 12 files changed, 1463 insertions(+), 1260 deletions(-)
 delete mode 100644 drivers/staging/skein/skein.c
 delete mode 100644 drivers/staging/skein/skein.h
 create mode 100644 drivers/staging/skein/skein_base.c
 create mode 100644 drivers/staging/skein/skein_base.h
 create mode 100644 drivers/staging/skein/skein_generic.c

-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 1/3] staging: skein: Adds CryptoAPI Support

2014-10-23 Thread Eric Rost
Adds CryptoAPI support for skein256, skein512, and skein1024
algorithms. Also collapses threefish algorithm into skein.o and removes
Kconfig option for Threefish.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Kconfig |  22 +-
 drivers/staging/skein/Makefile|  13 +-
 drivers/staging/skein/skein.c | 883 -
 drivers/staging/skein/skein.h | 346 -
 drivers/staging/skein/skein_api.h |   2 +-
 drivers/staging/skein/skein_base.c| 884 ++
 drivers/staging/skein/skein_base.h| 351 ++
 drivers/staging/skein/skein_block.c   |   2 +-
 drivers/staging/skein/skein_block.h   |   2 +-
 drivers/staging/skein/skein_generic.c | 194 
 drivers/staging/skein/skein_iv.h  |   2 +-
 drivers/staging/skein/threefish_api.h |   2 +-
 12 files changed, 1444 insertions(+), 1259 deletions(-)
 delete mode 100644 drivers/staging/skein/skein.c
 delete mode 100644 drivers/staging/skein/skein.h
 create mode 100644 drivers/staging/skein/skein_base.c
 create mode 100644 drivers/staging/skein/skein_base.h
 create mode 100644 drivers/staging/skein/skein_generic.c

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index b9172bf..de8bdd7 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,8 +1,8 @@
 config CRYPTO_SKEIN
bool Skein digest algorithm
depends on (X86 || UML_X86)  64BIT  CRYPTO
-   select CRYPTO_THREEFISH
select CRYPTO_HASH
+   select CRYPTO_ALGAPI
help
  Skein secure hash algorithm is one of 5 finalists from the NIST SHA3
  competition.
@@ -12,21 +12,5 @@ config CRYPTO_SKEIN
 
  http://www.skein-hash.info/sites/default/files/skein1.3.pdf
 
- for more information.  This module depends on the threefish block
- cipher module.
-
-config CRYPTO_THREEFISH
-   bool Threefish tweakable block cipher
-   depends on (X86 || UML_X86)  64BIT  CRYPTO
-   select CRYPTO_ALGAPI
-   help
- Threefish cipher algorithm is the tweakable block cipher underneath
- the Skein family of secure hash algorithms.  Skein is one of 5
- finalists from the NIST SHA3 competition.
-
- Skein is optimized for modern, 64bit processors and is highly
- customizable.  See:
-
- http://www.skein-hash.info/sites/default/files/skein1.3.pdf
-
- for more information.
+ for more information. This module also contains the threefish block
+ cipher algorithm.
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index a14aadd..66c8799 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,9 +1,10 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
-   skein_api.o \
-   skein_block.o
-
-obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
- threefish_api.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein.o
+skein-y := skein_base.o \
+   skein_api.o \
+   skein_block.o \
+   threefish_block.o \
+   threefish_api.o \
+   skein_generic.o
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
deleted file mode 100644
index 8cc8358..000
--- a/drivers/staging/skein/skein.c
+++ /dev/null
@@ -1,883 +0,0 @@
-/***
-**
-** Implementation of the Skein hash function.
-**
-** Source code author: Doug Whiting, 2008.
-**
-** This algorithm and source code is released to the public domain.
-**
-/
-
-#define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
-
-#include linux/string.h   /* get the memcpy/memset functions */
-#include skein.h /* get the Skein API definitions   */
-#include skein_iv.h/* get precomputed IVs */
-#include skein_block.h
-
-/*/
-/* 256-bit Skein */
-/*/
-
-/**/
-/* init the context for a straight hashing operation  */
-int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len)
-{
-   union {
-   u8 b[SKEIN_256_STATE_BYTES];
-   u64 w[SKEIN_256_STATE_WORDS];
-   } cfg;  /* config block */
-
-   skein_assert_ret(hash_bit_len  0, SKEIN_BAD_HASHLEN);
-   ctx-h.hash_bit_len = hash_bit_len; /* output hash bit count */
-
-   switch (hash_bit_len) { /* use pre-computed values, where available */
-   case  256:
-   memcpy(ctx-x, SKEIN_256_IV_256, sizeof(ctx-x));
-   break

[PATCH v4 2/3] staging: skein: Adds Loadable Module Support

2014-10-23 Thread Eric Rost
Adds loadable module support for the Skein Hashing Algorithm.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Kconfig |  2 +-
 drivers/staging/skein/skein_generic.c | 19 ++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index de8bdd7..012a823 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,5 +1,5 @@
 config CRYPTO_SKEIN
-   bool Skein digest algorithm
+   tristate Skein digest algorithm
depends on (X86 || UML_X86)  64BIT  CRYPTO
select CRYPTO_HASH
select CRYPTO_ALGAPI
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
index 815f9a4..3c9c6d0 100644
--- a/drivers/staging/skein/skein_generic.c
+++ b/drivers/staging/skein/skein_generic.c
@@ -16,6 +16,7 @@
  */
 #include linux/types.h
 #include linux/init.h
+#include linux/module.h
 #include crypto/internal/hash.h
 #include skein_base.h
 
@@ -142,6 +143,7 @@ static struct shash_alg alg256 = {
.cra_driver_name=   skein,
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_256_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -159,6 +161,7 @@ static struct shash_alg alg512 = {
.cra_driver_name=   skein,
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_512_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -176,6 +179,7 @@ static struct shash_alg alg1024 = {
.cra_driver_name=   skein,
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_1024_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -191,4 +195,17 @@ static int __init skein_generic_init(void)
return 0;
 }
 
-device_initcall(skein_generic_init);
+static void __exit skein_generic_fini(void)
+{
+   crypto_unregister_shash(alg256);
+   crypto_unregister_shash(alg512);
+   crypto_unregister_shash(alg1024);
+}
+
+module_init(skein_generic_init);
+module_exit(skein_generic_fini);
+
+MODULE_LICENSE(GPL);
+MODULE_DESCRIPTION(Skein Hash Algorithm);
+
+MODULE_ALIAS(skein);
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 3/3] staging: skein: Inlines rotl_64

2014-10-23 Thread Eric Rost
Inlines the macro definition rotl_64 to avoid bugs.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/skein_base.h | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/skein/skein_base.h 
b/drivers/staging/skein/skein_base.h
index 9f10af9..769bcb4 100644
--- a/drivers/staging/skein/skein_base.h
+++ b/drivers/staging/skein/skein_base.h
@@ -33,10 +33,6 @@
 #define SKEIN512_DIGEST_BIT_SIZE 512
 #define SKEIN1024_DIGEST_BIT_SIZE 1024
 
-#ifndef rotl_64
-#define rotl_64(x, N)(((x)  (N)) | ((x)  (64-(N
-#endif
-
 /* 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_get64_lsb_first(dst64, src08, w_cnt) \
@@ -92,6 +88,11 @@ struct skein_1024_ctx { /* 1024-bit Skein hash context 
structure */
u8 b[SKEIN_1024_BLOCK_BYTES];   /* partial block buf (8-byte aligned) */
 };
 
+static inline int rotl_64(int x, int N) 
+{
+   return (x  N) | (x  (64 - N));
+}
+
 /* Skein APIs for (incremental) straight hashing */
 int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len);
 int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len);
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 2/2] staging: skein: Add Loadable Module Support

2014-10-22 Thread Eric Rost
Adds loadable module support for skein_mod, containing skein256,
skein512, and skein1024 algorithms.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Kconfig |   2 +-
 drivers/staging/skein/skein_generic.c | 122 ++
 2 files changed, 123 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index de8bdd7..012a823 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,5 +1,5 @@
 config CRYPTO_SKEIN
-   bool "Skein digest algorithm"
+   tristate "Skein digest algorithm"
depends on (X86 || UML_X86) && 64BIT && CRYPTO
select CRYPTO_HASH
select CRYPTO_ALGAPI
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
index 14cc5bd..43e3cdf 100644
--- a/drivers/staging/skein/skein_generic.c
+++ b/drivers/staging/skein/skein_generic.c
@@ -16,6 +16,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -50,6 +51,22 @@ static int skein256_final(struct shash_desc *desc, u8 *out)
return ret;
 }
 
+static int skein256_export(struct shash_desc *desc, void *out)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein256_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
 static int skein512_init(struct shash_desc *desc)
 {
struct skein_512_ctx *sctx = shash_desc_ctx(desc);
@@ -78,6 +95,22 @@ static int skein512_final(struct shash_desc *desc, u8 *out)
return ret;
 }
 
+static int skein512_export(struct shash_desc *desc, void *out)
+{
+   struct skein_512_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein512_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_512_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
 static int skein1024_init(struct shash_desc *desc)
 {
struct skein_1024_ctx *sctx = shash_desc_ctx(desc);
@@ -106,4 +139,93 @@ static int skein1024_final(struct shash_desc *desc, u8 
*out)
return ret;
 }
 
+static int skein1024_export(struct shash_desc *desc, void *out)
+{
+   struct skein_1024_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein1024_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_1024_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
+static struct shash_alg alg256 = {
+   .digestsize =   (SKEIN256_DIGEST_BIT_SIZE / 8),
+   .init   =   skein256_init,
+   .update =   skein256_update,
+   .final  =   skein256_final,
+   .export =   skein256_export,
+   .import =   skein256_import,
+   .descsize   =   sizeof(struct skein_256_ctx),
+   .statesize  =   sizeof(struct skein_256_ctx),
+   .base   =   {
+   .cra_name   =   "skein256",
+   .cra_driver_name=   "skein-mod",
+   .cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
+   .cra_blocksize  =   SKEIN_256_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
+   }
+};
+
+static struct shash_alg alg512 = {
+   .digestsize =   (SKEIN512_DIGEST_BIT_SIZE / 8),
+   .init   =   skein512_init,
+   .update =   skein512_update,
+   .final  =   skein512_final,
+   .export =   skein512_export,
+   .import =   skein512_import,
+   .descsize   =   sizeof(struct skein_512_ctx),
+   .statesize  =   sizeof(struct skein_512_ctx),
+   .base   =   {
+   .cra_name   =   "skein512",
+   .cra_driver_name=   "skein-mod",
+   .cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
+   .cra_blocksize  =   SKEIN_512_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
+   }
+};
+
+static struct shash_alg alg1024 = {
+   .digestsize =   (SKEIN1024_DIGEST_BIT_SIZE / 8),
+   .init   =   skein1024_init,
+   .update =   skein1024_update,
+   .final  =   skein1024_final,
+   .export =   skein1024_export,
+   .import =   skein1024_import,
+   .descsize   =   sizeof(struct skein_1024_ctx),
+   .statesize  =   sizeof(struct skein_1024_ctx),
+   .base   

[PATCH v2 1/2] staging: skein: Add Crypto API support

2014-10-22 Thread Eric Rost
Adds crypto API support for the skein module. Also collapses the
threefish module into the skein module.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Kconfig |  22 +--
 drivers/staging/skein/Makefile|  13 ++--
 drivers/staging/skein/skein.c |   1 +
 drivers/staging/skein/skein.h |   5 ++
 drivers/staging/skein/skein_generic.c | 109 ++
 5 files changed, 125 insertions(+), 25 deletions(-)
 create mode 100644 drivers/staging/skein/skein_generic.c

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index b9172bf..de8bdd7 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,8 +1,8 @@
 config CRYPTO_SKEIN
bool "Skein digest algorithm"
depends on (X86 || UML_X86) && 64BIT && CRYPTO
-   select CRYPTO_THREEFISH
select CRYPTO_HASH
+   select CRYPTO_ALGAPI
help
  Skein secure hash algorithm is one of 5 finalists from the NIST SHA3
  competition.
@@ -12,21 +12,5 @@ config CRYPTO_SKEIN
 
  http://www.skein-hash.info/sites/default/files/skein1.3.pdf
 
- for more information.  This module depends on the threefish block
- cipher module.
-
-config CRYPTO_THREEFISH
-   bool "Threefish tweakable block cipher"
-   depends on (X86 || UML_X86) && 64BIT && CRYPTO
-   select CRYPTO_ALGAPI
-   help
- Threefish cipher algorithm is the tweakable block cipher underneath
- the Skein family of secure hash algorithms.  Skein is one of 5
- finalists from the NIST SHA3 competition.
-
- Skein is optimized for modern, 64bit processors and is highly
- customizable.  See:
-
- http://www.skein-hash.info/sites/default/files/skein1.3.pdf
-
- for more information.
+ for more information. This module also contains the threefish block
+ cipher algorithm.
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index a14aadd..382b041 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,9 +1,10 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
-   skein_api.o \
-   skein_block.o
-
-obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
- threefish_api.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein_mod.o
+skein_mod-y := skein.o \
+   skein_api.o \
+   skein_block.o \
+   threefish_block.o \
+   threefish_api.o \
+   skein_generic.o
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
index 8cc8358..1c3933d 100644
--- a/drivers/staging/skein/skein.c
+++ b/drivers/staging/skein/skein.c
@@ -11,6 +11,7 @@
 #define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
 
 #include/* get the memcpy/memset functions */
+#include 
 #include "skein.h" /* get the Skein API definitions   */
 #include "skein_iv.h"/* get precomputed IVs */
 #include "skein_block.h"
diff --git a/drivers/staging/skein/skein.h b/drivers/staging/skein/skein.h
index e6669f1..79fac00 100644
--- a/drivers/staging/skein/skein.h
+++ b/drivers/staging/skein/skein.h
@@ -28,6 +28,11 @@
 **
 ***/
 
+/*Skein digest sizes for crypto api*/
+#define SKEIN256_DIGEST_BIT_SIZE (256)
+#define SKEIN512_DIGEST_BIT_SIZE (512)
+#define SKEIN1024_DIGEST_BIT_SIZE (1024)
+
 #ifndef rotl_64
 #define rotl_64(x, N)(((x) << (N)) | ((x) >> (64-(N
 #endif
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
new file mode 100644
index 000..14cc5bd
--- /dev/null
+++ b/drivers/staging/skein/skein_generic.c
@@ -0,0 +1,109 @@
+/*
+ * Cryptographic API.
+ *
+ * Skein256 Hash Algorithm.
+ *
+ * Derived from cryptoapi implementation, adapted for in-place
+ * scatterlist interface.
+ *
+ * Copyright (c) Eric Rost 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "skein.h"
+#include 
+
+static int skein256_init(struct shash_desc *desc)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+   int ret = skein_256_init(sctx, SKEIN256_DIGEST_BIT_SIZE);
+
+   return ret;
+}
+
+int skein256_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+   size_t hbl = (size_t) len;
+   int ret = skein_256_update(sctx, data, hbl);
+
+   return ret;
+}
+EXPORT_SYMBOL(skein256_u

[PATCH v2 0/2] staging: skein: Add Crypto API and Loadable Module support

2014-10-22 Thread Eric Rost
This patchset adds crypto api support and loadable module support to the
skein driver.

Eric Rost (2):
  staging: skein: Add Crypto API support
  staging: skein: Add Loadable Module Support

 drivers/staging/skein/Kconfig |  24 +---
 drivers/staging/skein/Makefile|  13 +-
 drivers/staging/skein/skein.c |   1 +
 drivers/staging/skein/skein.h |   5 +
 drivers/staging/skein/skein_generic.c | 231 ++
 5 files changed, 248 insertions(+), 26 deletions(-)
 create mode 100644 drivers/staging/skein/skein_generic.c

-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] staging: skein: Loadable Module Support

2014-10-22 Thread Eric Rost
On Wed, 2014-10-22 at 11:10 -0400, Jason Cooper wrote:

> 
> If you don't mind, could you split this
> patch in two?  The first integrating into the crypto API (such that
> userspace could call into it), and the second enabling loadable module
> support?
> 

Will do!

> > Signed-off-by: Eric Rost 
> > ---
> >  drivers/staging/skein/Kconfig | 12 +
> >  drivers/staging/skein/Makefile|  6 +++
> >  drivers/staging/skein/skein.c | 11 +++-
> >  drivers/staging/skein/skein.h |  6 +++
> >  drivers/staging/skein/skein1024_generic.c | 88 
> > +++
> >  drivers/staging/skein/skein256_generic.c  | 88 
> > +++
> >  drivers/staging/skein/skein512_generic.c  | 88 
> > +++
> >  7 files changed, 298 insertions(+), 1 deletion(-)
> >  create mode 100644 drivers/staging/skein/skein1024_generic.c
> >  create mode 100644 drivers/staging/skein/skein256_generic.c
> >  create mode 100644 drivers/staging/skein/skein512_generic.c
> > 
> > diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
> > index b9172bf..e260111 100644
> > --- a/drivers/staging/skein/Kconfig
> > +++ b/drivers/staging/skein/Kconfig
> > @@ -15,6 +15,18 @@ config CRYPTO_SKEIN
> >   for more information.  This module depends on the threefish block
> >   cipher module.
> >  
> > +config CRYPTO_SKEIN_256
> > +   tristate "Skein256 driver"
> > +   select CRYPTO_SKEIN
> > +
> > +config CRYPTO_SKEIN_512
> > +   tristate "Skein512 driver"
> > +   select CRYPTO_SKEIN
> > +
> > +config CRYPTO_SKEIN_1024
> > +   tristate "Skein1024 driver"
> > +   select CRYPTO_SKEIN
> > +
> >  config CRYPTO_THREEFISH
> > bool "Threefish tweakable block cipher"
> > depends on (X86 || UML_X86) && 64BIT && CRYPTO
> > diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
> > index a14aadd..1be01fe 100644
> > --- a/drivers/staging/skein/Makefile
> > +++ b/drivers/staging/skein/Makefile
> > @@ -5,5 +5,11 @@ obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
> > skein_api.o \
> > skein_block.o
> >  
> > +obj-$(CONFIG_CRYPTO_SKEIN_256) += skein256_generic.o
> > +
> > +obj-$(CONFIG_CRYPTO_SKEIN_512) += skein512_generic.o
> > +
> > +obj-$(CONFIG_CRYPTO_SKEIN_1024) += skein1024_generic.o
> > +
> 
> This isn't really doing what we want.  You'll have loadable modules, but
> the actual code will still be built into the kernel.
> 
> >  obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
> >   threefish_api.o
> > diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
> > index 8cc8358..2138e22 100644
> > --- a/drivers/staging/skein/skein.c
> > +++ b/drivers/staging/skein/skein.c
> > @@ -11,6 +11,7 @@
> >  #define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
> >  
> >  #include/* get the memcpy/memset functions */
> > +#include 
> >  #include "skein.h" /* get the Skein API definitions   */
> >  #include "skein_iv.h"/* get precomputed IVs */
> >  #include "skein_block.h"
> > @@ -73,6 +74,7 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t 
> > hash_bit_len)
> >  
> > return SKEIN_SUCCESS;
> >  }
> > +EXPORT_SYMBOL(skein_256_init);
> 
> Once the above is corrected, these shouldn't be necessary.
> 
Will give it a whirl, I was having problems with undefined symbols at
linking even when I was building it as one module, but it may have been
something else
> > --- a/drivers/staging/skein/skein.h
> > +++ b/drivers/staging/skein/skein.h
> > @@ -26,8 +26,14 @@
> >  **0: use assert()  to flag errors
> >  **1: return SKEIN_FAIL to flag errors
> >  **
> > +**
> >  
> > ***/
> 
> superfluous whitespace addition?
> 
Remnants of a backed out change... will fix.

> > +
> > +static struct shash_alg alg = {
> > +   .digestsize =   (SKEIN1024_DIGEST_SIZE / 8),
> > +   .init   =   skein1024_init,
> > +   .update =   crypto_skein1024_update,
> 
> why is this function name different from the other two?

It was inherited from the sha1 file I based this off of, I can make them

[PATCH v2 0/2] staging: skein: Add Crypto API and Loadable Module support

2014-10-22 Thread Eric Rost
This patchset adds crypto api support and loadable module support to the
skein driver.

Eric Rost (2):
  staging: skein: Add Crypto API support
  staging: skein: Add Loadable Module Support

 drivers/staging/skein/Kconfig |  24 +---
 drivers/staging/skein/Makefile|  13 +-
 drivers/staging/skein/skein.c |   1 +
 drivers/staging/skein/skein.h |   5 +
 drivers/staging/skein/skein_generic.c | 231 ++
 5 files changed, 248 insertions(+), 26 deletions(-)
 create mode 100644 drivers/staging/skein/skein_generic.c

-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 1/2] staging: skein: Add Crypto API support

2014-10-22 Thread Eric Rost
Adds crypto API support for the skein module. Also collapses the
threefish module into the skein module.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Kconfig |  22 +--
 drivers/staging/skein/Makefile|  13 ++--
 drivers/staging/skein/skein.c |   1 +
 drivers/staging/skein/skein.h |   5 ++
 drivers/staging/skein/skein_generic.c | 109 ++
 5 files changed, 125 insertions(+), 25 deletions(-)
 create mode 100644 drivers/staging/skein/skein_generic.c

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index b9172bf..de8bdd7 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,8 +1,8 @@
 config CRYPTO_SKEIN
bool Skein digest algorithm
depends on (X86 || UML_X86)  64BIT  CRYPTO
-   select CRYPTO_THREEFISH
select CRYPTO_HASH
+   select CRYPTO_ALGAPI
help
  Skein secure hash algorithm is one of 5 finalists from the NIST SHA3
  competition.
@@ -12,21 +12,5 @@ config CRYPTO_SKEIN
 
  http://www.skein-hash.info/sites/default/files/skein1.3.pdf
 
- for more information.  This module depends on the threefish block
- cipher module.
-
-config CRYPTO_THREEFISH
-   bool Threefish tweakable block cipher
-   depends on (X86 || UML_X86)  64BIT  CRYPTO
-   select CRYPTO_ALGAPI
-   help
- Threefish cipher algorithm is the tweakable block cipher underneath
- the Skein family of secure hash algorithms.  Skein is one of 5
- finalists from the NIST SHA3 competition.
-
- Skein is optimized for modern, 64bit processors and is highly
- customizable.  See:
-
- http://www.skein-hash.info/sites/default/files/skein1.3.pdf
-
- for more information.
+ for more information. This module also contains the threefish block
+ cipher algorithm.
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index a14aadd..382b041 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,9 +1,10 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
-   skein_api.o \
-   skein_block.o
-
-obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
- threefish_api.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein_mod.o
+skein_mod-y := skein.o \
+   skein_api.o \
+   skein_block.o \
+   threefish_block.o \
+   threefish_api.o \
+   skein_generic.o
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
index 8cc8358..1c3933d 100644
--- a/drivers/staging/skein/skein.c
+++ b/drivers/staging/skein/skein.c
@@ -11,6 +11,7 @@
 #define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
 
 #include linux/string.h   /* get the memcpy/memset functions */
+#include linux/export.h
 #include skein.h /* get the Skein API definitions   */
 #include skein_iv.h/* get precomputed IVs */
 #include skein_block.h
diff --git a/drivers/staging/skein/skein.h b/drivers/staging/skein/skein.h
index e6669f1..79fac00 100644
--- a/drivers/staging/skein/skein.h
+++ b/drivers/staging/skein/skein.h
@@ -28,6 +28,11 @@
 **
 ***/
 
+/*Skein digest sizes for crypto api*/
+#define SKEIN256_DIGEST_BIT_SIZE (256)
+#define SKEIN512_DIGEST_BIT_SIZE (512)
+#define SKEIN1024_DIGEST_BIT_SIZE (1024)
+
 #ifndef rotl_64
 #define rotl_64(x, N)(((x)  (N)) | ((x)  (64-(N
 #endif
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
new file mode 100644
index 000..14cc5bd
--- /dev/null
+++ b/drivers/staging/skein/skein_generic.c
@@ -0,0 +1,109 @@
+/*
+ * Cryptographic API.
+ *
+ * Skein256 Hash Algorithm.
+ *
+ * Derived from cryptoapi implementation, adapted for in-place
+ * scatterlist interface.
+ *
+ * Copyright (c) Eric Rost eric.r...@mybabylon.net
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#include crypto/internal/hash.h
+#include linux/init.h
+#include linux/mm.h
+#include linux/cryptohash.h
+#include linux/types.h
+#include skein.h
+#include asm/byteorder.h
+
+static int skein256_init(struct shash_desc *desc)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+   int ret = skein_256_init(sctx, SKEIN256_DIGEST_BIT_SIZE);
+
+   return ret;
+}
+
+int skein256_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+   size_t hbl = (size_t) len;
+   int ret = skein_256_update(sctx, data, hbl

[PATCH v2 2/2] staging: skein: Add Loadable Module Support

2014-10-22 Thread Eric Rost
Adds loadable module support for skein_mod, containing skein256,
skein512, and skein1024 algorithms.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Kconfig |   2 +-
 drivers/staging/skein/skein_generic.c | 122 ++
 2 files changed, 123 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index de8bdd7..012a823 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,5 +1,5 @@
 config CRYPTO_SKEIN
-   bool Skein digest algorithm
+   tristate Skein digest algorithm
depends on (X86 || UML_X86)  64BIT  CRYPTO
select CRYPTO_HASH
select CRYPTO_ALGAPI
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
index 14cc5bd..43e3cdf 100644
--- a/drivers/staging/skein/skein_generic.c
+++ b/drivers/staging/skein/skein_generic.c
@@ -16,6 +16,7 @@
  */
 #include crypto/internal/hash.h
 #include linux/init.h
+#include linux/module.h
 #include linux/mm.h
 #include linux/cryptohash.h
 #include linux/types.h
@@ -50,6 +51,22 @@ static int skein256_final(struct shash_desc *desc, u8 *out)
return ret;
 }
 
+static int skein256_export(struct shash_desc *desc, void *out)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein256_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_256_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
 static int skein512_init(struct shash_desc *desc)
 {
struct skein_512_ctx *sctx = shash_desc_ctx(desc);
@@ -78,6 +95,22 @@ static int skein512_final(struct shash_desc *desc, u8 *out)
return ret;
 }
 
+static int skein512_export(struct shash_desc *desc, void *out)
+{
+   struct skein_512_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein512_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_512_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
 static int skein1024_init(struct shash_desc *desc)
 {
struct skein_1024_ctx *sctx = shash_desc_ctx(desc);
@@ -106,4 +139,93 @@ static int skein1024_final(struct shash_desc *desc, u8 
*out)
return ret;
 }
 
+static int skein1024_export(struct shash_desc *desc, void *out)
+{
+   struct skein_1024_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(out, sctx, sizeof(*sctx));
+   return 0;
+}
+
+static int skein1024_import(struct shash_desc *desc, const void *in)
+{
+   struct skein_1024_ctx *sctx = shash_desc_ctx(desc);
+
+   memcpy(sctx, in, sizeof(*sctx));
+   return 0;
+}
+
+static struct shash_alg alg256 = {
+   .digestsize =   (SKEIN256_DIGEST_BIT_SIZE / 8),
+   .init   =   skein256_init,
+   .update =   skein256_update,
+   .final  =   skein256_final,
+   .export =   skein256_export,
+   .import =   skein256_import,
+   .descsize   =   sizeof(struct skein_256_ctx),
+   .statesize  =   sizeof(struct skein_256_ctx),
+   .base   =   {
+   .cra_name   =   skein256,
+   .cra_driver_name=   skein-mod,
+   .cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
+   .cra_blocksize  =   SKEIN_256_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
+   }
+};
+
+static struct shash_alg alg512 = {
+   .digestsize =   (SKEIN512_DIGEST_BIT_SIZE / 8),
+   .init   =   skein512_init,
+   .update =   skein512_update,
+   .final  =   skein512_final,
+   .export =   skein512_export,
+   .import =   skein512_import,
+   .descsize   =   sizeof(struct skein_512_ctx),
+   .statesize  =   sizeof(struct skein_512_ctx),
+   .base   =   {
+   .cra_name   =   skein512,
+   .cra_driver_name=   skein-mod,
+   .cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
+   .cra_blocksize  =   SKEIN_512_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
+   }
+};
+
+static struct shash_alg alg1024 = {
+   .digestsize =   (SKEIN1024_DIGEST_BIT_SIZE / 8),
+   .init   =   skein1024_init,
+   .update =   skein1024_update,
+   .final  =   skein1024_final,
+   .export =   skein1024_export,
+   .import =   skein1024_import,
+   .descsize   =   sizeof(struct skein_1024_ctx),
+   .statesize  =   sizeof(struct skein_1024_ctx),
+   .base

Re: [PATCH v2] staging: skein: Loadable Module Support

2014-10-22 Thread Eric Rost
On Wed, 2014-10-22 at 11:10 -0400, Jason Cooper wrote:

 
 If you don't mind, could you split this
 patch in two?  The first integrating into the crypto API (such that
 userspace could call into it), and the second enabling loadable module
 support?
 

Will do!

  Signed-off-by: Eric Rost eric.r...@mybabylon.net
  ---
   drivers/staging/skein/Kconfig | 12 +
   drivers/staging/skein/Makefile|  6 +++
   drivers/staging/skein/skein.c | 11 +++-
   drivers/staging/skein/skein.h |  6 +++
   drivers/staging/skein/skein1024_generic.c | 88 
  +++
   drivers/staging/skein/skein256_generic.c  | 88 
  +++
   drivers/staging/skein/skein512_generic.c  | 88 
  +++
   7 files changed, 298 insertions(+), 1 deletion(-)
   create mode 100644 drivers/staging/skein/skein1024_generic.c
   create mode 100644 drivers/staging/skein/skein256_generic.c
   create mode 100644 drivers/staging/skein/skein512_generic.c
  
  diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
  index b9172bf..e260111 100644
  --- a/drivers/staging/skein/Kconfig
  +++ b/drivers/staging/skein/Kconfig
  @@ -15,6 +15,18 @@ config CRYPTO_SKEIN
for more information.  This module depends on the threefish block
cipher module.
   
  +config CRYPTO_SKEIN_256
  +   tristate Skein256 driver
  +   select CRYPTO_SKEIN
  +
  +config CRYPTO_SKEIN_512
  +   tristate Skein512 driver
  +   select CRYPTO_SKEIN
  +
  +config CRYPTO_SKEIN_1024
  +   tristate Skein1024 driver
  +   select CRYPTO_SKEIN
  +
   config CRYPTO_THREEFISH
  bool Threefish tweakable block cipher
  depends on (X86 || UML_X86)  64BIT  CRYPTO
  diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
  index a14aadd..1be01fe 100644
  --- a/drivers/staging/skein/Makefile
  +++ b/drivers/staging/skein/Makefile
  @@ -5,5 +5,11 @@ obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
  skein_api.o \
  skein_block.o
   
  +obj-$(CONFIG_CRYPTO_SKEIN_256) += skein256_generic.o
  +
  +obj-$(CONFIG_CRYPTO_SKEIN_512) += skein512_generic.o
  +
  +obj-$(CONFIG_CRYPTO_SKEIN_1024) += skein1024_generic.o
  +
 
 This isn't really doing what we want.  You'll have loadable modules, but
 the actual code will still be built into the kernel.
 
   obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
threefish_api.o
  diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
  index 8cc8358..2138e22 100644
  --- a/drivers/staging/skein/skein.c
  +++ b/drivers/staging/skein/skein.c
  @@ -11,6 +11,7 @@
   #define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
   
   #include linux/string.h   /* get the memcpy/memset functions */
  +#include linux/export.h
   #include skein.h /* get the Skein API definitions   */
   #include skein_iv.h/* get precomputed IVs */
   #include skein_block.h
  @@ -73,6 +74,7 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t 
  hash_bit_len)
   
  return SKEIN_SUCCESS;
   }
  +EXPORT_SYMBOL(skein_256_init);
 
 Once the above is corrected, these shouldn't be necessary.
 
Will give it a whirl, I was having problems with undefined symbols at
linking even when I was building it as one module, but it may have been
something else
  --- a/drivers/staging/skein/skein.h
  +++ b/drivers/staging/skein/skein.h
  @@ -26,8 +26,14 @@
   **0: use assert()  to flag errors
   **1: return SKEIN_FAIL to flag errors
   **
  +**
   
  ***/
 
 superfluous whitespace addition?
 
Remnants of a backed out change... will fix.

  +
  +static struct shash_alg alg = {
  +   .digestsize =   (SKEIN1024_DIGEST_SIZE / 8),
  +   .init   =   skein1024_init,
  +   .update =   crypto_skein1024_update,
 
 why is this function name different from the other two?

It was inherited from the sha1 file I based this off of, I can make them
the same.

 I think it might be best to have two loadable modules.  One for
 threefish, and one for skein.  Adding threefish to the crypto API is a
 bit more difficult than adding skein, as the crypto API doesn't
 currently support tweakable block ciphers.
 
 To keep things moving, it'd probably be best to do one module for now,
 skein.  Have all the object files for skein and threefish in it, and
 register the three hash algos with the API.
 
 After that, we can go back and split out threefish into a separate
 module with it's own registration into the crypto API.
 
 Does that sound sensible?
 
 thx,
 
 Jason.

Sounds fine to me, I will build it that way and resubmit.


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info

[PATCH v2] staging: skein: Loadable Module Support

2014-10-21 Thread Eric Rost
Adds loadable module support for Skein256, Skein512, and Skein1024 Hash
Algorithms.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Kconfig | 12 +
 drivers/staging/skein/Makefile|  6 +++
 drivers/staging/skein/skein.c | 11 +++-
 drivers/staging/skein/skein.h |  6 +++
 drivers/staging/skein/skein1024_generic.c | 88 +++
 drivers/staging/skein/skein256_generic.c  | 88 +++
 drivers/staging/skein/skein512_generic.c  | 88 +++
 7 files changed, 298 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/skein/skein1024_generic.c
 create mode 100644 drivers/staging/skein/skein256_generic.c
 create mode 100644 drivers/staging/skein/skein512_generic.c

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index b9172bf..e260111 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -15,6 +15,18 @@ config CRYPTO_SKEIN
  for more information.  This module depends on the threefish block
  cipher module.
 
+config CRYPTO_SKEIN_256
+   tristate "Skein256 driver"
+   select CRYPTO_SKEIN
+
+config CRYPTO_SKEIN_512
+   tristate "Skein512 driver"
+   select CRYPTO_SKEIN
+
+config CRYPTO_SKEIN_1024
+   tristate "Skein1024 driver"
+   select CRYPTO_SKEIN
+
 config CRYPTO_THREEFISH
bool "Threefish tweakable block cipher"
depends on (X86 || UML_X86) && 64BIT && CRYPTO
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index a14aadd..1be01fe 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -5,5 +5,11 @@ obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
skein_api.o \
skein_block.o
 
+obj-$(CONFIG_CRYPTO_SKEIN_256) += skein256_generic.o
+
+obj-$(CONFIG_CRYPTO_SKEIN_512) += skein512_generic.o
+
+obj-$(CONFIG_CRYPTO_SKEIN_1024) += skein1024_generic.o
+
 obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
  threefish_api.o
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
index 8cc8358..2138e22 100644
--- a/drivers/staging/skein/skein.c
+++ b/drivers/staging/skein/skein.c
@@ -11,6 +11,7 @@
 #define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
 
 #include/* get the memcpy/memset functions */
+#include 
 #include "skein.h" /* get the Skein API definitions   */
 #include "skein_iv.h"/* get precomputed IVs */
 #include "skein_block.h"
@@ -73,6 +74,7 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t 
hash_bit_len)
 
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_256_init);
 
 /**/
 /* init the context for a MAC and/or tree hash operation */
@@ -191,7 +193,7 @@ int skein_256_update(struct skein_256_ctx *ctx, const u8 
*msg,
 
return SKEIN_SUCCESS;
 }
-
+EXPORT_SYMBOL(skein_256_update);
 /**/
 /* finalize the hash computation and output the result */
 int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val)
@@ -240,6 +242,7 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val)
}
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_256_final);
 
 /*/
 /* 512-bit Skein */
@@ -303,6 +306,7 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t 
hash_bit_len)
 
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_512_init);
 
 /**/
 /* init the context for a MAC and/or tree hash operation */
@@ -420,6 +424,7 @@ int skein_512_update(struct skein_512_ctx *ctx, const u8 
*msg,
 
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_512_update);
 
 /**/
 /* finalize the hash computation and output the result */
@@ -469,6 +474,7 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val)
}
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_512_final);
 
 /*/
 /*1024-bit Skein */
@@ -526,6 +532,7 @@ int skein_1024_init(struct skein_1024_ctx *ctx, size_t 
hash_bit_len)
 
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_1024_init);
 
 /**/
 /* init the context for a MAC and/or tree hash operation */
@@ -644,6 +651,7 @@ int skein_1024_update(struct skein_1024_ctx *ctx, const u8 
*msg,
 
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_1024_update);
 
 /*+++

[PATCH v2] staging: skein: Loadable Module Support

2014-10-21 Thread Eric Rost
Adds loadable module support for Skein256, Skein512, and Skein1024 Hash
Algorithms.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Kconfig | 12 +
 drivers/staging/skein/Makefile|  6 +++
 drivers/staging/skein/skein.c | 11 +++-
 drivers/staging/skein/skein.h |  6 +++
 drivers/staging/skein/skein1024_generic.c | 88 +++
 drivers/staging/skein/skein256_generic.c  | 88 +++
 drivers/staging/skein/skein512_generic.c  | 88 +++
 7 files changed, 298 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/skein/skein1024_generic.c
 create mode 100644 drivers/staging/skein/skein256_generic.c
 create mode 100644 drivers/staging/skein/skein512_generic.c

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index b9172bf..e260111 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -15,6 +15,18 @@ config CRYPTO_SKEIN
  for more information.  This module depends on the threefish block
  cipher module.
 
+config CRYPTO_SKEIN_256
+   tristate Skein256 driver
+   select CRYPTO_SKEIN
+
+config CRYPTO_SKEIN_512
+   tristate Skein512 driver
+   select CRYPTO_SKEIN
+
+config CRYPTO_SKEIN_1024
+   tristate Skein1024 driver
+   select CRYPTO_SKEIN
+
 config CRYPTO_THREEFISH
bool Threefish tweakable block cipher
depends on (X86 || UML_X86)  64BIT  CRYPTO
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index a14aadd..1be01fe 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -5,5 +5,11 @@ obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
skein_api.o \
skein_block.o
 
+obj-$(CONFIG_CRYPTO_SKEIN_256) += skein256_generic.o
+
+obj-$(CONFIG_CRYPTO_SKEIN_512) += skein512_generic.o
+
+obj-$(CONFIG_CRYPTO_SKEIN_1024) += skein1024_generic.o
+
 obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
  threefish_api.o
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
index 8cc8358..2138e22 100644
--- a/drivers/staging/skein/skein.c
+++ b/drivers/staging/skein/skein.c
@@ -11,6 +11,7 @@
 #define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
 
 #include linux/string.h   /* get the memcpy/memset functions */
+#include linux/export.h
 #include skein.h /* get the Skein API definitions   */
 #include skein_iv.h/* get precomputed IVs */
 #include skein_block.h
@@ -73,6 +74,7 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t 
hash_bit_len)
 
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_256_init);
 
 /**/
 /* init the context for a MAC and/or tree hash operation */
@@ -191,7 +193,7 @@ int skein_256_update(struct skein_256_ctx *ctx, const u8 
*msg,
 
return SKEIN_SUCCESS;
 }
-
+EXPORT_SYMBOL(skein_256_update);
 /**/
 /* finalize the hash computation and output the result */
 int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val)
@@ -240,6 +242,7 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val)
}
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_256_final);
 
 /*/
 /* 512-bit Skein */
@@ -303,6 +306,7 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t 
hash_bit_len)
 
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_512_init);
 
 /**/
 /* init the context for a MAC and/or tree hash operation */
@@ -420,6 +424,7 @@ int skein_512_update(struct skein_512_ctx *ctx, const u8 
*msg,
 
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_512_update);
 
 /**/
 /* finalize the hash computation and output the result */
@@ -469,6 +474,7 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val)
}
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_512_final);
 
 /*/
 /*1024-bit Skein */
@@ -526,6 +532,7 @@ int skein_1024_init(struct skein_1024_ctx *ctx, size_t 
hash_bit_len)
 
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_1024_init);
 
 /**/
 /* init the context for a MAC and/or tree hash operation */
@@ -644,6 +651,7 @@ int skein_1024_update(struct skein_1024_ctx *ctx, const u8 
*msg,
 
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_1024_update);
 
 /**/
 /* finalize the hash computation and output

[PATCH] staging: skein: Loadable Module Support

2014-10-20 Thread Eric Rost
Adds loadable module support for Skein256, Skein512, and Skein1024
NOTE: skein1024_generic does not load, sending patch for feedback!
I don't understand why skein256_generic and skein512_generic load no
problem but skein1024_generic gives ERROR: Invalid argument from
modprobe.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Kconfig | 12 +
 drivers/staging/skein/Makefile|  6 +++
 drivers/staging/skein/skein.c | 11 +++-
 drivers/staging/skein/skein.h |  6 +++
 drivers/staging/skein/skein1024_generic.c | 88 +++
 drivers/staging/skein/skein256_generic.c  | 88 +++
 drivers/staging/skein/skein512_generic.c  | 88 +++
 7 files changed, 298 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/skein/skein1024_generic.c
 create mode 100644 drivers/staging/skein/skein256_generic.c
 create mode 100644 drivers/staging/skein/skein512_generic.c

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index b9172bf..e260111 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -15,6 +15,18 @@ config CRYPTO_SKEIN
  for more information.  This module depends on the threefish block
  cipher module.
 
+config CRYPTO_SKEIN_256
+   tristate "Skein256 driver"
+   select CRYPTO_SKEIN
+
+config CRYPTO_SKEIN_512
+   tristate "Skein512 driver"
+   select CRYPTO_SKEIN
+
+config CRYPTO_SKEIN_1024
+   tristate "Skein1024 driver"
+   select CRYPTO_SKEIN
+
 config CRYPTO_THREEFISH
bool "Threefish tweakable block cipher"
depends on (X86 || UML_X86) && 64BIT && CRYPTO
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index a14aadd..1be01fe 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -5,5 +5,11 @@ obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
skein_api.o \
skein_block.o
 
+obj-$(CONFIG_CRYPTO_SKEIN_256) += skein256_generic.o
+
+obj-$(CONFIG_CRYPTO_SKEIN_512) += skein512_generic.o
+
+obj-$(CONFIG_CRYPTO_SKEIN_1024) += skein1024_generic.o
+
 obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
  threefish_api.o
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
index 8cc8358..2138e22 100644
--- a/drivers/staging/skein/skein.c
+++ b/drivers/staging/skein/skein.c
@@ -11,6 +11,7 @@
 #define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
 
 #include/* get the memcpy/memset functions */
+#include 
 #include "skein.h" /* get the Skein API definitions   */
 #include "skein_iv.h"/* get precomputed IVs */
 #include "skein_block.h"
@@ -73,6 +74,7 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t 
hash_bit_len)
 
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_256_init);
 
 /**/
 /* init the context for a MAC and/or tree hash operation */
@@ -191,7 +193,7 @@ int skein_256_update(struct skein_256_ctx *ctx, const u8 
*msg,
 
return SKEIN_SUCCESS;
 }
-
+EXPORT_SYMBOL(skein_256_update);
 /**/
 /* finalize the hash computation and output the result */
 int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val)
@@ -240,6 +242,7 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val)
}
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_256_final);
 
 /*/
 /* 512-bit Skein */
@@ -303,6 +306,7 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t 
hash_bit_len)
 
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_512_init);
 
 /**/
 /* init the context for a MAC and/or tree hash operation */
@@ -420,6 +424,7 @@ int skein_512_update(struct skein_512_ctx *ctx, const u8 
*msg,
 
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_512_update);
 
 /**/
 /* finalize the hash computation and output the result */
@@ -469,6 +474,7 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val)
}
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_512_final);
 
 /*/
 /*1024-bit Skein */
@@ -526,6 +532,7 @@ int skein_1024_init(struct skein_1024_ctx *ctx, size_t 
hash_bit_len)
 
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_1024_init);
 
 /**/
 /* init the context for a MAC and/or tree hash operation */
@@ -644,6 +651,7 @@ int skein_

[PATCH] staging: skein: Loadable Module Support

2014-10-20 Thread Eric Rost
Adds loadable module support for Skein256, Skein512, and Skein1024
NOTE: skein1024_generic does not load, sending patch for feedback!
I don't understand why skein256_generic and skein512_generic load no
problem but skein1024_generic gives ERROR: Invalid argument from
modprobe.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/Kconfig | 12 +
 drivers/staging/skein/Makefile|  6 +++
 drivers/staging/skein/skein.c | 11 +++-
 drivers/staging/skein/skein.h |  6 +++
 drivers/staging/skein/skein1024_generic.c | 88 +++
 drivers/staging/skein/skein256_generic.c  | 88 +++
 drivers/staging/skein/skein512_generic.c  | 88 +++
 7 files changed, 298 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/skein/skein1024_generic.c
 create mode 100644 drivers/staging/skein/skein256_generic.c
 create mode 100644 drivers/staging/skein/skein512_generic.c

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index b9172bf..e260111 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -15,6 +15,18 @@ config CRYPTO_SKEIN
  for more information.  This module depends on the threefish block
  cipher module.
 
+config CRYPTO_SKEIN_256
+   tristate Skein256 driver
+   select CRYPTO_SKEIN
+
+config CRYPTO_SKEIN_512
+   tristate Skein512 driver
+   select CRYPTO_SKEIN
+
+config CRYPTO_SKEIN_1024
+   tristate Skein1024 driver
+   select CRYPTO_SKEIN
+
 config CRYPTO_THREEFISH
bool Threefish tweakable block cipher
depends on (X86 || UML_X86)  64BIT  CRYPTO
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index a14aadd..1be01fe 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -5,5 +5,11 @@ obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
skein_api.o \
skein_block.o
 
+obj-$(CONFIG_CRYPTO_SKEIN_256) += skein256_generic.o
+
+obj-$(CONFIG_CRYPTO_SKEIN_512) += skein512_generic.o
+
+obj-$(CONFIG_CRYPTO_SKEIN_1024) += skein1024_generic.o
+
 obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
  threefish_api.o
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
index 8cc8358..2138e22 100644
--- a/drivers/staging/skein/skein.c
+++ b/drivers/staging/skein/skein.c
@@ -11,6 +11,7 @@
 #define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
 
 #include linux/string.h   /* get the memcpy/memset functions */
+#include linux/export.h
 #include skein.h /* get the Skein API definitions   */
 #include skein_iv.h/* get precomputed IVs */
 #include skein_block.h
@@ -73,6 +74,7 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t 
hash_bit_len)
 
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_256_init);
 
 /**/
 /* init the context for a MAC and/or tree hash operation */
@@ -191,7 +193,7 @@ int skein_256_update(struct skein_256_ctx *ctx, const u8 
*msg,
 
return SKEIN_SUCCESS;
 }
-
+EXPORT_SYMBOL(skein_256_update);
 /**/
 /* finalize the hash computation and output the result */
 int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val)
@@ -240,6 +242,7 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val)
}
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_256_final);
 
 /*/
 /* 512-bit Skein */
@@ -303,6 +306,7 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t 
hash_bit_len)
 
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_512_init);
 
 /**/
 /* init the context for a MAC and/or tree hash operation */
@@ -420,6 +424,7 @@ int skein_512_update(struct skein_512_ctx *ctx, const u8 
*msg,
 
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_512_update);
 
 /**/
 /* finalize the hash computation and output the result */
@@ -469,6 +474,7 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val)
}
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_512_final);
 
 /*/
 /*1024-bit Skein */
@@ -526,6 +532,7 @@ int skein_1024_init(struct skein_1024_ctx *ctx, size_t 
hash_bit_len)
 
return SKEIN_SUCCESS;
 }
+EXPORT_SYMBOL(skein_1024_init);
 
 /**/
 /* init the context for a MAC and/or tree hash operation */
@@ -644,6 +651,7 @@ int skein_1024_update(struct skein_1024_ctx *ctx, const u8 
*msg

[PATCH v4 2/2] staging: skein: File Reorg

2014-09-30 Thread Eric Rost
Reorganizes file to remove #defines from middle of functions. Also
removes #if'd loop declarations and adds ternary if driven loops.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_block.c |  680 ++-
 1 file changed, 351 insertions(+), 329 deletions(-)

diff --git a/drivers/staging/skein/skein_block.c 
b/drivers/staging/skein/skein_block.c
index 71c14f5..88bc718 100644
--- a/drivers/staging/skein/skein_block.c
+++ b/drivers/staging/skein/skein_block.c
@@ -42,17 +42,9 @@
 #define debug_save_tweak(ctx)
 #endif
 
-/*  SKEIN_256 **/
 #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 */
-   enum {
-   WCNT = SKEIN_256_STATE_WORDS
-   };
 #undef  RCNT
 #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)
 #else
@@ -63,56 +55,7 @@ void skein_256_process_block(struct skein_256_ctx *ctx, 
const u8 *blk_ptr,
 #if (RCNT % SKEIN_UNROLL_256)
 #error "Invalid SKEIN_UNROLL_256" /* sanity check on unroll count */
 #endif
-   size_t  r;
-   u64  kw[WCNT+4+RCNT*2]; /* key schedule: chaining vars + tweak + "rot"*/
-#else
-   u64  kw[WCNT+4]; /* key schedule words : chaining vars + tweak */
-#endif
-   u64  X0, X1, X2, X3; /* local copy of context vars, for speed */
-   u64  w[WCNT]; /* local copy of input block */
-#ifdef SKEIN_DEBUG
-   const u64 *X_ptr[4]; /* use for debugging (help cc put Xn in regs) */
-
-   X_ptr[0] =   X_ptr[1] =   X_ptr[2] =   X_ptr[3] = 
 #endif
-   skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */
-   ts[0] = ctx->h.tweak[0];
-   ts[1] = ctx->h.tweak[1];
-   do  {
-   /*
-* this implementation only supports 2**64 input bytes
-* (no carry out here)
-*/
-   ts[0] += byte_cnt_add; /* update processed length */
-
-   /* precompute the key schedule for this block */
-   ks[0] = ctx->x[0];
-   ks[1] = ctx->x[1];
-   ks[2] = ctx->x[2];
-   ks[3] = ctx->x[3];
-   ks[4] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ SKEIN_KS_PARITY;
-
-   ts[2] = ts[0] ^ ts[1];
-
-   /* get input block in little-endian format */
-   skein_get64_lsb_first(w, blk_ptr, WCNT);
-   debug_save_tweak(ctx);
-   skein_show_block(BLK_BITS, >h, ctx->x, blk_ptr, w, ks, ts);
-
-   /* 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];
-
-   /* show starting state values */
-   skein_show_r_ptr(BLK_BITS, >h, SKEIN_RND_KEY_INITIAL,
-x_ptr);
-
-   blk_ptr += SKEIN_256_BLOCK_BYTES;
-
-   /* run the rounds */
-
 #define ROUND256(p0, p1, p2, p3, ROT, r_num) \
 do { \
X##p0 += X##p1;  \
@@ -159,10 +102,7 @@ do { \
ts[r + (R) + 2] = ts[r + (R) - 1];\
skein_show_r_ptr(BLK_BITS, >h, SKEIN_RND_KEY_INJECT, X_ptr); \
 } while (0)
-
-   for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_256)
 #endif
-   {
 #define R256_8_ROUNDS(R) \
 do { \
R256(0, 1, 2, 3, R_256_0, 8 * (R) + 1);  \
@@ -177,57 +117,362 @@ do { 
\
I256(2 * (R) + 1);   \
 } while (0)
 
-   R256_8_ROUNDS(0);
+#define R256_UNROLL_R(NN) \
+   ((SKEIN_UNROLL_256 == 0 &&\
+   SKEIN_256_ROUNDS_TOTAL / 8 > (NN)) || \
+   (SKEIN_UNROLL_256 > (NN)))
+
+#if  (SKEIN_UNROLL_256 > 14)
+#error  "need more unrolling in skein_256_process_block"
+#endif
+#endif
+
+#if !(SKEIN_USE_ASM & 512)
+#undef  RCNT
+#define RCNT  (SKEIN_512_ROUNDS_TOTAL/8)
+
+#ifdef SKEIN_LOOP /* configure how much to unroll the loop */
+#define SKEIN_UNROLL_512 (((SKEIN_LOOP)/10)%10)
+#else
+#define SKEIN_UNROLL_512 (0)
+#endif
+
+#if SKEIN_UNROLL_512
+#if (RCNT % SKEIN_UNROLL_512)
+#error "Invalid SKEIN_UNROLL_512" /* sanity check on unroll count */
+#endif
+#endif
+#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);  

[PATCH v4 1/2] staging: skein: Whitespace cleanup

2014-09-30 Thread Eric Rost
Pretties up multiline #defines and many other whitespace issues

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_block.c |  585 +++
 1 file changed, 315 insertions(+), 270 deletions(-)

diff --git a/drivers/staging/skein/skein_block.c 
b/drivers/staging/skein/skein_block.c
index 616364f..71c14f5 100644
--- a/drivers/staging/skein/skein_block.c
+++ b/drivers/staging/skein/skein_block.c
@@ -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, >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];
@@ -109,29 +113,34 @@ void skein_256_process_block(struct skein_256_ctx *ctx, 
const u8 *blk_ptr,
 
/* run the rounds */
 
-#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; \
+#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;  \
 } while (0)
 
 #if SKEIN_UNROLL_256 == 0
 #define R256(p0, p1, p2, p3, ROT, r_num) /* fully unrolled */ \
-do { \
-   ROUND256(p0, p1, p2, p3, ROT, r_num); \
-   skein_show_r_ptr(BLK_BITS, >h, r_num, X_ptr); \
+do {  \
+   ROUND256(p0, p1, p2, p3, ROT, r_num); \
+   skein_show_r_ptr(BLK_BITS, >h, r_num, X_ptr);\
 } while (0)
 
-#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;   \
+#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;  \
skein_show_r_ptr(BLK_BITS, >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,85 +150,85 @@ 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);\
-   /* rotate key schedule */ \
-   ks[r + (R) + 4]   = ks[r + (R) - 1]; \
-   ts[r + (R) + 2]   = ts[r + (R) - 1]; \
+   X0 += ks[r + (R) + 0]; \
+   X1 += k

[PATCH v4 0/2] staging: skein: Fixes Conditional white space problems

2014-09-30 Thread Eric Rost
This patchset fixes the following checkpatch.pl Warnings in
skein_block.c:

WARNING: suspect code indent for conditional statements (16, 16)
+   for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_512)
[...]
+   {

WARNING: suspect code indent for conditional statements (16, 16)
+   for (r = 1; r <= 2 * RCNT; r += 2 * SKEIN_UNROLL_1024)
[...]
+   {

It also removes macro definitions from inside functions and cleans up
whitespace issues.

Eric Rost (2):
  staging: skein: Whitespace cleanup
  staging: skein: File Reorg

 drivers/staging/skein/skein_block.c |  933 +++
 1 file changed, 500 insertions(+), 433 deletions(-)

-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 2/3] drivers: staging: skein: In progress

2014-09-30 Thread Eric Rost
On Tue, 2014-09-30 at 09:21 -0700, Greg KH wrote:
> On Tue, Sep 30, 2014 at 02:00:05AM -0500, Eric Rost wrote:
> > In progress commit
> > Signed-off-by: Eric Rost 
> > ---
> 
> What does this mean?
> 
> And you need a blank line before your signed-off-by: line.
> 
> thanks,
> 
> greg k-h

It means I need to collapse this into two patches and it was late. I
will resend.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 3/3] staging: skein: File Reorg

2014-09-30 Thread Eric Rost
Reorganizes file to remove #defines from middle of functions. Also
removes #if'd loop declarations and adds ternary if driven loops.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_block.c |  568 ++-
 1 file changed, 291 insertions(+), 277 deletions(-)

diff --git a/drivers/staging/skein/skein_block.c 
b/drivers/staging/skein/skein_block.c
index b8e4bd8..88bc718 100644
--- a/drivers/staging/skein/skein_block.c
+++ b/drivers/staging/skein/skein_block.c
@@ -122,8 +122,248 @@ do { \
SKEIN_256_ROUNDS_TOTAL / 8 > (NN)) || \
(SKEIN_UNROLL_256 > (NN)))
 
+#if  (SKEIN_UNROLL_256 > 14)
+#error  "need more unrolling in skein_256_process_block"
+#endif
+#endif
+
+#if !(SKEIN_USE_ASM & 512)
+#undef  RCNT
+#define RCNT  (SKEIN_512_ROUNDS_TOTAL/8)
+
+#ifdef SKEIN_LOOP /* configure how much to unroll the loop */
+#define SKEIN_UNROLL_512 (((SKEIN_LOOP)/10)%10)
+#else
+#define SKEIN_UNROLL_512 (0)
+#endif
+
+#if SKEIN_UNROLL_512
+#if (RCNT % SKEIN_UNROLL_512)
+#error "Invalid SKEIN_UNROLL_512" /* sanity check on unroll count */
+#endif
+#endif
+#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;  \
+} while (0)
+
+#if SKEIN_UNROLL_512 == 0
+#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) /* unrolled */ \
+do {\
+   ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num)\
+   skein_show_r_ptr(BLK_BITS, >h, r_num, X_ptr);  \
+} while (0)
+
+#define I512(R)   \
+do {  \
+   /* inject the key schedule value */   \
+   X0   += ks[((R) + 1) % 9];\
+   X1   += ks[((R) + 2) % 9];\
+   X2   += ks[((R) + 3) % 9];\
+   X3   += ks[((R) + 4) % 9];\
+   X4   += ks[((R) + 5) % 9];\
+   X5   += ks[((R) + 6) % 9] + ts[((R) + 1) % 3];\
+   X6   += ks[((R) + 7) % 9] + ts[((R) + 2) % 3];\
+   X7   += ks[((R) + 8) % 9] + (R) + 1;  \
+   skein_show_r_ptr(BLK_BITS, >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 { \
+   ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num);\
+   skein_show_r_ptr(BLK_BITS, >h, 4 * (r - 1) + r_num, X_ptr); \
+} while (0)
+
+#define I512(R)   \
+do {  \
+   /* inject the key schedule value */   \
+   X0   += ks[r + (R) + 0];  \
+   X1   += ks[r + (R) + 1];  \
+   X2   += ks[r + (R) + 2];  \
+   X3   += ks[r + (R) + 3];  \
+   X4   += ks[r + (R) + 4];  \
+   X5   += ks[r + (R) + 5] + ts[r + (R) + 0];\
+   X6   += ks[r + (R) + 6] + ts[r + (R) + 1];\
+   X7   += ks[r + (R) + 7] + r + (R);\
+   /* rotate key schedule */ \
+   ks[r + (R) + 8] = ks[r + (R) - 1];\
+   ts[r + (R) + 2] = ts[r + (R) - 1];\
+   skein_show_r_ptr(BLK_BITS, >h, SKEIN_RND_KEY_INJECT, X_ptr); \
+} while (0)
+#endif /* end of looped code definitions */
+#define R512_8_ROUNDS(R)  /* do 8 full rounds */  \
+do {  \
+   R512

[PATCH v3 2/3] drivers: staging: skein: In progress

2014-09-30 Thread Eric Rost
In progress commit
Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_block.c |  132 +++
 1 file changed, 70 insertions(+), 62 deletions(-)

diff --git a/drivers/staging/skein/skein_block.c 
b/drivers/staging/skein/skein_block.c
index 71c14f5..b8e4bd8 100644
--- a/drivers/staging/skein/skein_block.c
+++ b/drivers/staging/skein/skein_block.c
@@ -42,17 +42,9 @@
 #define debug_save_tweak(ctx)
 #endif
 
-/*  SKEIN_256 **/
 #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 */
-   enum {
-   WCNT = SKEIN_256_STATE_WORDS
-   };
 #undef  RCNT
 #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)
 #else
@@ -63,56 +55,7 @@ void skein_256_process_block(struct skein_256_ctx *ctx, 
const u8 *blk_ptr,
 #if (RCNT % SKEIN_UNROLL_256)
 #error "Invalid SKEIN_UNROLL_256" /* sanity check on unroll count */
 #endif
-   size_t  r;
-   u64  kw[WCNT+4+RCNT*2]; /* key schedule: chaining vars + tweak + "rot"*/
-#else
-   u64  kw[WCNT+4]; /* key schedule words : chaining vars + tweak */
 #endif
-   u64  X0, X1, X2, X3; /* local copy of context vars, for speed */
-   u64  w[WCNT]; /* local copy of input block */
-#ifdef SKEIN_DEBUG
-   const u64 *X_ptr[4]; /* use for debugging (help cc put Xn in regs) */
-
-   X_ptr[0] =   X_ptr[1] =   X_ptr[2] =   X_ptr[3] = 
-#endif
-   skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */
-   ts[0] = ctx->h.tweak[0];
-   ts[1] = ctx->h.tweak[1];
-   do  {
-   /*
-* this implementation only supports 2**64 input bytes
-* (no carry out here)
-*/
-   ts[0] += byte_cnt_add; /* update processed length */
-
-   /* precompute the key schedule for this block */
-   ks[0] = ctx->x[0];
-   ks[1] = ctx->x[1];
-   ks[2] = ctx->x[2];
-   ks[3] = ctx->x[3];
-   ks[4] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ SKEIN_KS_PARITY;
-
-   ts[2] = ts[0] ^ ts[1];
-
-   /* get input block in little-endian format */
-   skein_get64_lsb_first(w, blk_ptr, WCNT);
-   debug_save_tweak(ctx);
-   skein_show_block(BLK_BITS, >h, ctx->x, blk_ptr, w, ks, ts);
-
-   /* 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];
-
-   /* show starting state values */
-   skein_show_r_ptr(BLK_BITS, >h, SKEIN_RND_KEY_INITIAL,
-x_ptr);
-
-   blk_ptr += SKEIN_256_BLOCK_BYTES;
-
-   /* run the rounds */
-
 #define ROUND256(p0, p1, p2, p3, ROT, r_num) \
 do { \
X##p0 += X##p1;  \
@@ -159,10 +102,7 @@ do { \
ts[r + (R) + 2] = ts[r + (R) - 1];\
skein_show_r_ptr(BLK_BITS, >h, SKEIN_RND_KEY_INJECT, X_ptr); \
 } while (0)
-
-   for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_256)
 #endif
-   {
 #define R256_8_ROUNDS(R) \
 do { \
R256(0, 1, 2, 3, R_256_0, 8 * (R) + 1);  \
@@ -177,13 +117,81 @@ do { \
I256(2 * (R) + 1);   \
 } while (0)
 
-   R256_8_ROUNDS(0);
-
 #define R256_UNROLL_R(NN) \
((SKEIN_UNROLL_256 == 0 &&\
SKEIN_256_ROUNDS_TOTAL / 8 > (NN)) || \
(SKEIN_UNROLL_256 > (NN)))
 
+#endif
+
+
+/*  SKEIN_256 **/
+#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 */
+   enum {
+   WCNT = SKEIN_256_STATE_WORDS
+   };
+
+#if SKEIN_UNROLL_256
+   size_t  r;
+   u64  kw[WCNT+4+RCNT*2]; /* key schedule: chaining vars + tweak + "rot"*/
+#else
+   u64  kw[WCNT+4]; /* key schedule words : chaining vars + tweak */
+#endif
+   u64  X0, X1, X2, X3; /* local copy of context vars, for speed */
+   u64  w[WCNT]; /* local copy of input block */
+#ifdef SKEIN_DEBUG
+   const u64 *X_ptr[4]; /* use for debugging (help cc put Xn in regs) */
+
+   X_ptr[0] =   X_ptr[1] =   X_ptr[2] =   X_ptr[3] = 
+#endif
+   skein_assert(blk_cnt != 0); /* 

[PATCH v3 1/3] staging: skein: Whitespace cleanup

2014-09-30 Thread Eric Rost
Pretties up multiline #defines and many other whitespace issues
Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_block.c |  585 +++
 1 file changed, 315 insertions(+), 270 deletions(-)

diff --git a/drivers/staging/skein/skein_block.c 
b/drivers/staging/skein/skein_block.c
index 616364f..71c14f5 100644
--- a/drivers/staging/skein/skein_block.c
+++ b/drivers/staging/skein/skein_block.c
@@ -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, >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];
@@ -109,29 +113,34 @@ void skein_256_process_block(struct skein_256_ctx *ctx, 
const u8 *blk_ptr,
 
/* run the rounds */
 
-#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; \
+#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;  \
 } while (0)
 
 #if SKEIN_UNROLL_256 == 0
 #define R256(p0, p1, p2, p3, ROT, r_num) /* fully unrolled */ \
-do { \
-   ROUND256(p0, p1, p2, p3, ROT, r_num); \
-   skein_show_r_ptr(BLK_BITS, >h, r_num, X_ptr); \
+do {  \
+   ROUND256(p0, p1, p2, p3, ROT, r_num); \
+   skein_show_r_ptr(BLK_BITS, >h, r_num, X_ptr);\
 } while (0)
 
-#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;   \
+#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;  \
skein_show_r_ptr(BLK_BITS, >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,85 +150,85 @@ 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);\
-   /* rotate key schedule */ \
-   ks[r + (R) + 4]   = ks[r + (R) - 1]; \
-   ts[r + (R) + 2]   = ts[r + (R) - 1]; \
+   X0 += ks[r + (R) + 0]; \
+   X1 += k

[PATCH v3 0/3] staging: skein: checkpatch.pl warnings

2014-09-30 Thread Eric Rost
Fixes the follwoing checkpatch.pl warnings:
WARNING: suspect code indent for conditional statements (16, 16)
+   for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_512)
[...]
+   {

WARNING: suspect code indent for conditional statements (16, 16)
+   for (r = 1; r <= 2 * RCNT; r += 2 * SKEIN_UNROLL_1024)
[...]
+   {


Eric Rost (3):
  staging: skein: Whitespace cleanup
  drivers: staging: skein: In progress
  drivers: staging: skein: File Reorg

 drivers/staging/skein/skein_block.c |  933 +++
 1 file changed, 500 insertions(+), 433 deletions(-)

-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 4/4] staging: skein: File Reorg

2014-09-30 Thread Eric Rost
Reorganizes file to remove #defines from middle of functions. Also
removes #if'd loop declarations and adds ternary if driven loops.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_block.c |  568 ++-
 1 file changed, 291 insertions(+), 277 deletions(-)

diff --git a/drivers/staging/skein/skein_block.c 
b/drivers/staging/skein/skein_block.c
index b8e4bd8..88bc718 100644
--- a/drivers/staging/skein/skein_block.c
+++ b/drivers/staging/skein/skein_block.c
@@ -122,8 +122,248 @@ do { \
SKEIN_256_ROUNDS_TOTAL / 8 > (NN)) || \
(SKEIN_UNROLL_256 > (NN)))
 
+#if  (SKEIN_UNROLL_256 > 14)
+#error  "need more unrolling in skein_256_process_block"
+#endif
+#endif
+
+#if !(SKEIN_USE_ASM & 512)
+#undef  RCNT
+#define RCNT  (SKEIN_512_ROUNDS_TOTAL/8)
+
+#ifdef SKEIN_LOOP /* configure how much to unroll the loop */
+#define SKEIN_UNROLL_512 (((SKEIN_LOOP)/10)%10)
+#else
+#define SKEIN_UNROLL_512 (0)
+#endif
+
+#if SKEIN_UNROLL_512
+#if (RCNT % SKEIN_UNROLL_512)
+#error "Invalid SKEIN_UNROLL_512" /* sanity check on unroll count */
+#endif
+#endif
+#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;  \
+} while (0)
+
+#if SKEIN_UNROLL_512 == 0
+#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) /* unrolled */ \
+do {\
+   ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num)\
+   skein_show_r_ptr(BLK_BITS, >h, r_num, X_ptr);  \
+} while (0)
+
+#define I512(R)   \
+do {  \
+   /* inject the key schedule value */   \
+   X0   += ks[((R) + 1) % 9];\
+   X1   += ks[((R) + 2) % 9];\
+   X2   += ks[((R) + 3) % 9];\
+   X3   += ks[((R) + 4) % 9];\
+   X4   += ks[((R) + 5) % 9];\
+   X5   += ks[((R) + 6) % 9] + ts[((R) + 1) % 3];\
+   X6   += ks[((R) + 7) % 9] + ts[((R) + 2) % 3];\
+   X7   += ks[((R) + 8) % 9] + (R) + 1;  \
+   skein_show_r_ptr(BLK_BITS, >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 { \
+   ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num);\
+   skein_show_r_ptr(BLK_BITS, >h, 4 * (r - 1) + r_num, X_ptr); \
+} while (0)
+
+#define I512(R)   \
+do {  \
+   /* inject the key schedule value */   \
+   X0   += ks[r + (R) + 0];  \
+   X1   += ks[r + (R) + 1];  \
+   X2   += ks[r + (R) + 2];  \
+   X3   += ks[r + (R) + 3];  \
+   X4   += ks[r + (R) + 4];  \
+   X5   += ks[r + (R) + 5] + ts[r + (R) + 0];\
+   X6   += ks[r + (R) + 6] + ts[r + (R) + 1];\
+   X7   += ks[r + (R) + 7] + r + (R);\
+   /* rotate key schedule */ \
+   ks[r + (R) + 8] = ks[r + (R) - 1];\
+   ts[r + (R) + 2] = ts[r + (R) - 1];\
+   skein_show_r_ptr(BLK_BITS, >h, SKEIN_RND_KEY_INJECT, X_ptr); \
+} while (0)
+#endif /* end of looped code definitions */
+#define R512_8_ROUNDS(R)  /* do 8 full rounds */  \
+do {  \
+   R512

[PATCH v2 3/4] staging: skein: In progress changes

2014-09-30 Thread Eric Rost
In progress commit
Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_block.c |  132 +++
 1 file changed, 70 insertions(+), 62 deletions(-)

diff --git a/drivers/staging/skein/skein_block.c 
b/drivers/staging/skein/skein_block.c
index 71c14f5..b8e4bd8 100644
--- a/drivers/staging/skein/skein_block.c
+++ b/drivers/staging/skein/skein_block.c
@@ -42,17 +42,9 @@
 #define debug_save_tweak(ctx)
 #endif
 
-/*  SKEIN_256 **/
 #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 */
-   enum {
-   WCNT = SKEIN_256_STATE_WORDS
-   };
 #undef  RCNT
 #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)
 #else
@@ -63,56 +55,7 @@ void skein_256_process_block(struct skein_256_ctx *ctx, 
const u8 *blk_ptr,
 #if (RCNT % SKEIN_UNROLL_256)
 #error "Invalid SKEIN_UNROLL_256" /* sanity check on unroll count */
 #endif
-   size_t  r;
-   u64  kw[WCNT+4+RCNT*2]; /* key schedule: chaining vars + tweak + "rot"*/
-#else
-   u64  kw[WCNT+4]; /* key schedule words : chaining vars + tweak */
 #endif
-   u64  X0, X1, X2, X3; /* local copy of context vars, for speed */
-   u64  w[WCNT]; /* local copy of input block */
-#ifdef SKEIN_DEBUG
-   const u64 *X_ptr[4]; /* use for debugging (help cc put Xn in regs) */
-
-   X_ptr[0] =   X_ptr[1] =   X_ptr[2] =   X_ptr[3] = 
-#endif
-   skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */
-   ts[0] = ctx->h.tweak[0];
-   ts[1] = ctx->h.tweak[1];
-   do  {
-   /*
-* this implementation only supports 2**64 input bytes
-* (no carry out here)
-*/
-   ts[0] += byte_cnt_add; /* update processed length */
-
-   /* precompute the key schedule for this block */
-   ks[0] = ctx->x[0];
-   ks[1] = ctx->x[1];
-   ks[2] = ctx->x[2];
-   ks[3] = ctx->x[3];
-   ks[4] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ SKEIN_KS_PARITY;
-
-   ts[2] = ts[0] ^ ts[1];
-
-   /* get input block in little-endian format */
-   skein_get64_lsb_first(w, blk_ptr, WCNT);
-   debug_save_tweak(ctx);
-   skein_show_block(BLK_BITS, >h, ctx->x, blk_ptr, w, ks, ts);
-
-   /* 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];
-
-   /* show starting state values */
-   skein_show_r_ptr(BLK_BITS, >h, SKEIN_RND_KEY_INITIAL,
-x_ptr);
-
-   blk_ptr += SKEIN_256_BLOCK_BYTES;
-
-   /* run the rounds */
-
 #define ROUND256(p0, p1, p2, p3, ROT, r_num) \
 do { \
X##p0 += X##p1;  \
@@ -159,10 +102,7 @@ do { \
ts[r + (R) + 2] = ts[r + (R) - 1];\
skein_show_r_ptr(BLK_BITS, >h, SKEIN_RND_KEY_INJECT, X_ptr); \
 } while (0)
-
-   for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_256)
 #endif
-   {
 #define R256_8_ROUNDS(R) \
 do { \
R256(0, 1, 2, 3, R_256_0, 8 * (R) + 1);  \
@@ -177,13 +117,81 @@ do { \
I256(2 * (R) + 1);   \
 } while (0)
 
-   R256_8_ROUNDS(0);
-
 #define R256_UNROLL_R(NN) \
((SKEIN_UNROLL_256 == 0 &&\
SKEIN_256_ROUNDS_TOTAL / 8 > (NN)) || \
(SKEIN_UNROLL_256 > (NN)))
 
+#endif
+
+
+/*  SKEIN_256 **/
+#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 */
+   enum {
+   WCNT = SKEIN_256_STATE_WORDS
+   };
+
+#if SKEIN_UNROLL_256
+   size_t  r;
+   u64  kw[WCNT+4+RCNT*2]; /* key schedule: chaining vars + tweak + "rot"*/
+#else
+   u64  kw[WCNT+4]; /* key schedule words : chaining vars + tweak */
+#endif
+   u64  X0, X1, X2, X3; /* local copy of context vars, for speed */
+   u64  w[WCNT]; /* local copy of input block */
+#ifdef SKEIN_DEBUG
+   const u64 *X_ptr[4]; /* use for debugging (help cc put Xn in regs) */
+
+   X_ptr[0] =   X_ptr[1] =   X_ptr[2] =   X_ptr[3] = 
+#endif
+   skein_assert(blk_cnt != 0); /* 

[PATCH v2 2/4] staging: skein: Additional Whitespace Issues

2014-09-30 Thread Eric Rost
Fixes leading and trailing whitespace issues.
Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_block.c |   28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/skein/skein_block.c 
b/drivers/staging/skein/skein_block.c
index d49709c..71c14f5 100644
--- a/drivers/staging/skein/skein_block.c
+++ b/drivers/staging/skein/skein_block.c
@@ -36,7 +36,7 @@
 #define debug_save_tweak(ctx)   \
 {   \
ctx->h.tweak[0] = ts[0];\
-   ctx->h.tweak[1] = ts[1];\
+   ctx->h.tweak[1] = ts[1];\
 }
 #else
 #define debug_save_tweak(ctx)
@@ -139,7 +139,7 @@ do {
  \
X3   += ks[((R) + 4) % 5] + (R) + 1;  \
skein_show_r_ptr(BLK_BITS, >h, SKEIN_RND_KEY_INJECT, X_ptr); \
 } while (0)
-#else 
+#else
 /* looping version */
 #define R256(p0, p1, p2, p3, ROT, r_num) \
 do { \
@@ -531,20 +531,20 @@ 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] =  
-   X_ptr[1] =   
+   X_ptr[0] = 
+   X_ptr[1] = 
X_ptr[2] = 
-   X_ptr[3] =   
-   X_ptr[4] =   
+   X_ptr[3] = 
+   X_ptr[4] = 
X_ptr[5] = 
-   X_ptr[6] =   
-   X_ptr[7] =   
+   X_ptr[6] = 
+   X_ptr[7] = 
X_ptr[8] = 
-   X_ptr[9] =   
-   X_ptr[10] =   
+   X_ptr[9] = 
+   X_ptr[10] = 
X_ptr[11] = 
-   X_ptr[12] =   
-   X_ptr[13] =   
+   X_ptr[12] = 
+   X_ptr[13] = 
X_ptr[14] = 
X_ptr[15] = 
 #endif
@@ -589,7 +589,7 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, 
const u8 *blk_ptr,
skein_show_block(BLK_BITS, >h, ctx->x, blk_ptr, w, ks, ts);
 
/* do the first full key injection */
-   X00 = w[0] + ks[0]; 
+   X00 = w[0] + ks[0];
X01 = w[1] + ks[1];
X02 = w[2] + ks[2];
X03 = w[3] + ks[3];
@@ -614,7 +614,7 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, 
const u8 *blk_ptr,
 do {  \
X##p0 += X##p1;   \
X##p1 = rotl_64(X##p1, ROT##_0);  \
-   X##p1 ^= X##p0; 
  \
+   X##p1 ^= X##p0;   \
X##p2 += X##p3;   \
X##p3 = rotl_64(X##p3, ROT##_1);  \
X##p3 ^= X##p2;   \
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 1/4] staging: skein: Whitespace cleanup

2014-09-30 Thread Eric Rost
Pretties up multiline #defines and many other whitespace issues
Signed-off-by: Eric Rost 
---
 drivers/staging/skein/skein_block.c |  585 +++
 1 file changed, 315 insertions(+), 270 deletions(-)

diff --git a/drivers/staging/skein/skein_block.c 
b/drivers/staging/skein/skein_block.c
index 616364f..d49709c 100644
--- a/drivers/staging/skein/skein_block.c
+++ b/drivers/staging/skein/skein_block.c
@@ -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, >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];
@@ -109,29 +113,34 @@ void skein_256_process_block(struct skein_256_ctx *ctx, 
const u8 *blk_ptr,
 
/* run the rounds */
 
-#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; \
+#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;  \
 } while (0)
 
 #if SKEIN_UNROLL_256 == 0
 #define R256(p0, p1, p2, p3, ROT, r_num) /* fully unrolled */ \
-do { \
-   ROUND256(p0, p1, p2, p3, ROT, r_num); \
-   skein_show_r_ptr(BLK_BITS, >h, r_num, X_ptr); \
+do {  \
+   ROUND256(p0, p1, p2, p3, ROT, r_num); \
+   skein_show_r_ptr(BLK_BITS, >h, r_num, X_ptr);\
 } while (0)
 
-#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;   \
+#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;  \
skein_show_r_ptr(BLK_BITS, >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,85 +150,85 @@ 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);\
-   /* rotate key schedule */ \
-   ks[r + (R) + 4]   = ks[r + (R) - 1]; \
-   ts[r + (R) + 2]   = ts[r + (R) - 1]; \
+   X0 += ks[r + (R) + 0]; \
+   X1 += k

[PATCH v2 0/4] staging: skein: Fixes whitespace warnings

2014-09-30 Thread Eric Rost
This patchset reorganizes skein_block.c to move macro definitions out of
functions, fixes whitspace issues, and removes the need for the #if'd
for loops.

Eric Rost (4):
  drivers: staging: skein: Whitespace cleanup
  drivers: staging: skein: Additional Whitespace Issues
  drivers: staging: skein: In progress
  drivers: staging: skein: File Reorg

 drivers/staging/skein/skein_block.c |  933 +++
 1 file changed, 500 insertions(+), 433 deletions(-)

-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 0/4] staging: skein: Fixes whitespace warnings

2014-09-30 Thread Eric Rost
This patchset reorganizes skein_block.c to move macro definitions out of
functions, fixes whitspace issues, and removes the need for the #if'd
for loops.

Eric Rost (4):
  drivers: staging: skein: Whitespace cleanup
  drivers: staging: skein: Additional Whitespace Issues
  drivers: staging: skein: In progress
  drivers: staging: skein: File Reorg

 drivers/staging/skein/skein_block.c |  933 +++
 1 file changed, 500 insertions(+), 433 deletions(-)

-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 1/4] staging: skein: Whitespace cleanup

2014-09-30 Thread Eric Rost
Pretties up multiline #defines and many other whitespace issues
Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/skein_block.c |  585 +++
 1 file changed, 315 insertions(+), 270 deletions(-)

diff --git a/drivers/staging/skein/skein_block.c 
b/drivers/staging/skein/skein_block.c
index 616364f..d49709c 100644
--- a/drivers/staging/skein/skein_block.c
+++ b/drivers/staging/skein/skein_block.c
@@ -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];
@@ -109,29 +113,34 @@ void skein_256_process_block(struct skein_256_ctx *ctx, 
const u8 *blk_ptr,
 
/* run the rounds */
 
-#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; \
+#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;  \
 } while (0)
 
 #if SKEIN_UNROLL_256 == 0
 #define R256(p0, p1, p2, p3, ROT, r_num) /* fully unrolled */ \
-do { \
-   ROUND256(p0, p1, p2, p3, ROT, r_num); \
-   skein_show_r_ptr(BLK_BITS, ctx-h, r_num, X_ptr); \
+do {  \
+   ROUND256(p0, p1, p2, p3, ROT, r_num); \
+   skein_show_r_ptr(BLK_BITS, ctx-h, r_num, X_ptr);\
 } while (0)
 
-#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;   \
+#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;  \
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,85 +150,85 @@ 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);\
-   /* rotate key schedule */ \
-   ks[r + (R) + 4]   = ks[r + (R) - 1]; \
-   ts[r + (R) + 2]   = ts[r + (R) - 1]; \
+   X0 += ks[r + (R) + 0]; \
+   X1 += ks[r

[PATCH v2 2/4] staging: skein: Additional Whitespace Issues

2014-09-30 Thread Eric Rost
Fixes leading and trailing whitespace issues.
Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/skein_block.c |   28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/skein/skein_block.c 
b/drivers/staging/skein/skein_block.c
index d49709c..71c14f5 100644
--- a/drivers/staging/skein/skein_block.c
+++ b/drivers/staging/skein/skein_block.c
@@ -36,7 +36,7 @@
 #define debug_save_tweak(ctx)   \
 {   \
ctx-h.tweak[0] = ts[0];\
-   ctx-h.tweak[1] = ts[1];\
+   ctx-h.tweak[1] = ts[1];\
 }
 #else
 #define debug_save_tweak(ctx)
@@ -139,7 +139,7 @@ do {
  \
X3   += ks[((R) + 4) % 5] + (R) + 1;  \
skein_show_r_ptr(BLK_BITS, ctx-h, SKEIN_RND_KEY_INJECT, X_ptr); \
 } while (0)
-#else 
+#else
 /* looping version */
 #define R256(p0, p1, p2, p3, ROT, r_num) \
 do { \
@@ -531,20 +531,20 @@ 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[0] = X00;
+   X_ptr[1] = X01;
X_ptr[2] = X02;
-   X_ptr[3] = X03;  
-   X_ptr[4] = X04;  
+   X_ptr[3] = X03;
+   X_ptr[4] = X04;
X_ptr[5] = X05;
-   X_ptr[6] = X06;  
-   X_ptr[7] = X07;  
+   X_ptr[6] = X06;
+   X_ptr[7] = X07;
X_ptr[8] = X08;
-   X_ptr[9] = X09;  
-   X_ptr[10] = X10;  
+   X_ptr[9] = X09;
+   X_ptr[10] = X10;
X_ptr[11] = X11;
-   X_ptr[12] = X12;  
-   X_ptr[13] = X13;  
+   X_ptr[12] = X12;
+   X_ptr[13] = X13;
X_ptr[14] = X14;
X_ptr[15] = X15;
 #endif
@@ -589,7 +589,7 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, 
const u8 *blk_ptr,
skein_show_block(BLK_BITS, ctx-h, ctx-x, blk_ptr, w, ks, ts);
 
/* do the first full key injection */
-   X00 = w[0] + ks[0]; 
+   X00 = w[0] + ks[0];
X01 = w[1] + ks[1];
X02 = w[2] + ks[2];
X03 = w[3] + ks[3];
@@ -614,7 +614,7 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, 
const u8 *blk_ptr,
 do {  \
X##p0 += X##p1;   \
X##p1 = rotl_64(X##p1, ROT##_0);  \
-   X##p1 ^= X##p0; 
  \
+   X##p1 ^= X##p0;   \
X##p2 += X##p3;   \
X##p3 = rotl_64(X##p3, ROT##_1);  \
X##p3 ^= X##p2;   \
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 3/4] staging: skein: In progress changes

2014-09-30 Thread Eric Rost
In progress commit
Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/skein_block.c |  132 +++
 1 file changed, 70 insertions(+), 62 deletions(-)

diff --git a/drivers/staging/skein/skein_block.c 
b/drivers/staging/skein/skein_block.c
index 71c14f5..b8e4bd8 100644
--- a/drivers/staging/skein/skein_block.c
+++ b/drivers/staging/skein/skein_block.c
@@ -42,17 +42,9 @@
 #define debug_save_tweak(ctx)
 #endif
 
-/*  SKEIN_256 **/
 #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 */
-   enum {
-   WCNT = SKEIN_256_STATE_WORDS
-   };
 #undef  RCNT
 #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)
 #else
@@ -63,56 +55,7 @@ void skein_256_process_block(struct skein_256_ctx *ctx, 
const u8 *blk_ptr,
 #if (RCNT % SKEIN_UNROLL_256)
 #error Invalid SKEIN_UNROLL_256 /* sanity check on unroll count */
 #endif
-   size_t  r;
-   u64  kw[WCNT+4+RCNT*2]; /* key schedule: chaining vars + tweak + rot*/
-#else
-   u64  kw[WCNT+4]; /* key schedule words : chaining vars + tweak */
 #endif
-   u64  X0, X1, X2, X3; /* local copy of context vars, for speed */
-   u64  w[WCNT]; /* local copy of input block */
-#ifdef SKEIN_DEBUG
-   const u64 *X_ptr[4]; /* use for debugging (help cc put Xn in regs) */
-
-   X_ptr[0] = X0;  X_ptr[1] = X1;  X_ptr[2] = X2;  X_ptr[3] = X3;
-#endif
-   skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */
-   ts[0] = ctx-h.tweak[0];
-   ts[1] = ctx-h.tweak[1];
-   do  {
-   /*
-* this implementation only supports 2**64 input bytes
-* (no carry out here)
-*/
-   ts[0] += byte_cnt_add; /* update processed length */
-
-   /* precompute the key schedule for this block */
-   ks[0] = ctx-x[0];
-   ks[1] = ctx-x[1];
-   ks[2] = ctx-x[2];
-   ks[3] = ctx-x[3];
-   ks[4] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ SKEIN_KS_PARITY;
-
-   ts[2] = ts[0] ^ ts[1];
-
-   /* get input block in little-endian format */
-   skein_get64_lsb_first(w, blk_ptr, WCNT);
-   debug_save_tweak(ctx);
-   skein_show_block(BLK_BITS, ctx-h, ctx-x, blk_ptr, w, ks, ts);
-
-   /* 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];
-
-   /* show starting state values */
-   skein_show_r_ptr(BLK_BITS, ctx-h, SKEIN_RND_KEY_INITIAL,
-x_ptr);
-
-   blk_ptr += SKEIN_256_BLOCK_BYTES;
-
-   /* run the rounds */
-
 #define ROUND256(p0, p1, p2, p3, ROT, r_num) \
 do { \
X##p0 += X##p1;  \
@@ -159,10 +102,7 @@ do { \
ts[r + (R) + 2] = ts[r + (R) - 1];\
skein_show_r_ptr(BLK_BITS, ctx-h, SKEIN_RND_KEY_INJECT, X_ptr); \
 } while (0)
-
-   for (r = 1; r  2 * RCNT; r += 2 * SKEIN_UNROLL_256)
 #endif
-   {
 #define R256_8_ROUNDS(R) \
 do { \
R256(0, 1, 2, 3, R_256_0, 8 * (R) + 1);  \
@@ -177,13 +117,81 @@ do { \
I256(2 * (R) + 1);   \
 } while (0)
 
-   R256_8_ROUNDS(0);
-
 #define R256_UNROLL_R(NN) \
((SKEIN_UNROLL_256 == 0 \
SKEIN_256_ROUNDS_TOTAL / 8  (NN)) || \
(SKEIN_UNROLL_256  (NN)))
 
+#endif
+
+
+/*  SKEIN_256 **/
+#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 */
+   enum {
+   WCNT = SKEIN_256_STATE_WORDS
+   };
+
+#if SKEIN_UNROLL_256
+   size_t  r;
+   u64  kw[WCNT+4+RCNT*2]; /* key schedule: chaining vars + tweak + rot*/
+#else
+   u64  kw[WCNT+4]; /* key schedule words : chaining vars + tweak */
+#endif
+   u64  X0, X1, X2, X3; /* local copy of context vars, for speed */
+   u64  w[WCNT]; /* local copy of input block */
+#ifdef SKEIN_DEBUG
+   const u64 *X_ptr[4]; /* use for debugging (help cc put Xn in regs) */
+
+   X_ptr[0] = X0;  X_ptr[1] = X1;  X_ptr[2] = X2;  X_ptr[3] = X3;
+#endif
+   skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */
+   ts[0] = ctx

[PATCH v2 4/4] staging: skein: File Reorg

2014-09-30 Thread Eric Rost
Reorganizes file to remove #defines from middle of functions. Also
removes #if'd loop declarations and adds ternary if driven loops.

Signed-off-by: Eric Rost eric.r...@mybabylon.net
---
 drivers/staging/skein/skein_block.c |  568 ++-
 1 file changed, 291 insertions(+), 277 deletions(-)

diff --git a/drivers/staging/skein/skein_block.c 
b/drivers/staging/skein/skein_block.c
index b8e4bd8..88bc718 100644
--- a/drivers/staging/skein/skein_block.c
+++ b/drivers/staging/skein/skein_block.c
@@ -122,8 +122,248 @@ do { \
SKEIN_256_ROUNDS_TOTAL / 8  (NN)) || \
(SKEIN_UNROLL_256  (NN)))
 
+#if  (SKEIN_UNROLL_256  14)
+#error  need more unrolling in skein_256_process_block
+#endif
+#endif
+
+#if !(SKEIN_USE_ASM  512)
+#undef  RCNT
+#define RCNT  (SKEIN_512_ROUNDS_TOTAL/8)
+
+#ifdef SKEIN_LOOP /* configure how much to unroll the loop */
+#define SKEIN_UNROLL_512 (((SKEIN_LOOP)/10)%10)
+#else
+#define SKEIN_UNROLL_512 (0)
+#endif
+
+#if SKEIN_UNROLL_512
+#if (RCNT % SKEIN_UNROLL_512)
+#error Invalid SKEIN_UNROLL_512 /* sanity check on unroll count */
+#endif
+#endif
+#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;  \
+} while (0)
+
+#if SKEIN_UNROLL_512 == 0
+#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) /* unrolled */ \
+do {\
+   ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num)\
+   skein_show_r_ptr(BLK_BITS, ctx-h, r_num, X_ptr);  \
+} while (0)
+
+#define I512(R)   \
+do {  \
+   /* inject the key schedule value */   \
+   X0   += ks[((R) + 1) % 9];\
+   X1   += ks[((R) + 2) % 9];\
+   X2   += ks[((R) + 3) % 9];\
+   X3   += ks[((R) + 4) % 9];\
+   X4   += ks[((R) + 5) % 9];\
+   X5   += ks[((R) + 6) % 9] + ts[((R) + 1) % 3];\
+   X6   += ks[((R) + 7) % 9] + ts[((R) + 2) % 3];\
+   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 { \
+   ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num);\
+   skein_show_r_ptr(BLK_BITS, ctx-h, 4 * (r - 1) + r_num, X_ptr); \
+} while (0)
+
+#define I512(R)   \
+do {  \
+   /* inject the key schedule value */   \
+   X0   += ks[r + (R) + 0];  \
+   X1   += ks[r + (R) + 1];  \
+   X2   += ks[r + (R) + 2];  \
+   X3   += ks[r + (R) + 3];  \
+   X4   += ks[r + (R) + 4];  \
+   X5   += ks[r + (R) + 5] + ts[r + (R) + 0];\
+   X6   += ks[r + (R) + 6] + ts[r + (R) + 1];\
+   X7   += ks[r + (R) + 7] + r + (R);\
+   /* rotate key schedule */ \
+   ks[r + (R) + 8] = ks[r + (R) - 1];\
+   ts[r + (R) + 2] = ts[r + (R) - 1];\
+   skein_show_r_ptr(BLK_BITS, ctx-h, SKEIN_RND_KEY_INJECT, X_ptr); \
+} while (0)
+#endif /* end of looped code definitions */
+#define R512_8_ROUNDS(R)  /* do 8 full rounds */  \
+do {  \
+   R512(0, 1, 2, 3, 4, 5

  1   2   >