Commit 60eb8175 authored by Jason Cooper's avatar Jason Cooper Committed by Greg Kroah-Hartman

staging: crypto: skein: cleanup >80 character lines

Signed-off-by: default avatarJason Cooper <jason@lakedaemon.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 06a620f0
This diff is collapsed.
......@@ -72,7 +72,9 @@ struct threefish_key {
* @param tweak
* Pointer to the two tweak words (word has 64 bits).
*/
void threefishSetKey(struct threefish_key *keyCtx, enum threefish_size stateSize, u64 *keyData, u64 *tweak);
void threefishSetKey(struct threefish_key *keyCtx,
enum threefish_size stateSize,
u64 *keyData, u64 *tweak);
/**
* Encrypt Threefisch block (bytes).
......@@ -108,7 +110,8 @@ void threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out);
* @param out
* Pointer to cipher buffer.
*/
void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in, u64 *out);
void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in,
u64 *out);
/**
* Decrypt Threefisch block (bytes).
......@@ -144,14 +147,17 @@ void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out);
* @param out
* Pointer to plaintext buffer.
*/
void threefishDecryptBlockWords(struct threefish_key *keyCtx, u64 *in, u64 *out);
void threefishDecryptBlockWords(struct threefish_key *keyCtx, u64 *in,
u64 *out);
void threefishEncrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output);
void threefishEncrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output);
void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output);
void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input,
u64 *output);
void threefishDecrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output);
void threefishDecrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output);
void threefishDecrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output);
void threefishDecrypt1024(struct threefish_key *keyCtx, u64 *input,
u64 *output);
/**
* @}
*/
......
This diff is collapsed.
......@@ -46,9 +46,9 @@ int skeinInit(struct skein_ctx *ctx, size_t hashBitLen)
Skein_Assert(ctx, SKEIN_FAIL);
/*
* The following two lines rely of the fact that the real Skein contexts are
* a union in out context and thus have tha maximum memory available.
* The beauty of C :-) .
* The following two lines rely of the fact that the real Skein
* contexts are a union in out context and thus have tha maximum
* memory available. The beauty of C :-) .
*/
X = ctx->m.s256.X;
Xlen = ctx->skeinSize/8;
......@@ -72,7 +72,10 @@ int skeinInit(struct skein_ctx *ctx, size_t hashBitLen)
}
if (ret == SKEIN_SUCCESS) {
/* Save chaining variables for this combination of size and hashBitLen */
/*
* Save chaining variables for this combination of size and
* hashBitLen
*/
memcpy(ctx->XSave, X, Xlen);
}
return ret;
......@@ -113,7 +116,10 @@ int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen,
break;
}
if (ret == SKEIN_SUCCESS) {
/* Save chaining variables for this combination of key, keyLen, hashBitLen */
/*
* Save chaining variables for this combination of key,
* keyLen, hashBitLen
*/
memcpy(ctx->XSave, X, Xlen);
}
return ret;
......@@ -125,9 +131,9 @@ void skeinReset(struct skein_ctx *ctx)
u64 *X = NULL;
/*
* The following two lines rely of the fact that the real Skein contexts are
* a union in out context and thus have tha maximum memory available.
* The beautiy of C :-) .
* The following two lines rely of the fact that the real Skein
* contexts are a union in out context and thus have tha maximum
* memory available. The beautiy of C :-) .
*/
X = ctx->m.s256.X;
Xlen = ctx->skeinSize/8;
......@@ -146,13 +152,16 @@ int skeinUpdate(struct skein_ctx *ctx, const u8 *msg,
switch (ctx->skeinSize) {
case Skein256:
ret = Skein_256_Update(&ctx->m.s256, (const u8 *)msg, msgByteCnt);
ret = Skein_256_Update(&ctx->m.s256, (const u8 *)msg,
msgByteCnt);
break;
case Skein512:
ret = Skein_512_Update(&ctx->m.s512, (const u8 *)msg, msgByteCnt);
ret = Skein_512_Update(&ctx->m.s512, (const u8 *)msg,
msgByteCnt);
break;
case Skein1024:
ret = Skein1024_Update(&ctx->m.s1024, (const u8 *)msg, msgByteCnt);
ret = Skein1024_Update(&ctx->m.s1024, (const u8 *)msg,
msgByteCnt);
break;
}
return ret;
......@@ -164,15 +173,19 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg,
{
/*
* I've used the bit pad implementation from skein_test.c (see NIST CD)
* and modified it to use the convenience functions and added some pointer
* arithmetic.
* and modified it to use the convenience functions and added some
* pointer arithmetic.
*/
size_t length;
u8 mask;
u8 *up;
/* only the final Update() call is allowed do partial bytes, else assert an error */
Skein_Assert((ctx->m.h.T[1] & SKEIN_T1_FLAG_BIT_PAD) == 0 || msgBitCnt == 0, SKEIN_FAIL);
/*
* only the final Update() call is allowed do partial bytes, else
* assert an error
*/
Skein_Assert((ctx->m.h.T[1] & SKEIN_T1_FLAG_BIT_PAD) == 0 ||
msgBitCnt == 0, SKEIN_FAIL);
/* if number of bits is a multiple of bytes - that's easy */
if ((msgBitCnt & 0x7) == 0) {
......@@ -188,13 +201,18 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg,
*/
up = (u8 *)ctx->m.s256.X + ctx->skeinSize / 8;
Skein_Set_Bit_Pad_Flag(ctx->m.h); /* set tweak flag for the skeinFinal call */
/* set tweak flag for the skeinFinal call */
Skein_Set_Bit_Pad_Flag(ctx->m.h);
/* now "pad" the final partial byte the way NIST likes */
length = ctx->m.h.bCnt; /* get the bCnt value (same location for all block sizes) */
Skein_assert(length != 0); /* internal sanity check: there IS a partial byte in the buffer! */
mask = (u8) (1u << (7 - (msgBitCnt & 7))); /* partial byte bit mask */
up[length-1] = (u8)((up[length-1] & (0-mask))|mask); /* apply bit padding on final byte (in the buffer) */
/* get the bCnt value (same location for all block sizes) */
length = ctx->m.h.bCnt;
/* internal sanity check: there IS a partial byte in the buffer! */
Skein_assert(length != 0);
/* partial byte bit mask */
mask = (u8) (1u << (7 - (msgBitCnt & 7)));
/* apply bit padding on final byte (in the buffer) */
up[length-1] = (u8)((up[length-1] & (0-mask))|mask);
return SKEIN_SUCCESS;
}
......
......@@ -11,10 +11,10 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr,
struct threefish_key key;
u64 tweak[2];
int i;
u64 w[SKEIN_256_STATE_WORDS]; /* local copy of input block */
u64 w[SKEIN_256_STATE_WORDS]; /* local copy of input block */
u64 words[3];
Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */
Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */
tweak[0] = ctx->h.T[0];
tweak[1] = ctx->h.T[1];
......@@ -36,13 +36,14 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr,
threefishSetKey(&key, Threefish256, ctx->X, tweak);
Skein_Get64_LSB_First(w, blkPtr, SKEIN_256_STATE_WORDS); /* get input block in little-endian format */
/* get input block in little-endian format */
Skein_Get64_LSB_First(w, blkPtr, SKEIN_256_STATE_WORDS);
threefishEncryptBlockWords(&key, w, ctx->X);
blkPtr += SKEIN_256_BLOCK_BYTES;
/* do the final "feedforward" xor, update context chaining vars */
/* do the final "feedforward" xor, update ctx chaining vars */
ctx->X[0] = ctx->X[0] ^ w[0];
ctx->X[1] = ctx->X[1] ^ w[1];
ctx->X[2] = ctx->X[2] ^ w[2];
......@@ -62,9 +63,9 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr,
u64 tweak[2];
int i;
u64 words[3];
u64 w[SKEIN_512_STATE_WORDS]; /* local copy of input block */
u64 w[SKEIN_512_STATE_WORDS]; /* local copy of input block */
Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */
Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */
tweak[0] = ctx->h.T[0];
tweak[1] = ctx->h.T[1];
......@@ -86,13 +87,14 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr,
threefishSetKey(&key, Threefish512, ctx->X, tweak);
Skein_Get64_LSB_First(w, blkPtr, SKEIN_512_STATE_WORDS); /* get input block in little-endian format */
/* get input block in little-endian format */
Skein_Get64_LSB_First(w, blkPtr, SKEIN_512_STATE_WORDS);
threefishEncryptBlockWords(&key, w, ctx->X);
blkPtr += SKEIN_512_BLOCK_BYTES;
/* do the final "feedforward" xor, update context chaining vars */
/* do the final "feedforward" xor, update ctx chaining vars */
ctx->X[0] = ctx->X[0] ^ w[0];
ctx->X[1] = ctx->X[1] ^ w[1];
ctx->X[2] = ctx->X[2] ^ w[2];
......@@ -116,9 +118,9 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr,
u64 tweak[2];
int i;
u64 words[3];
u64 w[SKEIN1024_STATE_WORDS]; /* local copy of input block */
u64 w[SKEIN1024_STATE_WORDS]; /* local copy of input block */
Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */
Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */
tweak[0] = ctx->h.T[0];
tweak[1] = ctx->h.T[1];
......@@ -140,13 +142,14 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr,
threefishSetKey(&key, Threefish1024, ctx->X, tweak);
Skein_Get64_LSB_First(w, blkPtr, SKEIN1024_STATE_WORDS); /* get input block in little-endian format */
/* get input block in little-endian format */
Skein_Get64_LSB_First(w, blkPtr, SKEIN1024_STATE_WORDS);
threefishEncryptBlockWords(&key, w, ctx->X);
blkPtr += SKEIN1024_BLOCK_BYTES;
/* do the final "feedforward" xor, update context chaining vars */
/* do the final "feedforward" xor, update ctx chaining vars */
ctx->X[0] = ctx->X[0] ^ w[0];
ctx->X[1] = ctx->X[1] ^ w[1];
ctx->X[2] = ctx->X[2] ^ w[2];
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -3,8 +3,9 @@
#include <linux/string.h>
#include <threefishApi.h>
void threefishSetKey(struct threefish_key *keyCtx, enum threefish_size stateSize,
u64 *keyData, u64 *tweak)
void threefishSetKey(struct threefish_key *keyCtx,
enum threefish_size stateSize,
u64 *keyData, u64 *tweak)
{
int keyWords = stateSize / 64;
int i;
......@@ -28,9 +29,9 @@ void threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in,
u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/
u64 cipher[SKEIN_MAX_STATE_WORDS];
Skein_Get64_LSB_First(plain, in, keyCtx->stateSize / 64); /* bytes to words */
Skein_Get64_LSB_First(plain, in, keyCtx->stateSize / 64);
threefishEncryptBlockWords(keyCtx, plain, cipher);
Skein_Put64_LSB_First(out, cipher, keyCtx->stateSize / 8); /* words to bytes */
Skein_Put64_LSB_First(out, cipher, keyCtx->stateSize / 8);
}
void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in,
......@@ -55,9 +56,9 @@ void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in,
u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/
u64 cipher[SKEIN_MAX_STATE_WORDS];
Skein_Get64_LSB_First(cipher, in, keyCtx->stateSize / 64); /* bytes to words */
Skein_Get64_LSB_First(cipher, in, keyCtx->stateSize / 64);
threefishDecryptBlockWords(keyCtx, cipher, plain);
Skein_Put64_LSB_First(out, plain, keyCtx->stateSize / 8); /* words to bytes */
Skein_Put64_LSB_First(out, plain, keyCtx->stateSize / 8);
}
void threefishDecryptBlockWords(struct threefish_key *keyCtx, u64 *in,
......
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