X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=groestl_small.c;h=caf368b1c6f67bbbac8a7bd3b9e5491171023ca9;hb=dbbf324199b1aa27be910e00e1aad5e991d70e98;hp=1babf9a6a688eec13755b4aa0bd574a39e728b47;hpb=402f8b98e8bd4ca12bbac8fe6ccd07e594015a63;p=avr-crypto-lib.git 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