staging: skein: Adds CryptoAPI and Module Support
v4 cover staging: skein: Adds CryptoAPI and Module Support
Adds CryptoAPI and Loadable Module support to the Skein Hash Algorithm. Also inlines the rotl_64 macro.
Eric Rost (3):
staging: skein: Adds CryptoAPI Support
staging: skein: Adds Loadable Module Support
staging: skein: Inlines rotl_64
drivers/staging/skein/Kconfig | 24 +- drivers/staging/skein/Makefile | 13 +- drivers/staging/skein/skein.c | 883 --------------------------------- drivers/staging/skein/skein.h | 346 ------------- drivers/staging/skein/skein_api.h | 2 +- drivers/staging/skein/skein_base.c | 884 ++++++++++++++++++++++++++++++++++ drivers/staging/skein/skein_base.h | 352 ++++++++++++++ drivers/staging/skein/skein_block.c | 2 +- drivers/staging/skein/skein_block.h | 2 +- drivers/staging/skein/skein_generic.c | 211 ++++++++ drivers/staging/skein/skein_iv.h | 2 +- drivers/staging/skein/threefish_api.h | 2 +- 12 files changed, 1463 insertions(+), 1260 deletions(-) delete mode 100644 drivers/staging/skein/skein.c delete mode 100644 drivers/staging/skein/skein.h create mode 100644 drivers/staging/skein/skein_base.c create mode 100644 drivers/staging/skein/skein_base.h create mode 100644 drivers/staging/skein/skein_generic.c
Signature · 1 line
2.1.1
PATCH v4 1/3 staging: skein: Adds CryptoAPI Support
Adds CryptoAPI support for skein256, skein512, and skein1024 algorithms. Also collapses threefish algorithm into skein.o and removes Kconfig option for Threefish.
--- drivers/staging/skein/Kconfig | 22 +- drivers/staging/skein/Makefile | 13 +- drivers/staging/skein/skein.c | 883 --------------------------------- drivers/staging/skein/skein.h | 346 ------------- drivers/staging/skein/skein_api.h | 2 +- drivers/staging/skein/skein_base.c | 884 ++++++++++++++++++++++++++++++++++ drivers/staging/skein/skein_base.h | 351 ++++++++++++++ drivers/staging/skein/skein_block.c | 2 +- drivers/staging/skein/skein_block.h | 2 +- drivers/staging/skein/skein_generic.c | 194 ++++++++ drivers/staging/skein/skein_iv.h | 2 +- drivers/staging/skein/threefish_api.h | 2 +- 12 files changed, 1444 insertions(+), 1259 deletions(-) delete mode 100644 drivers/staging/skein/skein.c delete mode 100644 drivers/staging/skein/skein.h create mode 100644 drivers/staging/skein/skein_base.c create mode 100644 drivers/staging/skein/skein_base.h create mode 100644 drivers/staging/skein/skein_generic.c
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 +7 -6
@@ -1,9 +1,10 @@ # # Makefile for the skein secure hash algorithm # -obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \ - skein_api.o \ - skein_block.o - -obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \ - threefish_api.o +obj-$(CONFIG_CRYPTO_SKEIN) += skein.o +skein-y := skein_base.o \ + skein_api.o \ + skein_block.o \ + threefish_block.o \ + threefish_api.o \ + skein_generic.o
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_generic.c new file +194 -0
194 lines not on this page · raw message
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 v4 2/3 staging: skein: Adds Loadable Module Support
In reply to Eric RostAdds loadable module support for the Skein Hashing Algorithm.
--- drivers/staging/skein/Kconfig | 2 +- drivers/staging/skein/skein_generic.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 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/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"
@@ -142,6 +143,7 @@ static struct shash_alg alg256 = { .cra_driver_name = "skein", .cra_flags = CRYPTO_ALG_TYPE_SHASH, .cra_blocksize = SKEIN_256_BLOCK_BYTES, + .cra_module = THIS_MODULE, } };
@@ -159,6 +161,7 @@ static struct shash_alg alg512 = { .cra_driver_name = "skein", .cra_flags = CRYPTO_ALG_TYPE_SHASH, .cra_blocksize = SKEIN_512_BLOCK_BYTES, + .cra_module = THIS_MODULE, } };
@@ -176,6 +179,7 @@ static struct shash_alg alg1024 = { .cra_driver_name = "skein", .cra_flags = CRYPTO_ALG_TYPE_SHASH, .cra_blocksize = SKEIN_1024_BLOCK_BYTES, + .cra_module = THIS_MODULE, } };
@@ -191,4 +195,17 @@ static int __init skein_generic_init(void)return 0 ; } -device_initcall (skein_generic_init); +static void __exit skein_generic_fini(void) +{ +crypto_unregister_shash (&alg256); +crypto_unregister_shash (&alg512); +crypto_unregister_shash (&alg1024); +} + +module_init (skein_generic_init); +module_exit (skein_generic_fini); + +MODULE_LICENSE ("GPL" ); +MODULE_DESCRIPTION ("Skein Hash Algorithm" ); + +MODULE_ALIAS ("skein" );
Signature · 1 line
2.1.1
PATCH v4 3/3 staging: skein: Inlines rotl_64
In reply to Eric RostInlines the macro definition rotl_64 to avoid bugs.
--- drivers/staging/skein/skein_base.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/staging/skein/skein_base.h +5 -4
@@ -33,10 +33,6 @@#define SKEIN512_DIGEST_BIT_SIZE 512#define SKEIN1024_DIGEST_BIT_SIZE 1024 -#ifndef rotl_64 -#define rotl_64 (x,N ) (((x) << (N)) | ((x) >> (64-(N)))) -#endif -/* below two prototype assume we are handed aligned data */ #define skein_put64_lsb_first (dst08, src64, b_cnt) memcpy(dst08, src64, b_cnt)#define skein_get64_lsb_first (dst64, src08, w_cnt) \
@@ -92,6 +88,11 @@ struct skein_1024_ctx { /* 1024-bit Skein hash context structure */u8 b[SKEIN_1024_BLOCK_BYTES ];/* partial block buf (8-byte aligned) */ }; +static inline int rotl_64 (int x,int N ) +{ +return (x <<N ) | (x >> (64 -N )); +} +/* Skein APIs for (incremental) "straight hashing" */ int skein_256_init (struct skein_256_ctx *ctx,size_t hash_bit_len);int skein_512_init (struct skein_512_ctx *ctx,size_t hash_bit_len);
Signature · 1 line
2.1.1