staging: skein: CryptoAPI and Module Support
v6 cover staging: skein: CryptoAPI and Module Support
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.cSignature · 1 line
2.1.1
PATCH v6 1/7 staging: skein: Collapses threefish module
Collapses threefish module into skein module.
--- drivers/staging/skein/Kconfig | 22 +++------------------- drivers/staging/skein/Makefile | 11 +++++------ 2 files changed, 8 insertions(+), 25 deletions(-)
drivers/staging/skein/Kconfig +3 -19
@@ -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.
drivers/staging/skein/Makefile +5 -6
@@ -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
Signature · 1 line
2.1.1
PATCH v6 2/7 staging: skein: Renames skein to skein_base
In reply to Eric RostRenames skein.c to skein_base.c and skein.h to skein_base.h in preparation for naming loadable module skein.ko
---
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%)drivers/staging/skein/Makefile +1 -1
@@ -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 \
drivers/staging/skein/skein_api.h +1 -1
@@ -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
drivers/staging/skein/skein_base.c renamed from drivers/staging/skein/skein.c +2 -1
@@ -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"
drivers/staging/skein/skein_base.h renamed from drivers/staging/skein/skein.h +0 -0
drivers/staging/skein/skein_block.c +1 -1
@@ -15,7 +15,7 @@************************************************************************/ #include <linux/string.h> -#include "skein.h" +#include "skein_base.h" #include "skein_block.h" #ifndef SKEIN_USE_ASM
drivers/staging/skein/skein_block.h +1 -1
@@ -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);
drivers/staging/skein/skein_iv.h +1 -1
@@ -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 *******************
drivers/staging/skein/threefish_api.h +1 -1
@@ -29,7 +29,7 @@*/ #include <linux/types.h> -#include "skein.h" +#include "skein_base.h" #define KEY_SCHEDULE_CONST 0x1BD11BDAA9FC1A22L
Signature · 1 line
2.1.1
PATCH v6 3/7 staging: skein: Adds CryptoAPI Support
In reply to Eric RostAdds CryptoAPI support to the Skein Hashing Algorithm driver.
--- 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
drivers/staging/skein/Makefile +2 -1
@@ -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
drivers/staging/skein/skein_base.h +5 -0
@@ -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
drivers/staging/skein/skein_generic.c new file +199 -0
199 lines not on this page · raw message
Signature · 1 line
2.1.1
PATCH v6 4/7 staging: skein: Adds Loadable Module Support
In reply to Eric RostAdds loadable module support to the Skein Hashing Algorithm driver.
--- drivers/staging/skein/Kconfig | 2 +- drivers/staging/skein/Makefile | 13 +++++++------ drivers/staging/skein/skein_generic.c | 19 ++++++++++++++++++- 3 files changed, 26 insertions(+), 8 deletions(-)
drivers/staging/skein/Kconfig +1 -1
@@ -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
drivers/staging/skein/Makefile +7 -6
@@ -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
drivers/staging/skein/skein_generic.c +18 -1
@@ -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" );
Signature · 1 line
2.1.1
PATCH v6 5/7 staging: skein: Inlines rotl_64
In reply to Eric RostInlines the rotl_64 macro.
--- drivers/staging/skein/skein_base.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/staging/skein/skein_base.h +10 -9
@@ -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);
Signature · 1 line
2.1.1
PATCH v6 6/7 staging: skein: Removes unneeded #define
In reply to Eric RostRemoves unneeded #define SKEIN_PORT_CODE since skein_port.h is nonexistent.
--- drivers/staging/skein/skein_base.c | 2 -- 1 file changed, 2 deletions(-)
drivers/staging/skein/skein_base.c +0 -2
@@ -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 */
Signature · 1 line
2.1.1
PATCH v6 7/7 staging: skein: Removes skein_debug include
In reply to Eric RostRemoves skein_debug.h include since skein_debug.h is nonexistent.
--- drivers/staging/skein/skein_base.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/staging/skein/skein_base.h +1 -8
@@ -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)
Signature · 1 line
2.1.1
Re: [PATCH v6 7/7] staging: skein: Removes skein_debug include
Quoted 24 lines · Eric Rost
Removes
skein_debug.hinclude sinceskein_debug.his nonexistent.Signed-off-by Eric Rost <[email protected]>--- drivers/staging/skein/skein_base.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)drivers/staging/skein/skein_base.h +0
-4@@ -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);/*****************************************************************
drivers/staging/skein/skein_base.h int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); · line 285
Quoted 10 lines
drivers/staging/skein/skein_base.h +0
-3** "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)
Are these called anywhere (sorry, away from dev box atm)? If so, we should remove those as well.
We shouldn't let this hold up the rest of the series, though. I'll R-b the rest and we'll keep working on this one.
thx,
Jason.
Quoted 8 lines
drivers/staging/skein/skein_base.h +1
-1-#endif +/* ignore all asserts, for performance */ #define skein_assert_ret (x, ret_code)Signature · 1 line
2.1.1
Greg,
Quoted 6 lines · Eric Rost
Adds CryptoAPI and loadable module support to the Skein Hashing Algorithm. Collapses threefish module into skein module. Renames
skein.candskein.htoskein_base.candskein_base.hso module can be named skein.ko. Inlinesrotl_64macro. Removes unneeded #define andskein_debug.hinclude.
Quoted 7 lines
Eric Rost (7):
staging: skein: Collapses threefish module
staging: skein: Renames skein toskein_base
staging: skein: Adds CryptoAPI Support
staging: skein: Adds Loadable Module Support
staging: skein: Inlinesrotl_64
staging: skein: Removes unneeded #define
For patches 1 through 6,
We'll keep working on #7, but feel free to take the first six when you get a moment Greg.
thx,
Jason.
Quoted 20 lines
staging: skein: Removes
skein_debugincludedrivers/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.cSignature · 1 line
2.1.1
Greg KH
maintainerQuoted 17 lines · Jason Cooper
Greg,
Quoted 6 lines · Eric Rost
Adds CryptoAPI and loadable module support to the Skein Hashing Algorithm. Collapses threefish module into skein module. Renames
skein.candskein.htoskein_base.candskein_base.hso module can be named skein.ko. Inlinesrotl_64macro. Removes unneeded #define andskein_debug.hinclude.Quoted 7 lines
Eric Rost (7):
staging: skein: Collapses threefish module
staging: skein: Renames skein toskein_base
staging: skein: Adds CryptoAPI Support
staging: skein: Adds Loadable Module Support
staging: skein: Inlinesrotl_64
staging: skein: Removes unneeded #define
Quoted 6 lines
For patches 1 through 6,
Reviewed-by Jason Cooper <[email protected]>We'll keep working on #7, but feel free to take the first six when you get a moment Greg.
Now applied, thanks.
greg k-h