staging: crypto: skein: fixing style issues
v2 cover staging: crypto: skein: fixing style issues
Hi! To prepare skein driver for mainline inclusion we fixing most of style issues (wrong names of functions, vars, macros, files) and checkpatch problems in this patch set. For example, existing code is widely use camelCase names. This patch fix it.
Anton Saraev (6):
staging: crypto: skein: rename camelcase functions
staging: crypto: skein: rename camelcase vars
staging: crypto: skein: rename skein1024_ctx to skein_1024_ctx
staging: crypto: skein: rename enums
staging: crypto: skein: rename macros
staging: crypto: skein: rename files
drivers/staging/skein/Makefile | 10 +-
drivers/staging/skein/TODO | 3 -
drivers/staging/skein/include/skein.h | 180 +++----
.../skein/include/{skeinApi.h => skein_api.h} | 66 +--
drivers/staging/skein/include/skein_block.h | 12 +-
drivers/staging/skein/include/skein_iv.h | 6 +-
.../include/{threefishApi.h => threefish_api.h} | 84 +--
drivers/staging/skein/skein.c | 577 +++++++++++----------
drivers/staging/skein/{skeinApi.c => skein_api.c} | 170 +++---
drivers/staging/skein/skein_block.c | 411 +++++++--------
.../{skeinBlockNo3F.c => skein_block_no_3f.c} | 62 +--
drivers/staging/skein/threefishApi.c | 79 ---
...threefish1024Block.c => threefish_1024_block.c} | 80 +--
.../{threefish256Block.c => threefish_256_block.c} | 32 +-
.../{threefish512Block.c => threefish_512_block.c} | 48 +-
drivers/staging/skein/threefish_api.c | 78 +++
16 files changed, 959 insertions(+), 939 deletions(-)
rename drivers/staging/skein/include/{skeinApi.h => skein_api.h} (79%)
rename drivers/staging/skein/include/{threefishApi.h => threefish_api.h} (66%)
rename drivers/staging/skein/{skeinApi.c => skein_api.c} (52%)
rename drivers/staging/skein/{skeinBlockNo3F.c => skein_block_no_3f.c} (66%)
delete mode 100644 drivers/staging/skein/threefishApi.c
rename drivers/staging/skein/{threefish1024Block.c => threefish_1024_block.c} (98%)
rename drivers/staging/skein/{threefish256Block.c => threefish_256_block.c} (96%)
rename drivers/staging/skein/{threefish512Block.c => threefish_512_block.c} (97%)
create mode 100644 drivers/staging/skein/threefish_api.cSignature · 1 line
1.9.2
PATCH v2 1/6 staging: crypto: skein: rename camelcase functions
camelCase is not accepted in the Linux Kernel. To prepare skein driver for mainline inclusion, we rename all functions to non-camelCase equivalents.
--- drivers/staging/skein/TODO | 1 - drivers/staging/skein/include/skein.h | 66 ++++++++-------- drivers/staging/skein/include/skeinApi.h | 38 ++++----- drivers/staging/skein/include/skein_block.h | 12 +-- drivers/staging/skein/include/threefishApi.h | 44 ++++++----- drivers/staging/skein/skein.c | 114 +++++++++++++-------------- drivers/staging/skein/skeinApi.c | 72 ++++++++--------- drivers/staging/skein/skeinBlockNo3F.c | 24 +++--- drivers/staging/skein/skein_block.c | 40 +++++----- drivers/staging/skein/threefish1024Block.c | 6 +- drivers/staging/skein/threefish256Block.c | 6 +- drivers/staging/skein/threefish512Block.c | 6 +- drivers/staging/skein/threefishApi.c | 38 ++++----- 13 files changed, 239 insertions(+), 228 deletions(-)
drivers/staging/skein/TODO +0 -1
@@ -1,7 +1,6 @@ skein/threefish TODO - rename camelcase vars - - rename camelcase functions - rename files - move macros into appropriate header files - add / pass test vectors
drivers/staging/skein/include/skein.h +33 -33
92 lines not on this page · raw message
drivers/staging/skein/include/skeinApi.h +19 -19
@@ -50,31 +50,31 @@ OTHER DEALINGS IN THE SOFTWARE.* struct skein_ctx ctx; // a Skein hash or MAC context * * // prepare context, here for a Skein with a state size of 512 bits. -* skeinCtxPrepare(&ctx, Skein512); +* skein_ctx_prepare(&ctx, Skein512); * * // Initialize the context to set the requested hash length in bits * // here request a output hash size of 31 bits (Skein supports variable * // output sizes even very strange sizes) -* skeinInit(&ctx, 31); +* skein_init(&ctx, 31); * * // Now update Skein with any number of message bits. A function that * // takes a number of bytes is also available. -* skeinUpdateBits(&ctx, message, msgLength); +* skein_update_bits(&ctx, message, msgLength); * * // Now get the result of the Skein hash. The output buffer must be * // large enough to hold the request number of output bits. The application * // may now extract the bits. -* skeinFinal(&ctx, result); +* skein_final(&ctx, result); * ... * @endcode * -* An application may use @c skeinReset to reset a Skein context and use +* An application may use @c skein_reset to reset a Skein context and use * it for creation of another hash with the same Skein state size and output * bit length. In this case the API implementation restores some internal * internal state data and saves a full Skein initialization round. * -* To create a MAC the application just uses @c skeinMacInit instead of -* @c skeinInit. All other functions calls remain the same. +* To create a MAC the application just uses @c skein_mac_init instead of +* @c skein_init. All other functions calls remain the same. * */
@@ -123,7 +123,7 @@ struct skein_ctx {* @return * SKEIN_SUCESS of SKEIN_FAIL */ -int skeinCtxPrepare (struct skein_ctx *ctx,enum skein_size size); +int skein_ctx_prepare (struct skein_ctx *ctx,enum skein_size size);/** * Initialize a Skein context.
@@ -137,9 +137,9 @@ int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size);* Number of MAC hash bits to compute * @return * SKEIN_SUCESS of SKEIN_FAIL -* @see skeinReset +* @see skein_reset */ -int skeinInit (struct skein_ctx *ctx,size_t hashBitLen); +int skein_init (struct skein_ctx *ctx,size_t hashBitLen);/** * Resets a Skein context for further use.
@@ -151,7 +151,7 @@ int skeinInit(struct skein_ctx *ctx, size_t hashBitLen);* @param ctx * Pointer to a pre-initialized Skein MAC context */ -void skeinReset (struct skein_ctx *ctx); +void skein_reset (struct skein_ctx *ctx);/** * Initializes a Skein context for MAC usage.
@@ -173,8 +173,8 @@ void skeinReset(struct skein_ctx *ctx);* @return * SKEIN_SUCESS of SKEIN_FAIL */ -int skeinMacInit (struct skein_ctx *ctx,const u8 *key,size_t keyLen, -size_t hashBitLen); +int skein_mac_init (struct skein_ctx *ctx,const u8 *key,size_t keyLen, +size_t hashBitLen);/** * Update Skein with the next part of the message.
@@ -188,8 +188,8 @@ int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen,* @return * Success or error code. */ -int skeinUpdate (struct skein_ctx *ctx,const u8 *msg, -size_t msgByteCnt); +int skein_update (struct skein_ctx *ctx,const u8 *msg, +size_t msgByteCnt);/** * Update the hash with a message bit string.
@@ -204,8 +204,8 @@ int skeinUpdate(struct skein_ctx *ctx, const u8 *msg,* @param msgBitCnt * Length of the message in @b bits. */ -int skeinUpdateBits (struct skein_ctx *ctx,const u8 *msg, -size_t msgBitCnt); +int skein_update_bits (struct skein_ctx *ctx,const u8 *msg, +size_t msgBitCnt);/** * Finalize Skein and return the hash.
@@ -220,9 +220,9 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg,* enough to store @c hashBitLen bits. * @return * Success or error code. -* @see skeinReset +* @see skein_reset */ -int skeinFinal (struct skein_ctx *ctx,u8 *hash); +int skein_final (struct skein_ctx *ctx,u8 *hash);/** * @}
drivers/staging/skein/include/skein_block.h +6 -6
@@ -12,11 +12,11 @@#include <skein.h> /* get the Skein API definitions */ -void Skein_256_Process_Block (struct skein_256_ctx *ctx,const u8 *blkPtr, -size_t blkCnt,size_t byteCntAdd); -void Skein_512_Process_Block (struct skein_512_ctx *ctx,const u8 *blkPtr, -size_t blkCnt,size_t byteCntAdd); -void Skein1024_Process_Block (struct skein1024_ctx *ctx,const u8 *blkPtr, -size_t blkCnt,size_t byteCntAdd); +void skein_256_process_block (struct skein_256_ctx *ctx,const u8 *blkPtr, +size_t blkCnt,size_t byteCntAdd); +void skein_512_process_block (struct skein_512_ctx *ctx,const u8 *blkPtr, +size_t blkCnt,size_t byteCntAdd); +void skein_1024_process_block (struct skein1024_ctx *ctx,const u8 *blkPtr, +size_t blkCnt,size_t byteCntAdd);#endif
drivers/staging/skein/include/threefishApi.h +25 -19
83 lines not on this page · raw message
drivers/staging/skein/skein.c +57 -57
390 lines not on this page · raw message
drivers/staging/skein/skeinApi.c +36 -36
168 lines not on this page · raw message
drivers/staging/skein/skeinBlockNo3F.c +12 -12
@@ -5,8 +5,8 @@/***************************** Skein_256 ******************************/ -void Skein_256_Process_Block (struct skein_256_ctx *ctx,const u8 *blkPtr, -size_t blkCnt,size_t byteCntAdd) +void skein_256_process_block (struct skein_256_ctx *ctx,const u8 *blkPtr, +size_t blkCnt,size_t byteCntAdd) {struct threefish_key key;u64 tweak[2 ];
@@ -34,12 +34,12 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, tweak[0 ] |= (words[1 ] &0xffffffffL ) <<32 ; tweak[1 ] |= words[2 ] &0xffffffffL ; -threefishSetKey (&key, Threefish256, ctx->X, tweak); +threefish_set_key (&key, Threefish256, ctx->X, tweak);/* get input block in little-endian format */ Skein_Get64_LSB_First (w, blkPtr,SKEIN_256_STATE_WORDS ); -threefishEncryptBlockWords (&key, w, ctx->X); +threefish_encrypt_block_words (&key, w, ctx->X); blkPtr +=SKEIN_256_BLOCK_BYTES ;
@@ -56,8 +56,8 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, ctx->h.T[1 ] = tweak[1 ]; } -void Skein_512_Process_Block (struct skein_512_ctx *ctx,const u8 *blkPtr, -size_t blkCnt,size_t byteCntAdd) +void skein_512_process_block (struct skein_512_ctx *ctx,const u8 *blkPtr, +size_t blkCnt,size_t byteCntAdd) {struct threefish_key key;u64 tweak[2 ];
@@ -85,12 +85,12 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, tweak[0 ] |= (words[1 ] &0xffffffffL ) <<32 ; tweak[1 ] |= words[2 ] &0xffffffffL ; -threefishSetKey (&key, Threefish512, ctx->X, tweak); +threefish_set_key (&key, Threefish512, ctx->X, tweak);/* get input block in little-endian format */ Skein_Get64_LSB_First (w, blkPtr,SKEIN_512_STATE_WORDS ); -threefishEncryptBlockWords (&key, w, ctx->X); +threefish_encrypt_block_words (&key, w, ctx->X); blkPtr +=SKEIN_512_BLOCK_BYTES ;
@@ -111,8 +111,8 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, ctx->h.T[1 ] = tweak[1 ]; } -void Skein1024_Process_Block (struct skein1024_ctx *ctx,const u8 *blkPtr, -size_t blkCnt,size_t byteCntAdd) +void skein_1024_process_block (struct skein1024_ctx *ctx,const u8 *blkPtr, +size_t blkCnt,size_t byteCntAdd) {struct threefish_key key;u64 tweak[2 ];
@@ -140,12 +140,12 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, tweak[0 ] |= (words[1 ] &0xffffffffL ) <<32 ; tweak[1 ] |= words[2 ] &0xffffffffL ; -threefishSetKey (&key, Threefish1024, ctx->X, tweak); +threefish_set_key (&key, Threefish1024, ctx->X, tweak);/* get input block in little-endian format */ Skein_Get64_LSB_First (w, blkPtr,SKEIN1024_STATE_WORDS ); -threefishEncryptBlockWords (&key, w, ctx->X); +threefish_encrypt_block_words (&key, w, ctx->X); blkPtr +=SKEIN1024_BLOCK_BYTES ;
drivers/staging/skein/skein_block.c +20 -20
@@ -39,8 +39,8 @@/***************************** Skein_256 ******************************/ #if !(SKEIN_USE_ASM & 256) -void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd) +void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd) { /* do it in C */ enum { WCNT = SKEIN_256_STATE_WORDS
@@ -215,7 +215,7 @@ do { \R256_8_rounds (14 );#endif #if (SKEIN_UNROLL_256 >14 ) -#error "need more unrolling in Skein_256_Process_Block" +#error "need more unrolling in skein_256_process_block"#endif }/* do the final "feedforward" xor, update context chaining */
@@ -233,12 +233,12 @@ do { \ }#if defined(SKEIN_CODE_SIZE ) || defined(SKEIN_PERF ) -size_t Skein_256_Process_Block_CodeSize (void ) +size_t skein_256_process_block_code_size (void ) { -return ((u8 *) Skein_256_Process_Block_CodeSize) - - ((u8 *) Skein_256_Process_Block); +return ((u8 *) skein_256_process_block_code_size) - + ((u8 *) skein_256_process_block); } -unsigned int Skein_256_Unroll_Cnt (void ) +unsigned int skein_256_unroll_cnt (void ) {return SKEIN_UNROLL_256 ; }
@@ -247,8 +247,8 @@ unsigned int Skein_256_Unroll_Cnt(void)/***************************** Skein_512 ******************************/ #if !(SKEIN_USE_ASM & 512) -void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd) +void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd) { /* do it in C */ enum { WCNT = SKEIN_512_STATE_WORDS
@@ -441,7 +441,7 @@ do { \R512_8_rounds (14 );#endif #if (SKEIN_UNROLL_512 >14 ) -#error "need more unrolling in Skein_512_Process_Block" +#error "need more unrolling in skein_512_process_block"#endif }
@@ -463,12 +463,12 @@ do { \ }#if defined(SKEIN_CODE_SIZE ) || defined(SKEIN_PERF ) -size_t Skein_512_Process_Block_CodeSize (void ) +size_t skein_512_process_block_code_size (void ) { -return ((u8 *) Skein_512_Process_Block_CodeSize) - - ((u8 *) Skein_512_Process_Block); +return ((u8 *) skein_512_process_block_code_size) - + ((u8 *) skein_512_process_block); } -unsigned int Skein_512_Unroll_Cnt (void ) +unsigned int skein_512_unroll_cnt (void ) {return SKEIN_UNROLL_512 ; }
@@ -477,8 +477,8 @@ unsigned int Skein_512_Unroll_Cnt(void)/***************************** Skein1024 ******************************/ #if !(SKEIN_USE_ASM & 1024) -void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd) +void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd) { /* do it in C, always looping (unrolled is bigger AND slower!) */ enum { WCNT = SKEIN1024_STATE_WORDS
@@ -757,12 +757,12 @@ do { \ }#if defined(SKEIN_CODE_SIZE ) || defined(SKEIN_PERF ) -size_t Skein1024_Process_Block_CodeSize (void ) +size_t skein_1024_process_block_code_size (void ) { -return ((u8 *) Skein1024_Process_Block_CodeSize) - - ((u8 *) Skein1024_Process_Block); +return ((u8 *) skein_1024_process_block_code_size) - + ((u8 *) skein_1024_process_block); } -unsigned int Skein1024_Unroll_Cnt (void ) +unsigned int skein_1024_unroll_cnt (void ) {return SKEIN_UNROLL_1024 ; }
drivers/staging/skein/threefish1024Block.c +4 -2
@@ -2,7 +2,8 @@#include <threefishApi.h> -void threefishEncrypt1024 (struct threefish_key *keyCtx,u64 *input,u64 *output) +void threefish_encrypt_1024 (struct threefish_key *keyCtx,u64 *input, +u64 *output) {u64 b0 = input[0 ], b1 = input[1 ], b2 = input[2], b3 = input[3],
@@ -2122,7 +2123,8 @@ void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output) output[15 ] = b15 + k1 +20 ; } -void threefishDecrypt1024 (struct threefish_key *keyCtx,u64 *input,u64 *output) +void threefish_decrypt_1024 (struct threefish_key *keyCtx,u64 *input, +u64 *output) {u64 b0 = input[0 ], b1 = input[1 ], b2 = input[2], b3 = input[3],
drivers/staging/skein/threefish256Block.c +4 -2
@@ -2,7 +2,8 @@#include <threefishApi.h> -void threefishEncrypt256 (struct threefish_key *keyCtx,u64 *input,u64 *output) +void threefish_encrypt_256 (struct threefish_key *keyCtx,u64 *input, +u64 *output) {u64 b0 = input[0 ], b1 = input[1 ], b2 = input[2 ], b3 = input[3 ];
@@ -494,7 +495,8 @@ void threefishEncrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output) output[3 ] = b3 + k1 +18 ; } -void threefishDecrypt256 (struct threefish_key *keyCtx,u64 *input,u64 *output) +void threefish_decrypt_256 (struct threefish_key *keyCtx,u64 *input, +u64 *output) {u64 b0 = input[0 ], b1 = input[1 ], b2 = input[2 ], b3 = input[3 ];
drivers/staging/skein/threefish512Block.c +4 -2
@@ -2,7 +2,8 @@#include <threefishApi.h> -void threefishEncrypt512 (struct threefish_key *keyCtx,u64 *input,u64 *output) +void threefish_encrypt_512 (struct threefish_key *keyCtx,u64 *input, +u64 *output) {u64 b0 = input[0 ], b1 = input[1 ], b2 = input[2], b3 = input[3],
@@ -962,7 +963,8 @@ void threefishEncrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output) output[7 ] = b7 + k7 +18 ; } -void threefishDecrypt512 (struct threefish_key *keyCtx,u64 *input,u64 *output) +void threefish_decrypt_512 (struct threefish_key *keyCtx,u64 *input, +u64 *output) {u64 b0 = input[0 ], b1 = input[1 ], b2 = input[2], b3 = input[3],
drivers/staging/skein/threefishApi.c +19 -19
@@ -3,9 +3,9 @@#include <linux/string.h> #include <threefishApi.h> -void threefishSetKey (struct threefish_key *keyCtx, -enum threefish_size stateSize, -u64 *keyData,u64 *tweak) +void threefish_set_key (struct threefish_key *keyCtx, +enum threefish_size stateSize, +u64 *keyData,u64 *tweak) {int keyWords = stateSize /64 ;int i;
@@ -23,56 +23,56 @@ void threefishSetKey(struct threefish_key *keyCtx, keyCtx->stateSize = stateSize; } -void threefishEncryptBlockBytes (struct threefish_key *keyCtx,u8 *in, -u8 *out) +void threefish_encrypt_block_bytes (struct threefish_key *keyCtx,u8 *in, +u8 *out) {u64 plain[SKEIN_MAX_STATE_WORDS ];/* max number of words*/ u64 cipher[SKEIN_MAX_STATE_WORDS ];Skein_Get64_LSB_First (plain, in, keyCtx->stateSize /64 ); -threefishEncryptBlockWords (keyCtx, plain, cipher); +threefish_encrypt_block_words (keyCtx, plain, cipher);Skein_Put64_LSB_First (out, cipher, keyCtx->stateSize /8 ); } -void threefishEncryptBlockWords (struct threefish_key *keyCtx,u64 *in, -u64 *out) +void threefish_encrypt_block_words (struct threefish_key *keyCtx,u64 *in, +u64 *out) {switch (keyCtx->stateSize) {case Threefish256: -threefishEncrypt256 (keyCtx, in, out); +threefish_encrypt_256 (keyCtx, in, out);break ;case Threefish512: -threefishEncrypt512 (keyCtx, in, out); +threefish_encrypt_512 (keyCtx, in, out);break ;case Threefish1024: -threefishEncrypt1024 (keyCtx, in, out); +threefish_encrypt_1024 (keyCtx, in, out);break ; } } -void threefishDecryptBlockBytes (struct threefish_key *keyCtx,u8 *in, -u8 *out) +void threefish_decrypt_block_bytes (struct threefish_key *keyCtx,u8 *in, +u8 *out) {u64 plain[SKEIN_MAX_STATE_WORDS ];/* max number of words*/ u64 cipher[SKEIN_MAX_STATE_WORDS ];Skein_Get64_LSB_First (cipher, in, keyCtx->stateSize /64 ); -threefishDecryptBlockWords (keyCtx, cipher, plain); +threefish_decrypt_block_words (keyCtx, cipher, plain);Skein_Put64_LSB_First (out, plain, keyCtx->stateSize /8 ); } -void threefishDecryptBlockWords (struct threefish_key *keyCtx,u64 *in, -u64 *out) +void threefish_decrypt_block_words (struct threefish_key *keyCtx,u64 *in, +u64 *out) {switch (keyCtx->stateSize) {case Threefish256: -threefishDecrypt256 (keyCtx, in, out); +threefish_decrypt_256 (keyCtx, in, out);break ;case Threefish512: -threefishDecrypt512 (keyCtx, in, out); +threefish_decrypt_512 (keyCtx, in, out);break ;case Threefish1024: -threefishDecrypt1024 (keyCtx, in, out); +threefish_decrypt_1024 (keyCtx, in, out);break ; } }
Signature · 1 line
1.9.2
PATCH v2 4/6 staging: crypto: skein: rename enums
In reply to Anton SaraevLinux Kernel use capitalized names for enum. To prepare skein driver to mainline inclusion, we rename all enums to capitalized names.
--- drivers/staging/skein/include/skein.h | 6 +++--- drivers/staging/skein/include/skeinApi.h | 8 ++++---- drivers/staging/skein/include/threefishApi.h | 18 +++++++++--------- drivers/staging/skein/skeinApi.c | 24 ++++++++++++------------ drivers/staging/skein/skeinBlockNo3F.c | 6 +++--- drivers/staging/skein/skein_block.c | 6 +++--- drivers/staging/skein/threefishApi.c | 12 ++++++------ 7 files changed, 40 insertions(+), 40 deletions(-)
drivers/staging/skein/include/skein.h +3 -3
@@ -293,7 +293,7 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val);** Skein block function constants (shared across Ref and Opt code) ******************************************************************/ enum { -/* Skein_256 round rotation constants */ +/* SKEIN_256 round rotation constants */ R_256_0_0 =14 ,R_256_0_1 =16 ,R_256_1_0 =52 ,R_256_1_1 =57 ,R_256_2_0 =23 ,R_256_2_1 =40 ,
@@ -303,7 +303,7 @@ enum {R_256_6_0 =58 ,R_256_6_1 =22 ,R_256_7_0 =32 ,R_256_7_1 =32 , -/* Skein_512 round rotation constants */ +/* SKEIN_512 round rotation constants */ R_512_0_0 =46 ,R_512_0_1 =36 ,R_512_0_2 =19 ,R_512_0_3 =37 ,R_512_1_0 =33 ,R_512_1_1 =27 ,R_512_1_2 =14 ,R_512_1_3 =42 , R_512_2_0 = 17, R_512_2_1 = 49, R_512_2_2 = 36, R_512_2_3 = 39,
@@ -313,7 +313,7 @@ enum {R_512_6_0 =25 ,R_512_6_1 =29 ,R_512_6_2 =39 ,R_512_6_3 =43 ,R_512_7_0 =8 ,R_512_7_1 =35 ,R_512_7_2 =56 ,R_512_7_3 =22 , -/* Skein1024 round rotation constants */ +/* SKEIN_1024 round rotation constants */ R1024_0_0 =24 ,R1024_0_1 =13 ,R1024_0_2 =8 ,R1024_0_3 =47 ,R1024_0_4 =8 ,R1024_0_5 =17 ,R1024_0_6 =22 ,R1024_0_7 =37 , R1024_1_0 = 38, R1024_1_1 = 19, R1024_1_2 = 10, R1024_1_3 = 55,
drivers/staging/skein/include/skeinApi.h +4 -4
@@ -50,7 +50,7 @@ OTHER DEALINGS IN THE SOFTWARE.* struct skein_ctx ctx; // a Skein hash or MAC context * * // prepare context, here for a Skein with a state size of 512 bits. -* skein_ctx_prepare(&ctx, Skein512); +* skein_ctx_prepare(&ctx, SKEIN_512); * * // Initialize the context to set the requested hash length in bits * // here request a output hash size of 31 bits (Skein supports variable
@@ -85,9 +85,9 @@ OTHER DEALINGS IN THE SOFTWARE.* Which Skein size to use */ enum skein_size { - Skein256 =256 ,/*!< Skein with 256 bit state */ - Skein512 =512 ,/*!< Skein with 512 bit state */ - Skein1024 =1024 /*!< Skein with 1024 bit state */ +SKEIN_256 =256 ,/*!< Skein with 256 bit state */ +SKEIN_512 =512 ,/*!< Skein with 512 bit state */ +SKEIN_1024 =1024 /*!< Skein with 1024 bit state */ };/**
drivers/staging/skein/include/threefishApi.h +9 -9
@@ -17,14 +17,14 @@* functions. * @code -// Threefish cipher context data -struct threefish_key key_ctx; +// Threefish cipher context data +struct threefish_key key_ctx; -// Initialize the context -threefish_set_key(&key_ctx, Threefish512, key, tweak); +// Initialize the context +threefish_set_key(&key_ctx, THREEFISH_512, key, tweak); -// Encrypt -threefish_encrypt_block_bytes(&key_ctx, input, cipher); +// Encrypt +threefish_encrypt_block_bytes(&key_ctx, input, cipher); @endcode */
@@ -37,9 +37,9 @@* Which Threefish size to use */ enum threefish_size { - Threefish256 =256 ,/*!< Skein with 256 bit state */ - Threefish512 =512 ,/*!< Skein with 512 bit state */ - Threefish1024 =1024 /*!< Skein with 1024 bit state */ +THREEFISH_256 =256 ,/*!< Skein with 256 bit state */ +THREEFISH_512 =512 ,/*!< Skein with 512 bit state */ +THREEFISH_1024 =1024 /*!< Skein with 1024 bit state */ };/**
drivers/staging/skein/skeinApi.c +12 -12
@@ -57,15 +57,15 @@ int skein_init(struct skein_ctx *ctx, size_t hash_bit_len)* the save chaining variables. */ switch (ctx->skein_size) { -case Skein256: +case SKEIN_256 : ret =skein_256_init_ext (&ctx->m.s256, hash_bit_len, tree_info,NULL ,0 );break ; -case Skein512: +case SKEIN_512 : ret =skein_512_init_ext (&ctx->m.s512, hash_bit_len, tree_info,NULL ,0 );break ; -case Skein1024: +case SKEIN_1024 : ret =skein_1024_init_ext (&ctx->m.s1024, hash_bit_len, tree_info,NULL ,0 );break ;
@@ -97,18 +97,18 @@ int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t key_len,Skein_Assert (hash_bit_len,SKEIN_BAD_HASHLEN );switch (ctx->skein_size) { -case Skein256: +case SKEIN_256 : ret =skein_256_init_ext (&ctx->m.s256, hash_bit_len, tree_info, (const u8 *)key, key_len);break ; -case Skein512: +case SKEIN_512 : ret =skein_512_init_ext (&ctx->m.s512, hash_bit_len, tree_info, (const u8 *)key, key_len);break ; -case Skein1024: +case SKEIN_1024 : ret =skein_1024_init_ext (&ctx->m.s1024, hash_bit_len, tree_info, (const u8 *)key, key_len);
@@ -152,15 +152,15 @@ int skein_update(struct skein_ctx *ctx, const u8 *msg,Skein_Assert (ctx,SKEIN_FAIL );switch (ctx->skein_size) { -case Skein256: +case SKEIN_256 : ret =skein_256_update (&ctx->m.s256, (const u8 *)msg, msg_byte_cnt);break ; -case Skein512: +case SKEIN_512 : ret =skein_512_update (&ctx->m.s512, (const u8 *)msg, msg_byte_cnt);break ; -case Skein1024: +case SKEIN_1024 : ret =skein_1024_update (&ctx->m.s1024, (const u8 *)msg, msg_byte_cnt);break ;
@@ -225,13 +225,13 @@ int skein_final(struct skein_ctx *ctx, u8 *hash)Skein_Assert (ctx,SKEIN_FAIL );switch (ctx->skein_size) { -case Skein256: +case SKEIN_256 : ret =skein_256_final (&ctx->m.s256, (u8 *)hash);break ; -case Skein512: +case SKEIN_512 : ret =skein_512_final (&ctx->m.s512, (u8 *)hash);break ; -case Skein1024: +case SKEIN_1024 : ret =skein_1024_final (&ctx->m.s1024, (u8 *)hash);break ; }
drivers/staging/skein/skeinBlockNo3F.c +3 -3
@@ -34,7 +34,7 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, tweak[0 ] |= (words[1 ] &0xffffffffL ) <<32 ; tweak[1 ] |= words[2 ] &0xffffffffL ; -threefish_set_key (&key, Threefish256, ctx->X, tweak); +threefish_set_key (&key,THREEFISH_256 , ctx->X, tweak);/* get input block in little-endian format */ Skein_Get64_LSB_First (w, blk_ptr,SKEIN_256_STATE_WORDS );
@@ -85,7 +85,7 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, tweak[0 ] |= (words[1 ] &0xffffffffL ) <<32 ; tweak[1 ] |= words[2 ] &0xffffffffL ; -threefish_set_key (&key, Threefish512, ctx->X, tweak); +threefish_set_key (&key,THREEFISH_512 , ctx->X, tweak);/* get input block in little-endian format */ Skein_Get64_LSB_First (w, blk_ptr,SKEIN_512_STATE_WORDS );
@@ -140,7 +140,7 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, tweak[0 ] |= (words[1 ] &0xffffffffL ) <<32 ; tweak[1 ] |= words[2 ] &0xffffffffL ; -threefish_set_key (&key, Threefish1024, ctx->X, tweak); +threefish_set_key (&key,THREEFISH_1024 , ctx->X, tweak);/* get input block in little-endian format */ Skein_Get64_LSB_First (w, blk_ptr,SKEIN1024_STATE_WORDS );
drivers/staging/skein/skein_block.c +3 -3
@@ -37,7 +37,7 @@#define DebugSaveTweak (ctx)#endif -/***************************** Skein_256 ******************************/ +/***************************** SKEIN_256 ******************************/ #if !(SKEIN_USE_ASM &256 )void skein_256_process_block (struct skein_256_ctx *ctx,const u8 *blk_ptr,size_t blk_cnt,size_t byte_cnt_add)
@@ -246,7 +246,7 @@ unsigned int skein_256_unroll_cnt(void)#endif #endif -/***************************** Skein_512 ******************************/ +/***************************** SKEIN_512 ******************************/ #if !(SKEIN_USE_ASM &512 )void skein_512_process_block (struct skein_512_ctx *ctx,const u8 *blk_ptr,size_t blk_cnt,size_t byte_cnt_add)
@@ -477,7 +477,7 @@ unsigned int skein_512_unroll_cnt(void)#endif #endif -/***************************** Skein1024 ******************************/ +/***************************** SKEIN_1024 ******************************/ #if !(SKEIN_USE_ASM &1024 )void skein_1024_process_block (struct skein_1024_ctx *ctx,const u8 *blk_ptr,size_t blk_cnt,size_t byte_cnt_add)
drivers/staging/skein/threefishApi.c +6 -6
@@ -38,13 +38,13 @@ void threefish_encrypt_block_words(struct threefish_key *key_ctx, u64 *in, u64 *out) {switch (key_ctx->state_size) { -case Threefish256: +case THREEFISH_256 :threefish_encrypt_256 (key_ctx, in, out);break ; -case Threefish512: +case THREEFISH_512 :threefish_encrypt_512 (key_ctx, in, out);break ; -case Threefish1024: +case THREEFISH_1024 :threefish_encrypt_1024 (key_ctx, in, out);break ; }
@@ -65,13 +65,13 @@ void threefish_decrypt_block_words(struct threefish_key *key_ctx, u64 *in, u64 *out) {switch (key_ctx->state_size) { -case Threefish256: +case THREEFISH_256 :threefish_decrypt_256 (key_ctx, in, out);break ; -case Threefish512: +case THREEFISH_512 :threefish_decrypt_512 (key_ctx, in, out);break ; -case Threefish1024: +case THREEFISH_1024 :threefish_decrypt_1024 (key_ctx, in, out);break ; }
Signature · 1 line
1.9.2
PATCH v2 6/6 staging: crypto: skein: rename files
In reply to Anton SaraevcamelCase is not accepted in the Linux Kernel. To prepare skein driver for mainline inclusion, we rename all files to non-camelCase equivalents.
---
drivers/staging/skein/Makefile | 10 +++++-----
drivers/staging/skein/TODO | 1 -
drivers/staging/skein/include/{skeinApi.h => skein_api.h} | 4 ++--
.../staging/skein/include/{threefishApi.h => threefish_api.h} | 2 +-
drivers/staging/skein/{skeinApi.c => skein_api.c} | 2 +-
.../staging/skein/{skeinBlockNo3F.c => skein_block_no_3f.c} | 2 +-
.../skein/{threefish1024Block.c => threefish_1024_block.c} | 2 +-
.../skein/{threefish256Block.c => threefish_256_block.c} | 2 +-
.../skein/{threefish512Block.c => threefish_512_block.c} | 2 +-
drivers/staging/skein/{threefishApi.c => threefish_api.c} | 3 +--
10 files changed, 14 insertions(+), 16 deletions(-)
rename drivers/staging/skein/include/{skeinApi.h => skein_api.h} (99%)
rename drivers/staging/skein/include/{threefishApi.h => threefish_api.h} (99%)
rename drivers/staging/skein/{skeinApi.c => skein_api.c} (99%)
rename drivers/staging/skein/{skeinBlockNo3F.c => skein_block_no_3f.c} (99%)
rename drivers/staging/skein/{threefish1024Block.c => threefish_1024_block.c} (99%)
rename drivers/staging/skein/{threefish256Block.c => threefish_256_block.c} (99%)
rename drivers/staging/skein/{threefish512Block.c => threefish_512_block.c} (99%)
rename drivers/staging/skein/{threefishApi.c => threefish_api.c} (98%)drivers/staging/skein/Makefile +5 -5
@@ -4,10 +4,10 @@ subdir-ccflags-y := -I$(src)/include/ obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \ - skeinApi.o \ + skein_api.o \ skein_block.o -obj-$(CONFIG_CRYPTO_THREEFISH) += threefish1024Block.o \ - threefish256Block.o \ - threefish512Block.o \ - threefishApi.o +obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_1024_block.o \ + threefish_256_block.o \ + threefish_512_block.o \ + threefish_api.o
drivers/staging/skein/TODO +0 -1
@@ -1,6 +1,5 @@ skein/threefish TODO - - rename files - move macros into appropriate header files - add / pass test vectors - module support
drivers/staging/skein/include/skein_api.h renamed from drivers/staging/skein/include/skeinApi.h +2 -2
@@ -28,7 +28,7 @@ OTHER DEALINGS IN THE SOFTWARE.#define SKEINAPI_H /** -* @file skeinApi.h +* @file skein_api.h * @brief A Skein API and its functions. * @{ *
@@ -44,7 +44,7 @@ OTHER DEALINGS IN THE SOFTWARE.* * @code * -* #include <skeinApi.h> +* #include <skein_api.h> * * ... * struct skein_ctx ctx; // a Skein hash or MAC context
drivers/staging/skein/include/threefish_api.h renamed from drivers/staging/skein/include/threefishApi.h +1 -1
@@ -3,7 +3,7 @@#define THREEFISHAPI_H /** -* @file threefishApi.h +* @file threefish_api.h * @brief A Threefish cipher API and its functions. * @{ *
drivers/staging/skein/skein_api.c renamed from drivers/staging/skein/skeinApi.c +1 -1
@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.*/ #include <linux/string.h> -#include <skeinApi.h> +#include <skein_api.h> int skein_ctx_prepare (struct skein_ctx *ctx,enum skein_size size) {
drivers/staging/skein/skein_block_no_3f.c renamed from drivers/staging/skein/skeinBlockNo3F.c +1 -1
@@ -1,7 +1,7 @@#include <linux/string.h> #include <skein.h> -#include <threefishApi.h> +#include <threefish_api.h> /***************************** Skein_256 ******************************/
drivers/staging/skein/threefish_1024_block.c renamed from drivers/staging/skein/threefish1024Block.c +1 -1
@@ -1,5 +1,5 @@#include <linux/string.h> -#include <threefishApi.h> +#include <threefish_api.h> void threefish_encrypt_1024(struct threefish_key *key_ctx, u64 *input,
drivers/staging/skein/threefish_256_block.c renamed from drivers/staging/skein/threefish256Block.c +1 -1
@@ -1,5 +1,5 @@#include <linux/string.h> -#include <threefishApi.h> +#include <threefish_api.h> void threefish_encrypt_256(struct threefish_key *key_ctx, u64 *input,
drivers/staging/skein/threefish_512_block.c renamed from drivers/staging/skein/threefish512Block.c +1 -1
@@ -1,5 +1,5 @@#include <linux/string.h> -#include <threefishApi.h> +#include <threefish_api.h> void threefish_encrypt_512(struct threefish_key *key_ctx, u64 *input,
drivers/staging/skein/threefish_api.c renamed from drivers/staging/skein/threefishApi.c +1 -2
@@ -1,7 +1,7 @@#include <linux/string.h> -#include <threefishApi.h> +#include <threefish_api.h> void threefish_set_key(struct threefish_key *key_ctx, enum threefish_size state_size,
@@ -76,4 +76,3 @@ void threefish_decrypt_block_words(struct threefish_key *key_ctx, u64 *in,break ; } } -
Signature · 1 line
1.9.2
PATCH v2 5/6 staging: crypto: skein: rename macros
In reply to Anton SaraevMixing upper and lower case in names of macros like It_Is_Macro is not accepted in the Linux Kernel. To prepare skein driver for mainline inclusion, we rename all macros to uppercase or lowercase names.
--- drivers/staging/skein/include/skein.h | 75 +++---- drivers/staging/skein/include/skein_iv.h | 6 +- drivers/staging/skein/include/threefishApi.h | 2 +- drivers/staging/skein/skein.c | 262 +++++++++++------------ drivers/staging/skein/skeinApi.c | 22 +- drivers/staging/skein/skeinBlockNo3F.c | 20 +- drivers/staging/skein/skein_block.c | 308 +++++++++++++-------------- drivers/staging/skein/threefishApi.c | 10 +- 8 files changed, 353 insertions(+), 352 deletions(-)
drivers/staging/skein/include/skein.h +38 -37
@@ -28,15 +28,15 @@** ***************************************************************************/ -#ifndef RotL_64 -#define RotL_64 (x,N ) (((x) << (N)) | ((x) >> (64-(N)))) +#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) \ +#define skein_put64_lsb_first (dst08, src64, b_cnt) memcpy(dst08, src64, b_cnt) +#define skein_get64_lsb_first (dst64, src08, w_cnt) \ memcpy(dst64, src08, 8*(w_cnt)) -#define Skein_Swap64 (w64) (w64) +#define skein_swap64 (w64) (w64)enum {SKEIN_SUCCESS =0 ,/* return codes from Skein calls */
@@ -48,20 +48,20 @@ enum {#define SKEIN_256_STATE_WORDS (4)#define SKEIN_512_STATE_WORDS (8) -#define SKEIN1024_STATE_WORDS (16) +#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) -#define SKEIN1024_STATE_BYTES (8*SKEIN1024_STATE_WORDS) +#define SKEIN_1024_STATE_BYTES (8*SKEIN_1024_STATE_WORDS)#define SKEIN_256_STATE_BITS (64*SKEIN_256_STATE_WORDS)#define SKEIN_512_STATE_BITS (64*SKEIN_512_STATE_WORDS) -#define SKEIN1024_STATE_BITS (64*SKEIN1024_STATE_WORDS) +#define SKEIN_1024_STATE_BITS (64*SKEIN_1024_STATE_WORDS)#define SKEIN_256_BLOCK_BYTES (8*SKEIN_256_STATE_WORDS)#define SKEIN_512_BLOCK_BYTES (8*SKEIN_512_STATE_WORDS) -#define SKEIN1024_BLOCK_BYTES (8*SKEIN1024_STATE_WORDS) +#define SKEIN_1024_BLOCK_BYTES (8*SKEIN_1024_STATE_WORDS)struct skein_ctx_hdr {size_t hash_bit_len;/* size of hash result, in bits */
@@ -83,8 +83,8 @@ struct skein_512_ctx { /* 512-bit Skein hash context structure */struct skein_1024_ctx {/* 1024-bit Skein hash context structure */ struct skein_ctx_hdr h;/* common header context variables */ -u64 X[SKEIN1024_STATE_WORDS ];/* chaining variables */ -u8 b[SKEIN1024_BLOCK_BYTES ];/* partial block buf (8-byte aligned) */ +u64 X[SKEIN_1024_STATE_WORDS ];/* chaining variables */ +u8 b[SKEIN_1024_BLOCK_BYTES ];/* partial block buf (8-byte aligned) */ };/* Skein APIs for (incremental) "straight hashing" */
@@ -232,44 +232,44 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val);** 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.T[TWK_NUM]) -#define Skein_Set_Tweak (ctx_ptr,TWK_NUM , t_val) { \ +#define skein_get_tweak (ctx_ptr,TWK_NUM ) ((ctx_ptr)->h.T[TWK_NUM]) +#define skein_set_tweak (ctx_ptr,TWK_NUM , t_val) { \ (ctx_ptr)->h.T[TWK_NUM] = (t_val); \ } -#define Skein_Get_T0 (ctx_ptr) Skein_Get_Tweak(ctx_ptr, 0) -#define Skein_Get_T1 (ctx_ptr) Skein_Get_Tweak(ctx_ptr, 1) -#define Skein_Set_T0 (ctx_ptr,T0 ) Skein_Set_Tweak(ctx_ptr, 0, T0) -#define Skein_Set_T1 (ctx_ptr,T1 ) Skein_Set_Tweak(ctx_ptr, 1, T1) +#define skein_get_T0 (ctx_ptr) skein_get_tweak(ctx_ptr, 0) +#define skein_get_T1 (ctx_ptr) skein_get_tweak(ctx_ptr, 1) +#define skein_set_T0 (ctx_ptr,T0 ) skein_set_tweak(ctx_ptr, 0, T0) +#define skein_set_T1 (ctx_ptr,T1 ) skein_set_tweak(ctx_ptr, 1, T1)/* set both tweak words at once */ -#define Skein_Set_T0_T1 (ctx_ptr,T0 ,T1 ) \ - { \ - Skein_Set_T0(ctx_ptr, (T0)); \ - Skein_Set_T1(ctx_ptr, (T1)); \ +#define skein_set_T0_T1 (ctx_ptr,T0 ,T1 ) \ + { \ + skein_set_T0(ctx_ptr, (T0)); \ + skein_set_T1(ctx_ptr, (T1)); \ } -#define Skein_Set_Type (ctx_ptr,BLK_TYPE ) \ - Skein_Set_T1(ctx_ptr, SKEIN_T1_BLK_TYPE_##BLK_TYPE) +#define skein_set_type (ctx_ptr,BLK_TYPE ) \ + skein_set_T1(ctx_ptr, SKEIN_T1_BLK_TYPE_##BLK_TYPE)/* * setup for starting with a new type: * h.T[0]=0; h.T[1] = NEW_TYPE; h.b_cnt=0; */ -#define Skein_Start_New_Type (ctx_ptr,BLK_TYPE ) { \ - Skein_Set_T0_T1(ctx_ptr, 0, SKEIN_T1_FLAG_FIRST | \ +#define skein_start_new_type (ctx_ptr,BLK_TYPE ) { \ + skein_set_T0_T1(ctx_ptr, 0, SKEIN_T1_FLAG_FIRST | \ SKEIN_T1_BLK_TYPE_##BLK_TYPE); \ (ctx_ptr)->h.b_cnt = 0; \ } -#define Skein_Clear_First_Flag (hdr) { \ +#define skein_clear_first_flag (hdr) { \ (hdr).T[1] &= ~SKEIN_T1_FLAG_FIRST; \ } -#define Skein_Set_Bit_Pad_Flag (hdr) { \ +#define skein_set_bit_pad_flag (hdr) { \ (hdr).T[1] |= SKEIN_T1_FLAG_BIT_PAD; \ } -#define Skein_Set_Tree_Level (hdr, height) { \ +#define skein_set_tree_level (hdr, height) { \ (hdr).T[1] |= SKEIN_T1_TREE_LEVEL(height); \ }
@@ -279,15 +279,16 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val);#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) +#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 -#define Skein_Assert (x, ret_code)/* ignore all Asserts, for performance */ -#define Skein_assert (x) +/* ignore all asserts, for performance */ +#define skein_assert_ret (x, ret_code) +#define skein_assert (x)/***************************************************************** ** Skein block function constants (shared across Ref and Opt code)
@@ -335,11 +336,11 @@ enum {#ifndef SKEIN_ROUNDS #define SKEIN_256_ROUNDS_TOTAL (72)/* # rounds for diff block sizes */ #define SKEIN_512_ROUNDS_TOTAL (72) -#define SKEIN1024_ROUNDS_TOTAL (80) +#define SKEIN_1024_ROUNDS_TOTAL (80)#else /* allow command-line define in range 8*(5..14) */ #define SKEIN_256_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/100) + 5) % 10) + 5))#define SKEIN_512_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/10) + 5) % 10) + 5)) -#define SKEIN1024_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS) + 5) % 10) + 5)) +#define SKEIN_1024_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS) + 5) % 10) + 5))#endif #endif /* ifndef _SKEIN_H_ */
drivers/staging/skein/include/skein_iv.h +3 -3
@@ -124,7 +124,7 @@ const u64 SKEIN_512_IV_512[] = { };/* blkSize = 1024 bits. hashSize = 384 bits */ -const u64 SKEIN1024_IV_384 [] = { +const u64 SKEIN_1024_IV_384 [] = {MK_64 (0x5102B6B8 ,0xC1894A35 ),MK_64 (0xFEEBC9E3 ,0xFE8AF11A ),MK_64 (0x0C807F06 ,0xE32BED71 ),
@@ -144,7 +144,7 @@ const u64 SKEIN1024_IV_384[] = { };/* blkSize = 1024 bits. hashSize = 512 bits */ -const u64 SKEIN1024_IV_512 [] = { +const u64 SKEIN_1024_IV_512 [] = {MK_64 (0xCAEC0E5D ,0x7C1B1B18 ),MK_64 (0xA01B0E04 ,0x5F03E802 ),MK_64 (0x33840451 ,0xED912885 ),
@@ -164,7 +164,7 @@ const u64 SKEIN1024_IV_512[] = { };/* blkSize = 1024 bits. hashSize = 1024 bits */ -const u64 SKEIN1024_IV_1024 [] = { +const u64 SKEIN_1024_IV_1024 [] = {MK_64 (0xD593DA07 ,0x41E72355 ),MK_64 (0x15B5E511 ,0xAC73E00C ),MK_64 (0x5180E5AE ,0xBAF2C4F0 ),
drivers/staging/skein/include/threefishApi.h +1 -1
@@ -31,7 +31,7 @@#include <linux/types.h> #include <skein.h> -#define KeyScheduleConst 0x1BD11BDAA9FC1A22L +#define KEY_SCHEDULE_CONST 0x1BD11BDAA9FC1A22L/** * Which Threefish size to use
drivers/staging/skein/skein.c +131 -131
683 lines not on this page · raw message
drivers/staging/skein/skeinApi.c +11 -11
@@ -29,7 +29,7 @@ OTHER DEALINGS IN THE SOFTWARE.int skein_ctx_prepare (struct skein_ctx *ctx,enum skein_size size) { -Skein_Assert (ctx && size,SKEIN_FAIL ); +skein_assert_ret (ctx && size,SKEIN_FAIL );memset (ctx ,0 ,sizeof (struct skein_ctx )); ctx->skein_size = size;
@@ -44,7 +44,7 @@ int skein_init(struct skein_ctx *ctx, size_t hash_bit_len)u64 *X =NULL ;u64 tree_info =SKEIN_CFG_TREE_INFO_SEQUENTIAL ; -Skein_Assert (ctx,SKEIN_FAIL ); +skein_assert_ret (ctx,SKEIN_FAIL );/* * The following two lines rely of the fact that the real Skein * contexts are a union in out context and thus have tha maximum
@@ -89,12 +89,12 @@ int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t key_len,size_t X_len =0 ;u64 tree_info =SKEIN_CFG_TREE_INFO_SEQUENTIAL ; -Skein_Assert (ctx,SKEIN_FAIL ); +skein_assert_ret (ctx,SKEIN_FAIL );X = ctx->m.s256.X; X_len = ctx->skein_size/8 ; -Skein_Assert (hash_bit_len,SKEIN_BAD_HASHLEN ); +skein_assert_ret (hash_bit_len,SKEIN_BAD_HASHLEN );switch (ctx->skein_size) {case SKEIN_256 :
@@ -141,7 +141,7 @@ void skein_reset(struct skein_ctx *ctx)memcpy (X , ctx->X_save, X_len);/* Setup context to process the message */ -Skein_Start_New_Type (&ctx->m,MSG ); +skein_start_new_type (&ctx->m,MSG ); } int skein_update(struct skein_ctx *ctx, const u8 *msg,
@@ -149,7 +149,7 @@ int skein_update(struct skein_ctx *ctx, const u8 *msg, {int ret =SKEIN_FAIL ; -Skein_Assert (ctx,SKEIN_FAIL ); +skein_assert_ret (ctx,SKEIN_FAIL );switch (ctx->skein_size) {case SKEIN_256 :
@@ -185,8 +185,8 @@ int skein_update_bits(struct skein_ctx *ctx, const u8 *msg,* only the final Update() call is allowed do partial bytes, else * assert an error */ -Skein_Assert ((ctx->m.h.T[1 ] &SKEIN_T1_FLAG_BIT_PAD ) ==0 || - msg_bit_cnt ==0 ,SKEIN_FAIL ); +skein_assert_ret ((ctx->m.h.T[1 ] &SKEIN_T1_FLAG_BIT_PAD ) ==0 || + msg_bit_cnt ==0 ,SKEIN_FAIL );/* if number of bits is a multiple of bytes - that's easy */ if ((msg_bit_cnt &0x7 ) ==0 )
@@ -203,13 +203,13 @@ int skein_update_bits(struct skein_ctx *ctx, const u8 *msg, up = (u8 *)ctx->m.s256.X + ctx->skein_size /8 ;/* set tweak flag for the skein_final call */ -Skein_Set_Bit_Pad_Flag (ctx->m.h); +skein_set_bit_pad_flag (ctx->m.h);/* now "pad" the final partial byte the way NIST likes */ /* get the b_cnt value (same location for all block sizes) */ length = ctx->m.h.b_cnt;/* internal sanity check: there IS a partial byte in the buffer! */ -Skein_assert (length !=0 ); +skein_assert (length !=0 );/* partial byte bit mask */ mask = (u8) (1u << (7 - (msg_bit_cnt &7 )));/* apply bit padding on final byte (in the buffer) */
@@ -222,7 +222,7 @@ int skein_final(struct skein_ctx *ctx, u8 *hash) {int ret =SKEIN_FAIL ; -Skein_Assert (ctx,SKEIN_FAIL ); +skein_assert_ret (ctx,SKEIN_FAIL );switch (ctx->skein_size) {case SKEIN_256 :
drivers/staging/skein/skeinBlockNo3F.c +10 -10
@@ -11,10 +11,10 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr,struct threefish_key key;u64 tweak[2 ];int i; -u64 w[SKEIN_256_STATE_WORDS ];/* local copy of input block */ +u64 w[SKEIN_256_STATE_WORDS ];/* local copy of input block */ u64 words[3 ]; -Skein_assert (blk_cnt !=0 );/* never call with blk_cnt == 0! */ +skein_assert (blk_cnt !=0 );/* never call with blk_cnt == 0! */ tweak[0 ] = ctx->h.T[0 ]; tweak[1 ] = ctx->h.T[1 ];
@@ -37,7 +37,7 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr,threefish_set_key (&key,THREEFISH_256 , ctx->X, tweak);/* get input block in little-endian format */ -Skein_Get64_LSB_First (w, blk_ptr,SKEIN_256_STATE_WORDS ); +skein_get64_lsb_first (w, blk_ptr,SKEIN_256_STATE_WORDS );threefish_encrypt_block_words (&key, w, ctx->X);
@@ -63,9 +63,9 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr,u64 tweak[2 ];int i;u64 words[3 ]; -u64 w[SKEIN_512_STATE_WORDS ];/* local copy of input block */ +u64 w[SKEIN_512_STATE_WORDS ];/* local copy of input block */ -Skein_assert (blk_cnt !=0 );/* never call with blk_cnt == 0! */ +skein_assert (blk_cnt !=0 );/* never call with blk_cnt == 0! */ tweak[0 ] = ctx->h.T[0 ]; tweak[1 ] = ctx->h.T[1 ];
@@ -88,7 +88,7 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr,threefish_set_key (&key,THREEFISH_512 , ctx->X, tweak);/* get input block in little-endian format */ -Skein_Get64_LSB_First (w, blk_ptr,SKEIN_512_STATE_WORDS ); +skein_get64_lsb_first (w, blk_ptr,SKEIN_512_STATE_WORDS );threefish_encrypt_block_words (&key, w, ctx->X);
@@ -118,9 +118,9 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr,u64 tweak[2 ];int i;u64 words[3 ]; -u64 w[SKEIN1024_STATE_WORDS ];/* local copy of input block */ +u64 w[SKEIN_1024_STATE_WORDS ];/* local copy of input block */ -Skein_assert (blk_cnt !=0 );/* never call with blk_cnt == 0! */ +skein_assert (blk_cnt !=0 );/* never call with blk_cnt == 0! */ tweak[0 ] = ctx->h.T[0 ]; tweak[1 ] = ctx->h.T[1 ];
@@ -143,11 +143,11 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr,threefish_set_key (&key,THREEFISH_1024 , ctx->X, tweak);/* get input block in little-endian format */ -Skein_Get64_LSB_First (w, blk_ptr,SKEIN1024_STATE_WORDS ); +skein_get64_lsb_first (w, blk_ptr,SKEIN_1024_STATE_WORDS );threefish_encrypt_block_words (&key, w, ctx->X); - blk_ptr +=SKEIN1024_BLOCK_BYTES ; + blk_ptr +=SKEIN_1024_BLOCK_BYTES ;/* do the final "feedforward" xor, update ctx chaining vars */ ctx->X[0 ] = ctx->X[0 ] ^ w[0 ];
drivers/staging/skein/skein_block.c +154 -154
562 lines not on this page · raw message
drivers/staging/skein/threefishApi.c +5 -5
@@ -9,7 +9,7 @@ void threefish_set_key(struct threefish_key *key_ctx, {int key_words = state_size /64 ;int i; -u64 parity = KeyScheduleConst; +u64 parity =KEY_SCHEDULE_CONST ; key_ctx->tweak[0 ] = tweak[0 ]; key_ctx->tweak[1 ] = tweak[1 ];
@@ -29,9 +29,9 @@ void threefish_encrypt_block_bytes(struct threefish_key *key_ctx, u8 *in,u64 plain[SKEIN_MAX_STATE_WORDS ];/* max number of words*/ u64 cipher[SKEIN_MAX_STATE_WORDS ]; -Skein_Get64_LSB_First (plain, in, key_ctx->state_size /64 ); +skein_get64_lsb_first (plain, in, key_ctx->state_size /64 );threefish_encrypt_block_words (key_ctx, plain, cipher); -Skein_Put64_LSB_First (out, cipher, key_ctx->state_size /8 ); +skein_put64_lsb_first (out, cipher, key_ctx->state_size /8 ); } void threefish_encrypt_block_words(struct threefish_key *key_ctx, u64 *in,
@@ -56,9 +56,9 @@ void threefish_decrypt_block_bytes(struct threefish_key *key_ctx, u8 *in,u64 plain[SKEIN_MAX_STATE_WORDS ];/* max number of words*/ u64 cipher[SKEIN_MAX_STATE_WORDS ]; -Skein_Get64_LSB_First (cipher, in, key_ctx->state_size /64 ); +skein_get64_lsb_first (cipher, in, key_ctx->state_size /64 );threefish_decrypt_block_words (key_ctx, cipher, plain); -Skein_Put64_LSB_First (out, plain, key_ctx->state_size /8 ); +skein_put64_lsb_first (out, plain, key_ctx->state_size /8 ); } void threefish_decrypt_block_words(struct threefish_key *key_ctx, u64 *in,
Signature · 1 line
1.9.2
PATCH v2 3/6 staging: crypto: skein: rename skein1024_ctx to skein_1024_ctx
In reply to Anton SaraevCode have skein_512_ctx and skein_256_ctx but skein1024_ctx. It would be logical to convert these names to a single form.
--- drivers/staging/skein/include/skein.h | 14 +++++++------- drivers/staging/skein/include/skeinApi.h | 2 +- drivers/staging/skein/include/skein_block.h | 2 +- drivers/staging/skein/skein.c | 12 ++++++------ drivers/staging/skein/skeinBlockNo3F.c | 2 +- drivers/staging/skein/skein_block.c | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-)
drivers/staging/skein/include/skein.h +7 -7
@@ -81,7 +81,7 @@ struct skein_512_ctx { /* 512-bit Skein hash context structure */u8 b[SKEIN_512_BLOCK_BYTES ];/* partial block buf (8-byte aligned) */ }; -struct skein1024_ctx {/* 1024-bit Skein hash context structure */ +struct skein_1024_ctx {/* 1024-bit Skein hash context structure */ struct skein_ctx_hdr h;/* common header context variables */ u64 X[SKEIN1024_STATE_WORDS ];/* chaining variables */ u8 b[SKEIN1024_BLOCK_BYTES ];/* partial block buf (8-byte aligned) */
@@ -90,18 +90,18 @@ struct skein1024_ctx { /* 1024-bit Skein hash context structure *//* 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); -int skein_1024_init (struct skein1024_ctx *ctx,size_t hash_bit_len); +int skein_1024_init (struct skein_1024_ctx *ctx,size_t hash_bit_len);int skein_256_update (struct skein_256_ctx *ctx,const u8 *msg,size_t msg_byte_cnt);int skein_512_update (struct skein_512_ctx *ctx,const u8 *msg,size_t msg_byte_cnt); -int skein_1024_update (struct skein1024_ctx *ctx,const u8 *msg, +int skein_1024_update (struct skein_1024_ctx *ctx,const u8 *msg,size_t msg_byte_cnt);int skein_256_final (struct skein_256_ctx *ctx,u8 *hash_val);int skein_512_final (struct skein_512_ctx *ctx,u8 *hash_val); -int skein_1024_final (struct skein1024_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.
@@ -121,7 +121,7 @@ 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,u64 tree_info,const u8 *key,size_t key_bytes); -int skein_1024_init_ext (struct skein1024_ctx *ctx,size_t hash_bit_len, +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);/*
@@ -131,7 +131,7 @@ int skein_1024_init_ext(struct skein1024_ctx *ctx, size_t hash_bit_len,*/ 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); -int skein_1024_final_pad (struct skein1024_ctx *ctx,u8 *hash_val); +int skein_1024_final_pad (struct skein_1024_ctx *ctx,u8 *hash_val);#ifndef SKEIN_TREE_HASH #define SKEIN_TREE_HASH (1)
@@ -139,7 +139,7 @@ int skein_1024_final_pad(struct skein1024_ctx *ctx, u8 *hash_val);#if SKEIN_TREE_HASH int skein_256_output (struct skein_256_ctx *ctx,u8 *hash_val);int skein_512_output (struct skein_512_ctx *ctx,u8 *hash_val); -int skein_1024_output (struct skein1024_ctx *ctx,u8 *hash_val); +int skein_1024_output (struct skein_1024_ctx *ctx,u8 *hash_val);#endif /*****************************************************************
drivers/staging/skein/include/skeinApi.h +1 -1
@@ -105,7 +105,7 @@ struct skein_ctx {struct skein_ctx_hdr h;struct skein_256_ctx s256;struct skein_512_ctx s512; -struct skein1024_ctx s1024; +struct skein_1024_ctx s1024; } m; };
drivers/staging/skein/include/skein_block.h +1 -1
@@ -16,7 +16,7 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, size_t blk_cnt, size_t byte_cnt_add);void skein_512_process_block (struct skein_512_ctx *ctx,const u8 *blk_ptr,size_t blk_cnt,size_t byte_cnt_add); -void skein_1024_process_block (struct skein1024_ctx *ctx,const u8 *blk_ptr, +void skein_1024_process_block (struct skein_1024_ctx *ctx,const u8 *blk_ptr,size_t blk_cnt,size_t byte_cnt_add);#endif
drivers/staging/skein/skein.c +6 -6
@@ -476,7 +476,7 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val)/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a straight hashing operation */ -int skein_1024_init (struct skein1024_ctx *ctx,size_t hash_bit_len) +int skein_1024_init (struct skein_1024_ctx *ctx,size_t hash_bit_len) {union {u8 b[SKEIN1024_STATE_BYTES ];
@@ -531,7 +531,7 @@ int skein_1024_init(struct skein1024_ctx *ctx, size_t hash_bit_len)/* init the context for a MAC and/or tree hash operation */ /* [identical to skein_1024_init() when key_bytes == 0 && \ * tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int skein_1024_init_ext (struct skein1024_ctx *ctx,size_t hash_bit_len, +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) {union {
@@ -592,7 +592,7 @@ int skein_1024_init_ext(struct skein1024_ctx *ctx, size_t hash_bit_len,/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ -int skein_1024_update (struct skein1024_ctx *ctx,const u8 *msg, +int skein_1024_update (struct skein_1024_ctx *ctx,const u8 *msg,size_t msg_byte_cnt) {size_t n;
@@ -647,7 +647,7 @@ int skein_1024_update(struct skein1024_ctx *ctx, const u8 *msg,/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the result */ -int skein_1024_final (struct skein1024_ctx *ctx,u8 *hash_val) +int skein_1024_final (struct skein_1024_ctx *ctx,u8 *hash_val) {size_t i, n, byte_cnt;u64 X [SKEIN1024_STATE_WORDS ];
@@ -743,7 +743,7 @@ int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val)/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the block, no OUTPUT stage */ -int skein_1024_final_pad (struct skein1024_ctx *ctx,u8 *hash_val) +int skein_1024_final_pad (struct skein_1024_ctx *ctx,u8 *hash_val) {/* catch uninitialized context */ Skein_Assert (ctx->h.b_cnt <=SKEIN1024_BLOCK_BYTES ,SKEIN_FAIL );
@@ -844,7 +844,7 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val)/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* just do the OUTPUT stage */ -int skein_1024_output (struct skein1024_ctx *ctx,u8 *hash_val) +int skein_1024_output (struct skein_1024_ctx *ctx,u8 *hash_val) {size_t i, n, byte_cnt;u64 X [SKEIN1024_STATE_WORDS ];
drivers/staging/skein/skeinBlockNo3F.c +1 -1
@@ -111,7 +111,7 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, ctx->h.T[1 ] = tweak[1 ]; } -void skein_1024_process_block (struct skein1024_ctx *ctx,const u8 *blk_ptr, +void skein_1024_process_block (struct skein_1024_ctx *ctx,const u8 *blk_ptr,size_t blk_cnt,size_t byte_cnt_add) {struct threefish_key key;
drivers/staging/skein/skein_block.c +1 -1
@@ -479,7 +479,7 @@ unsigned int skein_512_unroll_cnt(void)/***************************** Skein1024 ******************************/ #if !(SKEIN_USE_ASM & 1024) -void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blk_ptr, +void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, size_t blk_cnt, size_t byte_cnt_add) { /* do it in C, always looping (unrolled is bigger AND slower!) */ enum {
Signature · 1 line
1.9.2
PATCH v2 2/6 staging: crypto: skein: rename camelcase vars
In reply to Anton SaraevcamelCase is not accepted in the Linux Kernel. To prepare skein driver for mainline inclusion, we rename all vars to non-camelCase equivalents.
--- drivers/staging/skein/TODO | 1 - drivers/staging/skein/include/skein.h | 119 ++++---- drivers/staging/skein/include/skeinApi.h | 28 +- drivers/staging/skein/include/skein_block.h | 12 +- drivers/staging/skein/include/threefishApi.h | 54 ++-- drivers/staging/skein/skein.c | 415 ++++++++++++++------------- drivers/staging/skein/skeinApi.c | 102 +++---- drivers/staging/skein/skeinBlockNo3F.c | 42 +-- drivers/staging/skein/skein_block.c | 125 ++++---- drivers/staging/skein/threefish1024Block.c | 76 ++--- drivers/staging/skein/threefish256Block.c | 28 +- drivers/staging/skein/threefish512Block.c | 44 +-- drivers/staging/skein/threefishApi.c | 60 ++-- 13 files changed, 558 insertions(+), 548 deletions(-)
drivers/staging/skein/TODO +0 -1
@@ -1,6 +1,5 @@ skein/threefish TODO - - rename camelcase vars - rename files - move macros into appropriate header files - add / pass test vectors
drivers/staging/skein/include/skein.h +60 -59
217 lines not on this page · raw message
drivers/staging/skein/include/skeinApi.h +14 -14
@@ -59,7 +59,7 @@ OTHER DEALINGS IN THE SOFTWARE.* * // Now update Skein with any number of message bits. A function that * // takes a number of bytes is also available. -* skein_update_bits(&ctx, message, msgLength); +* skein_update_bits(&ctx, message, msg_length); * * // Now get the result of the Skein hash. The output buffer must be * // large enough to hold the request number of output bits. The application
@@ -99,8 +99,8 @@ enum skein_size {* structures as well. */ struct skein_ctx { -u64 skeinSize; -u64 XSave[SKEIN_MAX_STATE_WORDS ];/* save area for state variables */ +u64 skein_size; +u64 X_save[SKEIN_MAX_STATE_WORDS ];/* save area for state variables */ union {struct skein_ctx_hdr h;struct skein_256_ctx s256;
@@ -133,13 +133,13 @@ int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size);* * @param ctx * Pointer to a Skein context. -* @param hashBitLen +* @param hash_bit_len * Number of MAC hash bits to compute * @return * SKEIN_SUCESS of SKEIN_FAIL * @see skein_reset */ -int skein_init (struct skein_ctx *ctx,size_t hashBitLen); +int skein_init (struct skein_ctx *ctx,size_t hash_bit_len);/** * Resets a Skein context for further use.
@@ -166,15 +166,15 @@ void skein_reset(struct skein_ctx *ctx);* Pointer to an empty or preinitialized Skein MAC context * @param key * Pointer to key bytes or NULL -* @param keyLen +* @param key_len * Length of the key in bytes or zero -* @param hashBitLen +* @param hash_bit_len * Number of MAC hash bits to compute * @return * SKEIN_SUCESS of SKEIN_FAIL */ -int skein_mac_init (struct skein_ctx *ctx,const u8 *key,size_t keyLen, -size_t hashBitLen); +int skein_mac_init (struct skein_ctx *ctx,const u8 *key,size_t key_len, +size_t hash_bit_len);/** * Update Skein with the next part of the message.
@@ -183,13 +183,13 @@ int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t keyLen,* Pointer to initialized Skein context * @param msg * Pointer to the message. -* @param msgByteCnt +* @param msg_byte_cnt * Length of the message in @b bytes * @return * Success or error code. */ int skein_update (struct skein_ctx *ctx,const u8 *msg, -size_t msgByteCnt); +size_t msg_byte_cnt);/** * Update the hash with a message bit string.
@@ -201,11 +201,11 @@ int skein_update(struct skein_ctx *ctx, const u8 *msg,* Pointer to initialized Skein context * @param msg * Pointer to the message. -* @param msgBitCnt +* @param msg_bit_cnt * Length of the message in @b bits. */ int skein_update_bits (struct skein_ctx *ctx,const u8 *msg, -size_t msgBitCnt); +size_t msg_bit_cnt);/** * Finalize Skein and return the hash.
@@ -217,7 +217,7 @@ int skein_update_bits(struct skein_ctx *ctx, const u8 *msg,* Pointer to initialized Skein context * @param hash * Pointer to buffer that receives the hash. The buffer must be large -* enough to store @c hashBitLen bits. +* enough to store @c hash_bit_len bits. * @return * Success or error code. * @see skein_reset
drivers/staging/skein/include/skein_block.h +6 -6
@@ -12,11 +12,11 @@#include <skein.h> /* get the Skein API definitions */ -void skein_256_process_block (struct skein_256_ctx *ctx,const u8 *blkPtr, -size_t blkCnt,size_t byteCntAdd); -void skein_512_process_block (struct skein_512_ctx *ctx,const u8 *blkPtr, -size_t blkCnt,size_t byteCntAdd); -void skein_1024_process_block (struct skein1024_ctx *ctx,const u8 *blkPtr, -size_t blkCnt,size_t byteCntAdd); +void skein_256_process_block (struct skein_256_ctx *ctx,const u8 *blk_ptr, +size_t blk_cnt,size_t byte_cnt_add); +void skein_512_process_block (struct skein_512_ctx *ctx,const u8 *blk_ptr, +size_t blk_cnt,size_t byte_cnt_add); +void skein_1024_process_block (struct skein1024_ctx *ctx,const u8 *blk_ptr, +size_t blk_cnt,size_t byte_cnt_add);#endif
drivers/staging/skein/include/threefishApi.h +27 -27
153 lines not on this page · raw message
drivers/staging/skein/skein.c +209 -206
932 lines not on this page · raw message
drivers/staging/skein/skeinApi.c +52 -50
231 lines not on this page · raw message
drivers/staging/skein/skeinBlockNo3F.c +21 -21
133 lines not on this page · raw message
drivers/staging/skein/skein_block.c +65 -60
318 lines not on this page · raw message
drivers/staging/skein/threefish1024Block.c +38 -38
94 lines not on this page · raw message
drivers/staging/skein/threefish256Block.c +14 -14
@@ -2,16 +2,16 @@#include <threefishApi.h> -void threefish_encrypt_256 (struct threefish_key *keyCtx,u64 *input, +void threefish_encrypt_256 (struct threefish_key *key_ctx,u64 *input,u64 *output) {u64 b0 = input[0 ], b1 = input[1 ], - b2 = input[2 ], b3 = input[3 ]; -u64 k0 = keyCtx->key[0 ], k1 = keyCtx->key[1 ], - k2 = keyCtx->key[2 ], k3 = keyCtx->key[3 ], - k4 = keyCtx->key[4 ]; -u64 t0 = keyCtx->tweak[0 ], t1 = keyCtx->tweak[1 ], - t2 = keyCtx->tweak[2 ]; + b2 = input[2 ], b3 = input[3 ]; +u64 k0 = key_ctx->key[0 ], k1 = key_ctx->key[1 ], + k2 = key_ctx->key[2 ], k3 = key_ctx->key[3 ], + k4 = key_ctx->key[4 ]; +u64 t0 = key_ctx->tweak[0 ], t1 = key_ctx->tweak[1 ], + t2 = key_ctx->tweak[2 ]; b1 += k1 + t0; b0 += b1 + k0;
@@ -495,16 +495,16 @@ void threefish_encrypt_256(struct threefish_key *keyCtx, u64 *input, output[3 ] = b3 + k1 +18 ; } -void threefish_decrypt_256 (struct threefish_key *keyCtx,u64 *input, +void threefish_decrypt_256 (struct threefish_key *key_ctx,u64 *input,u64 *output) {u64 b0 = input[0 ], b1 = input[1 ], - b2 = input[2 ], b3 = input[3 ]; -u64 k0 = keyCtx->key[0 ], k1 = keyCtx->key[1 ], - k2 = keyCtx->key[2 ], k3 = keyCtx->key[3 ], - k4 = keyCtx->key[4 ]; -u64 t0 = keyCtx->tweak[0 ], t1 = keyCtx->tweak[1 ], - t2 = keyCtx->tweak[2 ]; + b2 = input[2 ], b3 = input[3 ]; +u64 k0 = key_ctx->key[0 ], k1 = key_ctx->key[1 ], + k2 = key_ctx->key[2 ], k3 = key_ctx->key[3 ], + k4 = key_ctx->key[4 ]; +u64 t0 = key_ctx->tweak[0 ], t1 = key_ctx->tweak[1 ], + t2 = key_ctx->tweak[2 ];u64 tmp;
drivers/staging/skein/threefish512Block.c +22 -22
62 lines not on this page · raw message
drivers/staging/skein/threefishApi.c +30 -30
106 lines not on this page · raw message
Signature · 1 line
1.9.2
Was there really a v1 version of this patchset because I don't see it in my inbox?
regards,
dan carpenter
Re: [PATCH v2 02/06] staging: crypto: skein: rename camelcase vars
In reply to Anton Saraevdrivers/staging/skein/skein_block.c void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr, · line 120
Quoted 8 lines · Anton Saraev
#if
SKEIN_UNROLL_256== 0drivers/staging/skein/skein_block.c +3
-3-#define R256 (p0, p1, p2, p3,ROT , rNum)/* fully unrolled */ \ +#define R256 (p0, p1, p2, p3,ROT , r_num)/* fully unrolled */ \ do { \ - Round256(p0, p1, p2, p3, ROT, rNum) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); \ + Round256(p0, p1, p2, p3, ROT, r_num); \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, r_num, X_ptr); \
Adding a semi-colon here looks suspiciously like a compile fix. It's great that you're fixing bugs, but do it in a separate patch with a changelog.
regards,
dan carpenter
Re: [PATCH v2 05/06] staging: crypto: skein: rename macros
In reply to Anton Saraevdrivers/staging/skein/include/skein.h int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); · line 291
Quoted 3 lines · Anton Saraev
drivers/staging/skein/include/skein.h +3
-0+/* ignore all asserts, for performance */ +#define skein_assert_ret (x, ret_code) +#define skein_assert (x)
Not related to this patch, but defining away asserts like this is a bad idea. What if they have side affects like:
skein_assert(foo++ == bar);
regards,
dan carpenter
Re: [PATCH v2 06/06] staging: crypto: skein: rename files
In reply to Anton SaraevQuoted 2 lines · On Mon, 19 May 2014 12:09:59 +0400 Anton Saraev wrote:
rename
drivers/staging/skein/{skeinBlockNo3F.c=>skein_block_no_3f.c} (99%)
fwiw, this file (skeinBlockNo3F.c) seems to be unused ... it kind of looks like a temporary file that got checked in by mistake. It's probably worth deleting it in this patch or a separate one, it seems to me.
jake
Signature · 1 line
Jake Edge - LWN - [email protected] - http://lwn.net
Re: [PATCH v2 06/06] staging: crypto: skein: rename files
In reply to Anton Saraevdrivers/staging/skein/Makefile line 4
Quoted 4 lines · On Mon, 19 May 2014 12:09:59 +0400 Anton Saraev wrote:
drivers/staging/skein/Makefile +0
-0@@ -4,10 +4,10 @@ subdir-ccflags-y := -I$(src)/include/
as part of the rearranging of files, I think you want to get rid of this include directory, move the files up to the main directory and include them as "skein.h" (rather than <skein.h>).
Then this line can be removed from the Makefile.
drivers/staging/skein/threefish_1024_block.c line 2
Quoted 6 lines
drivers/staging/skein/threefish_1024_block.c renamed from drivers/staging/skein/threefish1024Block.c +1
-1@@ -1,5 +1,5 @@#include <linux/string.h> -#include <threefishApi.h> +#include <threefish_api.h>
incidentally, none of the threefish_*_block.c files actually needs linux/string.h ... there may be other files where that's true too, it seems to have just gotten added everywhere ...
jake
Signature · 1 line
Jake Edge - LWN - [email protected] - http://lwn.net
Re: [PATCH v2 05/06] staging: crypto: skein: rename macros
In reply to Dan CarpenterQuoted 9 lines · Dan Carpenter
drivers/staging/skein/include/skein.h int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); · line 291
Quoted 3 lines · Anton Saraev
drivers/staging/skein/include/skein.h +3
-0+/* ignore all asserts, for performance */ +#define skein_assert_ret (x, ret_code) +#define skein_assert (x)Not related to this patch, but defining away asserts like this is a bad idea. What if they have side affects like:
skein_assert(foo++ == bar);
Agreed. This driver is definitely a work in progress. If you look at the history, you'll see that I started with a bit-for-bit copy of a publicly available reference implementation. After we get the coding style in shape, there are plenty of other improvements to make.
Thanks for the review.
thx,
Jason.
Re: [PATCH v2 06/06] staging: crypto: skein: rename files
In reply to Jake EdgeQuoted 8 lines · Jake Edge
Quoted 2 lines · On Mon, 19 May 2014 12:09:59 +0400 Anton Saraev wrote:
rename
drivers/staging/skein/{skeinBlockNo3F.c=>skein_block_no_3f.c} (99%)fwiw, this file (
skeinBlockNo3F.c) seems to be unused ... it kind of looks like a temporary file that got checked in by mistake. It's probably worth deleting it in this patch or a separate one, it seems to me.
Correct. It was a part of the reference implementation I started with. It's never actually compiled. I'm not sure what it's purpose was in the reference implementation, either.
thx,
Jason.
Dan,
Quoted 2 lines · Dan Carpenter
Was there really a v1 version of this patchset because I don't see it in my inbox?
There was. Anton is doing this as part of the Eudyptula Challenge [1], and he sent the first version to me offlist. I helped him with some of the git format-patch/send-email options and the result is this v2.
thx,
Jason.
Re: [PATCH v2 02/06] staging: crypto: skein: rename camelcase vars
In reply to Anton Saraevdrivers/staging/skein/include/skein.h enum { · line 69
Quoted 7 lines · On Mon, 19 May 2014 12:09:55 +0400 Anton Saraev wrote:
struct
skein_ctx_hdr{drivers/staging/skein/include/skein.h +3
-3-size_t hashBitLen;/* size of hash result, in bits */ -size_t bCnt;/* current byte count in buffer b[] */ -u64 T [SKEIN_MODIFIER_WORDS ];/* tweak: T[0]=byte cnt, T[1]=flags */ +size_t hash_bit_len;/* size of hash result, in bits */ +size_t b_cnt;/* current byte count in buffer b[] */ +u64 T [SKEIN_MODIFIER_WORDS ];/* tweak: T[0]=byte cnt, T[1]=flags */
seems like 'T' should be lower case ... maybe renamed too (tweak?)?
Quoted 12 lines
struct
skein_256_ctx{ /* 256-bit Skein hash context structure */drivers/staging/skein/include/skein.h +2
-4struct skein_ctx_hdr h;/* common header context variables */ -u64 X [SKEIN_256_STATE_WORDS ];/* chaining variables */ -u8 b[SKEIN_256_BLOCK_BYTES ];/* partial block buf (8-byte aligned) */ +u64 X [SKEIN_256_STATE_WORDS ];/* chaining variables */ +u8 b[SKEIN_256_BLOCK_BYTES ];/* partial block buf (8-byte aligned) */ };struct skein_512_ctx {/* 512-bit Skein hash context structure */ struct skein_ctx_hdr h;/* common header context variables */ -u64 X[SKEIN_512_STATE_WORDS ];/* chaining variables */ -u8 b[SKEIN_512_BLOCK_BYTES ];/* partial block buf (8-byte aligned) */
drivers/staging/skein/include/skein.h enum { · line 87
Quoted 10 lines
drivers/staging/skein/include/skein.h +4
-2+u64 X [SKEIN_512_STATE_WORDS ];/* chaining variables */ +u8 b[SKEIN_512_BLOCK_BYTES ];/* partial block buf (8-byte aligned) */ };struct skein1024_ctx {/* 1024-bit Skein hash context structure */ struct skein_ctx_hdr h;/* common header context variables */ -u64 X[SKEIN1024_STATE_WORDS ];/* chaining variables */ -u8 b[SKEIN1024_BLOCK_BYTES ];/* partial block buf (8-byte aligned) */ +u64 X[SKEIN1024_STATE_WORDS ];/* chaining variables */ +u8 b[SKEIN1024_BLOCK_BYTES ];/* partial block buf (8-byte aligned) */
the X arrays here should be renamed too, I suspect ...
drivers/staging/skein/include/skeinApi.h enum skein_size { · line 103
Quoted 8 lines
drivers/staging/skein/include/skeinApi.h +2
-2@@ -99,8 +99,8 @@ enum skein_size {* structures as well. */ struct skein_ctx { -u64 skeinSize; -u64 XSave[SKEIN_MAX_STATE_WORDS ];/* save area for state variables */ +u64 skein_size; +u64 X_save[SKEIN_MAX_STATE_WORDS ];/* save area for state variables */
why not x_save?
drivers/staging/skein/skeinApi.c int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size) · line 44
Quoted 7 lines
drivers/staging/skein/skeinApi.c +2
-2-int skein_init (struct skein_ctx *ctx,size_t hashBitLen) +int skein_init (struct skein_ctx *ctx,size_t hash_bit_len) {int ret =SKEIN_FAIL ; -size_t Xlen =0 ; +size_t X_len =0 ;u64 *X =NULL ;
maybe I am missing something, but why not 'x' and 'x_len' ?
drivers/staging/skein/skeinApi.c int skein_init(struct skein_ctx *ctx, size_t hashBitLen) · line 90
Quoted 11 lines
drivers/staging/skein/skeinApi.c +4
-4-int skein_mac_init (struct skein_ctx *ctx,const u8 *key,size_t keyLen, -size_t hashBitLen) +int skein_mac_init (struct skein_ctx *ctx,const u8 *key,size_t key_len, +size_t hash_bit_len) {int ret =SKEIN_FAIL ;u64 *X =NULL ; -size_t Xlen =0 ; -u64 treeInfo =SKEIN_CFG_TREE_INFO_SEQUENTIAL ; +size_t X_len =0 ; +u64 tree_info =SKEIN_CFG_TREE_INFO_SEQUENTIAL ;
and the same here?
drivers/staging/skein/skeinApi.c int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size) · line 44
Quoted 5 lines
void
skein_reset(struct skein_ctx *ctx)
{drivers/staging/skein/skeinApi.c +1
-1-size_t Xlen =0 ; +size_t X_len =0 ;u64 *X =NULL ;
here too ...
Quoted 8 lines
drivers/staging/skein/skein_block.c +2
-2-void skein_256_process_block (struct skein_256_ctx *ctx,const u8 *blkPtr, -size_t blkCnt,size_t byteCntAdd) +void skein_256_process_block (struct skein_256_ctx *ctx,const u8 *blk_ptr, +size_t blk_cnt,size_t byte_cnt_add) {/* do it in C */ enum {WCNT =SKEIN_256_STATE_WORDS
drivers/staging/skein/skein_block.c void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr, · line 71
Quoted 8 lines
drivers/staging/skein/skein_block.c +3
-2@@ -66,10 +66,11 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr,u64 X0 ,X1 ,X2 ,X3 ;/* local copy of context vars, for speed */ u64 w[WCNT ];/* local copy of input block */ #ifdef SKEIN_DEBUG -const u64 *Xptr[4 ];/* use for debugging (help cc put Xn in regs) */ - Xptr[0 ] = &X0 ; Xptr[1 ] = &X1 ; Xptr[2 ] = &X2 ; Xptr[3 ] = &X3 ; +const u64 *X_ptr[4 ];/* use for debugging (help cc put Xn in regs) */ + + X_ptr[0 ] = &X0 ; X_ptr[1 ] = &X1 ; X_ptr[2 ] = &X2 ; X_ptr[3 ] = &X3 ;
bunch of Xs in through here too ... is X special somehow? maybe so because it is used in all that loop-unrolling gunk?
jake
Signature · 1 line
Jake Edge - LWN - [email protected] - http://lwn.net
Re: [PATCH v2 02/06] staging: crypto: skein: rename camelcase vars
So, Jake, you're right, but if he redoes patch 2/6 then he has to redo the rest as well. The bad names were bad in the original code already, so normally we let people fix things up in follow on patches in that case.
Is that ok with you?
I totally do appreciate your review comments and agree with them.
regards,
dan carpenter
Jake Edge
Reviewed-byRe: [PATCH v2 02/06] staging: crypto: skein: rename camelcase vars
Quoted 6 lines · On Mon, 19 May 2014 22:21:12 +0300 Dan Carpenter wrote:
So, Jake, you're right, but if he redoes patch 2/6 then he has to redo the rest as well. The bad names were bad in the original code already, so normally we let people fix things up in follow on patches in that case.
Is that ok with you?
Sure, that seems fine ... I only had fairly minor quibbles, the vast majority of it is good stuff ...
Not sure it's useful (or even the right way to go about it), but, if it is, Greg (or Jason or whoever) can add my:
to the patch set ...
jake
Signature · 1 line
Jake Edge - LWN - [email protected] - http://lwn.net
Re: [PATCH v2 02/06] staging: crypto: skein: rename camelcase vars
Quoted 5 lines · Jake Edge
Not sure it's useful (or even the right way to go about it), but, if it is, Greg (or Jason or whoever) can add my:
Reviewed-by Jake Edge <[email protected]>
Yep. Great. Greg will add it.
regards,
dan carpenter
Greg KH
maintainerRe: [PATCH v2 06/06] staging: crypto: skein: rename files
In reply to Jake EdgeQuoted 11 lines · Jake Edge
drivers/staging/skein/Makefile line 4
Quoted 4 lines · On Mon, 19 May 2014 12:09:59 +0400 Anton Saraev wrote:
drivers/staging/skein/Makefile +0
-0@@ -4,10 +4,10 @@ subdir-ccflags-y := -I$(src)/include/as part of the rearranging of files, I think you want to get rid of this include directory, move the files up to the main directory and include them as "
skein.h" (rather than <skein.h>).
Quoted 1 line
Then this line can be removed from the
Makefile.
I agree, I'll not take this last one in the series.
thanks,
greg k-h