Commit 68ace624 authored by Anton Saraev's avatar Anton Saraev Committed by Greg Kroah-Hartman

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.
Signed-off-by: default avatarAnton Saraev <antonysaraev@gmail.com>
Reviewed-by: default avatarJake Edge <jake@lwn.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6559e221
skein/threefish TODO skein/threefish TODO
- rename camelcase vars - rename camelcase vars
- rename camelcase functions
- rename files - rename files
- move macros into appropriate header files - move macros into appropriate header files
- add / pass test vectors - add / pass test vectors
......
...@@ -87,58 +87,58 @@ struct skein1024_ctx { /* 1024-bit Skein hash context structure */ ...@@ -87,58 +87,58 @@ struct skein1024_ctx { /* 1024-bit Skein hash context structure */
}; };
/* Skein APIs for (incremental) "straight hashing" */ /* Skein APIs for (incremental) "straight hashing" */
int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen); int skein_256_init(struct skein_256_ctx *ctx, size_t hashBitLen);
int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen); int skein_512_init(struct skein_512_ctx *ctx, size_t hashBitLen);
int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen); int skein_1024_init(struct skein1024_ctx *ctx, size_t hashBitLen);
int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg,
size_t msgByteCnt); size_t msgByteCnt);
int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg,
size_t msgByteCnt); size_t msgByteCnt);
int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, int skein_1024_update(struct skein1024_ctx *ctx, const u8 *msg,
size_t msgByteCnt); size_t msgByteCnt);
int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal); int skein_256_final(struct skein_256_ctx *ctx, u8 *hashVal);
int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal); int skein_512_final(struct skein_512_ctx *ctx, u8 *hashVal);
int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal); int skein_1024_final(struct skein1024_ctx *ctx, u8 *hashVal);
/* /*
** Skein APIs for "extended" initialization: MAC keys, tree hashing. ** Skein APIs for "extended" initialization: MAC keys, tree hashing.
** After an InitExt() call, just use Update/Final calls as with Init(). ** After an init_ext() call, just use update/final calls as with init().
** **
** Notes: Same parameters as _Init() calls, plus treeInfo/key/keyBytes. ** Notes: Same parameters as _init() calls, plus treeInfo/key/keyBytes.
** When keyBytes == 0 and treeInfo == SKEIN_SEQUENTIAL, ** When keyBytes == 0 and treeInfo == SKEIN_SEQUENTIAL,
** the results of InitExt() are identical to calling Init(). ** the results of init_ext() are identical to calling init().
** The function Init() may be called once to "precompute" the IV for ** The function init() may be called once to "precompute" the IV for
** a given hashBitLen value, then by saving a copy of the context ** a given hashBitLen value, then by saving a copy of the context
** the IV computation may be avoided in later calls. ** the IV computation may be avoided in later calls.
** Similarly, the function InitExt() may be called once per MAC key ** 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 ** to precompute the MAC IV, then a copy of the context saved and
** reused for each new MAC computation. ** reused for each new MAC computation.
**/ **/
int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hashBitLen,
u64 treeInfo, const u8 *key, size_t keyBytes); u64 treeInfo, const u8 *key, size_t keyBytes);
int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hashBitLen,
u64 treeInfo, const u8 *key, size_t keyBytes); u64 treeInfo, const u8 *key, size_t keyBytes);
int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, int skein_1024_init_ext(struct skein1024_ctx *ctx, size_t hashBitLen,
u64 treeInfo, const u8 *key, size_t keyBytes); u64 treeInfo, const u8 *key, size_t keyBytes);
/* /*
** Skein APIs for MAC and tree hash: ** Skein APIs for MAC and tree hash:
** Final_Pad: pad, do final block, but no OUTPUT type ** final_pad: pad, do final block, but no OUTPUT type
** Output: do just the output stage ** output: do just the output stage
*/ */
int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal); int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hashVal);
int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal); int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hashVal);
int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal); int skein_1024_final_pad(struct skein1024_ctx *ctx, u8 *hashVal);
#ifndef SKEIN_TREE_HASH #ifndef SKEIN_TREE_HASH
#define SKEIN_TREE_HASH (1) #define SKEIN_TREE_HASH (1)
#endif #endif
#if SKEIN_TREE_HASH #if SKEIN_TREE_HASH
int Skein_256_Output(struct skein_256_ctx *ctx, u8 *hashVal); int skein_256_output(struct skein_256_ctx *ctx, u8 *hashVal);
int Skein_512_Output(struct skein_512_ctx *ctx, u8 *hashVal); int skein_512_output(struct skein_512_ctx *ctx, u8 *hashVal);
int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal); int skein_1024_output(struct skein1024_ctx *ctx, u8 *hashVal);
#endif #endif
/***************************************************************** /*****************************************************************
......
...@@ -50,31 +50,31 @@ OTHER DEALINGS IN THE SOFTWARE. ...@@ -50,31 +50,31 @@ OTHER DEALINGS IN THE SOFTWARE.
* struct skein_ctx ctx; // a Skein hash or MAC context * struct skein_ctx ctx; // a Skein hash or MAC context
* *
* // prepare context, here for a Skein with a state size of 512 bits. * // 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 * // Initialize the context to set the requested hash length in bits
* // here request a output hash size of 31 bits (Skein supports variable * // here request a output hash size of 31 bits (Skein supports variable
* // output sizes even very strange sizes) * // 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 * // Now update Skein with any number of message bits. A function that
* // takes a number of bytes is also available. * // 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 * // 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 * // large enough to hold the request number of output bits. The application
* // may now extract the bits. * // may now extract the bits.
* skeinFinal(&ctx, result); * skein_final(&ctx, result);
* ... * ...
* @endcode * @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 * 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 * bit length. In this case the API implementation restores some internal
* internal state data and saves a full Skein initialization round. * internal state data and saves a full Skein initialization round.
* *
* To create a MAC the application just uses @c skeinMacInit instead of * To create a MAC the application just uses @c skein_mac_init instead of
* @c skeinInit. All other functions calls remain the same. * @c skein_init. All other functions calls remain the same.
* *
*/ */
...@@ -123,7 +123,7 @@ struct skein_ctx { ...@@ -123,7 +123,7 @@ struct skein_ctx {
* @return * @return
* SKEIN_SUCESS of SKEIN_FAIL * 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. * Initialize a Skein context.
...@@ -137,9 +137,9 @@ int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size); ...@@ -137,9 +137,9 @@ int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size);
* Number of MAC hash bits to compute * Number of MAC hash bits to compute
* @return * @return
* SKEIN_SUCESS of SKEIN_FAIL * 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. * Resets a Skein context for further use.
...@@ -151,7 +151,7 @@ int skeinInit(struct skein_ctx *ctx, size_t hashBitLen); ...@@ -151,7 +151,7 @@ int skeinInit(struct skein_ctx *ctx, size_t hashBitLen);
* @param ctx * @param ctx
* Pointer to a pre-initialized Skein MAC context * 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. * Initializes a Skein context for MAC usage.
...@@ -173,7 +173,7 @@ void skeinReset(struct skein_ctx *ctx); ...@@ -173,7 +173,7 @@ void skeinReset(struct skein_ctx *ctx);
* @return * @return
* SKEIN_SUCESS of SKEIN_FAIL * SKEIN_SUCESS of SKEIN_FAIL
*/ */
int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen, int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t keyLen,
size_t hashBitLen); size_t hashBitLen);
/** /**
...@@ -188,7 +188,7 @@ int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen, ...@@ -188,7 +188,7 @@ int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen,
* @return * @return
* Success or error code. * Success or error code.
*/ */
int skeinUpdate(struct skein_ctx *ctx, const u8 *msg, int skein_update(struct skein_ctx *ctx, const u8 *msg,
size_t msgByteCnt); size_t msgByteCnt);
/** /**
...@@ -204,7 +204,7 @@ int skeinUpdate(struct skein_ctx *ctx, const u8 *msg, ...@@ -204,7 +204,7 @@ int skeinUpdate(struct skein_ctx *ctx, const u8 *msg,
* @param msgBitCnt * @param msgBitCnt
* Length of the message in @b bits. * Length of the message in @b bits.
*/ */
int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, int skein_update_bits(struct skein_ctx *ctx, const u8 *msg,
size_t msgBitCnt); size_t msgBitCnt);
/** /**
...@@ -220,9 +220,9 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, ...@@ -220,9 +220,9 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg,
* enough to store @c hashBitLen bits. * enough to store @c hashBitLen bits.
* @return * @return
* Success or error code. * 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);
/** /**
* @} * @}
......
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
#include <skein.h> /* get the Skein API definitions */ #include <skein.h> /* get the Skein API definitions */
void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr,
size_t blkCnt, size_t byteCntAdd); size_t blkCnt, size_t byteCntAdd);
void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blkPtr,
size_t blkCnt, size_t byteCntAdd); size_t blkCnt, size_t byteCntAdd);
void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blkPtr,
size_t blkCnt, size_t byteCntAdd); size_t blkCnt, size_t byteCntAdd);
#endif #endif
...@@ -21,10 +21,10 @@ ...@@ -21,10 +21,10 @@
struct threefish_key keyCtx; struct threefish_key keyCtx;
// Initialize the context // Initialize the context
threefishSetKey(&keyCtx, Threefish512, key, tweak); threefish_set_key(&keyCtx, Threefish512, key, tweak);
// Encrypt // Encrypt
threefishEncryptBlockBytes(&keyCtx, input, cipher); threefish_encrypt_block_bytes(&keyCtx, input, cipher);
@endcode @endcode
*/ */
...@@ -72,7 +72,7 @@ struct threefish_key { ...@@ -72,7 +72,7 @@ struct threefish_key {
* @param tweak * @param tweak
* Pointer to the two tweak words (word has 64 bits). * Pointer to the two tweak words (word has 64 bits).
*/ */
void threefishSetKey(struct threefish_key *keyCtx, void threefish_set_key(struct threefish_key *keyCtx,
enum threefish_size stateSize, enum threefish_size stateSize,
u64 *keyData, u64 *tweak); u64 *keyData, u64 *tweak);
...@@ -91,7 +91,8 @@ void threefishSetKey(struct threefish_key *keyCtx, ...@@ -91,7 +91,8 @@ void threefishSetKey(struct threefish_key *keyCtx,
* @param out * @param out
* Pointer to cipher buffer. * Pointer to cipher buffer.
*/ */
void threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out); void threefish_encrypt_block_bytes(struct threefish_key *keyCtx, u8 *in,
u8 *out);
/** /**
* Encrypt Threefisch block (words). * Encrypt Threefisch block (words).
...@@ -110,7 +111,7 @@ void threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out); ...@@ -110,7 +111,7 @@ void threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out);
* @param out * @param out
* Pointer to cipher buffer. * Pointer to cipher buffer.
*/ */
void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in, void threefish_encrypt_block_words(struct threefish_key *keyCtx, u64 *in,
u64 *out); u64 *out);
/** /**
...@@ -128,7 +129,8 @@ void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in, ...@@ -128,7 +129,8 @@ void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in,
* @param out * @param out
* Pointer to plaintext buffer. * Pointer to plaintext buffer.
*/ */
void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out); void threefish_decrypt_block_bytes(struct threefish_key *keyCtx, u8 *in,
u8 *out);
/** /**
* Decrypt Threefisch block (words). * Decrypt Threefisch block (words).
...@@ -147,16 +149,20 @@ void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out); ...@@ -147,16 +149,20 @@ void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out);
* @param out * @param out
* Pointer to plaintext buffer. * Pointer to plaintext buffer.
*/ */
void threefishDecryptBlockWords(struct threefish_key *keyCtx, u64 *in, void threefish_decrypt_block_words(struct threefish_key *keyCtx, u64 *in,
u64 *out); u64 *out);
void threefishEncrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output); void threefish_encrypt_256(struct threefish_key *keyCtx, u64 *input,
void threefishEncrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output);
void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input,
u64 *output); u64 *output);
void threefishDecrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output); void threefish_encrypt_512(struct threefish_key *keyCtx, u64 *input,
void threefishDecrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output); u64 *output);
void threefishDecrypt1024(struct threefish_key *keyCtx, u64 *input, void threefish_encrypt_1024(struct threefish_key *keyCtx, u64 *input,
u64 *output);
void threefish_decrypt_256(struct threefish_key *keyCtx, u64 *input,
u64 *output);
void threefish_decrypt_512(struct threefish_key *keyCtx, u64 *input,
u64 *output);
void threefish_decrypt_1024(struct threefish_key *keyCtx, u64 *input,
u64 *output); u64 *output);
/** /**
* @} * @}
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* init the context for a straight hashing operation */ /* init the context for a straight hashing operation */
int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen) int skein_256_init(struct skein_256_ctx *ctx, size_t hashBitLen)
{ {
union { union {
u8 b[SKEIN_256_STATE_BYTES]; u8 b[SKEIN_256_STATE_BYTES];
...@@ -64,7 +64,7 @@ int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen) ...@@ -64,7 +64,7 @@ int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen)
/* compute the initial chaining values from config block */ /* compute the initial chaining values from config block */
/* zero the chaining variables */ /* zero the chaining variables */
memset(ctx->X, 0, sizeof(ctx->X)); memset(ctx->X, 0, sizeof(ctx->X));
Skein_256_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
break; break;
} }
/* The chaining vars ctx->X are now initialized for hashBitLen. */ /* The chaining vars ctx->X are now initialized for hashBitLen. */
...@@ -76,9 +76,9 @@ int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen) ...@@ -76,9 +76,9 @@ int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen)
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* init the context for a MAC and/or tree hash operation */ /* init the context for a MAC and/or tree hash operation */
/* [identical to Skein_256_Init() when keyBytes == 0 && \ /* [identical to skein_256_init() when keyBytes == 0 && \
* treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ * treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hashBitLen,
u64 treeInfo, const u8 *key, size_t keyBytes) u64 treeInfo, const u8 *key, size_t keyBytes)
{ {
union { union {
...@@ -103,9 +103,9 @@ int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, ...@@ -103,9 +103,9 @@ int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen,
/* zero the initial chaining variables */ /* zero the initial chaining variables */
memset(ctx->X, 0, sizeof(ctx->X)); memset(ctx->X, 0, sizeof(ctx->X));
/* hash the key */ /* hash the key */
Skein_256_Update(ctx, key, keyBytes); skein_256_update(ctx, key, keyBytes);
/* put result into cfg.b[] */ /* put result into cfg.b[] */
Skein_256_Final_Pad(ctx, cfg.b); skein_256_final_pad(ctx, cfg.b);
/* copy over into ctx->X[] */ /* copy over into ctx->X[] */
memcpy(ctx->X, cfg.b, sizeof(cfg.b)); memcpy(ctx->X, cfg.b, sizeof(cfg.b));
} }
...@@ -128,7 +128,7 @@ int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, ...@@ -128,7 +128,7 @@ int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen,
Skein_Show_Key(256, &ctx->h, key, keyBytes); Skein_Show_Key(256, &ctx->h, key, keyBytes);
/* compute the initial chaining values from config block */ /* compute the initial chaining values from config block */
Skein_256_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
/* The chaining vars ctx->X are now initialized */ /* The chaining vars ctx->X are now initialized */
/* Set up to process the data message portion of the hash (default) */ /* Set up to process the data message portion of the hash (default) */
...@@ -139,7 +139,7 @@ int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, ...@@ -139,7 +139,7 @@ int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen,
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* process the input bytes */ /* process the input bytes */
int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg,
size_t msgByteCnt) size_t msgByteCnt)
{ {
size_t n; size_t n;
...@@ -162,7 +162,7 @@ int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, ...@@ -162,7 +162,7 @@ int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg,
ctx->h.bCnt += n; ctx->h.bCnt += n;
} }
Skein_assert(ctx->h.bCnt == SKEIN_256_BLOCK_BYTES); Skein_assert(ctx->h.bCnt == SKEIN_256_BLOCK_BYTES);
Skein_256_Process_Block(ctx, ctx->b, 1, skein_256_process_block(ctx, ctx->b, 1,
SKEIN_256_BLOCK_BYTES); SKEIN_256_BLOCK_BYTES);
ctx->h.bCnt = 0; ctx->h.bCnt = 0;
} }
...@@ -173,7 +173,7 @@ int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, ...@@ -173,7 +173,7 @@ int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg,
if (msgByteCnt > SKEIN_256_BLOCK_BYTES) { if (msgByteCnt > SKEIN_256_BLOCK_BYTES) {
/* number of full blocks to process */ /* number of full blocks to process */
n = (msgByteCnt-1) / SKEIN_256_BLOCK_BYTES; n = (msgByteCnt-1) / SKEIN_256_BLOCK_BYTES;
Skein_256_Process_Block(ctx, msg, n, skein_256_process_block(ctx, msg, n,
SKEIN_256_BLOCK_BYTES); SKEIN_256_BLOCK_BYTES);
msgByteCnt -= n * SKEIN_256_BLOCK_BYTES; msgByteCnt -= n * SKEIN_256_BLOCK_BYTES;
msg += n * SKEIN_256_BLOCK_BYTES; msg += n * SKEIN_256_BLOCK_BYTES;
...@@ -193,7 +193,7 @@ int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, ...@@ -193,7 +193,7 @@ int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg,
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* finalize the hash computation and output the result */ /* finalize the hash computation and output the result */
int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal) int skein_256_final(struct skein_256_ctx *ctx, u8 *hashVal)
{ {
size_t i, n, byteCnt; size_t i, n, byteCnt;
u64 X[SKEIN_256_STATE_WORDS]; u64 X[SKEIN_256_STATE_WORDS];
...@@ -208,7 +208,7 @@ int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal) ...@@ -208,7 +208,7 @@ int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal)
SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); SKEIN_256_BLOCK_BYTES - ctx->h.bCnt);
/* process the final block */ /* process the final block */
Skein_256_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); skein_256_process_block(ctx, ctx->b, 1, ctx->h.bCnt);
/* now output the result */ /* now output the result */
/* total number of output bytes */ /* total number of output bytes */
...@@ -224,7 +224,7 @@ int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal) ...@@ -224,7 +224,7 @@ int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal)
((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i);
Skein_Start_New_Type(ctx, OUT_FINAL); Skein_Start_New_Type(ctx, OUT_FINAL);
/* run "counter mode" */ /* run "counter mode" */
Skein_256_Process_Block(ctx, ctx->b, 1, sizeof(u64)); skein_256_process_block(ctx, ctx->b, 1, sizeof(u64));
/* number of output bytes left to go */ /* number of output bytes left to go */
n = byteCnt - i*SKEIN_256_BLOCK_BYTES; n = byteCnt - i*SKEIN_256_BLOCK_BYTES;
if (n >= SKEIN_256_BLOCK_BYTES) if (n >= SKEIN_256_BLOCK_BYTES)
...@@ -246,7 +246,7 @@ int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal) ...@@ -246,7 +246,7 @@ int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal)
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* init the context for a straight hashing operation */ /* init the context for a straight hashing operation */
int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen) int skein_512_init(struct skein_512_ctx *ctx, size_t hashBitLen)
{ {
union { union {
u8 b[SKEIN_512_STATE_BYTES]; u8 b[SKEIN_512_STATE_BYTES];
...@@ -289,7 +289,7 @@ int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen) ...@@ -289,7 +289,7 @@ int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen)
/* compute the initial chaining values from config block */ /* compute the initial chaining values from config block */
/* zero the chaining variables */ /* zero the chaining variables */
memset(ctx->X, 0, sizeof(ctx->X)); memset(ctx->X, 0, sizeof(ctx->X));
Skein_512_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
break; break;
} }
...@@ -305,9 +305,9 @@ int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen) ...@@ -305,9 +305,9 @@ int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen)
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* init the context for a MAC and/or tree hash operation */ /* init the context for a MAC and/or tree hash operation */
/* [identical to Skein_512_Init() when keyBytes == 0 && \ /* [identical to skein_512_init() when keyBytes == 0 && \
* treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ * treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hashBitLen,
u64 treeInfo, const u8 *key, size_t keyBytes) u64 treeInfo, const u8 *key, size_t keyBytes)
{ {
union { union {
...@@ -332,9 +332,9 @@ int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, ...@@ -332,9 +332,9 @@ int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen,
/* zero the initial chaining variables */ /* zero the initial chaining variables */
memset(ctx->X, 0, sizeof(ctx->X)); memset(ctx->X, 0, sizeof(ctx->X));
/* hash the key */ /* hash the key */
Skein_512_Update(ctx, key, keyBytes); skein_512_update(ctx, key, keyBytes);
/* put result into cfg.b[] */ /* put result into cfg.b[] */
Skein_512_Final_Pad(ctx, cfg.b); skein_512_final_pad(ctx, cfg.b);
/* copy over into ctx->X[] */ /* copy over into ctx->X[] */
memcpy(ctx->X, cfg.b, sizeof(cfg.b)); memcpy(ctx->X, cfg.b, sizeof(cfg.b));
} }
...@@ -356,7 +356,7 @@ int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, ...@@ -356,7 +356,7 @@ int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen,
Skein_Show_Key(512, &ctx->h, key, keyBytes); Skein_Show_Key(512, &ctx->h, key, keyBytes);
/* compute the initial chaining values from config block */ /* compute the initial chaining values from config block */
Skein_512_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
/* The chaining vars ctx->X are now initialized */ /* The chaining vars ctx->X are now initialized */
/* Set up to process the data message portion of the hash (default) */ /* Set up to process the data message portion of the hash (default) */
...@@ -367,7 +367,7 @@ int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, ...@@ -367,7 +367,7 @@ int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen,
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* process the input bytes */ /* process the input bytes */
int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg,
size_t msgByteCnt) size_t msgByteCnt)
{ {
size_t n; size_t n;
...@@ -390,7 +390,7 @@ int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, ...@@ -390,7 +390,7 @@ int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg,
ctx->h.bCnt += n; ctx->h.bCnt += n;
} }
Skein_assert(ctx->h.bCnt == SKEIN_512_BLOCK_BYTES); Skein_assert(ctx->h.bCnt == SKEIN_512_BLOCK_BYTES);
Skein_512_Process_Block(ctx, ctx->b, 1, skein_512_process_block(ctx, ctx->b, 1,
SKEIN_512_BLOCK_BYTES); SKEIN_512_BLOCK_BYTES);
ctx->h.bCnt = 0; ctx->h.bCnt = 0;
} }
...@@ -401,7 +401,7 @@ int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, ...@@ -401,7 +401,7 @@ int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg,
if (msgByteCnt > SKEIN_512_BLOCK_BYTES) { if (msgByteCnt > SKEIN_512_BLOCK_BYTES) {
/* number of full blocks to process */ /* number of full blocks to process */
n = (msgByteCnt-1) / SKEIN_512_BLOCK_BYTES; n = (msgByteCnt-1) / SKEIN_512_BLOCK_BYTES;
Skein_512_Process_Block(ctx, msg, n, skein_512_process_block(ctx, msg, n,
SKEIN_512_BLOCK_BYTES); SKEIN_512_BLOCK_BYTES);
msgByteCnt -= n * SKEIN_512_BLOCK_BYTES; msgByteCnt -= n * SKEIN_512_BLOCK_BYTES;
msg += n * SKEIN_512_BLOCK_BYTES; msg += n * SKEIN_512_BLOCK_BYTES;
...@@ -421,7 +421,7 @@ int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, ...@@ -421,7 +421,7 @@ int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg,
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* finalize the hash computation and output the result */ /* finalize the hash computation and output the result */
int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal) int skein_512_final(struct skein_512_ctx *ctx, u8 *hashVal)
{ {
size_t i, n, byteCnt; size_t i, n, byteCnt;
u64 X[SKEIN_512_STATE_WORDS]; u64 X[SKEIN_512_STATE_WORDS];
...@@ -436,7 +436,7 @@ int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal) ...@@ -436,7 +436,7 @@ int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal)
SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); SKEIN_512_BLOCK_BYTES - ctx->h.bCnt);
/* process the final block */ /* process the final block */
Skein_512_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); skein_512_process_block(ctx, ctx->b, 1, ctx->h.bCnt);
/* now output the result */ /* now output the result */
/* total number of output bytes */ /* total number of output bytes */
...@@ -452,7 +452,7 @@ int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal) ...@@ -452,7 +452,7 @@ int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal)
((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i);
Skein_Start_New_Type(ctx, OUT_FINAL); Skein_Start_New_Type(ctx, OUT_FINAL);
/* run "counter mode" */ /* run "counter mode" */
Skein_512_Process_Block(ctx, ctx->b, 1, sizeof(u64)); skein_512_process_block(ctx, ctx->b, 1, sizeof(u64));
/* number of output bytes left to go */ /* number of output bytes left to go */
n = byteCnt - i*SKEIN_512_BLOCK_BYTES; n = byteCnt - i*SKEIN_512_BLOCK_BYTES;
if (n >= SKEIN_512_BLOCK_BYTES) if (n >= SKEIN_512_BLOCK_BYTES)
...@@ -474,7 +474,7 @@ int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal) ...@@ -474,7 +474,7 @@ int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal)
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* init the context for a straight hashing operation */ /* init the context for a straight hashing operation */
int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen) int skein_1024_init(struct skein1024_ctx *ctx, size_t hashBitLen)
{ {
union { union {
u8 b[SKEIN1024_STATE_BYTES]; u8 b[SKEIN1024_STATE_BYTES];
...@@ -514,7 +514,7 @@ int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen) ...@@ -514,7 +514,7 @@ int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen)
/* compute the initial chaining values from config block */ /* compute the initial chaining values from config block */
/* zero the chaining variables */ /* zero the chaining variables */
memset(ctx->X, 0, sizeof(ctx->X)); memset(ctx->X, 0, sizeof(ctx->X));
Skein1024_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
break; break;
} }
...@@ -527,9 +527,9 @@ int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen) ...@@ -527,9 +527,9 @@ int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen)
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* init the context for a MAC and/or tree hash operation */ /* init the context for a MAC and/or tree hash operation */
/* [identical to Skein1024_Init() when keyBytes == 0 && \ /* [identical to skein_1024_init() when keyBytes == 0 && \
* treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ * treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, int skein_1024_init_ext(struct skein1024_ctx *ctx, size_t hashBitLen,
u64 treeInfo, const u8 *key, size_t keyBytes) u64 treeInfo, const u8 *key, size_t keyBytes)
{ {
union { union {
...@@ -554,9 +554,9 @@ int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, ...@@ -554,9 +554,9 @@ int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen,
/* zero the initial chaining variables */ /* zero the initial chaining variables */
memset(ctx->X, 0, sizeof(ctx->X)); memset(ctx->X, 0, sizeof(ctx->X));
/* hash the key */ /* hash the key */
Skein1024_Update(ctx, key, keyBytes); skein_1024_update(ctx, key, keyBytes);
/* put result into cfg.b[] */ /* put result into cfg.b[] */
Skein1024_Final_Pad(ctx, cfg.b); skein_1024_final_pad(ctx, cfg.b);
/* copy over into ctx->X[] */ /* copy over into ctx->X[] */
memcpy(ctx->X, cfg.b, sizeof(cfg.b)); memcpy(ctx->X, cfg.b, sizeof(cfg.b));
} }
...@@ -579,7 +579,7 @@ int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, ...@@ -579,7 +579,7 @@ int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen,
Skein_Show_Key(1024, &ctx->h, key, keyBytes); Skein_Show_Key(1024, &ctx->h, key, keyBytes);
/* compute the initial chaining values from config block */ /* compute the initial chaining values from config block */
Skein1024_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
/* The chaining vars ctx->X are now initialized */ /* The chaining vars ctx->X are now initialized */
/* Set up to process the data message portion of the hash (default) */ /* Set up to process the data message portion of the hash (default) */
...@@ -590,7 +590,7 @@ int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, ...@@ -590,7 +590,7 @@ int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen,
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* process the input bytes */ /* process the input bytes */
int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, int skein_1024_update(struct skein1024_ctx *ctx, const u8 *msg,
size_t msgByteCnt) size_t msgByteCnt)
{ {
size_t n; size_t n;
...@@ -613,7 +613,7 @@ int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, ...@@ -613,7 +613,7 @@ int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg,
ctx->h.bCnt += n; ctx->h.bCnt += n;
} }
Skein_assert(ctx->h.bCnt == SKEIN1024_BLOCK_BYTES); Skein_assert(ctx->h.bCnt == SKEIN1024_BLOCK_BYTES);
Skein1024_Process_Block(ctx, ctx->b, 1, skein_1024_process_block(ctx, ctx->b, 1,
SKEIN1024_BLOCK_BYTES); SKEIN1024_BLOCK_BYTES);
ctx->h.bCnt = 0; ctx->h.bCnt = 0;
} }
...@@ -624,7 +624,7 @@ int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, ...@@ -624,7 +624,7 @@ int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg,
if (msgByteCnt > SKEIN1024_BLOCK_BYTES) { if (msgByteCnt > SKEIN1024_BLOCK_BYTES) {
/* number of full blocks to process */ /* number of full blocks to process */
n = (msgByteCnt-1) / SKEIN1024_BLOCK_BYTES; n = (msgByteCnt-1) / SKEIN1024_BLOCK_BYTES;
Skein1024_Process_Block(ctx, msg, n, skein_1024_process_block(ctx, msg, n,
SKEIN1024_BLOCK_BYTES); SKEIN1024_BLOCK_BYTES);
msgByteCnt -= n * SKEIN1024_BLOCK_BYTES; msgByteCnt -= n * SKEIN1024_BLOCK_BYTES;
msg += n * SKEIN1024_BLOCK_BYTES; msg += n * SKEIN1024_BLOCK_BYTES;
...@@ -644,7 +644,7 @@ int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, ...@@ -644,7 +644,7 @@ int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg,
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* finalize the hash computation and output the result */ /* finalize the hash computation and output the result */
int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal) int skein_1024_final(struct skein1024_ctx *ctx, u8 *hashVal)
{ {
size_t i, n, byteCnt; size_t i, n, byteCnt;
u64 X[SKEIN1024_STATE_WORDS]; u64 X[SKEIN1024_STATE_WORDS];
...@@ -659,7 +659,7 @@ int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal) ...@@ -659,7 +659,7 @@ int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal)
SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); SKEIN1024_BLOCK_BYTES - ctx->h.bCnt);
/* process the final block */ /* process the final block */
Skein1024_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); skein_1024_process_block(ctx, ctx->b, 1, ctx->h.bCnt);
/* now output the result */ /* now output the result */
/* total number of output bytes */ /* total number of output bytes */
...@@ -675,7 +675,7 @@ int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal) ...@@ -675,7 +675,7 @@ int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal)
((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i);
Skein_Start_New_Type(ctx, OUT_FINAL); Skein_Start_New_Type(ctx, OUT_FINAL);
/* run "counter mode" */ /* run "counter mode" */
Skein1024_Process_Block(ctx, ctx->b, 1, sizeof(u64)); skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64));
/* number of output bytes left to go */ /* number of output bytes left to go */
n = byteCnt - i*SKEIN1024_BLOCK_BYTES; n = byteCnt - i*SKEIN1024_BLOCK_BYTES;
if (n >= SKEIN1024_BLOCK_BYTES) if (n >= SKEIN1024_BLOCK_BYTES)
...@@ -696,7 +696,7 @@ int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal) ...@@ -696,7 +696,7 @@ int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal)
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* finalize the hash computation and output the block, no OUTPUT stage */ /* finalize the hash computation and output the block, no OUTPUT stage */
int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal) int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hashVal)
{ {
/* catch uninitialized context */ /* catch uninitialized context */
Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
...@@ -708,7 +708,7 @@ int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal) ...@@ -708,7 +708,7 @@ int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal)
memset(&ctx->b[ctx->h.bCnt], 0, memset(&ctx->b[ctx->h.bCnt], 0,
SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); SKEIN_256_BLOCK_BYTES - ctx->h.bCnt);
/* process the final block */ /* process the final block */
Skein_256_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); skein_256_process_block(ctx, ctx->b, 1, ctx->h.bCnt);
/* "output" the state bytes */ /* "output" the state bytes */
Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_256_BLOCK_BYTES); Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_256_BLOCK_BYTES);
...@@ -718,7 +718,7 @@ int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal) ...@@ -718,7 +718,7 @@ int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal)
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* finalize the hash computation and output the block, no OUTPUT stage */ /* finalize the hash computation and output the block, no OUTPUT stage */
int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal) int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hashVal)
{ {
/* catch uninitialized context */ /* catch uninitialized context */
Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
...@@ -730,7 +730,7 @@ int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal) ...@@ -730,7 +730,7 @@ int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal)
memset(&ctx->b[ctx->h.bCnt], 0, memset(&ctx->b[ctx->h.bCnt], 0,
SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); SKEIN_512_BLOCK_BYTES - ctx->h.bCnt);
/* process the final block */ /* process the final block */
Skein_512_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); skein_512_process_block(ctx, ctx->b, 1, ctx->h.bCnt);
/* "output" the state bytes */ /* "output" the state bytes */
Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_512_BLOCK_BYTES); Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_512_BLOCK_BYTES);
...@@ -740,7 +740,7 @@ int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal) ...@@ -740,7 +740,7 @@ int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal)
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* finalize the hash computation and output the block, no OUTPUT stage */ /* finalize the hash computation and output the block, no OUTPUT stage */
int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal) int skein_1024_final_pad(struct skein1024_ctx *ctx, u8 *hashVal)
{ {
/* catch uninitialized context */ /* catch uninitialized context */
Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL);
...@@ -752,7 +752,7 @@ int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal) ...@@ -752,7 +752,7 @@ int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal)
memset(&ctx->b[ctx->h.bCnt], 0, memset(&ctx->b[ctx->h.bCnt], 0,
SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); SKEIN1024_BLOCK_BYTES - ctx->h.bCnt);
/* process the final block */ /* process the final block */
Skein1024_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); skein_1024_process_block(ctx, ctx->b, 1, ctx->h.bCnt);
/* "output" the state bytes */ /* "output" the state bytes */
Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN1024_BLOCK_BYTES); Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN1024_BLOCK_BYTES);
...@@ -763,7 +763,7 @@ int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal) ...@@ -763,7 +763,7 @@ int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal)
#if SKEIN_TREE_HASH #if SKEIN_TREE_HASH
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* just do the OUTPUT stage */ /* just do the OUTPUT stage */
int Skein_256_Output(struct skein_256_ctx *ctx, u8 *hashVal) int skein_256_output(struct skein_256_ctx *ctx, u8 *hashVal)
{ {
size_t i, n, byteCnt; size_t i, n, byteCnt;
u64 X[SKEIN_256_STATE_WORDS]; u64 X[SKEIN_256_STATE_WORDS];
...@@ -784,7 +784,7 @@ int Skein_256_Output(struct skein_256_ctx *ctx, u8 *hashVal) ...@@ -784,7 +784,7 @@ int Skein_256_Output(struct skein_256_ctx *ctx, u8 *hashVal)
((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i);
Skein_Start_New_Type(ctx, OUT_FINAL); Skein_Start_New_Type(ctx, OUT_FINAL);
/* run "counter mode" */ /* run "counter mode" */
Skein_256_Process_Block(ctx, ctx->b, 1, sizeof(u64)); skein_256_process_block(ctx, ctx->b, 1, sizeof(u64));
/* number of output bytes left to go */ /* number of output bytes left to go */
n = byteCnt - i*SKEIN_256_BLOCK_BYTES; n = byteCnt - i*SKEIN_256_BLOCK_BYTES;
if (n >= SKEIN_256_BLOCK_BYTES) if (n >= SKEIN_256_BLOCK_BYTES)
...@@ -802,7 +802,7 @@ int Skein_256_Output(struct skein_256_ctx *ctx, u8 *hashVal) ...@@ -802,7 +802,7 @@ int Skein_256_Output(struct skein_256_ctx *ctx, u8 *hashVal)
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* just do the OUTPUT stage */ /* just do the OUTPUT stage */
int Skein_512_Output(struct skein_512_ctx *ctx, u8 *hashVal) int skein_512_output(struct skein_512_ctx *ctx, u8 *hashVal)
{ {
size_t i, n, byteCnt; size_t i, n, byteCnt;
u64 X[SKEIN_512_STATE_WORDS]; u64 X[SKEIN_512_STATE_WORDS];
...@@ -823,7 +823,7 @@ int Skein_512_Output(struct skein_512_ctx *ctx, u8 *hashVal) ...@@ -823,7 +823,7 @@ int Skein_512_Output(struct skein_512_ctx *ctx, u8 *hashVal)
((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i);
Skein_Start_New_Type(ctx, OUT_FINAL); Skein_Start_New_Type(ctx, OUT_FINAL);
/* run "counter mode" */ /* run "counter mode" */
Skein_512_Process_Block(ctx, ctx->b, 1, sizeof(u64)); skein_512_process_block(ctx, ctx->b, 1, sizeof(u64));
/* number of output bytes left to go */ /* number of output bytes left to go */
n = byteCnt - i*SKEIN_512_BLOCK_BYTES; n = byteCnt - i*SKEIN_512_BLOCK_BYTES;
if (n >= SKEIN_512_BLOCK_BYTES) if (n >= SKEIN_512_BLOCK_BYTES)
...@@ -841,7 +841,7 @@ int Skein_512_Output(struct skein_512_ctx *ctx, u8 *hashVal) ...@@ -841,7 +841,7 @@ int Skein_512_Output(struct skein_512_ctx *ctx, u8 *hashVal)
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* just do the OUTPUT stage */ /* just do the OUTPUT stage */
int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal) int skein_1024_output(struct skein1024_ctx *ctx, u8 *hashVal)
{ {
size_t i, n, byteCnt; size_t i, n, byteCnt;
u64 X[SKEIN1024_STATE_WORDS]; u64 X[SKEIN1024_STATE_WORDS];
...@@ -862,7 +862,7 @@ int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal) ...@@ -862,7 +862,7 @@ int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal)
((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i);
Skein_Start_New_Type(ctx, OUT_FINAL); Skein_Start_New_Type(ctx, OUT_FINAL);
/* run "counter mode" */ /* run "counter mode" */
Skein1024_Process_Block(ctx, ctx->b, 1, sizeof(u64)); skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64));
/* number of output bytes left to go */ /* number of output bytes left to go */
n = byteCnt - i*SKEIN1024_BLOCK_BYTES; n = byteCnt - i*SKEIN1024_BLOCK_BYTES;
if (n >= SKEIN1024_BLOCK_BYTES) if (n >= SKEIN1024_BLOCK_BYTES)
......
...@@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE. ...@@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
#include <linux/string.h> #include <linux/string.h>
#include <skeinApi.h> #include <skeinApi.h>
int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size) int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size)
{ {
Skein_Assert(ctx && size, SKEIN_FAIL); Skein_Assert(ctx && size, SKEIN_FAIL);
...@@ -37,7 +37,7 @@ int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size) ...@@ -37,7 +37,7 @@ int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size)
return SKEIN_SUCCESS; return SKEIN_SUCCESS;
} }
int skeinInit(struct skein_ctx *ctx, size_t hashBitLen) int skein_init(struct skein_ctx *ctx, size_t hashBitLen)
{ {
int ret = SKEIN_FAIL; int ret = SKEIN_FAIL;
size_t Xlen = 0; size_t Xlen = 0;
...@@ -58,15 +58,15 @@ int skeinInit(struct skein_ctx *ctx, size_t hashBitLen) ...@@ -58,15 +58,15 @@ int skeinInit(struct skein_ctx *ctx, size_t hashBitLen)
*/ */
switch (ctx->skeinSize) { switch (ctx->skeinSize) {
case Skein256: case Skein256:
ret = Skein_256_InitExt(&ctx->m.s256, hashBitLen, ret = skein_256_init_ext(&ctx->m.s256, hashBitLen,
treeInfo, NULL, 0); treeInfo, NULL, 0);
break; break;
case Skein512: case Skein512:
ret = Skein_512_InitExt(&ctx->m.s512, hashBitLen, ret = skein_512_init_ext(&ctx->m.s512, hashBitLen,
treeInfo, NULL, 0); treeInfo, NULL, 0);
break; break;
case Skein1024: case Skein1024:
ret = Skein1024_InitExt(&ctx->m.s1024, hashBitLen, ret = skein_1024_init_ext(&ctx->m.s1024, hashBitLen,
treeInfo, NULL, 0); treeInfo, NULL, 0);
break; break;
} }
...@@ -81,7 +81,7 @@ int skeinInit(struct skein_ctx *ctx, size_t hashBitLen) ...@@ -81,7 +81,7 @@ int skeinInit(struct skein_ctx *ctx, size_t hashBitLen)
return ret; return ret;
} }
int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen, int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t keyLen,
size_t hashBitLen) size_t hashBitLen)
{ {
int ret = SKEIN_FAIL; int ret = SKEIN_FAIL;
...@@ -98,18 +98,18 @@ int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen, ...@@ -98,18 +98,18 @@ int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen,
switch (ctx->skeinSize) { switch (ctx->skeinSize) {
case Skein256: case Skein256:
ret = Skein_256_InitExt(&ctx->m.s256, hashBitLen, ret = skein_256_init_ext(&ctx->m.s256, hashBitLen,
treeInfo, treeInfo,
(const u8 *)key, keyLen); (const u8 *)key, keyLen);
break; break;
case Skein512: case Skein512:
ret = Skein_512_InitExt(&ctx->m.s512, hashBitLen, ret = skein_512_init_ext(&ctx->m.s512, hashBitLen,
treeInfo, treeInfo,
(const u8 *)key, keyLen); (const u8 *)key, keyLen);
break; break;
case Skein1024: case Skein1024:
ret = Skein1024_InitExt(&ctx->m.s1024, hashBitLen, ret = skein_1024_init_ext(&ctx->m.s1024, hashBitLen,
treeInfo, treeInfo,
(const u8 *)key, keyLen); (const u8 *)key, keyLen);
...@@ -125,7 +125,7 @@ int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen, ...@@ -125,7 +125,7 @@ int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen,
return ret; return ret;
} }
void skeinReset(struct skein_ctx *ctx) void skein_reset(struct skein_ctx *ctx)
{ {
size_t Xlen = 0; size_t Xlen = 0;
u64 *X = NULL; u64 *X = NULL;
...@@ -144,7 +144,7 @@ void skeinReset(struct skein_ctx *ctx) ...@@ -144,7 +144,7 @@ void skeinReset(struct skein_ctx *ctx)
Skein_Start_New_Type(&ctx->m, MSG); Skein_Start_New_Type(&ctx->m, MSG);
} }
int skeinUpdate(struct skein_ctx *ctx, const u8 *msg, int skein_update(struct skein_ctx *ctx, const u8 *msg,
size_t msgByteCnt) size_t msgByteCnt)
{ {
int ret = SKEIN_FAIL; int ret = SKEIN_FAIL;
...@@ -152,15 +152,15 @@ int skeinUpdate(struct skein_ctx *ctx, const u8 *msg, ...@@ -152,15 +152,15 @@ int skeinUpdate(struct skein_ctx *ctx, const u8 *msg,
switch (ctx->skeinSize) { switch (ctx->skeinSize) {
case Skein256: case Skein256:
ret = Skein_256_Update(&ctx->m.s256, (const u8 *)msg, ret = skein_256_update(&ctx->m.s256, (const u8 *)msg,
msgByteCnt); msgByteCnt);
break; break;
case Skein512: case Skein512:
ret = Skein_512_Update(&ctx->m.s512, (const u8 *)msg, ret = skein_512_update(&ctx->m.s512, (const u8 *)msg,
msgByteCnt); msgByteCnt);
break; break;
case Skein1024: case Skein1024:
ret = Skein1024_Update(&ctx->m.s1024, (const u8 *)msg, ret = skein_1024_update(&ctx->m.s1024, (const u8 *)msg,
msgByteCnt); msgByteCnt);
break; break;
} }
...@@ -168,7 +168,7 @@ int skeinUpdate(struct skein_ctx *ctx, const u8 *msg, ...@@ -168,7 +168,7 @@ int skeinUpdate(struct skein_ctx *ctx, const u8 *msg,
} }
int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, int skein_update_bits(struct skein_ctx *ctx, const u8 *msg,
size_t msgBitCnt) size_t msgBitCnt)
{ {
/* /*
...@@ -189,9 +189,9 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, ...@@ -189,9 +189,9 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg,
/* if number of bits is a multiple of bytes - that's easy */ /* if number of bits is a multiple of bytes - that's easy */
if ((msgBitCnt & 0x7) == 0) if ((msgBitCnt & 0x7) == 0)
return skeinUpdate(ctx, msg, msgBitCnt >> 3); return skein_update(ctx, msg, msgBitCnt >> 3);
skeinUpdate(ctx, msg, (msgBitCnt >> 3) + 1); skein_update(ctx, msg, (msgBitCnt >> 3) + 1);
/* /*
* The next line rely on the fact that the real Skein contexts * The next line rely on the fact that the real Skein contexts
...@@ -201,7 +201,7 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, ...@@ -201,7 +201,7 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg,
*/ */
up = (u8 *)ctx->m.s256.X + ctx->skeinSize / 8; up = (u8 *)ctx->m.s256.X + ctx->skeinSize / 8;
/* set tweak flag for the skeinFinal call */ /* 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 */ /* now "pad" the final partial byte the way NIST likes */
...@@ -217,20 +217,20 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, ...@@ -217,20 +217,20 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg,
return SKEIN_SUCCESS; return SKEIN_SUCCESS;
} }
int skeinFinal(struct skein_ctx *ctx, u8 *hash) int skein_final(struct skein_ctx *ctx, u8 *hash)
{ {
int ret = SKEIN_FAIL; int ret = SKEIN_FAIL;
Skein_Assert(ctx, SKEIN_FAIL); Skein_Assert(ctx, SKEIN_FAIL);
switch (ctx->skeinSize) { switch (ctx->skeinSize) {
case Skein256: case Skein256:
ret = Skein_256_Final(&ctx->m.s256, (u8 *)hash); ret = skein_256_final(&ctx->m.s256, (u8 *)hash);
break; break;
case Skein512: case Skein512:
ret = Skein_512_Final(&ctx->m.s512, (u8 *)hash); ret = skein_512_final(&ctx->m.s512, (u8 *)hash);
break; break;
case Skein1024: case Skein1024:
ret = Skein1024_Final(&ctx->m.s1024, (u8 *)hash); ret = skein_1024_final(&ctx->m.s1024, (u8 *)hash);
break; break;
} }
return ret; return ret;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/***************************** Skein_256 ******************************/ /***************************** Skein_256 ******************************/
void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr,
size_t blkCnt, size_t byteCntAdd) size_t blkCnt, size_t byteCntAdd)
{ {
struct threefish_key key; struct threefish_key key;
...@@ -34,12 +34,12 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, ...@@ -34,12 +34,12 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr,
tweak[0] |= (words[1] & 0xffffffffL) << 32; tweak[0] |= (words[1] & 0xffffffffL) << 32;
tweak[1] |= words[2] & 0xffffffffL; 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 */ /* get input block in little-endian format */
Skein_Get64_LSB_First(w, blkPtr, SKEIN_256_STATE_WORDS); 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; blkPtr += SKEIN_256_BLOCK_BYTES;
...@@ -56,7 +56,7 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, ...@@ -56,7 +56,7 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr,
ctx->h.T[1] = tweak[1]; ctx->h.T[1] = tweak[1];
} }
void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blkPtr,
size_t blkCnt, size_t byteCntAdd) size_t blkCnt, size_t byteCntAdd)
{ {
struct threefish_key key; struct threefish_key key;
...@@ -85,12 +85,12 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, ...@@ -85,12 +85,12 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr,
tweak[0] |= (words[1] & 0xffffffffL) << 32; tweak[0] |= (words[1] & 0xffffffffL) << 32;
tweak[1] |= words[2] & 0xffffffffL; 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 */ /* get input block in little-endian format */
Skein_Get64_LSB_First(w, blkPtr, SKEIN_512_STATE_WORDS); 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; blkPtr += SKEIN_512_BLOCK_BYTES;
...@@ -111,7 +111,7 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, ...@@ -111,7 +111,7 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr,
ctx->h.T[1] = tweak[1]; ctx->h.T[1] = tweak[1];
} }
void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blkPtr,
size_t blkCnt, size_t byteCntAdd) size_t blkCnt, size_t byteCntAdd)
{ {
struct threefish_key key; struct threefish_key key;
...@@ -140,12 +140,12 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, ...@@ -140,12 +140,12 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr,
tweak[0] |= (words[1] & 0xffffffffL) << 32; tweak[0] |= (words[1] & 0xffffffffL) << 32;
tweak[1] |= words[2] & 0xffffffffL; 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 */ /* get input block in little-endian format */
Skein_Get64_LSB_First(w, blkPtr, SKEIN1024_STATE_WORDS); 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; blkPtr += SKEIN1024_BLOCK_BYTES;
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
/***************************** Skein_256 ******************************/ /***************************** Skein_256 ******************************/
#if !(SKEIN_USE_ASM & 256) #if !(SKEIN_USE_ASM & 256)
void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr,
size_t blkCnt, size_t byteCntAdd) size_t blkCnt, size_t byteCntAdd)
{ /* do it in C */ { /* do it in C */
enum { enum {
...@@ -215,7 +215,7 @@ do { \ ...@@ -215,7 +215,7 @@ do { \
R256_8_rounds(14); R256_8_rounds(14);
#endif #endif
#if (SKEIN_UNROLL_256 > 14) #if (SKEIN_UNROLL_256 > 14)
#error "need more unrolling in Skein_256_Process_Block" #error "need more unrolling in skein_256_process_block"
#endif #endif
} }
/* do the final "feedforward" xor, update context chaining */ /* do the final "feedforward" xor, update context chaining */
...@@ -233,12 +233,12 @@ do { \ ...@@ -233,12 +233,12 @@ do { \
} }
#if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) #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) - return ((u8 *) skein_256_process_block_code_size) -
((u8 *) Skein_256_Process_Block); ((u8 *) skein_256_process_block);
} }
unsigned int Skein_256_Unroll_Cnt(void) unsigned int skein_256_unroll_cnt(void)
{ {
return SKEIN_UNROLL_256; return SKEIN_UNROLL_256;
} }
...@@ -247,7 +247,7 @@ unsigned int Skein_256_Unroll_Cnt(void) ...@@ -247,7 +247,7 @@ unsigned int Skein_256_Unroll_Cnt(void)
/***************************** Skein_512 ******************************/ /***************************** Skein_512 ******************************/
#if !(SKEIN_USE_ASM & 512) #if !(SKEIN_USE_ASM & 512)
void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blkPtr,
size_t blkCnt, size_t byteCntAdd) size_t blkCnt, size_t byteCntAdd)
{ /* do it in C */ { /* do it in C */
enum { enum {
...@@ -441,7 +441,7 @@ do { \ ...@@ -441,7 +441,7 @@ do { \
R512_8_rounds(14); R512_8_rounds(14);
#endif #endif
#if (SKEIN_UNROLL_512 > 14) #if (SKEIN_UNROLL_512 > 14)
#error "need more unrolling in Skein_512_Process_Block" #error "need more unrolling in skein_512_process_block"
#endif #endif
} }
...@@ -463,12 +463,12 @@ do { \ ...@@ -463,12 +463,12 @@ do { \
} }
#if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) #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) - return ((u8 *) skein_512_process_block_code_size) -
((u8 *) Skein_512_Process_Block); ((u8 *) skein_512_process_block);
} }
unsigned int Skein_512_Unroll_Cnt(void) unsigned int skein_512_unroll_cnt(void)
{ {
return SKEIN_UNROLL_512; return SKEIN_UNROLL_512;
} }
...@@ -477,7 +477,7 @@ unsigned int Skein_512_Unroll_Cnt(void) ...@@ -477,7 +477,7 @@ unsigned int Skein_512_Unroll_Cnt(void)
/***************************** Skein1024 ******************************/ /***************************** Skein1024 ******************************/
#if !(SKEIN_USE_ASM & 1024) #if !(SKEIN_USE_ASM & 1024)
void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blkPtr,
size_t blkCnt, size_t byteCntAdd) size_t blkCnt, size_t byteCntAdd)
{ /* do it in C, always looping (unrolled is bigger AND slower!) */ { /* do it in C, always looping (unrolled is bigger AND slower!) */
enum { enum {
...@@ -757,12 +757,12 @@ do { \ ...@@ -757,12 +757,12 @@ do { \
} }
#if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) #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) - return ((u8 *) skein_1024_process_block_code_size) -
((u8 *) Skein1024_Process_Block); ((u8 *) skein_1024_process_block);
} }
unsigned int Skein1024_Unroll_Cnt(void) unsigned int skein_1024_unroll_cnt(void)
{ {
return SKEIN_UNROLL_1024; return SKEIN_UNROLL_1024;
} }
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
#include <threefishApi.h> #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], u64 b0 = input[0], b1 = input[1],
b2 = input[2], b3 = input[3], b2 = input[2], b3 = input[3],
...@@ -2122,7 +2123,8 @@ void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output) ...@@ -2122,7 +2123,8 @@ void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output)
output[15] = b15 + k1 + 20; 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], u64 b0 = input[0], b1 = input[1],
b2 = input[2], b3 = input[3], b2 = input[2], b3 = input[3],
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
#include <threefishApi.h> #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], u64 b0 = input[0], b1 = input[1],
b2 = input[2], b3 = input[3]; b2 = input[2], b3 = input[3];
...@@ -494,7 +495,8 @@ void threefishEncrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output) ...@@ -494,7 +495,8 @@ void threefishEncrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output)
output[3] = b3 + k1 + 18; 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], u64 b0 = input[0], b1 = input[1],
b2 = input[2], b3 = input[3]; b2 = input[2], b3 = input[3];
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
#include <threefishApi.h> #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], u64 b0 = input[0], b1 = input[1],
b2 = input[2], b3 = input[3], b2 = input[2], b3 = input[3],
...@@ -962,7 +963,8 @@ void threefishEncrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output) ...@@ -962,7 +963,8 @@ void threefishEncrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output)
output[7] = b7 + k7 + 18; 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], u64 b0 = input[0], b1 = input[1],
b2 = input[2], b3 = input[3], b2 = input[2], b3 = input[3],
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <linux/string.h> #include <linux/string.h>
#include <threefishApi.h> #include <threefishApi.h>
void threefishSetKey(struct threefish_key *keyCtx, void threefish_set_key(struct threefish_key *keyCtx,
enum threefish_size stateSize, enum threefish_size stateSize,
u64 *keyData, u64 *tweak) u64 *keyData, u64 *tweak)
{ {
...@@ -23,56 +23,56 @@ void threefishSetKey(struct threefish_key *keyCtx, ...@@ -23,56 +23,56 @@ void threefishSetKey(struct threefish_key *keyCtx,
keyCtx->stateSize = stateSize; keyCtx->stateSize = stateSize;
} }
void threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in, void threefish_encrypt_block_bytes(struct threefish_key *keyCtx, u8 *in,
u8 *out) u8 *out)
{ {
u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/
u64 cipher[SKEIN_MAX_STATE_WORDS]; u64 cipher[SKEIN_MAX_STATE_WORDS];
Skein_Get64_LSB_First(plain, in, keyCtx->stateSize / 64); 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); Skein_Put64_LSB_First(out, cipher, keyCtx->stateSize / 8);
} }
void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in, void threefish_encrypt_block_words(struct threefish_key *keyCtx, u64 *in,
u64 *out) u64 *out)
{ {
switch (keyCtx->stateSize) { switch (keyCtx->stateSize) {
case Threefish256: case Threefish256:
threefishEncrypt256(keyCtx, in, out); threefish_encrypt_256(keyCtx, in, out);
break; break;
case Threefish512: case Threefish512:
threefishEncrypt512(keyCtx, in, out); threefish_encrypt_512(keyCtx, in, out);
break; break;
case Threefish1024: case Threefish1024:
threefishEncrypt1024(keyCtx, in, out); threefish_encrypt_1024(keyCtx, in, out);
break; break;
} }
} }
void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in, void threefish_decrypt_block_bytes(struct threefish_key *keyCtx, u8 *in,
u8 *out) u8 *out)
{ {
u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/
u64 cipher[SKEIN_MAX_STATE_WORDS]; u64 cipher[SKEIN_MAX_STATE_WORDS];
Skein_Get64_LSB_First(cipher, in, keyCtx->stateSize / 64); 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); Skein_Put64_LSB_First(out, plain, keyCtx->stateSize / 8);
} }
void threefishDecryptBlockWords(struct threefish_key *keyCtx, u64 *in, void threefish_decrypt_block_words(struct threefish_key *keyCtx, u64 *in,
u64 *out) u64 *out)
{ {
switch (keyCtx->stateSize) { switch (keyCtx->stateSize) {
case Threefish256: case Threefish256:
threefishDecrypt256(keyCtx, in, out); threefish_decrypt_256(keyCtx, in, out);
break; break;
case Threefish512: case Threefish512:
threefishDecrypt512(keyCtx, in, out); threefish_decrypt_512(keyCtx, in, out);
break; break;
case Threefish1024: case Threefish1024:
threefishDecrypt1024(keyCtx, in, out); threefish_decrypt_1024(keyCtx, in, out);
break; break;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment