Loading drivers/staging/skein/skein_base.h +59 −53 Original line number Diff line number Diff line #ifndef _SKEIN_H_ #define _SKEIN_H_ 1 /************************************************************************** ** ** Interface declarations and internal definitions for Skein hashing. ** ** Source code author: Doug Whiting, 2008. ** ** 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. ** ** The "default" note explains what happens when the switch is not defined. ** ** SKEIN_ERR_CHECK -- how error checking is handled inside Skein ** 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 ** ***************************************************************************/ /* ************************************************************************** * * Interface declarations and internal definitions for Skein hashing. * * Source code author: Doug Whiting, 2008. * * 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. * * The "default" note explains what happens when the switch is not defined. * * SKEIN_ERR_CHECK -- how error checking is handled inside Skein * 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 * ************************************************************************** */ /*Skein digest sizes for crypto api*/ #define SKEIN256_DIGEST_BIT_SIZE 256 Loading Loading @@ -101,19 +103,19 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val); int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val); /* ** Skein APIs for "extended" initialization: MAC keys, tree hashing. ** After an init_ext() call, just use update/final calls as with init(). ** ** Notes: Same parameters as _init() calls, plus tree_info/key/key_bytes. ** When key_bytes == 0 and tree_info == SKEIN_SEQUENTIAL, ** the results of init_ext() are identical to calling init(). ** The function init() may be called once to "precompute" the IV for ** a given hash_bit_len value, then by saving a copy of the context ** the IV computation may be avoided in later calls. ** Similarly, the function init_ext() 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. **/ * Skein APIs for "extended" initialization: MAC keys, tree hashing. * After an init_ext() call, just use update/final calls as with init(). * * Notes: Same parameters as _init() calls, plus tree_info/key/key_bytes. * When key_bytes == 0 and tree_info == SKEIN_SEQUENTIAL, * the results of init_ext() are identical to calling init(). * The function init() may be called once to "precompute" the IV for * a given hash_bit_len value, then by saving a copy of the context * the IV computation may be avoided in later calls. * Similarly, the function init_ext() 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. */ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, u64 tree_info, const u8 *key, size_t key_bytes); int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, Loading @@ -122,9 +124,9 @@ int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, u64 tree_info, const u8 *key, size_t key_bytes); /* ** Skein APIs for MAC and tree hash: ** final_pad: pad, do final block, but no OUTPUT type ** output: do just the output stage * Skein APIs for MAC and tree hash: * 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 *hash_val); int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val); Loading @@ -139,13 +141,15 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val); int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); #endif /***************************************************************** ** "Internal" Skein definitions ** -- 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. ******************************************************************/ /* ***************************************************************** * "Internal" Skein definitions * -- 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. ***************************************************************** */ /* tweak word tweak[1]: bit field starting positions */ #define SKEIN_T1_BIT(BIT) ((BIT) - 64) /* second word */ Loading Loading @@ -226,9 +230,9 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); #define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0, 0, 0) /* ** Skein macros for getting/setting tweak words, etc. ** These are useful for partial input bytes, hash tree init/update, etc. **/ * Skein macros for getting/setting tweak words, etc. * These are useful for partial input bytes, hash tree init/update, etc. */ #define skein_get_tweak(ctx_ptr, TWK_NUM) ((ctx_ptr)->h.tweak[TWK_NUM]) #define skein_set_tweak(ctx_ptr, TWK_NUM, t_val) { \ (ctx_ptr)->h.tweak[TWK_NUM] = (t_val); \ Loading Loading @@ -274,9 +278,11 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); #define skein_assert_ret(x, ret_code) #define skein_assert(x) /***************************************************************** ** Skein block function constants (shared across Ref and Opt code) ******************************************************************/ /* ***************************************************************** * Skein block function constants (shared across Ref and Opt code) ***************************************************************** */ enum { /* SKEIN_256 round rotation constants */ R_256_0_0 = 14, R_256_0_1 = 16, Loading drivers/staging/skein/skein_block.c +17 −15 Original line number Diff line number Diff line /*********************************************************************** ** ** Implementation of the Skein block functions. ** ** Source code author: Doug Whiting, 2008. ** ** This algorithm and source code is released to the public domain. ** ** Compile-time switches: ** ** SKEIN_USE_ASM -- set bits (256/512/1024) to select which ** versions use ASM code for block processing ** [default: use C for all block sizes] ** ************************************************************************/ /* *********************************************************************** * * Implementation of the Skein block functions. * * Source code author: Doug Whiting, 2008. * * This algorithm and source code is released to the public domain. * * Compile-time switches: * * SKEIN_USE_ASM -- set bits (256/512/1024) to select which * versions use ASM code for block processing * [default: use C for all block sizes] * *********************************************************************** */ #include <linux/string.h> #include <linux/bitops.h> Loading drivers/staging/skein/skein_block.h +11 −9 Original line number Diff line number Diff line /*********************************************************************** ** ** Implementation of the Skein hash function. ** ** Source code author: Doug Whiting, 2008. ** ** This algorithm and source code is released to the public domain. ** ************************************************************************/ /* *********************************************************************** * * 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_ Loading drivers/staging/skein/skein_iv.h +12 −12 Original line number Diff line number Diff line Loading @@ -4,18 +4,18 @@ #include "skein_base.h" /* get Skein macros and types */ /* ***************** Pre-computed Skein IVs ******************* ** ** NOTE: these values are not "magic" constants, but ** are generated using the Threefish block function. ** They are pre-computed here only for speed; i.e., to ** avoid the need for a Threefish call during Init(). ** ** The IV for any fixed hash length may be pre-computed. ** Only the most common values are included here. ** ************************************************************ **/ **************** Pre-computed Skein IVs ******************* * * NOTE: these values are not "magic" constants, but * are generated using the Threefish block function. * They are pre-computed here only for speed; i.e., to * avoid the need for a Threefish call during Init(). * * The IV for any fixed hash length may be pre-computed. * Only the most common values are included here. * *********************************************************** */ #define MK_64 SKEIN_MK_64 Loading Loading
drivers/staging/skein/skein_base.h +59 −53 Original line number Diff line number Diff line #ifndef _SKEIN_H_ #define _SKEIN_H_ 1 /************************************************************************** ** ** Interface declarations and internal definitions for Skein hashing. ** ** Source code author: Doug Whiting, 2008. ** ** 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. ** ** The "default" note explains what happens when the switch is not defined. ** ** SKEIN_ERR_CHECK -- how error checking is handled inside Skein ** 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 ** ***************************************************************************/ /* ************************************************************************** * * Interface declarations and internal definitions for Skein hashing. * * Source code author: Doug Whiting, 2008. * * 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. * * The "default" note explains what happens when the switch is not defined. * * SKEIN_ERR_CHECK -- how error checking is handled inside Skein * 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 * ************************************************************************** */ /*Skein digest sizes for crypto api*/ #define SKEIN256_DIGEST_BIT_SIZE 256 Loading Loading @@ -101,19 +103,19 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val); int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val); /* ** Skein APIs for "extended" initialization: MAC keys, tree hashing. ** After an init_ext() call, just use update/final calls as with init(). ** ** Notes: Same parameters as _init() calls, plus tree_info/key/key_bytes. ** When key_bytes == 0 and tree_info == SKEIN_SEQUENTIAL, ** the results of init_ext() are identical to calling init(). ** The function init() may be called once to "precompute" the IV for ** a given hash_bit_len value, then by saving a copy of the context ** the IV computation may be avoided in later calls. ** Similarly, the function init_ext() 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. **/ * Skein APIs for "extended" initialization: MAC keys, tree hashing. * After an init_ext() call, just use update/final calls as with init(). * * Notes: Same parameters as _init() calls, plus tree_info/key/key_bytes. * When key_bytes == 0 and tree_info == SKEIN_SEQUENTIAL, * the results of init_ext() are identical to calling init(). * The function init() may be called once to "precompute" the IV for * a given hash_bit_len value, then by saving a copy of the context * the IV computation may be avoided in later calls. * Similarly, the function init_ext() 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. */ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, u64 tree_info, const u8 *key, size_t key_bytes); int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, Loading @@ -122,9 +124,9 @@ int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, u64 tree_info, const u8 *key, size_t key_bytes); /* ** Skein APIs for MAC and tree hash: ** final_pad: pad, do final block, but no OUTPUT type ** output: do just the output stage * Skein APIs for MAC and tree hash: * 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 *hash_val); int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val); Loading @@ -139,13 +141,15 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val); int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); #endif /***************************************************************** ** "Internal" Skein definitions ** -- 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. ******************************************************************/ /* ***************************************************************** * "Internal" Skein definitions * -- 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. ***************************************************************** */ /* tweak word tweak[1]: bit field starting positions */ #define SKEIN_T1_BIT(BIT) ((BIT) - 64) /* second word */ Loading Loading @@ -226,9 +230,9 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); #define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0, 0, 0) /* ** Skein macros for getting/setting tweak words, etc. ** These are useful for partial input bytes, hash tree init/update, etc. **/ * Skein macros for getting/setting tweak words, etc. * These are useful for partial input bytes, hash tree init/update, etc. */ #define skein_get_tweak(ctx_ptr, TWK_NUM) ((ctx_ptr)->h.tweak[TWK_NUM]) #define skein_set_tweak(ctx_ptr, TWK_NUM, t_val) { \ (ctx_ptr)->h.tweak[TWK_NUM] = (t_val); \ Loading Loading @@ -274,9 +278,11 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); #define skein_assert_ret(x, ret_code) #define skein_assert(x) /***************************************************************** ** Skein block function constants (shared across Ref and Opt code) ******************************************************************/ /* ***************************************************************** * Skein block function constants (shared across Ref and Opt code) ***************************************************************** */ enum { /* SKEIN_256 round rotation constants */ R_256_0_0 = 14, R_256_0_1 = 16, Loading
drivers/staging/skein/skein_block.c +17 −15 Original line number Diff line number Diff line /*********************************************************************** ** ** Implementation of the Skein block functions. ** ** Source code author: Doug Whiting, 2008. ** ** This algorithm and source code is released to the public domain. ** ** Compile-time switches: ** ** SKEIN_USE_ASM -- set bits (256/512/1024) to select which ** versions use ASM code for block processing ** [default: use C for all block sizes] ** ************************************************************************/ /* *********************************************************************** * * Implementation of the Skein block functions. * * Source code author: Doug Whiting, 2008. * * This algorithm and source code is released to the public domain. * * Compile-time switches: * * SKEIN_USE_ASM -- set bits (256/512/1024) to select which * versions use ASM code for block processing * [default: use C for all block sizes] * *********************************************************************** */ #include <linux/string.h> #include <linux/bitops.h> Loading
drivers/staging/skein/skein_block.h +11 −9 Original line number Diff line number Diff line /*********************************************************************** ** ** Implementation of the Skein hash function. ** ** Source code author: Doug Whiting, 2008. ** ** This algorithm and source code is released to the public domain. ** ************************************************************************/ /* *********************************************************************** * * 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_ Loading
drivers/staging/skein/skein_iv.h +12 −12 Original line number Diff line number Diff line Loading @@ -4,18 +4,18 @@ #include "skein_base.h" /* get Skein macros and types */ /* ***************** Pre-computed Skein IVs ******************* ** ** NOTE: these values are not "magic" constants, but ** are generated using the Threefish block function. ** They are pre-computed here only for speed; i.e., to ** avoid the need for a Threefish call during Init(). ** ** The IV for any fixed hash length may be pre-computed. ** Only the most common values are included here. ** ************************************************************ **/ **************** Pre-computed Skein IVs ******************* * * NOTE: these values are not "magic" constants, but * are generated using the Threefish block function. * They are pre-computed here only for speed; i.e., to * avoid the need for a Threefish call during Init(). * * The IV for any fixed hash length may be pre-computed. * Only the most common values are included here. * *********************************************************** */ #define MK_64 SKEIN_MK_64 Loading