From dbbf324199b1aa27be910e00e1aad5e991d70e98 Mon Sep 17 00:00:00 2001 From: bg Date: Wed, 10 Jun 2009 21:10:43 +0000 Subject: [PATCH] =?utf8?q?speed=20upgrade=20for=20gr=C3=B8stl?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- groestl_small.c | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/groestl_small.c b/groestl_small.c index 1babf9a..caf368b 100644 --- a/groestl_small.c +++ b/groestl_small.c @@ -40,7 +40,7 @@ #if DEBUG #include "cli.h" - void dump_m(uint8_t* m){ + void dump_m(const uint8_t* m){ uint8_t i,j; for(i=0; i<8; ++i){ cli_putstr_P(PSTR("\r\n")); @@ -70,7 +70,7 @@ void groestl_small_rounds(uint8_t *m, uint8_t q){ uint8_t tmp[8]; for(r=0; rh, 0, 8*8); - ctx->h[8*7-1] = 1; + ctx->h[8*8-2] = 1; ctx->counter = 0; } void groestl_small_nextBlock(groestl_small_ctx_t* ctx, const void* block){ uint8_t tmp1[64], tmp2[65]; - uint8_t i,j; - for(i=0; i<8; ++i){ +/* for(i=0; i<8; ++i){ for(j=0; j<8; ++j){ tmp1[j*8+i] = ((uint8_t*)block)[i*8+j]; } } +*/ + memcpy(tmp1, block, 64); memcpy(tmp2, tmp1, 64); memxor(tmp1, ctx->h, 64); groestl_small_rounds(tmp1, 0); @@ -163,24 +163,23 @@ void groestl_small_lastBlock(groestl_small_ctx_t* ctx, const void* block, uint16 memset(buffer, 0, 64-4); } ctx->counter++; - buffer[64-1] = (uint8_t)(ctx->counter); - buffer[64-2] = (uint8_t)((ctx->counter)>>8); - buffer[64-3] = (uint8_t)((ctx->counter)>>16); - buffer[64-4] = (uint8_t)((ctx->counter)>>24); + buffer[64-1] = (uint8_t)(ctx->counter); + buffer[64-2] = (uint8_t)((ctx->counter)>>8); + buffer[64-3] = (uint8_t)((ctx->counter)>>16); + buffer[64-4] = (uint8_t)((ctx->counter)>>24); groestl_small_nextBlock(ctx, buffer); } void groestl_small_ctx2hash(void* dest, const groestl_small_ctx_t* ctx, uint16_t outlength_b){ uint8_t tmp[64]; - uint8_t i,a,b; memcpy(tmp, ctx->h, 64); groestl_small_rounds(tmp, 0); memxor(tmp, ctx->h, 64); - for(i=0; i