staging: skein: Adds CryptoAPI and Module Support
v3 cover staging: skein: Adds CryptoAPI and Module Support
Adds CryptoAPI and Loadable Module support to the Skein Hashing Algorithm.
Eric Rost (2):
staging: skein: Adds CryptoAPI Support
staging: skein: Adds Loadable Module Support
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 | 351 ++++++++++++++ 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, 1462 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 v3 1/2 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
Re: [PATCH v3 1/2] staging: skein: Adds CryptoAPI Support
First of all this patch does too many things at once. Collapsing files and deleting them needs to be done in separate patches from adding them. There is the "one thing per patch" and each one of those is a separate thing.
drivers/staging/skein/skein_generic.c line 34
Quoted 6 lines · Eric Rost
drivers/staging/skein/skein_generic.c new file +6
-0+int skein256_update (struct shash_desc *desc,const u8 *data, +unsigned int len) +{ +return skein_256_update ((struct skein_256_ctx *)shash_desc_ctx (desc), + data, (size_t ) len); +}
The two line version of this cast was prettier. Also if you run checkpatch.pl --strict over this it will hopefully warn about the space in the middle of the cast and the alignment of data. Also the cast to size_t is superflous.
The checkpatch --strict version of this looks like:
int skein256_update(struct shash_desc *desc, const u8 *data,
unsigned int len)
{
return skein_256_update((struct skein_256_ctx *)shash_desc_ctx(desc),
data, len);
}Eventually, I feel like we would wave skein_256_update() to just take a shash_desc pointer? We'd have to shuffle the skein_ctx struct a bit to make that work. (I haven't looked at this carefully).
regards,
dan carpenter
PATCH v3 2/2 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