summaryrefslogtreecommitdiff
path: root/drivers/staging/skein/skein.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/skein/skein.c')
-rw-r--r--drivers/staging/skein/skein.c415
1 files changed, 209 insertions, 206 deletions
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
index ac64d9f096f0..d4f3534feae0 100644
--- a/drivers/staging/skein/skein.c
+++ b/drivers/staging/skein/skein.c
@@ -21,17 +21,17 @@
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* 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 hash_bit_len)
{
union {
- u8 b[SKEIN_256_STATE_BYTES];
- u64 w[SKEIN_256_STATE_WORDS];
+ u8 b[SKEIN_256_STATE_BYTES];
+ u64 w[SKEIN_256_STATE_WORDS];
} cfg; /* config block */
- Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN);
- ctx->h.hashBitLen = hashBitLen; /* output hash bit count */
+ Skein_Assert(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
+ ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */
- switch (hashBitLen) { /* use pre-computed values, where available */
+ switch (hash_bit_len) { /* use pre-computed values, where available */
case 256:
memcpy(ctx->X, SKEIN_256_IV_256, sizeof(ctx->X));
break;
@@ -56,7 +56,7 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t hashBitLen)
/* set the schema, version */
cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER);
/* hash result length in bits */
- cfg.w[1] = Skein_Swap64(hashBitLen);
+ cfg.w[1] = Skein_Swap64(hash_bit_len);
cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL);
/* zero pad config block */
memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0]));
@@ -67,7 +67,7 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t hashBitLen)
skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
break;
}
- /* The chaining vars ctx->X are now initialized for hashBitLen. */
+ /* The chaining vars ctx->X are now initialized for hash_bit_len. */
/* Set up to process the data message portion of the hash (default) */
Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */
@@ -76,34 +76,34 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t hashBitLen)
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* init the context for a MAC and/or tree hash operation */
-/* [identical to skein_256_init() when keyBytes == 0 && \
- * treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
-int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hashBitLen,
- u64 treeInfo, const u8 *key, size_t keyBytes)
+/* [identical to skein_256_init() when key_bytes == 0 && \
+ * tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
+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)
{
union {
u8 b[SKEIN_256_STATE_BYTES];
- u64 w[SKEIN_256_STATE_WORDS];
+ u64 w[SKEIN_256_STATE_WORDS];
} cfg; /* config block */
- Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN);
- Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL);
+ Skein_Assert(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
+ Skein_Assert(key_bytes == 0 || key != NULL, SKEIN_FAIL);
/* compute the initial chaining values ctx->X[], based on key */
- if (keyBytes == 0) { /* is there a key? */
+ if (key_bytes == 0) { /* is there a key? */
/* no key: use all zeroes as key for config block */
memset(ctx->X, 0, sizeof(ctx->X));
} else { /* here to pre-process a key */
Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X));
/* do a mini-Init right here */
/* set output hash bit count = state size */
- ctx->h.hashBitLen = 8*sizeof(ctx->X);
+ ctx->h.hash_bit_len = 8*sizeof(ctx->X);
/* set tweaks: T0 = 0; T1 = KEY type */
Skein_Start_New_Type(ctx, KEY);
/* zero the initial chaining variables */
memset(ctx->X, 0, sizeof(ctx->X));
/* hash the key */
- skein_256_update(ctx, key, keyBytes);
+ skein_256_update(ctx, key, key_bytes);
/* put result into cfg.b[] */
skein_256_final_pad(ctx, cfg.b);
/* copy over into ctx->X[] */
@@ -114,18 +114,18 @@ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hashBitLen,
* precomputed for each key)
*/
/* output hash bit count */
- ctx->h.hashBitLen = hashBitLen;
+ ctx->h.hash_bit_len = hash_bit_len;
Skein_Start_New_Type(ctx, CFG_FINAL);
/* pre-pad cfg.w[] with zeroes */
memset(&cfg.w, 0, sizeof(cfg.w));
cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER);
/* hash result length in bits */
- cfg.w[1] = Skein_Swap64(hashBitLen);
+ cfg.w[1] = Skein_Swap64(hash_bit_len);
/* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
- cfg.w[2] = Skein_Swap64(treeInfo);
+ cfg.w[2] = Skein_Swap64(tree_info);
- Skein_Show_Key(256, &ctx->h, key, keyBytes);
+ Skein_Show_Key(256, &ctx->h, key, key_bytes);
/* compute the initial chaining values from config block */
skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
@@ -140,52 +140,53 @@ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hashBitLen,
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* process the input bytes */
int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg,
- size_t msgByteCnt)
+ size_t msg_byte_cnt)
{
size_t n;
/* catch uninitialized context */
- Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
+ Skein_Assert(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
/* process full blocks, if any */
- if (msgByteCnt + ctx->h.bCnt > SKEIN_256_BLOCK_BYTES) {
+ if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_256_BLOCK_BYTES) {
/* finish up any buffered message data */
- if (ctx->h.bCnt) {
+ if (ctx->h.b_cnt) {
/* # bytes free in buffer b[] */
- n = SKEIN_256_BLOCK_BYTES - ctx->h.bCnt;
+ n = SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt;
if (n) {
/* check on our logic here */
- Skein_assert(n < msgByteCnt);
- memcpy(&ctx->b[ctx->h.bCnt], msg, n);
- msgByteCnt -= n;
+ Skein_assert(n < msg_byte_cnt);
+ memcpy(&ctx->b[ctx->h.b_cnt], msg, n);
+ msg_byte_cnt -= n;
msg += n;
- ctx->h.bCnt += n;
+ ctx->h.b_cnt += n;
}
- Skein_assert(ctx->h.bCnt == SKEIN_256_BLOCK_BYTES);
+ Skein_assert(ctx->h.b_cnt == SKEIN_256_BLOCK_BYTES);
skein_256_process_block(ctx, ctx->b, 1,
SKEIN_256_BLOCK_BYTES);
- ctx->h.bCnt = 0;
+ ctx->h.b_cnt = 0;
}
/*
* now process any remaining full blocks, directly from input
* message data
*/
- if (msgByteCnt > SKEIN_256_BLOCK_BYTES) {
+ if (msg_byte_cnt > SKEIN_256_BLOCK_BYTES) {
/* number of full blocks to process */
- n = (msgByteCnt-1) / SKEIN_256_BLOCK_BYTES;
+ n = (msg_byte_cnt-1) / SKEIN_256_BLOCK_BYTES;
skein_256_process_block(ctx, msg, n,
SKEIN_256_BLOCK_BYTES);
- msgByteCnt -= n * SKEIN_256_BLOCK_BYTES;
+ msg_byte_cnt -= n * SKEIN_256_BLOCK_BYTES;
msg += n * SKEIN_256_BLOCK_BYTES;
}
- Skein_assert(ctx->h.bCnt == 0);
+ Skein_assert(ctx->h.b_cnt == 0);
}
/* copy any remaining source message data bytes into b[] */
- if (msgByteCnt) {
- Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES);
- memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt);
- ctx->h.bCnt += msgByteCnt;
+ if (msg_byte_cnt) {
+ Skein_assert(msg_byte_cnt + ctx->h.b_cnt <=
+ SKEIN_256_BLOCK_BYTES);
+ memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt);
+ ctx->h.b_cnt += msg_byte_cnt;
}
return SKEIN_SUCCESS;
@@ -193,47 +194,47 @@ int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg,
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* 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 *hash_val)
{
- size_t i, n, byteCnt;
+ size_t i, n, byte_cnt;
u64 X[SKEIN_256_STATE_WORDS];
/* catch uninitialized context */
- Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
+ Skein_Assert(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
/* tag as the final block */
ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL;
/* zero pad b[] if necessary */
- if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES)
- memset(&ctx->b[ctx->h.bCnt], 0,
- SKEIN_256_BLOCK_BYTES - ctx->h.bCnt);
+ if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES)
+ memset(&ctx->b[ctx->h.b_cnt], 0,
+ SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt);
/* 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.b_cnt);
/* now output the result */
/* total number of output bytes */
- byteCnt = (ctx->h.hashBitLen + 7) >> 3;
+ byte_cnt = (ctx->h.hash_bit_len + 7) >> 3;
/* run Threefish in "counter mode" to generate output */
/* zero out b[], so it can hold the counter */
memset(ctx->b, 0, sizeof(ctx->b));
/* keep a local copy of counter mode "key" */
memcpy(X, ctx->X, sizeof(X));
- for (i = 0; i*SKEIN_256_BLOCK_BYTES < byteCnt; i++) {
+ for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) {
/* build the counter block */
((u64 *)ctx->b)[0] = Skein_Swap64((u64) i);
Skein_Start_New_Type(ctx, OUT_FINAL);
/* run "counter mode" */
skein_256_process_block(ctx, ctx->b, 1, sizeof(u64));
/* number of output bytes left to go */
- n = byteCnt - i*SKEIN_256_BLOCK_BYTES;
+ n = byte_cnt - i*SKEIN_256_BLOCK_BYTES;
if (n >= SKEIN_256_BLOCK_BYTES)
n = SKEIN_256_BLOCK_BYTES;
/* "output" the ctr mode bytes */
- Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES, ctx->X,
+ Skein_Put64_LSB_First(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->X,
n);
Skein_Show_Final(256, &ctx->h, n,
- hashVal+i*SKEIN_256_BLOCK_BYTES);
+ hash_val+i*SKEIN_256_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx->X, X, sizeof(X));
}
@@ -246,17 +247,17 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hashVal)
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* 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 hash_bit_len)
{
union {
- u8 b[SKEIN_512_STATE_BYTES];
- u64 w[SKEIN_512_STATE_WORDS];
+ u8 b[SKEIN_512_STATE_BYTES];
+ u64 w[SKEIN_512_STATE_WORDS];
} cfg; /* config block */
- Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN);
- ctx->h.hashBitLen = hashBitLen; /* output hash bit count */
+ Skein_Assert(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
+ ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */
- switch (hashBitLen) { /* use pre-computed values, where available */
+ switch (hash_bit_len) { /* use pre-computed values, where available */
case 512:
memcpy(ctx->X, SKEIN_512_IV_512, sizeof(ctx->X));
break;
@@ -281,7 +282,7 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t hashBitLen)
/* set the schema, version */
cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER);
/* hash result length in bits */
- cfg.w[1] = Skein_Swap64(hashBitLen);
+ cfg.w[1] = Skein_Swap64(hash_bit_len);
cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL);
/* zero pad config block */
memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0]));
@@ -295,7 +296,7 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t hashBitLen)
/*
* The chaining vars ctx->X are now initialized for the given
- * hashBitLen.
+ * hash_bit_len.
*/
/* Set up to process the data message portion of the hash (default) */
Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */
@@ -305,34 +306,34 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t hashBitLen)
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* init the context for a MAC and/or tree hash operation */
-/* [identical to skein_512_init() when keyBytes == 0 && \
- * treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
-int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hashBitLen,
- u64 treeInfo, const u8 *key, size_t keyBytes)
+/* [identical to skein_512_init() when key_bytes == 0 && \
+ * tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
+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)
{
union {
- u8 b[SKEIN_512_STATE_BYTES];
- u64 w[SKEIN_512_STATE_WORDS];
+ u8 b[SKEIN_512_STATE_BYTES];
+ u64 w[SKEIN_512_STATE_WORDS];
} cfg; /* config block */
- Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN);
- Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL);
+ Skein_Assert(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
+ Skein_Assert(key_bytes == 0 || key != NULL, SKEIN_FAIL);
/* compute the initial chaining values ctx->X[], based on key */
- if (keyBytes == 0) { /* is there a key? */
+ if (key_bytes == 0) { /* is there a key? */
/* no key: use all zeroes as key for config block */
memset(ctx->X, 0, sizeof(ctx->X));
} else { /* here to pre-process a key */
Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X));
/* do a mini-Init right here */
/* set output hash bit count = state size */
- ctx->h.hashBitLen = 8*sizeof(ctx->X);
+ ctx->h.hash_bit_len = 8*sizeof(ctx->X);
/* set tweaks: T0 = 0; T1 = KEY type */
Skein_Start_New_Type(ctx, KEY);
/* zero the initial chaining variables */
memset(ctx->X, 0, sizeof(ctx->X));
/* hash the key */
- skein_512_update(ctx, key, keyBytes);
+ skein_512_update(ctx, key, key_bytes);
/* put result into cfg.b[] */
skein_512_final_pad(ctx, cfg.b);
/* copy over into ctx->X[] */
@@ -342,18 +343,18 @@ int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hashBitLen,
* build/process the config block, type == CONFIG (could be
* precomputed for each key)
*/
- ctx->h.hashBitLen = hashBitLen; /* output hash bit count */
+ ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */
Skein_Start_New_Type(ctx, CFG_FINAL);
/* pre-pad cfg.w[] with zeroes */
memset(&cfg.w, 0, sizeof(cfg.w));
cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER);
/* hash result length in bits */
- cfg.w[1] = Skein_Swap64(hashBitLen);
+ cfg.w[1] = Skein_Swap64(hash_bit_len);
/* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
- cfg.w[2] = Skein_Swap64(treeInfo);
+ cfg.w[2] = Skein_Swap64(tree_info);
- Skein_Show_Key(512, &ctx->h, key, keyBytes);
+ Skein_Show_Key(512, &ctx->h, key, key_bytes);
/* compute the initial chaining values from config block */
skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
@@ -368,52 +369,53 @@ int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hashBitLen,
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* process the input bytes */
int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg,
- size_t msgByteCnt)
+ size_t msg_byte_cnt)
{
size_t n;
/* catch uninitialized context */
- Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
+ Skein_Assert(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
/* process full blocks, if any */
- if (msgByteCnt + ctx->h.bCnt > SKEIN_512_BLOCK_BYTES) {
+ if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_512_BLOCK_BYTES) {
/* finish up any buffered message data */
- if (ctx->h.bCnt) {
+ if (ctx->h.b_cnt) {
/* # bytes free in buffer b[] */
- n = SKEIN_512_BLOCK_BYTES - ctx->h.bCnt;
+ n = SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt;
if (n) {
/* check on our logic here */
- Skein_assert(n < msgByteCnt);
- memcpy(&ctx->b[ctx->h.bCnt], msg, n);
- msgByteCnt -= n;
+ Skein_assert(n < msg_byte_cnt);
+ memcpy(&ctx->b[ctx->h.b_cnt], msg, n);
+ msg_byte_cnt -= n;
msg += n;
- ctx->h.bCnt += n;
+ ctx->h.b_cnt += n;
}
- Skein_assert(ctx->h.bCnt == SKEIN_512_BLOCK_BYTES);
+ Skein_assert(ctx->h.b_cnt == SKEIN_512_BLOCK_BYTES);
skein_512_process_block(ctx, ctx->b, 1,
SKEIN_512_BLOCK_BYTES);
- ctx->h.bCnt = 0;
+ ctx->h.b_cnt = 0;
}
/*
* now process any remaining full blocks, directly from input
* message data
*/
- if (msgByteCnt > SKEIN_512_BLOCK_BYTES) {
+ if (msg_byte_cnt > SKEIN_512_BLOCK_BYTES) {
/* number of full blocks to process */
- n = (msgByteCnt-1) / SKEIN_512_BLOCK_BYTES;
+ n = (msg_byte_cnt-1) / SKEIN_512_BLOCK_BYTES;
skein_512_process_block(ctx, msg, n,
SKEIN_512_BLOCK_BYTES);
- msgByteCnt -= n * SKEIN_512_BLOCK_BYTES;
+ msg_byte_cnt -= n * SKEIN_512_BLOCK_BYTES;
msg += n * SKEIN_512_BLOCK_BYTES;
}
- Skein_assert(ctx->h.bCnt == 0);
+ Skein_assert(ctx->h.b_cnt == 0);
}
/* copy any remaining source message data bytes into b[] */
- if (msgByteCnt) {
- Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES);
- memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt);
- ctx->h.bCnt += msgByteCnt;
+ if (msg_byte_cnt) {
+ Skein_assert(msg_byte_cnt + ctx->h.b_cnt <=
+ SKEIN_512_BLOCK_BYTES);
+ memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt);
+ ctx->h.b_cnt += msg_byte_cnt;
}
return SKEIN_SUCCESS;
@@ -421,47 +423,47 @@ int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg,
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* 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 *hash_val)
{
- size_t i, n, byteCnt;
+ size_t i, n, byte_cnt;
u64 X[SKEIN_512_STATE_WORDS];
/* catch uninitialized context */
- Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
+ Skein_Assert(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
/* tag as the final block */
ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL;
/* zero pad b[] if necessary */
- if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES)
- memset(&ctx->b[ctx->h.bCnt], 0,
- SKEIN_512_BLOCK_BYTES - ctx->h.bCnt);
+ if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES)
+ memset(&ctx->b[ctx->h.b_cnt], 0,
+ SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt);
/* 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.b_cnt);
/* now output the result */
/* total number of output bytes */
- byteCnt = (ctx->h.hashBitLen + 7) >> 3;
+ byte_cnt = (ctx->h.hash_bit_len + 7) >> 3;
/* run Threefish in "counter mode" to generate output */
/* zero out b[], so it can hold the counter */
memset(ctx->b, 0, sizeof(ctx->b));
/* keep a local copy of counter mode "key" */
memcpy(X, ctx->X, sizeof(X));
- for (i = 0; i*SKEIN_512_BLOCK_BYTES < byteCnt; i++) {
+ for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) {
/* build the counter block */
((u64 *)ctx->b)[0] = Skein_Swap64((u64) i);
Skein_Start_New_Type(ctx, OUT_FINAL);
/* run "counter mode" */
skein_512_process_block(ctx, ctx->b, 1, sizeof(u64));
/* number of output bytes left to go */
- n = byteCnt - i*SKEIN_512_BLOCK_BYTES;
+ n = byte_cnt - i*SKEIN_512_BLOCK_BYTES;
if (n >= SKEIN_512_BLOCK_BYTES)
n = SKEIN_512_BLOCK_BYTES;
/* "output" the ctr mode bytes */
- Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES, ctx->X,
+ Skein_Put64_LSB_First(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->X,
n);
Skein_Show_Final(512, &ctx->h, n,
- hashVal+i*SKEIN_512_BLOCK_BYTES);
+ hash_val+i*SKEIN_512_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx->X, X, sizeof(X));
}
@@ -474,17 +476,17 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hashVal)
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* init the context for a straight hashing operation */
-int skein_1024_init(struct skein1024_ctx *ctx, size_t hashBitLen)
+int skein_1024_init(struct skein1024_ctx *ctx, size_t hash_bit_len)
{
union {
- u8 b[SKEIN1024_STATE_BYTES];
- u64 w[SKEIN1024_STATE_WORDS];
+ u8 b[SKEIN1024_STATE_BYTES];
+ u64 w[SKEIN1024_STATE_WORDS];
} cfg; /* config block */
- Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN);
- ctx->h.hashBitLen = hashBitLen; /* output hash bit count */
+ Skein_Assert(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
+ ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */
- switch (hashBitLen) { /* use pre-computed values, where available */
+ switch (hash_bit_len) { /* use pre-computed values, where available */
case 512:
memcpy(ctx->X, SKEIN1024_IV_512, sizeof(ctx->X));
break;
@@ -506,7 +508,7 @@ int skein_1024_init(struct skein1024_ctx *ctx, size_t hashBitLen)
/* set the schema, version */
cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER);
/* hash result length in bits */
- cfg.w[1] = Skein_Swap64(hashBitLen);
+ cfg.w[1] = Skein_Swap64(hash_bit_len);
cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL);
/* zero pad config block */
memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0]));
@@ -518,7 +520,7 @@ int skein_1024_init(struct skein1024_ctx *ctx, size_t hashBitLen)
break;
}
- /* The chaining vars ctx->X are now initialized for the hashBitLen. */
+ /* The chaining vars ctx->X are now initialized for the hash_bit_len. */
/* Set up to process the data message portion of the hash (default) */
Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */
@@ -527,34 +529,34 @@ int skein_1024_init(struct skein1024_ctx *ctx, size_t hashBitLen)
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* init the context for a MAC and/or tree hash operation */
-/* [identical to skein_1024_init() when keyBytes == 0 && \
- * treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
-int skein_1024_init_ext(struct skein1024_ctx *ctx, size_t hashBitLen,
- u64 treeInfo, const u8 *key, size_t keyBytes)
+/* [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,
+ u64 tree_info, const u8 *key, size_t key_bytes)
{
union {
- u8 b[SKEIN1024_STATE_BYTES];
- u64 w[SKEIN1024_STATE_WORDS];
+ u8 b[SKEIN1024_STATE_BYTES];
+ u64 w[SKEIN1024_STATE_WORDS];
} cfg; /* config block */
- Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN);
- Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL);
+ Skein_Assert(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
+ Skein_Assert(key_bytes == 0 || key != NULL, SKEIN_FAIL);
/* compute the initial chaining values ctx->X[], based on key */
- if (keyBytes == 0) { /* is there a key? */
+ if (key_bytes == 0) { /* is there a key? */
/* no key: use all zeroes as key for config block */
memset(ctx->X, 0, sizeof(ctx->X));
} else { /* here to pre-process a key */
Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X));
/* do a mini-Init right here */
/* set output hash bit count = state size */
- ctx->h.hashBitLen = 8*sizeof(ctx->X);
+ ctx->h.hash_bit_len = 8*sizeof(ctx->X);
/* set tweaks: T0 = 0; T1 = KEY type */
Skein_Start_New_Type(ctx, KEY);
/* zero the initial chaining variables */
memset(ctx->X, 0, sizeof(ctx->X));
/* hash the key */
- skein_1024_update(ctx, key, keyBytes);
+ skein_1024_update(ctx, key, key_bytes);
/* put result into cfg.b[] */
skein_1024_final_pad(ctx, cfg.b);
/* copy over into ctx->X[] */
@@ -565,18 +567,18 @@ int skein_1024_init_ext(struct skein1024_ctx *ctx, size_t hashBitLen,
* precomputed for each key)
*/
/* output hash bit count */
- ctx->h.hashBitLen = hashBitLen;
+ ctx->h.hash_bit_len = hash_bit_len;
Skein_Start_New_Type(ctx, CFG_FINAL);
/* pre-pad cfg.w[] with zeroes */
memset(&cfg.w, 0, sizeof(cfg.w));
cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER);
/* hash result length in bits */
- cfg.w[1] = Skein_Swap64(hashBitLen);
+ cfg.w[1] = Skein_Swap64(hash_bit_len);
/* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
- cfg.w[2] = Skein_Swap64(treeInfo);
+ cfg.w[2] = Skein_Swap64(tree_info);
- Skein_Show_Key(1024, &ctx->h, key, keyBytes);
+ Skein_Show_Key(1024, &ctx->h, key, key_bytes);
/* compute the initial chaining values from config block */
skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
@@ -591,52 +593,53 @@ int skein_1024_init_ext(struct skein1024_ctx *ctx, size_t hashBitLen,
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* process the input bytes */
int skein_1024_update(struct skein1024_ctx *ctx, const u8 *msg,
- size_t msgByteCnt)
+ size_t msg_byte_cnt)
{
size_t n;
/* catch uninitialized context */
- Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL);
+ Skein_Assert(ctx->h.b_cnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL);
/* process full blocks, if any */
- if (msgByteCnt + ctx->h.bCnt > SKEIN1024_BLOCK_BYTES) {
+ if (msg_byte_cnt + ctx->h.b_cnt > SKEIN1024_BLOCK_BYTES) {
/* finish up any buffered message data */
- if (ctx->h.bCnt) {
+ if (ctx->h.b_cnt) {
/* # bytes free in buffer b[] */
- n = SKEIN1024_BLOCK_BYTES - ctx->h.bCnt;
+ n = SKEIN1024_BLOCK_BYTES - ctx->h.b_cnt;
if (n) {
/* check on our logic here */
- Skein_assert(n < msgByteCnt);
- memcpy(&ctx->b[ctx->h.bCnt], msg, n);
- msgByteCnt -= n;
+ Skein_assert(n < msg_byte_cnt);
+ memcpy(&ctx->b[ctx->h.b_cnt], msg, n);
+ msg_byte_cnt -= n;
msg += n;
- ctx->h.bCnt += n;
+ ctx->h.b_cnt += n;
}
- Skein_assert(ctx->h.bCnt == SKEIN1024_BLOCK_BYTES);
+ Skein_assert(ctx->h.b_cnt == SKEIN1024_BLOCK_BYTES);
skein_1024_process_block(ctx, ctx->b, 1,
SKEIN1024_BLOCK_BYTES);
- ctx->h.bCnt = 0;
+ ctx->h.b_cnt = 0;
}
/*
* now process any remaining full blocks, directly from input
* message data
*/
- if (msgByteCnt > SKEIN1024_BLOCK_BYTES) {
+ if (msg_byte_cnt > SKEIN1024_BLOCK_BYTES) {
/* number of full blocks to process */
- n = (msgByteCnt-1) / SKEIN1024_BLOCK_BYTES;
+ n = (msg_byte_cnt-1) / SKEIN1024_BLOCK_BYTES;
skein_1024_process_block(ctx, msg, n,
SKEIN1024_BLOCK_BYTES);
- msgByteCnt -= n * SKEIN1024_BLOCK_BYTES;
+ msg_byte_cnt -= n * SKEIN1024_BLOCK_BYTES;
msg += n * SKEIN1024_BLOCK_BYTES;
}
- Skein_assert(ctx->h.bCnt == 0);
+ Skein_assert(ctx->h.b_cnt == 0);
}
/* copy any remaining source message data bytes into b[] */
- if (msgByteCnt) {
- Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES);
- memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt);
- ctx->h.bCnt += msgByteCnt;
+ if (msg_byte_cnt) {
+ Skein_assert(msg_byte_cnt + ctx->h.b_cnt <=
+ SKEIN1024_BLOCK_BYTES);
+ memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt);
+ ctx->h.b_cnt += msg_byte_cnt;
}
return SKEIN_SUCCESS;
@@ -644,47 +647,47 @@ 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 *hashVal)
+int skein_1024_final(struct skein1024_ctx *ctx, u8 *hash_val)
{
- size_t i, n, byteCnt;
+ size_t i, n, byte_cnt;
u64 X[SKEIN1024_STATE_WORDS];
/* catch uninitialized context */
- Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL);
+ Skein_Assert(ctx->h.b_cnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL);
/* tag as the final block */
ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL;
/* zero pad b[] if necessary */
- if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES)
- memset(&ctx->b[ctx->h.bCnt], 0,
- SKEIN1024_BLOCK_BYTES - ctx->h.bCnt);
+ if (ctx->h.b_cnt < SKEIN1024_BLOCK_BYTES)
+ memset(&ctx->b[ctx->h.b_cnt], 0,
+ SKEIN1024_BLOCK_BYTES - ctx->h.b_cnt);
/* process the final block */
- skein_1024_process_block(ctx, ctx->b, 1, ctx->h.bCnt);
+ skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt);
/* now output the result */
/* total number of output bytes */
- byteCnt = (ctx->h.hashBitLen + 7) >> 3;
+ byte_cnt = (ctx->h.hash_bit_len + 7) >> 3;
/* run Threefish in "counter mode" to generate output */
/* zero out b[], so it can hold the counter */
memset(ctx->b, 0, sizeof(ctx->b));
/* keep a local copy of counter mode "key" */
memcpy(X, ctx->X, sizeof(X));
- for (i = 0; i*SKEIN1024_BLOCK_BYTES < byteCnt; i++) {
+ for (i = 0; i*SKEIN1024_BLOCK_BYTES < byte_cnt; i++) {
/* build the counter block */
((u64 *)ctx->b)[0] = Skein_Swap64((u64) i);
Skein_Start_New_Type(ctx, OUT_FINAL);
/* run "counter mode" */
skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64));
/* number of output bytes left to go */
- n = byteCnt - i*SKEIN1024_BLOCK_BYTES;
+ n = byte_cnt - i*SKEIN1024_BLOCK_BYTES;
if (n >= SKEIN1024_BLOCK_BYTES)
n = SKEIN1024_BLOCK_BYTES;
/* "output" the ctr mode bytes */
- Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES, ctx->X,
+ Skein_Put64_LSB_First(hash_val+i*SKEIN1024_BLOCK_BYTES, ctx->X,
n);
Skein_Show_Final(1024, &ctx->h, n,
- hashVal+i*SKEIN1024_BLOCK_BYTES);
+ hash_val+i*SKEIN1024_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx->X, X, sizeof(X));
}
@@ -696,66 +699,66 @@ int skein_1024_final(struct skein1024_ctx *ctx, u8 *hashVal)
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* 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 *hash_val)
{
/* catch uninitialized context */
- Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
+ Skein_Assert(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
/* tag as the final block */
ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL;
/* zero pad b[] if necessary */
- if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES)
- memset(&ctx->b[ctx->h.bCnt], 0,
- SKEIN_256_BLOCK_BYTES - ctx->h.bCnt);
+ if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES)
+ memset(&ctx->b[ctx->h.b_cnt], 0,
+ SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt);
/* 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.b_cnt);
/* "output" the state bytes */
- Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_256_BLOCK_BYTES);
+ Skein_Put64_LSB_First(hash_val, ctx->X, SKEIN_256_BLOCK_BYTES);
return SKEIN_SUCCESS;
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* 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 *hash_val)
{
/* catch uninitialized context */
- Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
+ Skein_Assert(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
/* tag as the final block */
ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL;
/* zero pad b[] if necessary */
- if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES)
- memset(&ctx->b[ctx->h.bCnt], 0,
- SKEIN_512_BLOCK_BYTES - ctx->h.bCnt);
+ if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES)
+ memset(&ctx->b[ctx->h.b_cnt], 0,
+ SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt);
/* 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.b_cnt);
/* "output" the state bytes */
- Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_512_BLOCK_BYTES);
+ Skein_Put64_LSB_First(hash_val, ctx->X, SKEIN_512_BLOCK_BYTES);
return SKEIN_SUCCESS;
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* finalize the hash computation and output the block, no OUTPUT stage */
-int skein_1024_final_pad(struct skein1024_ctx *ctx, u8 *hashVal)
+int skein_1024_final_pad(struct skein1024_ctx *ctx, u8 *hash_val)
{
/* catch uninitialized context */
- Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL);
+ Skein_Assert(ctx->h.b_cnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL);
/* tag as the final block */
ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL;
/* zero pad b[] if necessary */
- if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES)
- memset(&ctx->b[ctx->h.bCnt], 0,
- SKEIN1024_BLOCK_BYTES - ctx->h.bCnt);
+ if (ctx->h.b_cnt < SKEIN1024_BLOCK_BYTES)
+ memset(&ctx->b[ctx->h.b_cnt], 0,
+ SKEIN1024_BLOCK_BYTES - ctx->h.b_cnt);
/* process the final block */
- skein_1024_process_block(ctx, ctx->b, 1, ctx->h.bCnt);
+ skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt);
/* "output" the state bytes */
- Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN1024_BLOCK_BYTES);
+ Skein_Put64_LSB_First(hash_val, ctx->X, SKEIN1024_BLOCK_BYTES);
return SKEIN_SUCCESS;
}
@@ -763,37 +766,37 @@ int skein_1024_final_pad(struct skein1024_ctx *ctx, u8 *hashVal)
#if SKEIN_TREE_HASH
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* 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 *hash_val)
{
- size_t i, n, byteCnt;
+ size_t i, n, byte_cnt;
u64 X[SKEIN_256_STATE_WORDS];
/* catch uninitialized context */
- Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
+ Skein_Assert(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
/* now output the result */
/* total number of output bytes */
- byteCnt = (ctx->h.hashBitLen + 7) >> 3;
+ byte_cnt = (ctx->h.hash_bit_len + 7) >> 3;
/* run Threefish in "counter mode" to generate output */
/* zero out b[], so it can hold the counter */
memset(ctx->b, 0, sizeof(ctx->b));
/* keep a local copy of counter mode "key" */
memcpy(X, ctx->X, sizeof(X));
- for (i = 0; i*SKEIN_256_BLOCK_BYTES < byteCnt; i++) {
+ for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) {
/* build the counter block */
((u64 *)ctx->b)[0] = Skein_Swap64((u64) i);
Skein_Start_New_Type(ctx, OUT_FINAL);
/* run "counter mode" */
skein_256_process_block(ctx, ctx->b, 1, sizeof(u64));
/* number of output bytes left to go */
- n = byteCnt - i*SKEIN_256_BLOCK_BYTES;
+ n = byte_cnt - i*SKEIN_256_BLOCK_BYTES;
if (n >= SKEIN_256_BLOCK_BYTES)
n = SKEIN_256_BLOCK_BYTES;
/* "output" the ctr mode bytes */
- Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES, ctx->X,
+ Skein_Put64_LSB_First(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->X,
n);
Skein_Show_Final(256, &ctx->h, n,
- hashVal+i*SKEIN_256_BLOCK_BYTES);
+ hash_val+i*SKEIN_256_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx->X, X, sizeof(X));
}
@@ -802,37 +805,37 @@ int skein_256_output(struct skein_256_ctx *ctx, u8 *hashVal)
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* 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 *hash_val)
{
- size_t i, n, byteCnt;
+ size_t i, n, byte_cnt;
u64 X[SKEIN_512_STATE_WORDS];
/* catch uninitialized context */
- Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
+ Skein_Assert(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
/* now output the result */
/* total number of output bytes */
- byteCnt = (ctx->h.hashBitLen + 7) >> 3;
+ byte_cnt = (ctx->h.hash_bit_len + 7) >> 3;
/* run Threefish in "counter mode" to generate output */
/* zero out b[], so it can hold the counter */
memset(ctx->b, 0, sizeof(ctx->b));
/* keep a local copy of counter mode "key" */
memcpy(X, ctx->X, sizeof(X));
- for (i = 0; i*SKEIN_512_BLOCK_BYTES < byteCnt; i++) {
+ for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) {
/* build the counter block */
((u64 *)ctx->b)[0] = Skein_Swap64((u64) i);
Skein_Start_New_Type(ctx, OUT_FINAL);
/* run "counter mode" */
skein_512_process_block(ctx, ctx->b, 1, sizeof(u64));
/* number of output bytes left to go */
- n = byteCnt - i*SKEIN_512_BLOCK_BYTES;
+ n = byte_cnt - i*SKEIN_512_BLOCK_BYTES;
if (n >= SKEIN_512_BLOCK_BYTES)
n = SKEIN_512_BLOCK_BYTES;
/* "output" the ctr mode bytes */
- Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES, ctx->X,
+ Skein_Put64_LSB_First(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->X,
n);
Skein_Show_Final(256, &ctx->h, n,
- hashVal+i*SKEIN_512_BLOCK_BYTES);
+ hash_val+i*SKEIN_512_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx->X, X, sizeof(X));
}
@@ -841,37 +844,37 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 *hashVal)
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* just do the OUTPUT stage */
-int skein_1024_output(struct skein1024_ctx *ctx, u8 *hashVal)
+int skein_1024_output(struct skein1024_ctx *ctx, u8 *hash_val)
{
- size_t i, n, byteCnt;
+ size_t i, n, byte_cnt;
u64 X[SKEIN1024_STATE_WORDS];
/* catch uninitialized context */
- Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL);
+ Skein_Assert(ctx->h.b_cnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL);
/* now output the result */
/* total number of output bytes */
- byteCnt = (ctx->h.hashBitLen + 7) >> 3;
+ byte_cnt = (ctx->h.hash_bit_len + 7) >> 3;
/* run Threefish in "counter mode" to generate output */
/* zero out b[], so it can hold the counter */
memset(ctx->b, 0, sizeof(ctx->b));
/* keep a local copy of counter mode "key" */
memcpy(X, ctx->X, sizeof(X));
- for (i = 0; i*SKEIN1024_BLOCK_BYTES < byteCnt; i++) {
+ for (i = 0; i*SKEIN1024_BLOCK_BYTES < byte_cnt; i++) {
/* build the counter block */
((u64 *)ctx->b)[0] = Skein_Swap64((u64) i);
Skein_Start_New_Type(ctx, OUT_FINAL);
/* run "counter mode" */
skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64));
/* number of output bytes left to go */
- n = byteCnt - i*SKEIN1024_BLOCK_BYTES;
+ n = byte_cnt - i*SKEIN1024_BLOCK_BYTES;
if (n >= SKEIN1024_BLOCK_BYTES)
n = SKEIN1024_BLOCK_BYTES;
/* "output" the ctr mode bytes */
- Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES, ctx->X,
+ Skein_Put64_LSB_First(hash_val+i*SKEIN1024_BLOCK_BYTES, ctx->X,
n);
Skein_Show_Final(256, &ctx->h, n,
- hashVal+i*SKEIN1024_BLOCK_BYTES);
+ hash_val+i*SKEIN1024_BLOCK_BYTES);
/* restore the counter mode key for next time */
memcpy(ctx->X, X, sizeof(X));
}