staging: skein: CryptoAPI and Module Support
v5 cover staging: skein: CryptoAPI and Module Support
Adds CryptoAPI and Module support to Skein Hash Algorithm. Also inlines rotl_64 macro, and removes nonexistent header references.
Eric Rost (7):
staging: skein: Collapses threefish module
staging: skein: Renames skein to skein_base
staging: skein: Adds CryptoAPI Support
staging: skein: Adds Loadable Module Support
staging: skein: Inlines rotl_64
staging: skein: Removes unneeded #define
staging: skein: Removes skein_debug include
drivers/staging/skein/Kconfig | 24 +- drivers/staging/skein/Makefile | 13 +- drivers/staging/skein/skein.c | 883 ---------------------------------- drivers/staging/skein/skein.h | 346 ------------- drivers/staging/skein/skein_api.h | 2 +- drivers/staging/skein/skein_base.c | 882 +++++++++++++++++++++++++++++++++ drivers/staging/skein/skein_base.h | 345 +++++++++++++ drivers/staging/skein/skein_block.c | 2 +- drivers/staging/skein/skein_block.h | 2 +- drivers/staging/skein/skein_generic.c | 208 ++++++++ drivers/staging/skein/skein_iv.h | 2 +- drivers/staging/skein/threefish_api.h | 2 +- 12 files changed, 1451 insertions(+), 1260 deletions(-) delete mode 100644 drivers/staging/skein/skein.c delete mode 100644 drivers/staging/skein/skein.h create mode 100644 drivers/staging/skein/skein_base.c create mode 100644 drivers/staging/skein/skein_base.h create mode 100644 drivers/staging/skein/skein_generic.c
Signature · 1 line
2.1.1
PATCH v5 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 v5 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
--- drivers/staging/skein/Makefile | 2 +- drivers/staging/skein/skein.c | 883 --------------------------------- drivers/staging/skein/skein.h | 346 ------------- drivers/staging/skein/skein_api.h | 2 +- drivers/staging/skein/skein_base.c | 884 ++++++++++++++++++++++++++++++++++ drivers/staging/skein/skein_base.h | 351 ++++++++++++++ drivers/staging/skein/skein_block.c | 2 +- drivers/staging/skein/skein_block.h | 2 +- drivers/staging/skein/skein_iv.h | 2 +- drivers/staging/skein/threefish_api.h | 2 +- 10 files changed, 1241 insertions(+), 1235 deletions(-) delete mode 100644 drivers/staging/skein/skein.c delete mode 100644 drivers/staging/skein/skein.h create mode 100644 drivers/staging/skein/skein_base.c create mode 100644 drivers/staging/skein/skein_base.h
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.c deleted +0 -883
883 lines not on this page · raw message
drivers/staging/skein/skein.h deleted +0 -346
346 lines not on this page · raw message
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 new file +884 -0
884 lines not on this page · raw message
drivers/staging/skein/skein_base.h new file +351 -0
351 lines not on this page · raw message
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
Re: [PATCH v5 2/7] staging: skein: Renames skein to skein_base
Quoted 1 line · Eric Rost
Renames
skein.ctoskein_base.candskein.htoskein_base.h
It's worth a mention in here that this is in preparation for skein.ko.
Quoted 17 lines
Signed-off-by Eric Rost <[email protected]>--- drivers/staging/skein/Makefile | 2 +- drivers/staging/skein/skein.c | 883 --------------------------------- drivers/staging/skein/skein.h | 346 ------------- drivers/staging/skein/skein_api.h | 2 +- drivers/staging/skein/skein_base.c | 884 ++++++++++++++++++++++++++++++++++ drivers/staging/skein/skein_base.h | 351 ++++++++++++++ drivers/staging/skein/skein_block.c | 2 +- drivers/staging/skein/skein_block.h | 2 +- drivers/staging/skein/skein_iv.h | 2 +- drivers/staging/skein/threefish_api.h | 2 +- 10 files changed, 1241 insertions(+), 1235 deletions(-) delete mode 100644 drivers/staging/skein/skein.c delete mode 100644 drivers/staging/skein/skein.h create mode 100644 drivers/staging/skein/skein_base.c create mode 100644 drivers/staging/skein/skein_base.h
you can add '-M' to diff or format-patch to detect renames. It'll make this patch a *lot* smaller, and allow us to see more easily that nothing changed. Well, other than the #include rename inside {skein.c ->skein_base.c}.
thx,
Jason.
PATCH v5 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_generic.c | 191 ++++++++++++++++++++++++++++++++++ 2 files changed, 193 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_generic.c new file +191 -0
191 lines not on this page · raw message
Signature · 1 line
2.1.1
Re: [PATCH v5 3/7] staging: skein: Adds CryptoAPI Support
Eric,
We're almost there... :)
Quoted 25 lines · Eric Rost
Adds CryptoAPI support to the Skein Hashing Algorithm driver.
Signed-off-by Eric Rost <[email protected]>--- drivers/staging/skein/Makefile | 3 +- drivers/staging/skein/skein_generic.c | 191 ++++++++++++++++++++++++++++++++++ 2 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/skein/skein_generic.cdrivers/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.odrivers/staging/skein/skein_generic.c new file +0
-0
...
drivers/staging/skein/skein_generic.c line 189
Quoted 11 lines
drivers/staging/skein/skein_generic.c new file +11
-0+static int __init skein_generic_init (void ) +{ +if (crypto_register_shash (&alg256) ||crypto_register_shash (&alg512) + ||crypto_register_shash (&alg1024)) { +crypto_unregister_shash (&alg256); +crypto_unregister_shash (&alg512); +crypto_unregister_shash (&alg1024); +return -1 ; + } +return 0 ; +}
This really needs to be something like:
if (crypto_register_shash(&alg256)) goto bail; if (crypto_register_shash(&alg512)) goto unreg256; if (crypto_register_shash(&alg1024)) goto unreg512; return 0;
unreg512:
crypto_unregister_shash(&alg512); unreg256: crypto_unregister_shash(&alg256); bail: return -1;
thx,
Jason.
PATCH v5 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, } };
@@ -188,4 +192,17 @@ static int __init skein_generic_init(void)return 0 ; } -device_initcall (skein_generic_init); +static void __exit skein_generic_fini(void) +{ +crypto_unregister_shash (&alg256); +crypto_unregister_shash (&alg512); +crypto_unregister_shash (&alg1024); +} + +module_init (skein_generic_init); +module_exit (skein_generic_fini); + +MODULE_LICENSE ("GPL" ); +MODULE_DESCRIPTION ("Skein Hash Algorithm" ); + +MODULE_ALIAS ("skein" );
Signature · 1 line
2.1.1
PATCH v5 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 v5 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 v5 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