alistair23-linux/drivers/staging/skein/skein_base.c

865 lines
29 KiB
C
Raw Normal View History

staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
/***********************************************************************
**
** Implementation of the Skein hash function.
**
** Source code author: Doug Whiting, 2008.
**
** This algorithm and source code is released to the public domain.
**
************************************************************************/
#include <linux/string.h> /* get the memcpy/memset functions */
#include <linux/export.h>
#include "skein_base.h" /* get the Skein API definitions */
#include "skein_iv.h" /* get precomputed IVs */
#include "skein_block.h"
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
/*****************************************************************/
/* 256-bit Skein */
/*****************************************************************/
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* init the context for a straight hashing operation */
int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len)
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
{
union {
u8 b[SKEIN_256_STATE_BYTES];
u64 w[SKEIN_256_STATE_WORDS];
} cfg; /* config block */
skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */
switch (hash_bit_len) { /* use pre-computed values, where available */
case 256:
memcpy(ctx->x, SKEIN_256_IV_256, sizeof(ctx->x));
break;
case 224:
memcpy(ctx->x, SKEIN_256_IV_224, sizeof(ctx->x));
break;
case 160:
memcpy(ctx->x, SKEIN_256_IV_160, sizeof(ctx->x));
break;
case 128:
memcpy(ctx->x, SKEIN_256_IV_128, sizeof(ctx->x));
break;
default:
/* here if there is no precomputed IV value available */
/*
* build/process the config block, type == CONFIG (could be
* precomputed)
*/
/* set tweaks: T0=0; T1=CFG | FINAL */
skein_start_new_type(ctx, CFG_FINAL);
/* set the schema, version */
cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER);
/* hash result length in bits */
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]));
/* compute the initial chaining values from config block */
/* zero the chaining variables */
memset(ctx->x, 0, sizeof(ctx->x));
skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
break;
}
/* 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 */
return SKEIN_SUCCESS;
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* init the context for a MAC and/or tree hash operation */
/* [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)
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
{
union {
u8 b[SKEIN_256_STATE_BYTES];
u64 w[SKEIN_256_STATE_WORDS];
} cfg; /* config block */
skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL);
/* compute the initial chaining values ctx->x[], based on 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.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, key_bytes);
/* put result into cfg.b[] */
skein_256_final_pad(ctx, cfg.b);
/* copy over into ctx->x[] */
memcpy(ctx->x, cfg.b, sizeof(cfg.b));
}
/*
* build/process the config block, type == CONFIG (could be
* precomputed for each key)
*/
/* output hash bit count */
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(hash_bit_len);
/* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
cfg.w[2] = skein_swap64(tree_info);
/* compute the initial chaining values from config block */
skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
/* The chaining vars ctx->x are now initialized */
/* Set up to process the data message portion of the hash (default) */
skein_start_new_type(ctx, MSG);
return SKEIN_SUCCESS;
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* process the input bytes */
int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg,
size_t msg_byte_cnt)
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
{
size_t n;
/* catch uninitialized context */
skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
/* process full blocks, if any */
if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_256_BLOCK_BYTES) {
/* finish up any buffered message data */
if (ctx->h.b_cnt) {
/* # bytes free in buffer b[] */
n = SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt;
if (n) {
/* check on our logic here */
skein_assert(n < msg_byte_cnt);
memcpy(&ctx->b[ctx->h.b_cnt], msg, n);
msg_byte_cnt -= n;
msg += n;
ctx->h.b_cnt += n;
}
skein_assert(ctx->h.b_cnt == SKEIN_256_BLOCK_BYTES);
skein_256_process_block(ctx, ctx->b, 1,
SKEIN_256_BLOCK_BYTES);
ctx->h.b_cnt = 0;
}
/*
* now process any remaining full blocks, directly from input
* message data
*/
if (msg_byte_cnt > SKEIN_256_BLOCK_BYTES) {
/* number of full blocks to process */
n = (msg_byte_cnt-1) / SKEIN_256_BLOCK_BYTES;
skein_256_process_block(ctx, msg, n,
SKEIN_256_BLOCK_BYTES);
msg_byte_cnt -= n * SKEIN_256_BLOCK_BYTES;
msg += n * SKEIN_256_BLOCK_BYTES;
}
skein_assert(ctx->h.b_cnt == 0);
}
/* copy any remaining source message data bytes into b[] */
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;
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* finalize the hash computation and output the result */
int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val)
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
{
size_t i, n, byte_cnt;
u64 x[SKEIN_256_STATE_WORDS];
/* catch uninitialized context */
skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
/* tag as the final block */
ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL;
/* zero pad b[] if necessary */
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.b_cnt);
/* now output the result */
/* total number of output bytes */
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 < 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 = 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(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x,
n);
/* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x));
}
return SKEIN_SUCCESS;
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
}
/*****************************************************************/
/* 512-bit Skein */
/*****************************************************************/
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* init the context for a straight hashing operation */
int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len)
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
{
union {
u8 b[SKEIN_512_STATE_BYTES];
u64 w[SKEIN_512_STATE_WORDS];
} cfg; /* config block */
skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */
switch (hash_bit_len) { /* use pre-computed values, where available */
case 512:
memcpy(ctx->x, SKEIN_512_IV_512, sizeof(ctx->x));
break;
case 384:
memcpy(ctx->x, SKEIN_512_IV_384, sizeof(ctx->x));
break;
case 256:
memcpy(ctx->x, SKEIN_512_IV_256, sizeof(ctx->x));
break;
case 224:
memcpy(ctx->x, SKEIN_512_IV_224, sizeof(ctx->x));
break;
default:
/* here if there is no precomputed IV value available */
/*
* build/process the config block, type == CONFIG (could be
* precomputed)
*/
/* set tweaks: T0=0; T1=CFG | FINAL */
skein_start_new_type(ctx, CFG_FINAL);
/* set the schema, version */
cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER);
/* hash result length in bits */
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]));
/* compute the initial chaining values from config block */
/* zero the chaining variables */
memset(ctx->x, 0, sizeof(ctx->x));
skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
break;
}
/*
* The chaining vars ctx->x are now initialized for the given
* 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 */
return SKEIN_SUCCESS;
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* init the context for a MAC and/or tree hash operation */
/* [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)
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
{
union {
u8 b[SKEIN_512_STATE_BYTES];
u64 w[SKEIN_512_STATE_WORDS];
} cfg; /* config block */
skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL);
/* compute the initial chaining values ctx->x[], based on 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.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, key_bytes);
/* put result into cfg.b[] */
skein_512_final_pad(ctx, cfg.b);
/* copy over into ctx->x[] */
memcpy(ctx->x, cfg.b, sizeof(cfg.b));
}
/*
* build/process the config block, type == CONFIG (could be
* precomputed for each key)
*/
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(hash_bit_len);
/* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
cfg.w[2] = skein_swap64(tree_info);
/* compute the initial chaining values from config block */
skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
/* The chaining vars ctx->x are now initialized */
/* Set up to process the data message portion of the hash (default) */
skein_start_new_type(ctx, MSG);
return SKEIN_SUCCESS;
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* process the input bytes */
int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg,
size_t msg_byte_cnt)
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
{
size_t n;
/* catch uninitialized context */
skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
/* process full blocks, if any */
if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_512_BLOCK_BYTES) {
/* finish up any buffered message data */
if (ctx->h.b_cnt) {
/* # bytes free in buffer b[] */
n = SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt;
if (n) {
/* check on our logic here */
skein_assert(n < msg_byte_cnt);
memcpy(&ctx->b[ctx->h.b_cnt], msg, n);
msg_byte_cnt -= n;
msg += n;
ctx->h.b_cnt += n;
}
skein_assert(ctx->h.b_cnt == SKEIN_512_BLOCK_BYTES);
skein_512_process_block(ctx, ctx->b, 1,
SKEIN_512_BLOCK_BYTES);
ctx->h.b_cnt = 0;
}
/*
* now process any remaining full blocks, directly from input
* message data
*/
if (msg_byte_cnt > SKEIN_512_BLOCK_BYTES) {
/* number of full blocks to process */
n = (msg_byte_cnt-1) / SKEIN_512_BLOCK_BYTES;
skein_512_process_block(ctx, msg, n,
SKEIN_512_BLOCK_BYTES);
msg_byte_cnt -= n * SKEIN_512_BLOCK_BYTES;
msg += n * SKEIN_512_BLOCK_BYTES;
}
skein_assert(ctx->h.b_cnt == 0);
}
/* copy any remaining source message data bytes into b[] */
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;
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* finalize the hash computation and output the result */
int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val)
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
{
size_t i, n, byte_cnt;
u64 x[SKEIN_512_STATE_WORDS];
/* catch uninitialized context */
skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
/* tag as the final block */
ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL;
/* zero pad b[] if necessary */
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.b_cnt);
/* now output the result */
/* total number of output bytes */
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 < 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 = 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(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x,
n);
/* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x));
}
return SKEIN_SUCCESS;
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
}
/*****************************************************************/
/* 1024-bit Skein */
/*****************************************************************/
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* init the context for a straight hashing operation */
int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len)
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
{
union {
u8 b[SKEIN_1024_STATE_BYTES];
u64 w[SKEIN_1024_STATE_WORDS];
} cfg; /* config block */
skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */
switch (hash_bit_len) { /* use pre-computed values, where available */
case 512:
memcpy(ctx->x, SKEIN_1024_IV_512, sizeof(ctx->x));
break;
case 384:
memcpy(ctx->x, SKEIN_1024_IV_384, sizeof(ctx->x));
break;
case 1024:
memcpy(ctx->x, SKEIN_1024_IV_1024, sizeof(ctx->x));
break;
default:
/* here if there is no precomputed IV value available */
/*
* build/process the config block, type == CONFIG
* (could be precomputed)
*/
/* set tweaks: T0=0; T1=CFG | FINAL */
skein_start_new_type(ctx, CFG_FINAL);
/* set the schema, version */
cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER);
/* hash result length in bits */
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]));
/* compute the initial chaining values from config block */
/* zero the chaining variables */
memset(ctx->x, 0, sizeof(ctx->x));
skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
break;
}
/* 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 */
return SKEIN_SUCCESS;
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* init the context for a MAC and/or tree hash operation */
/* [identical to skein_1024_init() when key_bytes == 0 && \
* tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */
int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len,
u64 tree_info, const u8 *key, size_t key_bytes)
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
{
union {
u8 b[SKEIN_1024_STATE_BYTES];
u64 w[SKEIN_1024_STATE_WORDS];
} cfg; /* config block */
skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL);
/* compute the initial chaining values ctx->x[], based on 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.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, key_bytes);
/* put result into cfg.b[] */
skein_1024_final_pad(ctx, cfg.b);
/* copy over into ctx->x[] */
memcpy(ctx->x, cfg.b, sizeof(cfg.b));
}
/*
* build/process the config block, type == CONFIG (could be
* precomputed for each key)
*/
/* output hash bit count */
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(hash_bit_len);
/* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */
cfg.w[2] = skein_swap64(tree_info);
/* compute the initial chaining values from config block */
skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
/* The chaining vars ctx->x are now initialized */
/* Set up to process the data message portion of the hash (default) */
skein_start_new_type(ctx, MSG);
return SKEIN_SUCCESS;
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* process the input bytes */
int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg,
size_t msg_byte_cnt)
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
{
size_t n;
/* catch uninitialized context */
skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL);
/* process full blocks, if any */
if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_1024_BLOCK_BYTES) {
/* finish up any buffered message data */
if (ctx->h.b_cnt) {
/* # bytes free in buffer b[] */
n = SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt;
if (n) {
/* check on our logic here */
skein_assert(n < msg_byte_cnt);
memcpy(&ctx->b[ctx->h.b_cnt], msg, n);
msg_byte_cnt -= n;
msg += n;
ctx->h.b_cnt += n;
}
skein_assert(ctx->h.b_cnt == SKEIN_1024_BLOCK_BYTES);
skein_1024_process_block(ctx, ctx->b, 1,
SKEIN_1024_BLOCK_BYTES);
ctx->h.b_cnt = 0;
}
/*
* now process any remaining full blocks, directly from input
* message data
*/
if (msg_byte_cnt > SKEIN_1024_BLOCK_BYTES) {
/* number of full blocks to process */
n = (msg_byte_cnt-1) / SKEIN_1024_BLOCK_BYTES;
skein_1024_process_block(ctx, msg, n,
SKEIN_1024_BLOCK_BYTES);
msg_byte_cnt -= n * SKEIN_1024_BLOCK_BYTES;
msg += n * SKEIN_1024_BLOCK_BYTES;
}
skein_assert(ctx->h.b_cnt == 0);
}
/* copy any remaining source message data bytes into b[] */
if (msg_byte_cnt) {
skein_assert(msg_byte_cnt + ctx->h.b_cnt <=
SKEIN_1024_BLOCK_BYTES);
memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt);
ctx->h.b_cnt += msg_byte_cnt;
}
return SKEIN_SUCCESS;
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* finalize the hash computation and output the result */
int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val)
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
{
size_t i, n, byte_cnt;
u64 x[SKEIN_1024_STATE_WORDS];
/* catch uninitialized context */
skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL);
/* tag as the final block */
ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL;
/* zero pad b[] if necessary */
if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES)
memset(&ctx->b[ctx->h.b_cnt], 0,
SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt);
/* process the final block */
skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt);
/* now output the result */
/* total number of output bytes */
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_1024_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 = byte_cnt - i*SKEIN_1024_BLOCK_BYTES;
if (n >= SKEIN_1024_BLOCK_BYTES)
n = SKEIN_1024_BLOCK_BYTES;
/* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x,
n);
/* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x));
}
return SKEIN_SUCCESS;
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
}
/**************** Functions to support MAC/tree hashing ***************/
/* (this code is identical for Optimized and Reference versions) */
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* finalize the hash computation and output the block, no OUTPUT stage */
int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val)
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
{
/* catch uninitialized context */
skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
/* tag as the final block */
ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL;
/* zero pad b[] if necessary */
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.b_cnt);
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
/* "output" the state bytes */
skein_put64_lsb_first(hash_val, ctx->x, SKEIN_256_BLOCK_BYTES);
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
return SKEIN_SUCCESS;
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* finalize the hash computation and output the block, no OUTPUT stage */
int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val)
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
{
/* catch uninitialized context */
skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
/* tag as the final block */
ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL;
/* zero pad b[] if necessary */
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.b_cnt);
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
/* "output" the state bytes */
skein_put64_lsb_first(hash_val, ctx->x, SKEIN_512_BLOCK_BYTES);
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
return SKEIN_SUCCESS;
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* finalize the hash computation and output the block, no OUTPUT stage */
int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val)
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
{
/* catch uninitialized context */
skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL);
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
/* tag as the final block */
ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL;
/* zero pad b[] if necessary */
if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES)
memset(&ctx->b[ctx->h.b_cnt], 0,
SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt);
/* process the final block */
skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt);
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
/* "output" the state bytes */
skein_put64_lsb_first(hash_val, ctx->x, SKEIN_1024_BLOCK_BYTES);
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
return SKEIN_SUCCESS;
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
}
#if SKEIN_TREE_HASH
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* just do the OUTPUT stage */
int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val)
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
{
size_t i, n, byte_cnt;
u64 x[SKEIN_256_STATE_WORDS];
/* catch uninitialized context */
skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
/* now output the result */
/* total number of output bytes */
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 < 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 = 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(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x,
n);
/* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x));
}
return SKEIN_SUCCESS;
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* just do the OUTPUT stage */
int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val)
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
{
size_t i, n, byte_cnt;
u64 x[SKEIN_512_STATE_WORDS];
/* catch uninitialized context */
skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
/* now output the result */
/* total number of output bytes */
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 < 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 = 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(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x,
n);
/* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x));
}
return SKEIN_SUCCESS;
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* just do the OUTPUT stage */
int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val)
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
{
size_t i, n, byte_cnt;
u64 x[SKEIN_1024_STATE_WORDS];
/* catch uninitialized context */
skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL);
/* now output the result */
/* total number of output bytes */
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_1024_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 = byte_cnt - i*SKEIN_1024_BLOCK_BYTES;
if (n >= SKEIN_1024_BLOCK_BYTES)
n = SKEIN_1024_BLOCK_BYTES;
/* "output" the ctr mode bytes */
skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x,
n);
/* restore the counter mode key for next time */
memcpy(ctx->x, x, sizeof(x));
}
return SKEIN_SUCCESS;
staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 19:48:58 -06:00
}
#endif