[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:
-   memcpy(ctx->x, SKEIN_256_IV_256, sizeof(ctx->x));
-   break;
-   case  

[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;
-