[PATCH V3 02/21] staging: crypto: skein: allow building statically

2014-03-23 Thread Jason Cooper
These are the minimum changes required to get the code to build
statically in the kernel.  It's necessary to do this first so that we
can empirically determine that future cleanup patches aren't changing
the generated object code.

Signed-off-by: Jason Cooper 
---
Changes since V2:

 - fixed whitespace in staging/Makefile (gregkh)

Changes since RFC:

 - rebased onto staging-next caused conflicts in Kconfig and Makefile, fixed.


 drivers/staging/Kconfig  |  2 +
 drivers/staging/Makefile |  1 +
 drivers/staging/skein/CMakeLists.txt | 27 -
 drivers/staging/skein/Kconfig| 32 
 drivers/staging/skein/Makefile   | 13 +++
 drivers/staging/skein/include/brg_types.h| 57 
 drivers/staging/skein/include/skein.h| 10 -
 drivers/staging/skein/include/skeinApi.h |  2 +-
 drivers/staging/skein/include/skein_port.h   | 16 +---
 drivers/staging/skein/include/threefishApi.h |  2 +-
 drivers/staging/skein/skein.c|  2 +-
 drivers/staging/skein/skeinApi.c |  4 +-
 drivers/staging/skein/skeinBlockNo3F.c   |  2 +-
 drivers/staging/skein/skein_block.c  |  2 +-
 drivers/staging/skein/threefish1024Block.c   |  3 +-
 drivers/staging/skein/threefish256Block.c|  3 +-
 drivers/staging/skein/threefish512Block.c|  3 +-
 drivers/staging/skein/threefishApi.c |  3 +-
 18 files changed, 59 insertions(+), 125 deletions(-)
 delete mode 100755 drivers/staging/skein/CMakeLists.txt
 create mode 100644 drivers/staging/skein/Kconfig
 create mode 100644 drivers/staging/skein/Makefile

diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index 47cf17543008..b78f669b7ed8 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -144,6 +144,8 @@ source "drivers/staging/gs_fpgaboot/Kconfig"
 
 source "drivers/staging/nokia_h4p/Kconfig"
 
+source "drivers/staging/skein/Kconfig"
+
 source "drivers/staging/unisys/Kconfig"
 
 endif # STAGING
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index d12f6189db46..fc05783bb7da 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -64,4 +64,5 @@ obj-$(CONFIG_DGAP)+= dgap/
 obj-$(CONFIG_MTD_SPINAND_MT29F)+= mt29f_spinand/
 obj-$(CONFIG_GS_FPGABOOT)  += gs_fpgaboot/
 obj-$(CONFIG_BT_NOKIA_H4P) += nokia_h4p/
+obj-$(CONFIG_CRYPTO_SKEIN) += skein/
 obj-$(CONFIG_UNISYSSPAR)   += unisys/
diff --git a/drivers/staging/skein/CMakeLists.txt 
b/drivers/staging/skein/CMakeLists.txt
deleted file mode 100755
index 604aaa394cb1..
--- a/drivers/staging/skein/CMakeLists.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-cmake_minimum_required (VERSION 2.6)
-
-include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
-
-# set(skeinBlock_src skein_block.c)
-set(skeinBlock_src skeinBlockNo3F.c)
-
-set(skein_src 
-${skeinBlock_src}
-skein.c
-skeinApi.c
-)
-
-set(threefish_src
-threefishApi.c
-threefish256Block.c
-threefish512Block.c
-threefish1024Block.c
-)
-set(s3f_src ${skein_src} ${threefish_src})
-
-add_library(skein3fish SHARED ${s3f_src})
-set_target_properties(skein3fish PROPERTIES VERSION ${VERSION} SOVERSION 
${SOVERSION})
-target_link_libraries(skein3fish ${LIBS})
-
-install(TARGETS skein3fish DESTINATION ${LIBDIRNAME})
-
diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
new file mode 100644
index ..8f5a72a90ced
--- /dev/null
+++ b/drivers/staging/skein/Kconfig
@@ -0,0 +1,32 @@
+config CRYPTO_SKEIN
+   bool "Skein digest algorithm"
+   depends on (X86 || UML_X86) && 64BIT
+   select CRYPTO_THREEFISH
+   select CRYPTO_HASH
+   help
+ Skein secure hash algorithm 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.  This module depends on the threefish block
+ cipher module.
+
+config CRYPTO_THREEFISH
+   bool "Threefish tweakable block cipher"
+   depends on (X86 || UML_X86) && 64BIT
+   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.
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
new file mode 100644
index ..2bb386e1e58c
--- /dev/null
+++ b/drivers/staging/skein/Makefile
@@ -0,0 +1,13 @@
+#
+# Makefile for the skein secure hash algorithm
+#
+subdir-cc

Re: [RFC PATCH 03/22] staging: crypto: skein: allow building statically

2014-03-23 Thread Jason Cooper
On Tue, Mar 18, 2014 at 02:28:20PM +, Greg KH wrote:
> On Tue, Mar 18, 2014 at 08:58:49AM -0400, Jason Cooper wrote:
> > On Mon, Mar 17, 2014 at 02:52:52PM -0700, Greg KH wrote:
> > > On Tue, Mar 11, 2014 at 09:32:35PM +, Jason Cooper wrote:
> > > > These are the minimum changes required to get the code to build
> > > > statically in the kernel.  It's necessary to do this first so that we
> > > > can empirically determine that future cleanup patches aren't changing
> > > > the generated object code.
> > > > 
> > > > Signed-off-by: Jason Cooper 
> > > 
> > > This doesn't apply to my latest tree :(
> > 
> > Ah, ok.  I'll rebase this series on the staging tree.

Done, submitted.

> > > > --- a/drivers/staging/Makefile
> > > > +++ b/drivers/staging/Makefile
> > > > @@ -65,3 +65,4 @@ obj-$(CONFIG_XILLYBUS)+= xillybus/
> > > >  obj-$(CONFIG_DGNC) += dgnc/
> > > >  obj-$(CONFIG_DGAP) += dgap/
> > > >  obj-$(CONFIG_MTD_SPINAND_MT29F)+= mt29f_spinand/
> > > > +obj-$(CONFIG_CRYPTO_SKEIN) += skein/
> > > 
> > > Care to align these up with the way this file is formatted?
> > 
> > Of course, not sure what happened there (well, other than the obvious
> > :-P)

dabbit.  I thought I remembered everything.  I'll do a V3 of this patch.

> > > And I have no objection to taking the drivers/staging/ patches, the
> > > script looks useful, but I can't take it through the staging tree,
> > > sorry.
> > 
> > Ok, I'll pull that out as a separate branch.

s/branch/patch/.  Done.

thx,

Jason.
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 03/21] staging: crypto: skein: remove brg_*.h includes

2014-03-23 Thread Jason Cooper
Signed-off-by: Jason Cooper 
---
 drivers/staging/skein/include/brg_endian.h | 148 -
 drivers/staging/skein/include/brg_types.h  | 131 -
 drivers/staging/skein/include/skein_port.h |   6 +-
 3 files changed, 2 insertions(+), 283 deletions(-)
 delete mode 100644 drivers/staging/skein/include/brg_endian.h
 delete mode 100644 drivers/staging/skein/include/brg_types.h

diff --git a/drivers/staging/skein/include/brg_endian.h 
b/drivers/staging/skein/include/brg_endian.h
deleted file mode 100644
index c03c7c5d1eb4..
--- a/drivers/staging/skein/include/brg_endian.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- ---
- Copyright (c) 2003, Dr Brian Gladman, Worcester, UK.   All rights reserved.
-
- LICENSE TERMS
-
- The free distribution and use of this software in both source and binary
- form is allowed (with or without changes) provided that:
-
-   1. distributions of this source code include the above copyright
-  notice, this list of conditions and the following disclaimer;
-
-   2. distributions in binary form include the above copyright
-  notice, this list of conditions and the following disclaimer
-  in the documentation and/or other associated materials;
-
-   3. the copyright holder's name is not used to endorse products
-  built using this software without specific written permission.
-
- ALTERNATIVELY, provided that this notice is retained in full, this product
- may be distributed under the terms of the GNU General Public License (GPL),
- in which case the provisions of the GPL apply INSTEAD OF those given above.
-
- DISCLAIMER
-
- This software is provided 'as is' with no explicit or implied warranties
- in respect of its properties, including, but not limited to, correctness
- and/or fitness for purpose.
- ---
- Issue 20/10/2006
-*/
-
-#ifndef BRG_ENDIAN_H
-#define BRG_ENDIAN_H
-
-#define IS_BIG_ENDIAN  4321 /* byte 0 is most significant (mc68k) */
-#define IS_LITTLE_ENDIAN   1234 /* byte 0 is least significant (i386) */
-
-/* Include files where endian defines and byteswap functions may reside */
-#if defined( __FreeBSD__ ) || defined( __OpenBSD__ ) || defined( __NetBSD__ )
-#  include 
-#elif defined( BSD ) && ( BSD >= 199103 ) || defined( __APPLE__ ) || \
-  defined( __CYGWIN32__ ) || defined( __DJGPP__ ) || defined( __osf__ )
-#  include 
-#elif defined( __linux__ ) || defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
-#  if !defined( __MINGW32__ ) && !defined(AVR)
-#include 
-#if !defined( __BEOS__ )
-#  include 
-#endif
-#  endif
-#endif
-
-/* Now attempt to set the define for platform byte order using any  */
-/* of the four forms SYMBOL, _SYMBOL, __SYMBOL & __SYMBOL__, which  */
-/* seem to encompass most endian symbol definitions */
-
-#if defined( BIG_ENDIAN ) && defined( LITTLE_ENDIAN )
-#  if defined( BYTE_ORDER ) && BYTE_ORDER == BIG_ENDIAN
-#define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
-#  elif defined( BYTE_ORDER ) && BYTE_ORDER == LITTLE_ENDIAN
-#define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
-#  endif
-#elif defined( BIG_ENDIAN )
-#  define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
-#elif defined( LITTLE_ENDIAN )
-#  define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
-#endif
-
-#if defined( _BIG_ENDIAN ) && defined( _LITTLE_ENDIAN )
-#  if defined( _BYTE_ORDER ) && _BYTE_ORDER == _BIG_ENDIAN
-#define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
-#  elif defined( _BYTE_ORDER ) && _BYTE_ORDER == _LITTLE_ENDIAN
-#define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
-#  endif
-#elif defined( _BIG_ENDIAN )
-#  define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
-#elif defined( _LITTLE_ENDIAN )
-#  define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
-#endif
-
-#if defined( __BIG_ENDIAN ) && defined( __LITTLE_ENDIAN )
-#  if defined( __BYTE_ORDER ) && __BYTE_ORDER == __BIG_ENDIAN
-#define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
-#  elif defined( __BYTE_ORDER ) && __BYTE_ORDER == __LITTLE_ENDIAN
-#define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
-#  endif
-#elif defined( __BIG_ENDIAN )
-#  define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
-#elif defined( __LITTLE_ENDIAN )
-#  define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
-#endif
-
-#if defined( __BIG_ENDIAN__ ) && defined( __LITTLE_ENDIAN__ )
-#  if defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __BIG_ENDIAN__
-#define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
-#  elif defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __LITTLE_ENDIAN__
-#define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
-#  endif
-#elif defined( __BIG_ENDIAN__ )
-#  define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
-#elif defined( __LITTLE_ENDIAN__ )
-#  define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
-#endif
-
-/*  if the platform byte order could not be determined, then try to */
-/*  set this define using common machine defines*/
-#if !defined(PLATFORM_BYTE_ORDER)
-
-#if   defined(

[PATCH V2 07/21] staging: crypto: skein: remove all typedef {struct,enum}

2014-03-23 Thread Jason Cooper
Signed-off-by: Jason Cooper 
---
 drivers/staging/skein/include/skein.h| 58 ++--
 drivers/staging/skein/include/skeinApi.h | 32 +++
 drivers/staging/skein/include/threefishApi.h | 32 +++
 drivers/staging/skein/skein.c| 42 ++--
 drivers/staging/skein/skeinApi.c | 16 
 drivers/staging/skein/skeinBlockNo3F.c   | 12 +++---
 drivers/staging/skein/skein_block.c  |  6 +--
 drivers/staging/skein/threefish1024Block.c   |  4 +-
 drivers/staging/skein/threefish256Block.c|  4 +-
 drivers/staging/skein/threefish512Block.c|  4 +-
 drivers/staging/skein/threefishApi.c | 10 ++---
 11 files changed, 110 insertions(+), 110 deletions(-)

diff --git a/drivers/staging/skein/include/skein.h 
b/drivers/staging/skein/include/skein.h
index 12c5c8d612b0..77b712e73253 100644
--- a/drivers/staging/skein/include/skein.h
+++ b/drivers/staging/skein/include/skein.h
@@ -63,46 +63,46 @@ enum
 #define  SKEIN_512_BLOCK_BYTES ( 8*SKEIN_512_STATE_WORDS)
 #define  SKEIN1024_BLOCK_BYTES ( 8*SKEIN1024_STATE_WORDS)
 
-typedef struct
+struct skein_ctx_hdr
 {
 size_t  hashBitLen;  /* size of hash result, in bits */
 size_t  bCnt;/* current byte count in buffer 
b[] */
 u64  T[SKEIN_MODIFIER_WORDS]; /* tweak words: T[0]=byte cnt, 
T[1]=flags */
-} Skein_Ctxt_Hdr_t;
+};
 
-typedef struct   /*  256-bit Skein hash context 
structure */
+struct skein_256_ctx   /*  256-bit Skein hash 
context structure */
 {
-Skein_Ctxt_Hdr_t h;  /* common header context 
variables */
+struct skein_ctx_hdr h;  /* common header context 
variables */
 u64  X[SKEIN_256_STATE_WORDS];/* chaining variables */
 u8  b[SKEIN_256_BLOCK_BYTES];/* partial block buffer (8-byte 
aligned) */
-} Skein_256_Ctxt_t;
+};
 
-typedef struct   /*  512-bit Skein hash context 
structure */
+struct skein_512_ctx /*  512-bit Skein hash 
context structure */
 {
-Skein_Ctxt_Hdr_t h;  /* common header context 
variables */
+struct skein_ctx_hdr h;  /* common header context 
variables */
 u64  X[SKEIN_512_STATE_WORDS];/* chaining variables */
 u8  b[SKEIN_512_BLOCK_BYTES];/* partial block buffer (8-byte 
aligned) */
-} Skein_512_Ctxt_t;
+};
 
-typedef struct   /* 1024-bit Skein hash context 
structure */
+struct skein1024_ctx  /* 1024-bit Skein hash 
context structure */
 {
-Skein_Ctxt_Hdr_t h;  /* common header context 
variables */
+struct skein_ctx_hdr h;  /* common header context 
variables */
 u64  X[SKEIN1024_STATE_WORDS];/* chaining variables */
 u8  b[SKEIN1024_BLOCK_BYTES];/* partial block buffer (8-byte 
aligned) */
-} Skein1024_Ctxt_t;
+};
 
 /*   Skein APIs for (incremental) "straight hashing" */
-int  Skein_256_Init  (Skein_256_Ctxt_t *ctx, size_t hashBitLen);
-int  Skein_512_Init  (Skein_512_Ctxt_t *ctx, size_t hashBitLen);
-int  Skein1024_Init  (Skein1024_Ctxt_t *ctx, size_t hashBitLen);
+int  Skein_256_Init  (struct skein_256_ctx *ctx, size_t hashBitLen);
+int  Skein_512_Init  (struct skein_512_ctx *ctx, size_t hashBitLen);
+int  Skein1024_Init  (struct skein1024_ctx *ctx, size_t hashBitLen);
 
-int  Skein_256_Update(Skein_256_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt);
-int  Skein_512_Update(Skein_512_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt);
-int  Skein1024_Update(Skein1024_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt);
+int  Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, size_t 
msgByteCnt);
+int  Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, size_t 
msgByteCnt);
+int  Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, size_t 
msgByteCnt);
 
-int  Skein_256_Final (Skein_256_Ctxt_t *ctx, u8 * hashVal);
-int  Skein_512_Final (Skein_512_Ctxt_t *ctx, u8 * hashVal);
-int  Skein1024_Final (Skein1024_Ctxt_t *ctx, u8 * hashVal);
+int  Skein_256_Final (struct skein_256_ctx *ctx, u8 * hashVal);
+int  Skein_512_Final (struct skein_512_ctx *ctx, u8 * hashVal);
+int  Skein1024_Final (struct skein1024_ctx *ctx, u8 * hashVal);
 
 /*
 **   Skein APIs for "extended" initialization: MAC keys, tree hashing.
@@ -118,26 +118,26 @@ int  Skein1024_Final (Skein1024_Ctxt_t *ctx, u8 * 
hashVal);
 **  to precompute the MAC IV, then a copy of the context saved and
 **  reused for each new MAC computation.
 **/
-int  Skein_256_InitExt(Skein_256_Ctxt_t *ctx, size_t hashBitLen, u64 treeInfo, 
const u8 *key, size_t keyBytes);
-int  Skein_512_InitExt(Skein_512_Ctxt_t *ctx, size_t hashBitLen, u64 treeInfo, 
const u8 *key,

[PATCH V2 06/21] staging: crypto: skein: remove unneeded typedefs

2014-03-23 Thread Jason Cooper
Signed-off-by: Jason Cooper 
---
 drivers/staging/skein/include/skein.h| 73 ++---
 drivers/staging/skein/include/skeinApi.h |  4 +-
 drivers/staging/skein/include/skein_iv.h | 26 
 drivers/staging/skein/include/threefishApi.h |  6 +-
 drivers/staging/skein/skein.c| 96 ++--
 drivers/staging/skein/skeinApi.c | 24 +++
 drivers/staging/skein/skeinBlockNo3F.c   | 30 -
 drivers/staging/skein/skein_block.c  | 54 
 drivers/staging/skein/threefishApi.c |  8 +--
 9 files changed, 159 insertions(+), 162 deletions(-)

diff --git a/drivers/staging/skein/include/skein.h 
b/drivers/staging/skein/include/skein.h
index b1e55b08d150..12c5c8d612b0 100644
--- a/drivers/staging/skein/include/skein.h
+++ b/drivers/staging/skein/include/skein.h
@@ -27,9 +27,6 @@
 **1: return SKEIN_FAIL to flag errors
 **
 ***/
-typedef unsigned intuint_t; /* native unsigned integer */
-typedef uint8_t u08b_t; /*  8-bit unsigned integer */
-typedef uint64_tu64b_t; /* 64-bit unsigned integer */
 
 #ifndef RotL_64
 #define RotL_64(x,N)(((x) << (N)) | ((x) >> (64-(N
@@ -70,28 +67,28 @@ typedef struct
 {
 size_t  hashBitLen;  /* size of hash result, in bits */
 size_t  bCnt;/* current byte count in buffer 
b[] */
-u64b_t  T[SKEIN_MODIFIER_WORDS]; /* tweak words: T[0]=byte cnt, 
T[1]=flags */
+u64  T[SKEIN_MODIFIER_WORDS]; /* tweak words: T[0]=byte cnt, 
T[1]=flags */
 } Skein_Ctxt_Hdr_t;
 
 typedef struct   /*  256-bit Skein hash context 
structure */
 {
 Skein_Ctxt_Hdr_t h;  /* common header context 
variables */
-u64b_t  X[SKEIN_256_STATE_WORDS];/* chaining variables */
-u08b_t  b[SKEIN_256_BLOCK_BYTES];/* partial block buffer (8-byte 
aligned) */
+u64  X[SKEIN_256_STATE_WORDS];/* chaining variables */
+u8  b[SKEIN_256_BLOCK_BYTES];/* partial block buffer (8-byte 
aligned) */
 } Skein_256_Ctxt_t;
 
 typedef struct   /*  512-bit Skein hash context 
structure */
 {
 Skein_Ctxt_Hdr_t h;  /* common header context 
variables */
-u64b_t  X[SKEIN_512_STATE_WORDS];/* chaining variables */
-u08b_t  b[SKEIN_512_BLOCK_BYTES];/* partial block buffer (8-byte 
aligned) */
+u64  X[SKEIN_512_STATE_WORDS];/* chaining variables */
+u8  b[SKEIN_512_BLOCK_BYTES];/* partial block buffer (8-byte 
aligned) */
 } Skein_512_Ctxt_t;
 
 typedef struct   /* 1024-bit Skein hash context 
structure */
 {
 Skein_Ctxt_Hdr_t h;  /* common header context 
variables */
-u64b_t  X[SKEIN1024_STATE_WORDS];/* chaining variables */
-u08b_t  b[SKEIN1024_BLOCK_BYTES];/* partial block buffer (8-byte 
aligned) */
+u64  X[SKEIN1024_STATE_WORDS];/* chaining variables */
+u8  b[SKEIN1024_BLOCK_BYTES];/* partial block buffer (8-byte 
aligned) */
 } Skein1024_Ctxt_t;
 
 /*   Skein APIs for (incremental) "straight hashing" */
@@ -99,13 +96,13 @@ int  Skein_256_Init  (Skein_256_Ctxt_t *ctx, size_t 
hashBitLen);
 int  Skein_512_Init  (Skein_512_Ctxt_t *ctx, size_t hashBitLen);
 int  Skein1024_Init  (Skein1024_Ctxt_t *ctx, size_t hashBitLen);
 
-int  Skein_256_Update(Skein_256_Ctxt_t *ctx, const u08b_t *msg, size_t 
msgByteCnt);
-int  Skein_512_Update(Skein_512_Ctxt_t *ctx, const u08b_t *msg, size_t 
msgByteCnt);
-int  Skein1024_Update(Skein1024_Ctxt_t *ctx, const u08b_t *msg, size_t 
msgByteCnt);
+int  Skein_256_Update(Skein_256_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt);
+int  Skein_512_Update(Skein_512_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt);
+int  Skein1024_Update(Skein1024_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt);
 
-int  Skein_256_Final (Skein_256_Ctxt_t *ctx, u08b_t * hashVal);
-int  Skein_512_Final (Skein_512_Ctxt_t *ctx, u08b_t * hashVal);
-int  Skein1024_Final (Skein1024_Ctxt_t *ctx, u08b_t * hashVal);
+int  Skein_256_Final (Skein_256_Ctxt_t *ctx, u8 * hashVal);
+int  Skein_512_Final (Skein_512_Ctxt_t *ctx, u8 * hashVal);
+int  Skein1024_Final (Skein1024_Ctxt_t *ctx, u8 * hashVal);
 
 /*
 **   Skein APIs for "extended" initialization: MAC keys, tree hashing.
@@ -121,26 +118,26 @@ int  Skein1024_Final (Skein1024_Ctxt_t *ctx, u08b_t * 
hashVal);
 **  to precompute the MAC IV, then a copy of the context saved and
 **  reused for each new MAC computation.
 **/
-int  Skein_256_InitExt(Skein_256_Ctxt_t *ctx, size_t hashBitLen, u64b_t 
treeInfo, const u08b_t *key, size_t keyBytes);
-int  Skein_512_InitExt(Skein_512_Ctxt_t *ctx, size_t hashBitLen, u64b_

[PATCH V2 15/21] staging: crypto: skein: fix do/while brace formatting

2014-03-23 Thread Jason Cooper
Signed-off-by: Jason Cooper 
---
 drivers/staging/skein/skein_block.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/skein/skein_block.c 
b/drivers/staging/skein/skein_block.c
index 780b4936f783..6e0f4a21aae3 100644
--- a/drivers/staging/skein/skein_block.c
+++ b/drivers/staging/skein/skein_block.c
@@ -215,8 +215,7 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, 
const u8 *blkPtr,
Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X);
 
ts[1] &= ~SKEIN_T1_FLAG_FIRST;
-   }
-   while (--blkCnt);
+   } while (--blkCnt);
ctx->h.T[0] = ts[0];
ctx->h.T[1] = ts[1];
 }
@@ -434,8 +433,7 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, 
const u8 *blkPtr,
Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X);
 
ts[1] &= ~SKEIN_T1_FLAG_FIRST;
-   }
-   while (--blkCnt);
+   } while (--blkCnt);
ctx->h.T[0] = ts[0];
ctx->h.T[1] = ts[1];
 }
@@ -717,8 +715,7 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, 
const u8 *blkPtr, \
 
ts[1] &= ~SKEIN_T1_FLAG_FIRST;
blkPtr += SKEIN1024_BLOCK_BYTES;
-   }
-   while (--blkCnt);
+   } while (--blkCnt);
ctx->h.T[0] = ts[0];
ctx->h.T[1] = ts[1];
 }
-- 
1.9.1

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


[PATCH V2 05/21] staging: crypto: skein: remove __cplusplus and an unneeded stddef.h

2014-03-23 Thread Jason Cooper
Signed-off-by: Jason Cooper 
---
 drivers/staging/skein/include/skein.h| 11 ---
 drivers/staging/skein/include/skeinApi.h |  9 -
 drivers/staging/skein/include/threefishApi.h |  9 -
 3 files changed, 29 deletions(-)

diff --git a/drivers/staging/skein/include/skein.h 
b/drivers/staging/skein/include/skein.h
index 211aca1b1036..b1e55b08d150 100644
--- a/drivers/staging/skein/include/skein.h
+++ b/drivers/staging/skein/include/skein.h
@@ -27,13 +27,6 @@
 **1: return SKEIN_FAIL to flag errors
 **
 ***/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include   /* get size_t definition */
-
 typedef unsigned intuint_t; /* native unsigned integer */
 typedef uint8_t u08b_t; /*  8-bit unsigned integer */
 typedef uint64_tu64b_t; /* 64-bit unsigned integer */
@@ -322,8 +315,4 @@ enum
 #define SKEIN1024_ROUNDS_TOTAL (8*SKEIN_ROUNDS) + 5) % 10) + 5))
 #endif
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif  /* ifndef _SKEIN_H_ */
diff --git a/drivers/staging/skein/include/skeinApi.h 
b/drivers/staging/skein/include/skeinApi.h
index 734d27b79f01..f55c67e81f2b 100755
--- a/drivers/staging/skein/include/skeinApi.h
+++ b/drivers/staging/skein/include/skeinApi.h
@@ -81,11 +81,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include 
 #include 
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
 /**
  * Which Skein size to use
  */
@@ -229,10 +224,6 @@ extern "C"
  */
 int skeinFinal(SkeinCtx_t* ctx, uint8_t* hash);
 
-#ifdef __cplusplus
-}
-#endif
-
 /**
  * @}
  */
diff --git a/drivers/staging/skein/include/threefishApi.h 
b/drivers/staging/skein/include/threefishApi.h
index dae270cf71d3..aaecfe822142 100644
--- a/drivers/staging/skein/include/threefishApi.h
+++ b/drivers/staging/skein/include/threefishApi.h
@@ -33,11 +33,6 @@
 
 #define KeyScheduleConst 0x1BD11BDAA9FC1A22L
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
 /**
  * Which Threefish size to use
  */
@@ -157,10 +152,6 @@ extern "C"
 void threefishDecrypt256(ThreefishKey_t* keyCtx, uint64_t* input, 
uint64_t* output);
 void threefishDecrypt512(ThreefishKey_t* keyCtx, uint64_t* input, 
uint64_t* output);
 void threefishDecrypt1024(ThreefishKey_t* keyCtx, uint64_t* input, 
uint64_t* output);
-#ifdef __cplusplus
-}
-#endif
-
 /**
  * @}
  */
-- 
1.9.1

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


[PATCH V2 00/21] staging: add skein/threefish crypto algos

2014-03-23 Thread Jason Cooper
Greg, all,

Changes from RFC:

 - dropped scripts/objdiff patch to be submitted separately

 - rebased onto staging-next and resolved conflicts

-- updated original text to reflect the above --

Attached is a series I've sat on for the past month and a half.

I'm hoping that by posting it in it's incomplete state, it will either a)
motivate me to finish hooking into the crypto API, or b) motivate someone else
to pitch in. ;-)

>From patch 2, all commits build successfully.  In addition, using the script
I've submitted separately (objdiff), I can confirm that no object code was
harmed in this process.

I'm under no time crunch with this, and I add to it as I find time.  If Greg
wants to take it for v3.15, great.  Otherwise is fine as well.

Barring a few false-positives, this series makes the code checkpatch-clean, but
it is not ready for mainline as yet.  In particular, I really don't like the
adhoc macro definitions, nor the camelCase.

The plan is to get skein and threefish registered into the crypto API, build as
modules, and then move it to crypto/.

thx,

Jason.


Jason Cooper (21):
  staging: crypto: skein: import code from Skein3Fish.git
  staging: crypto: skein: allow building statically
  staging: crypto: skein: remove brg_*.h includes
  staging: crypto: skein: remove skein_port.h
  staging: crypto: skein: remove __cplusplus and an unneeded stddef.h
  staging: crypto: skein: remove unneeded typedefs
  staging: crypto: skein: remove all typedef {struct,enum}
  staging: crypto: skein: use u8, u64 vice uint*_t
  staging: crypto: skein: fixup pointer whitespace
  staging: crypto: skein: cleanup whitespace around operators/punc.
  staging: crypto: skein: dos2unix, remove executable perms
  staging: crypto: skein: fix leading whitespace
  staging: crypto: skein: remove trailing whitespace
  staging: crypto: skein: cleanup >80 character lines
  staging: crypto: skein: fix do/while brace formatting
  staging: crypto: skein: fix brace placement errors
  staging: crypto: skein: wrap multi-line macros in do-while loops
  staging: crypto: skein: remove externs from .c files
  staging: crypto: skein: remove braces from single-statement block
  staging: crypto: skein: remove unnecessary line continuation
  staging: crypto: skein: add TODO file

 drivers/staging/Kconfig  |2 +
 drivers/staging/Makefile |1 +
 drivers/staging/skein/Kconfig|   32 +
 drivers/staging/skein/Makefile   |   13 +
 drivers/staging/skein/TODO   |   11 +
 drivers/staging/skein/include/skein.h|  344 ++
 drivers/staging/skein/include/skeinApi.h |  230 ++
 drivers/staging/skein/include/skein_block.h  |   22 +
 drivers/staging/skein/include/skein_iv.h |  186 +
 drivers/staging/skein/include/threefishApi.h |  164 +
 drivers/staging/skein/skein.c|  880 +
 drivers/staging/skein/skeinApi.c |  237 ++
 drivers/staging/skein/skeinBlockNo3F.c   |  175 +
 drivers/staging/skein/skein_block.c  |  770 
 drivers/staging/skein/threefish1024Block.c   | 4900 ++
 drivers/staging/skein/threefish256Block.c| 1137 ++
 drivers/staging/skein/threefish512Block.c| 2223 
 drivers/staging/skein/threefishApi.c |   79 +
 18 files changed, 11406 insertions(+)
 create mode 100644 drivers/staging/skein/Kconfig
 create mode 100644 drivers/staging/skein/Makefile
 create mode 100644 drivers/staging/skein/TODO
 create mode 100644 drivers/staging/skein/include/skein.h
 create mode 100644 drivers/staging/skein/include/skeinApi.h
 create mode 100644 drivers/staging/skein/include/skein_block.h
 create mode 100644 drivers/staging/skein/include/skein_iv.h
 create mode 100644 drivers/staging/skein/include/threefishApi.h
 create mode 100644 drivers/staging/skein/skein.c
 create mode 100644 drivers/staging/skein/skeinApi.c
 create mode 100644 drivers/staging/skein/skeinBlockNo3F.c
 create mode 100644 drivers/staging/skein/skein_block.c
 create mode 100644 drivers/staging/skein/threefish1024Block.c
 create mode 100644 drivers/staging/skein/threefish256Block.c
 create mode 100644 drivers/staging/skein/threefish512Block.c
 create mode 100644 drivers/staging/skein/threefishApi.c

-- 
1.9.1

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


[PATCH V2 16/21] staging: crypto: skein: fix brace placement errors

2014-03-23 Thread Jason Cooper
Signed-off-by: Jason Cooper 
---
 drivers/staging/skein/include/skein.h|  30 -
 drivers/staging/skein/include/skein_iv.h |  65 --
 drivers/staging/skein/skein.c| 111 ++-
 3 files changed, 74 insertions(+), 132 deletions(-)

diff --git a/drivers/staging/skein/include/skein.h 
b/drivers/staging/skein/include/skein.h
index f92dc40711d1..0a2abcecd2f7 100644
--- a/drivers/staging/skein/include/skein.h
+++ b/drivers/staging/skein/include/skein.h
@@ -37,12 +37,11 @@
 #define Skein_Get64_LSB_First(dst64, src08, wCnt) memcpy(dst64, src08, 
8*(wCnt))
 #define Skein_Swap64(w64)  (w64)
 
-enum
-   {
+enum {
SKEIN_SUCCESS =  0, /* return codes from Skein calls */
SKEIN_FAIL=  1,
SKEIN_BAD_HASHLEN =  2
-   };
+};
 
 #define  SKEIN_MODIFIER_WORDS   (2) /* number of modifier (tweak) words */
 
@@ -63,33 +62,29 @@ enum
 #define  SKEIN_512_BLOCK_BYTES  (8*SKEIN_512_STATE_WORDS)
 #define  SKEIN1024_BLOCK_BYTES  (8*SKEIN1024_STATE_WORDS)
 
-struct skein_ctx_hdr
-   {
+struct skein_ctx_hdr {
size_t  hashBitLen; /* size of hash result, in bits */
size_t  bCnt;   /* current byte count in buffer b[] */
u64  T[SKEIN_MODIFIER_WORDS];   /* tweak: T[0]=byte cnt, T[1]=flags */
-   };
+};
 
-struct skein_256_ctx /* 256-bit Skein hash context structure */
-   {
+struct skein_256_ctx { /* 256-bit Skein hash context structure */
struct skein_ctx_hdr h; /* common header context variables */
u64  X[SKEIN_256_STATE_WORDS];  /* chaining variables */
u8  b[SKEIN_256_BLOCK_BYTES];   /* partial block buf (8-byte aligned) */
-   };
+};
 
-struct skein_512_ctx /* 512-bit Skein hash context structure */
-   {
+struct skein_512_ctx { /* 512-bit Skein hash context structure */
struct skein_ctx_hdr h; /* common header context variables */
u64  X[SKEIN_512_STATE_WORDS];  /* chaining variables */
u8  b[SKEIN_512_BLOCK_BYTES];   /* partial block buf (8-byte aligned) */
-   };
+};
 
-struct skein1024_ctx /* 1024-bit Skein hash context structure */
-   {
+struct skein1024_ctx { /* 1024-bit Skein hash context structure */
struct skein_ctx_hdr h; /* common header context variables */
u64  X[SKEIN1024_STATE_WORDS];  /* chaining variables */
u8  b[SKEIN1024_BLOCK_BYTES];   /* partial block buf (8-byte aligned) */
-   };
+};
 
 /*   Skein APIs for (incremental) "straight hashing" */
 int  Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen);
@@ -296,8 +291,7 @@ int  Skein1024_Output(struct skein1024_ctx *ctx, u8 
*hashVal);
 /*
 ** Skein block function constants (shared across Ref and Opt code)
 **/
-enum
-   {
+enum {
/* Skein_256 round rotation constants */
R_256_0_0 = 14, R_256_0_1 = 16,
R_256_1_0 = 52, R_256_1_1 = 57,
@@ -335,7 +329,7 @@ enum
R1024_6_4 = 19, R1024_6_5 = 42, R1024_6_6 = 44, R1024_6_7 = 25,
R1024_7_0 =  9, R1024_7_1 = 48, R1024_7_2 = 35, R1024_7_3 = 52,
R1024_7_4 = 23, R1024_7_5 = 31, R1024_7_6 = 37, R1024_7_7 = 20
-   };
+};
 
 #ifndef SKEIN_ROUNDS
 #define SKEIN_256_ROUNDS_TOTAL (72)/* # rounds for diff block sizes */
diff --git a/drivers/staging/skein/include/skein_iv.h 
b/drivers/staging/skein/include/skein_iv.h
index a77c44d3..8dd5e4d88a1d 100644
--- a/drivers/staging/skein/include/skein_iv.h
+++ b/drivers/staging/skein/include/skein_iv.h
@@ -20,44 +20,39 @@
 #define MK_64 SKEIN_MK_64
 
 /* blkSize =  256 bits. hashSize =  128 bits */
-const u64 SKEIN_256_IV_128[] =
-   {
+const u64 SKEIN_256_IV_128[] = {
MK_64(0xE906, 0x964D7260),
MK_64(0x883DAAA7, 0x7C8D811C),
MK_64(0x10080DF4, 0x91960F7A),
MK_64(0xCCF7DDE5, 0xB45BC1C2)
-   };
+};
 
 /* blkSize =  256 bits. hashSize =  160 bits */
-const u64 SKEIN_256_IV_160[] =
-   {
+const u64 SKEIN_256_IV_160[] = {
MK_64(0x14202314, 0x72825E98),
MK_64(0x2AC4E9A2, 0x5A77E590),
MK_64(0xD47A5856, 0x8838D63E),
MK_64(0x2DD2E496, 0x8586AB7D)
-   };
+};
 
 /* blkSize =  256 bits. hashSize =  224 bits */
-const u64 SKEIN_256_IV_224[] =
-   {
+const u64 SKEIN_256_IV_224[] = {
MK_64(0xC6098A8C, 0x9AE5EA0B),
MK_64(0x876D5686, 0x08C5191C),
MK_64(0x99CB88D7, 0xD7F53884),
MK_64(0x384BDDB1, 0xAEDDB5DE)
-   };
+};
 
 /* blkSize =  256 bits. hashSize =  256 bits */
-const u64 SKEIN_256_IV_256[] =
-   {
+const u64 SKEIN_256_IV_256[] = {
MK_64(0xFC9DA860, 0xD048B449),
MK_64(0x2FCA6647, 0x9FA7D833),
MK_64(0xB33BC389, 0x6656840F),
MK_64(0x6A54E920, 0xFDE8DA69)
-   };
+};
 
 /* blkSize =  512 bits. hashSize =  128 bits */
-const u64 SKEIN_512_IV_128[

[PATCH V2 08/21] staging: crypto: skein: use u8, u64 vice uint*_t

2014-03-23 Thread Jason Cooper
Signed-off-by: Jason Cooper 
---
 drivers/staging/skein/include/skeinApi.h |  8 
 drivers/staging/skein/include/threefishApi.h | 22 +++---
 drivers/staging/skein/skeinApi.c | 22 +++---
 drivers/staging/skein/threefish1024Block.c   | 18 +-
 drivers/staging/skein/threefish256Block.c| 18 +-
 drivers/staging/skein/threefish512Block.c| 18 +-
 drivers/staging/skein/threefishApi.c | 20 ++--
 7 files changed, 63 insertions(+), 63 deletions(-)

diff --git a/drivers/staging/skein/include/skeinApi.h 
b/drivers/staging/skein/include/skeinApi.h
index 548c639431de..4ad294f7945d 100755
--- a/drivers/staging/skein/include/skeinApi.h
+++ b/drivers/staging/skein/include/skeinApi.h
@@ -173,7 +173,7 @@ OTHER DEALINGS IN THE SOFTWARE.
  * @return
  * SKEIN_SUCESS of SKEIN_FAIL
  */
-int skeinMacInit(struct skein_ctx* ctx, const uint8_t *key, size_t keyLen,
+int skeinMacInit(struct skein_ctx* ctx, const u8 *key, size_t keyLen,
  size_t hashBitLen);
 
 /**
@@ -188,7 +188,7 @@ OTHER DEALINGS IN THE SOFTWARE.
  * @return
  * Success or error code.
  */
-int skeinUpdate(struct skein_ctx *ctx, const uint8_t *msg,
+int skeinUpdate(struct skein_ctx *ctx, const u8 *msg,
 size_t msgByteCnt);
 
 /**
@@ -204,7 +204,7 @@ OTHER DEALINGS IN THE SOFTWARE.
  * @param msgBitCnt
  * Length of the message in @b bits.
  */
-int skeinUpdateBits(struct skein_ctx *ctx, const uint8_t *msg,
+int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg,
 size_t msgBitCnt);
 
 /**
@@ -222,7 +222,7 @@ OTHER DEALINGS IN THE SOFTWARE.
  * Success or error code.
  * @see skeinReset
  */
-int skeinFinal(struct skein_ctx* ctx, uint8_t* hash);
+int skeinFinal(struct skein_ctx* ctx, u8* hash);
 
 /**
  * @}
diff --git a/drivers/staging/skein/include/threefishApi.h 
b/drivers/staging/skein/include/threefishApi.h
index 4c1cd81f30c4..194e313b6b62 100644
--- a/drivers/staging/skein/include/threefishApi.h
+++ b/drivers/staging/skein/include/threefishApi.h
@@ -72,7 +72,7 @@
  * @param tweak
  * Pointer to the two tweak words (word has 64 bits).
  */
-void threefishSetKey(struct threefish_key* keyCtx, enum threefish_size 
stateSize, uint64_t* keyData, uint64_t* tweak);
+void threefishSetKey(struct threefish_key* keyCtx, enum threefish_size 
stateSize, u64* keyData, u64* tweak);
 
 /**
  * Encrypt Threefisch block (bytes).
@@ -89,7 +89,7 @@
  * @param out
  * Pointer to cipher buffer.
  */
-void threefishEncryptBlockBytes(struct threefish_key* keyCtx, uint8_t* in, 
uint8_t* out);
+void threefishEncryptBlockBytes(struct threefish_key* keyCtx, u8* in, u8* 
out);
 
 /**
  * Encrypt Threefisch block (words).
@@ -108,7 +108,7 @@
  * @param out
  * Pointer to cipher buffer.
  */
-void threefishEncryptBlockWords(struct threefish_key* keyCtx, uint64_t* 
in, uint64_t* out);
+void threefishEncryptBlockWords(struct threefish_key* keyCtx, u64* in, 
u64* out);
 
 /**
  * Decrypt Threefisch block (bytes).
@@ -125,7 +125,7 @@
  * @param out
  * Pointer to plaintext buffer.
  */
-void threefishDecryptBlockBytes(struct threefish_key* keyCtx, uint8_t* in, 
uint8_t* out);
+void threefishDecryptBlockBytes(struct threefish_key* keyCtx, u8* in, u8* 
out);
 
 /**
  * Decrypt Threefisch block (words).
@@ -144,14 +144,14 @@
  * @param out
  * Pointer to plaintext buffer.
  */
-void threefishDecryptBlockWords(struct threefish_key* keyCtx, uint64_t* 
in, uint64_t* out);
+void threefishDecryptBlockWords(struct threefish_key* keyCtx, u64* in, 
u64* out);
 
-void threefishEncrypt256(struct threefish_key* keyCtx, uint64_t* input, 
uint64_t* output);
-void threefishEncrypt512(struct threefish_key* keyCtx, uint64_t* input, 
uint64_t* output);
-void threefishEncrypt1024(struct threefish_key* keyCtx, uint64_t* input, 
uint64_t* output);
-void threefishDecrypt256(struct threefish_key* keyCtx, uint64_t* input, 
uint64_t* output);
-void threefishDecrypt512(struct threefish_key* keyCtx, uint64_t* input, 
uint64_t* output);
-void threefishDecrypt1024(struct threefish_key* keyCtx, uint64_t* input, 
uint64_t* output);
+void threefishEncrypt256(struct threefish_key* keyCtx, u64* input, u64* 
output);
+void threefishEncrypt512(struct threefish_key* keyCtx, u64* input, u64* 
output);
+void threefishEncrypt1024(struct threefish_key* keyCtx, u64* input, u64* 
output);
+void threefishDecrypt256(struct threefish_key* keyCtx, u64* input, u64* 
output);
+void threefishDecrypt512(struct threefish_key* keyCtx, u64* input, u64* 
output);
+void threefishDecrypt1024(struct threefish_key* keyCtx, u64* input, u64* 
output);

[PATCH V2 13/21] staging: crypto: skein: remove trailing whitespace

2014-03-23 Thread Jason Cooper
Signed-off-by: Jason Cooper 
---
 drivers/staging/skein/include/skein.h| 16 +-
 drivers/staging/skein/include/skeinApi.h | 44 ++--
 drivers/staging/skein/include/threefishApi.h | 40 -
 drivers/staging/skein/skeinBlockNo3F.c   |  6 ++--
 drivers/staging/skein/skein_block.c  | 20 ++---
 5 files changed, 63 insertions(+), 63 deletions(-)

diff --git a/drivers/staging/skein/include/skein.h 
b/drivers/staging/skein/include/skein.h
index 906bcee41c39..dd9a210cf5dd 100644
--- a/drivers/staging/skein/include/skein.h
+++ b/drivers/staging/skein/include/skein.h
@@ -9,7 +9,7 @@
 ** This algorithm and source code is released to the public domain.
 **
 ***
-** 
+**
 ** The following compile-time switches may be defined to control some
 ** tradeoffs between speed, code size, error checking, and security.
 **
@@ -20,8 +20,8 @@
 **[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, 
+**code. If not defined, most error checking
+**is disabled (for performance). Otherwise,
 **the switch value is interpreted as:
 **0: use assert()  to flag errors
 **1: return SKEIN_FAIL to flag errors
@@ -109,12 +109,12 @@ int  Skein1024_Final(struct skein1024_ctx *ctx, u8 
*hashVal);
 **   After an InitExt() call, just use Update/Final calls as with Init().
 **
 **   Notes: Same parameters as _Init() calls, plus treeInfo/key/keyBytes.
-**  When keyBytes == 0 and treeInfo == SKEIN_SEQUENTIAL, 
+**  When keyBytes == 0 and treeInfo == SKEIN_SEQUENTIAL,
 **  the results of InitExt() are identical to calling Init().
 **  The function Init() may be called once to "precompute" the IV for
 **  a given hashBitLen value, then by saving a copy of the context
 **  the IV computation may be avoided in later calls.
-**  Similarly, the function InitExt() may be called once per MAC key 
+**  Similarly, the function InitExt() may be called once per MAC key
 **  to precompute the MAC IV, then a copy of the context saved and
 **  reused for each new MAC computation.
 **/
@@ -142,7 +142,7 @@ int  Skein1024_Output(struct skein1024_ctx *ctx, u8 
*hashVal);
 
 /*
 ** "Internal" Skein definitions
-**-- not needed for sequential hashing API, but will be 
+**-- not needed for sequential hashing API, but will be
 **   helpful for other uses of Skein (e.g., tree hash mode).
 **-- included here so that they can be shared between
 **   reference and optimized code.
@@ -269,8 +269,8 @@ int  Skein1024_Output(struct skein1024_ctx *ctx, u8 
*hashVal);
 /*
 ** Skein block function constants (shared across Ref and Opt code)
 **/
-enum
-   {   
+enum
+   {
/* Skein_256 round rotation constants */
R_256_0_0 = 14, R_256_0_1 = 16,
R_256_1_0 = 52, R_256_1_1 = 57,
diff --git a/drivers/staging/skein/include/skeinApi.h 
b/drivers/staging/skein/include/skeinApi.h
index 0d7d59eff460..ace931a67c23 100644
--- a/drivers/staging/skein/include/skeinApi.h
+++ b/drivers/staging/skein/include/skeinApi.h
@@ -36,46 +36,46 @@ OTHER DEALINGS IN THE SOFTWARE.
  * of Skein. The design and the way to use the functions follow the openSSL
  * design but at the same time take care of some Skein specific behaviour
  * and possibilities.
- * 
+ *
  * The functions enable applications to create a normal Skein hashes and
  * message authentication codes (MAC).
- * 
+ *
  * Using these functions is simple and straight forward:
- * 
+ *
  * @code
- * 
+ *
  * #include 
- * 
+ *
  * ...
  * struct skein_ctx ctx; // a Skein hash or MAC context
- * 
+ *
  * // prepare context, here for a Skein with a state size of 512 bits.
  * skeinCtxPrepare(&ctx, Skein512);
- * 
+ *
  * // Initialize the context to set the requested hash length in bits
  * // here request a output hash size of 31 bits (Skein supports variable
  * // output sizes even very strange sizes)
  * skeinInit(&ctx, 31);
- * 
+ *
  * // Now update Skein with any number of message bits. A function that
  * // takes a number of bytes is also available.
  * skeinUpdateBits(&ctx, message, msgLength);
- * 
+ *
  * // Now get the result of the Skein hash. The output buffer must be
  * // large enough to hold the request number of output bits. The applica

[PATCH V2 04/21] staging: crypto: skein: remove skein_port.h

2014-03-23 Thread Jason Cooper
Signed-off-by: Jason Cooper 
---
 drivers/staging/skein/include/skein.h  |  14 +++-
 drivers/staging/skein/include/skein_port.h | 108 -
 drivers/staging/skein/skein.c  |  21 --
 3 files changed, 13 insertions(+), 130 deletions(-)
 delete mode 100644 drivers/staging/skein/include/skein_port.h

diff --git a/drivers/staging/skein/include/skein.h 
b/drivers/staging/skein/include/skein.h
index 315cdcd14413..211aca1b1036 100644
--- a/drivers/staging/skein/include/skein.h
+++ b/drivers/staging/skein/include/skein.h
@@ -33,7 +33,19 @@ extern "C"
 #endif
 
 #include   /* get size_t definition */
-#include/* get platform-specific definitions */
+
+typedef unsigned intuint_t; /* native unsigned integer */
+typedef uint8_t u08b_t; /*  8-bit unsigned integer */
+typedef uint64_tu64b_t; /* 64-bit unsigned integer */
+
+#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,bCnt) memcpy(dst08,src64,bCnt)
+#define Skein_Get64_LSB_First(dst64,src08,wCnt) memcpy(dst64,src08,8*(wCnt))
+#define Skein_Swap64(w64)  (w64)
 
 enum
 {
diff --git a/drivers/staging/skein/include/skein_port.h 
b/drivers/staging/skein/include/skein_port.h
deleted file mode 100644
index e78c976dccc5..
--- a/drivers/staging/skein/include/skein_port.h
+++ /dev/null
@@ -1,108 +0,0 @@
-#ifndef _SKEIN_PORT_H_
-#define _SKEIN_PORT_H_
-/***
-**
-** Platform-specific definitions for Skein hash function.
-**
-** Source code author: Doug Whiting, 2008.
-**
-** This algorithm and source code is released to the public domain.
-**
-** Many thanks to Brian Gladman for his portable header files.
-**
-** To port Skein to an "unsupported" platform, change the definitions
-** in this file appropriately.
-** 
-/
-
-typedef unsigned intuint_t; /* native unsigned integer */
-typedef uint8_t u08b_t; /*  8-bit unsigned integer */
-typedef uint64_tu64b_t; /* 64-bit unsigned integer */
-
-#ifndef RotL_64
-#define RotL_64(x,N)(((x) << (N)) | ((x) >> (64-(N
-#endif
-
-/*
- * Skein is "natively" little-endian (unlike SHA-xxx), for optimal
- * performance on x86 CPUs.  The Skein code requires the following
- * definitions for dealing with endianness:
- *
- *SKEIN_NEED_SWAP:  0 for little-endian, 1 for big-endian
- *Skein_Put64_LSB_First
- *Skein_Get64_LSB_First
- *Skein_Swap64
- *
- * If SKEIN_NEED_SWAP is defined at compile time, it is used here
- * along with the portable versions of Put64/Get64/Swap64, which 
- * are slow in general.
- *
- * Otherwise, an "auto-detect" of endianness is attempted below.
- * If the default handling doesn't work well, the user may insert
- * platform-specific code instead (e.g., for big-endian CPUs).
- *
- */
-#define SKEIN_NEED_SWAP   (0)
-/* below two prototype assume we are handed aligned data */
-#define Skein_Put64_LSB_First(dst08,src64,bCnt) memcpy(dst08,src64,bCnt)
-#define Skein_Get64_LSB_First(dst64,src08,wCnt) memcpy(dst64,src08,8*(wCnt))
-
-/*
- **
- *  Provide any definitions still needed.
- **
- */
-#ifndef Skein_Swap64  /* swap for big-endian, nop for little-endian */
-#if SKEIN_NEED_SWAP
-#define Skein_Swap64(w64)   \
-  ( (( ((u64b_t)(w64))   & 0xFF) << 56) |   \
-(u64b_t)(w64)) >> 8) & 0xFF) << 48) |   \
-(u64b_t)(w64)) >>16) & 0xFF) << 40) |   \
-(u64b_t)(w64)) >>24) & 0xFF) << 32) |   \
-(u64b_t)(w64)) >>32) & 0xFF) << 24) |   \
-(u64b_t)(w64)) >>40) & 0xFF) << 16) |   \
-(u64b_t)(w64)) >>48) & 0xFF) <<  8) |   \
-(u64b_t)(w64)) >>56) & 0xFF)  ) )
-#else
-#define Skein_Swap64(w64)  (w64)
-#endif
-#endif  /* ifndef Skein_Swap64 */
-
-
-#ifndef Skein_Put64_LSB_First
-voidSkein_Put64_LSB_First(u08b_t *dst,const u64b_t *src,size_t bCnt)
-#ifdef  SKEIN_PORT_CODE /* instantiate the function code here? */
-{ /* this version is fully portable (big-endian or little-endian), but 
slow */
-size_t n;
-
-for (n=0;n>3] >> (8*(n&7)));
-}
-#else
-;/* output only the function prototype */
-#endif
-#endif   /* ifndef Skein_Put64_LSB_First */
-
-
-#ifndef Skein_Get64_LSB_First
-voidSkein_Get64_LSB_First(u64b_t *dst,const u08b_t *src,size_t wCnt)
-#ifdef  SKEIN_PORT_CODE /* instantiate the function code here? */
-{ /* this version is fully portable (big-endian or little-endian), but 
slow */
-size_t n;
-
-for (n=0;n<8*wCnt;n+=8)
-dst[n/8] = (((u64b_t) src[n  ])  ) +
- 

[PATCH V2 21/21] staging: crypto: skein: add TODO file

2014-03-23 Thread Jason Cooper
Signed-off-by: Jason Cooper 
---
 drivers/staging/skein/TODO | 11 +++
 1 file changed, 11 insertions(+)
 create mode 100644 drivers/staging/skein/TODO

diff --git a/drivers/staging/skein/TODO b/drivers/staging/skein/TODO
new file mode 100644
index ..f5c167a305ae
--- /dev/null
+++ b/drivers/staging/skein/TODO
@@ -0,0 +1,11 @@
+skein/threefish TODO
+
+ - rename camelcase vars
+ - rename camelcase functions
+ - rename files
+ - move macros into appropriate header files
+ - add / pass test vectors
+ - module support
+
+Please send patches to Jason Cooper  in addition to the
+staging tree mailinglist.
-- 
1.9.1

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


[PATCH V2 17/21] staging: crypto: skein: wrap multi-line macros in do-while loops

2014-03-23 Thread Jason Cooper
Signed-off-by: Jason Cooper 
---
 drivers/staging/skein/skein_block.c | 66 -
 1 file changed, 51 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/skein/skein_block.c 
b/drivers/staging/skein/skein_block.c
index 6e0f4a21aae3..707a21ae53c6 100644
--- a/drivers/staging/skein/skein_block.c
+++ b/drivers/staging/skein/skein_block.c
@@ -107,27 +107,36 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, 
const u8 *blkPtr,
/* run the rounds */
 
 #define Round256(p0, p1, p2, p3, ROT, rNum)  \
+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, rNum) /* fully unrolled */ \
+do { \
Round256(p0, p1, p2, p3, ROT, rNum) \
-   Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr);
+   Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); \
+} 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;   \
-   Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr);
+   Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \
+} while (0)
 #else /* looping version */
 #define R256(p0, p1, p2, p3, ROT, rNum) \
+do { \
Round256(p0, p1, p2, p3, ROT, rNum) \
-   Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr);
+   Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr); \
+} while (0)
 
 #define I256(R) \
+do { \
/* inject the key schedule value */ \
X0   += ks[r+(R)+0]; \
X1   += ks[r+(R)+1] + ts[r+(R)+0]; \
@@ -136,12 +145,14 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, 
const u8 *blkPtr,
/* rotate key schedule */ \
ks[r + (R) + 4]   = ks[r + (R) - 1]; \
ts[r + (R) + 2]   = ts[r + (R) - 1]; \
-   Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr);
+   Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \
+} 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);  \
R256(0, 3, 2, 1, R_256_1, 8 * (R) + 2);  \
R256(0, 1, 2, 3, R_256_2, 8 * (R) + 3);  \
@@ -151,7 +162,8 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, 
const u8 *blkPtr,
R256(0, 3, 2, 1, R_256_5, 8 * (R) + 6);  \
R256(0, 1, 2, 3, R_256_6, 8 * (R) + 7);  \
R256(0, 3, 2, 1, R_256_7, 8 * (R) + 8);  \
-   I256(2 * (R) + 1);
+   I256(2 * (R) + 1); \
+} while (0)
 
R256_8_rounds(0);
 
@@ -311,17 +323,22 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, 
const u8 *blkPtr,
 Xptr);
/* run the rounds */
 #define Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \
+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, rNum) /* unrolled */ \
+do { \
Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \
-   Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr);
+   Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); \
+} while (0)
 
 #define I512(R) \
+do { \
/* inject the key schedule value */ \
X0   += ks[((R) + 1) % 9]; \
X1   += ks[((R) + 2) % 9]; \
@@ -331,13 +348,17 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, 
const u8 *blkPtr,
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, Xptr);
+   Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \
+} while (0)
 #else /* looping version */
 #define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \
+do { \
Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \
-   Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr);
+   Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr); \
+} while (0)
 
 #define I512(R) \
+do { \
/* inject the key schedule value */ \
X0   += ks[r + (R) + 0]; \
X1   += ks[r + (R) + 1]; \
@@ -350,12 +371,14 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, 
const u8 *blkPtr,
  

[PATCH V2 20/21] staging: crypto: skein: remove unnecessary line continuation

2014-03-23 Thread Jason Cooper
Signed-off-by: Jason Cooper 
---
 drivers/staging/skein/skein_block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/skein/skein_block.c 
b/drivers/staging/skein/skein_block.c
index 707a21ae53c6..fd96ca0ad0ed 100644
--- a/drivers/staging/skein/skein_block.c
+++ b/drivers/staging/skein/skein_block.c
@@ -477,7 +477,7 @@ unsigned int Skein_512_Unroll_Cnt(void)
 
 /*  Skein1024 **/
 #if !(SKEIN_USE_ASM & 1024)
-void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, \
+void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr,
size_t blkCnt, size_t byteCntAdd)
 { /* do it in C, always looping (unrolled is bigger AND slower!) */
enum {
-- 
1.9.1

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


[PATCH V2 19/21] staging: crypto: skein: remove braces from single-statement block

2014-03-23 Thread Jason Cooper
Signed-off-by: Jason Cooper 
---
 drivers/staging/skein/skeinApi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/skein/skeinApi.c b/drivers/staging/skein/skeinApi.c
index f0015d5b10f5..dd109bf6f7b9 100644
--- a/drivers/staging/skein/skeinApi.c
+++ b/drivers/staging/skein/skeinApi.c
@@ -188,9 +188,9 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg,
msgBitCnt == 0, SKEIN_FAIL);
 
/* if number of bits is a multiple of bytes - that's easy */
-   if ((msgBitCnt & 0x7) == 0) {
+   if ((msgBitCnt & 0x7) == 0)
return skeinUpdate(ctx, msg, msgBitCnt >> 3);
-   }
+
skeinUpdate(ctx, msg, (msgBitCnt >> 3) + 1);
 
/*
-- 
1.9.1

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


[PATCH V2 18/21] staging: crypto: skein: remove externs from .c files

2014-03-23 Thread Jason Cooper
Signed-off-by: Jason Cooper 
---
 drivers/staging/skein/include/skein_block.h | 22 ++
 drivers/staging/skein/skein.c   | 10 +-
 2 files changed, 23 insertions(+), 9 deletions(-)
 create mode 100644 drivers/staging/skein/include/skein_block.h

diff --git a/drivers/staging/skein/include/skein_block.h 
b/drivers/staging/skein/include/skein_block.h
new file mode 100644
index ..b15c079b5bd4
--- /dev/null
+++ b/drivers/staging/skein/include/skein_block.h
@@ -0,0 +1,22 @@
+/***
+**
+** Implementation of the Skein hash function.
+**
+** Source code author: Doug Whiting, 2008.
+**
+** This algorithm and source code is released to the public domain.
+**
+/
+#ifndef _SKEIN_BLOCK_H_
+#define _SKEIN_BLOCK_H_
+
+#include  /* get the Skein API definitions   */
+
+void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr,
+   size_t blkCnt, size_t byteCntAdd);
+void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr,
+   size_t blkCnt, size_t byteCntAdd);
+void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr,
+   size_t blkCnt, size_t byteCntAdd);
+
+#endif
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
index 0d8c70c02c6f..096b86bf9430 100644
--- a/drivers/staging/skein/skein.c
+++ b/drivers/staging/skein/skein.c
@@ -13,15 +13,7 @@
 #include/* get the memcpy/memset functions */
 #include  /* get the Skein API definitions   */
 #include /* get precomputed IVs */
-
-/*/
-/* External function to process blkCnt (nonzero) full block(s) of data. */
-void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr,
-   size_t blkCnt, size_t byteCntAdd);
-void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr,
-   size_t blkCnt, size_t byteCntAdd);
-void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr,
-   size_t blkCnt, size_t byteCntAdd);
+#include 
 
 /*/
 /* 256-bit Skein */
-- 
1.9.1

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


[PATCH V2 09/21] staging: crypto: skein: fixup pointer whitespace

2014-03-23 Thread Jason Cooper
Signed-off-by: Jason Cooper 
---
 drivers/staging/skein/include/skein.h| 18 +-
 drivers/staging/skein/include/skeinApi.h | 10 +-
 drivers/staging/skein/include/threefishApi.h | 22 +++---
 drivers/staging/skein/skeinApi.c | 18 +-
 drivers/staging/skein/threefish1024Block.c   |  4 ++--
 drivers/staging/skein/threefish256Block.c|  4 ++--
 drivers/staging/skein/threefish512Block.c|  4 ++--
 drivers/staging/skein/threefishApi.c | 20 ++--
 8 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/skein/include/skein.h 
b/drivers/staging/skein/include/skein.h
index 77b712e73253..b7cd6c0cef2f 100644
--- a/drivers/staging/skein/include/skein.h
+++ b/drivers/staging/skein/include/skein.h
@@ -100,9 +100,9 @@ int  Skein_256_Update(struct skein_256_ctx *ctx, const u8 
*msg, size_t msgByteCn
 int  Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, size_t 
msgByteCnt);
 int  Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, size_t 
msgByteCnt);
 
-int  Skein_256_Final (struct skein_256_ctx *ctx, u8 * hashVal);
-int  Skein_512_Final (struct skein_512_ctx *ctx, u8 * hashVal);
-int  Skein1024_Final (struct skein1024_ctx *ctx, u8 * hashVal);
+int  Skein_256_Final (struct skein_256_ctx *ctx, u8 *hashVal);
+int  Skein_512_Final (struct skein_512_ctx *ctx, u8 *hashVal);
+int  Skein1024_Final (struct skein1024_ctx *ctx, u8 *hashVal);
 
 /*
 **   Skein APIs for "extended" initialization: MAC keys, tree hashing.
@@ -127,17 +127,17 @@ int  Skein1024_InitExt(struct skein1024_ctx *ctx, size_t 
hashBitLen, u64 treeInf
 **  Final_Pad:  pad, do final block, but no OUTPUT type
 **  Output: do just the output stage
 */
-int  Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 * hashVal);
-int  Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 * hashVal);
-int  Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 * hashVal);
+int  Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal);
+int  Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal);
+int  Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal);
 
 #ifndef SKEIN_TREE_HASH
 #define SKEIN_TREE_HASH (1)
 #endif
 #if  SKEIN_TREE_HASH
-int  Skein_256_Output   (struct skein_256_ctx *ctx, u8 * hashVal);
-int  Skein_512_Output   (struct skein_512_ctx *ctx, u8 * hashVal);
-int  Skein1024_Output   (struct skein1024_ctx *ctx, u8 * hashVal);
+int  Skein_256_Output   (struct skein_256_ctx *ctx, u8 *hashVal);
+int  Skein_512_Output   (struct skein_512_ctx *ctx, u8 *hashVal);
+int  Skein1024_Output   (struct skein1024_ctx *ctx, u8 *hashVal);
 #endif
 
 /*
diff --git a/drivers/staging/skein/include/skeinApi.h 
b/drivers/staging/skein/include/skeinApi.h
index 4ad294f7945d..2c52797918cf 100755
--- a/drivers/staging/skein/include/skeinApi.h
+++ b/drivers/staging/skein/include/skeinApi.h
@@ -123,7 +123,7 @@ OTHER DEALINGS IN THE SOFTWARE.
  * @return
  * SKEIN_SUCESS of SKEIN_FAIL
  */
-int skeinCtxPrepare(struct skein_ctx* ctx, enum skein_size size);
+int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size);
 
 /**
  * Initialize a Skein context.
@@ -139,7 +139,7 @@ OTHER DEALINGS IN THE SOFTWARE.
  * SKEIN_SUCESS of SKEIN_FAIL
  * @see skeinReset
  */
-int skeinInit(struct skein_ctx* ctx, size_t hashBitLen);
+int skeinInit(struct skein_ctx *ctx, size_t hashBitLen);
 
 /**
  * Resets a Skein context for further use.
@@ -151,7 +151,7 @@ OTHER DEALINGS IN THE SOFTWARE.
  * @param ctx
  * Pointer to a pre-initialized Skein MAC context
  */
-void skeinReset(struct skein_ctx* ctx);
+void skeinReset(struct skein_ctx *ctx);
 
 /**
  * Initializes a Skein context for MAC usage.
@@ -173,7 +173,7 @@ OTHER DEALINGS IN THE SOFTWARE.
  * @return
  * SKEIN_SUCESS of SKEIN_FAIL
  */
-int skeinMacInit(struct skein_ctx* ctx, const u8 *key, size_t keyLen,
+int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen,
  size_t hashBitLen);
 
 /**
@@ -222,7 +222,7 @@ OTHER DEALINGS IN THE SOFTWARE.
  * Success or error code.
  * @see skeinReset
  */
-int skeinFinal(struct skein_ctx* ctx, u8* hash);
+int skeinFinal(struct skein_ctx *ctx, u8 *hash);
 
 /**
  * @}
diff --git a/drivers/staging/skein/include/threefishApi.h 
b/drivers/staging/skein/include/threefishApi.h
index 194e313b6b62..1f9e6e14f50b 100644
--- a/drivers/staging/skein/include/threefishApi.h
+++ b/drivers/staging/skein/include/threefishApi.h
@@ -72,7 +72,7 @@
  * @param tweak
  * Pointer to the two tweak words (word has 64 bits).
  */
-void threefishSetKey(struct threefish_key* keyCtx, enum threefish_size 
stateSize, u64* keyData, u64* tweak);
+void threefishSetKey(struct threefish_key *keyCtx, enum threefish_si

[PATCH V2 02/21] staging: crypto: skein: allow building statically

2014-03-23 Thread Jason Cooper
These are the minimum changes required to get the code to build
statically in the kernel.  It's necessary to do this first so that we
can empirically determine that future cleanup patches aren't changing
the generated object code.

Signed-off-by: Jason Cooper 
---
Changes since RFC:

 - rebased onto staging-next caused conflicts in Kconfig and Makefile, fixed.


 drivers/staging/Kconfig  |  2 +
 drivers/staging/Makefile |  1 +
 drivers/staging/skein/CMakeLists.txt | 27 -
 drivers/staging/skein/Kconfig| 32 
 drivers/staging/skein/Makefile   | 13 +++
 drivers/staging/skein/include/brg_types.h| 57 
 drivers/staging/skein/include/skein.h| 10 -
 drivers/staging/skein/include/skeinApi.h |  2 +-
 drivers/staging/skein/include/skein_port.h   | 16 +---
 drivers/staging/skein/include/threefishApi.h |  2 +-
 drivers/staging/skein/skein.c|  2 +-
 drivers/staging/skein/skeinApi.c |  4 +-
 drivers/staging/skein/skeinBlockNo3F.c   |  2 +-
 drivers/staging/skein/skein_block.c  |  2 +-
 drivers/staging/skein/threefish1024Block.c   |  3 +-
 drivers/staging/skein/threefish256Block.c|  3 +-
 drivers/staging/skein/threefish512Block.c|  3 +-
 drivers/staging/skein/threefishApi.c |  3 +-
 18 files changed, 59 insertions(+), 125 deletions(-)
 delete mode 100755 drivers/staging/skein/CMakeLists.txt
 create mode 100644 drivers/staging/skein/Kconfig
 create mode 100644 drivers/staging/skein/Makefile

diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index 47cf17543008..b78f669b7ed8 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -144,6 +144,8 @@ source "drivers/staging/gs_fpgaboot/Kconfig"
 
 source "drivers/staging/nokia_h4p/Kconfig"
 
+source "drivers/staging/skein/Kconfig"
+
 source "drivers/staging/unisys/Kconfig"
 
 endif # STAGING
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index d12f6189db46..eec54a9f53e8 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -64,4 +64,5 @@ obj-$(CONFIG_DGAP)+= dgap/
 obj-$(CONFIG_MTD_SPINAND_MT29F)+= mt29f_spinand/
 obj-$(CONFIG_GS_FPGABOOT)  += gs_fpgaboot/
 obj-$(CONFIG_BT_NOKIA_H4P) += nokia_h4p/
+obj-$(CONFIG_CRYPTO_SKEIN) += skein/
 obj-$(CONFIG_UNISYSSPAR)   += unisys/
diff --git a/drivers/staging/skein/CMakeLists.txt 
b/drivers/staging/skein/CMakeLists.txt
deleted file mode 100755
index 604aaa394cb1..
--- a/drivers/staging/skein/CMakeLists.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-cmake_minimum_required (VERSION 2.6)
-
-include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
-
-# set(skeinBlock_src skein_block.c)
-set(skeinBlock_src skeinBlockNo3F.c)
-
-set(skein_src 
-${skeinBlock_src}
-skein.c
-skeinApi.c
-)
-
-set(threefish_src
-threefishApi.c
-threefish256Block.c
-threefish512Block.c
-threefish1024Block.c
-)
-set(s3f_src ${skein_src} ${threefish_src})
-
-add_library(skein3fish SHARED ${s3f_src})
-set_target_properties(skein3fish PROPERTIES VERSION ${VERSION} SOVERSION 
${SOVERSION})
-target_link_libraries(skein3fish ${LIBS})
-
-install(TARGETS skein3fish DESTINATION ${LIBDIRNAME})
-
diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
new file mode 100644
index ..8f5a72a90ced
--- /dev/null
+++ b/drivers/staging/skein/Kconfig
@@ -0,0 +1,32 @@
+config CRYPTO_SKEIN
+   bool "Skein digest algorithm"
+   depends on (X86 || UML_X86) && 64BIT
+   select CRYPTO_THREEFISH
+   select CRYPTO_HASH
+   help
+ Skein secure hash algorithm 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.  This module depends on the threefish block
+ cipher module.
+
+config CRYPTO_THREEFISH
+   bool "Threefish tweakable block cipher"
+   depends on (X86 || UML_X86) && 64BIT
+   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.
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
new file mode 100644
index ..2bb386e1e58c
--- /dev/null
+++ b/drivers/staging/skein/Makefile
@@ -0,0 +1,13 @@
+#
+# Makefile for the skein secure hash algorithm
+#
+subdir-ccflags-y := -I$(src)/include/
+
+obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \

[PATCH] drivers/crypto: Use RCU_INIT_POINTER(x, NULL) in nx/nx-842.c

2014-03-23 Thread Monam Agarwal
This patch replaces rcu_assign_pointer(x, NULL) with RCU_INIT_POINTER(x, NULL)

The rcu_assign_pointer() ensures that the initialization of a structure   
is carried out before storing a pointer to that structure. 
And in the case of the NULL pointer, there is no structure to initialize. 
So, rcu_assign_pointer(p, NULL) can be safely converted to RCU_INIT_POINTER(p, 
NULL)

Signed-off-by: Monam Agarwal 
---
 drivers/crypto/nx/nx-842.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/nx/nx-842.c b/drivers/crypto/nx/nx-842.c
index 1e5481d..c4fcbf4 100644
--- a/drivers/crypto/nx/nx-842.c
+++ b/drivers/crypto/nx/nx-842.c
@@ -1234,7 +1234,7 @@ static int __exit nx842_remove(struct vio_dev *viodev)
old_devdata = rcu_dereference_check(devdata,
lockdep_is_held(&devdata_mutex));
of_reconfig_notifier_unregister(&nx842_of_nb);
-   rcu_assign_pointer(devdata, NULL);
+   RCU_INIT_POINTER(devdata, NULL);
spin_unlock_irqrestore(&devdata_mutex, flags);
synchronize_rcu();
dev_set_drvdata(&viodev->dev, NULL);
@@ -1285,7 +1285,7 @@ static void __exit nx842_exit(void)
spin_lock_irqsave(&devdata_mutex, flags);
old_devdata = rcu_dereference_check(devdata,
lockdep_is_held(&devdata_mutex));
-   rcu_assign_pointer(devdata, NULL);
+   RCU_INIT_POINTER(devdata, NULL);
spin_unlock_irqrestore(&devdata_mutex, flags);
synchronize_rcu();
if (old_devdata)
-- 
1.7.9.5

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