X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=twister%2Ftwister-large.c;h=905cd59001e8d8722e0799f5a82ca5cde94e35c1;hb=e542ff92d053ecf40b42364a44bc887431cecae2;hp=1775488ef3c128e30bb932363af4bfe892e6400a;hpb=4f50c75ee5a6cc88bf7ea71957ed509e298e6c25;p=avr-crypto-lib.git diff --git a/twister/twister-large.c b/twister/twister-large.c index 1775488..905cd59 100644 --- a/twister/twister-large.c +++ b/twister/twister-large.c @@ -26,7 +26,7 @@ /*********************************************************************/ static -void checksum_update(twister_large_ctx_t* ctx, uint8_t col){ +void checksum_update(twister_large_ctx_t *ctx, uint8_t col){ uint8_t i, col2; uint8_t carry = 0; int sum = 0; @@ -46,7 +46,7 @@ void checksum_update(twister_large_ctx_t* ctx, uint8_t col){ /*********************************************************************/ -void twister_large_init(twister_large_ctx_t* ctx, uint16_t hashsize_b){ +void twister_large_init(twister_large_ctx_t *ctx, uint16_t hashsize_b){ memset(ctx->state.s, 0, 64); memset(ctx->checksum, 0, 64); ctx->state.counter=0xffffffffffffffffLL; @@ -57,7 +57,7 @@ void twister_large_init(twister_large_ctx_t* ctx, uint16_t hashsize_b){ /*********************************************************************/ -void twister_large_nextBlock(twister_large_ctx_t* ctx, const void* msg){ +void twister_large_nextBlock(twister_large_ctx_t *ctx, const void *msg){ uint8_t tmp[8][8]; /* 1st maxi round */ @@ -108,14 +108,18 @@ void twister_large_nextBlock(twister_large_ctx_t* ctx, const void* msg){ /*********************************************************************/ -void twister_inject_chksum(twister_large_ctx_t* ctx, uint8_t col){ - *((uint64_t*)(&ctx->state.s[7][0])) ^= *((uint64_t*)(&ctx->checksum[col][0])); +void twister_inject_chksum(twister_large_ctx_t *ctx, uint8_t col){ + uint8_t i=7; + do{ + ctx->state.s[7][i] ^= ctx->checksum[col][i]; + + }while(i--); twister_blank_round(&ctx->state); } /*********************************************************************/ -void twister_large_lastBlock(twister_large_ctx_t* ctx, const void* msg, uint16_t length_b){ +void twister_large_lastBlock(twister_large_ctx_t *ctx, const void *msg, uint16_t length_b){ uint8_t tmp[64]; while(length_b>=512){ twister_large_nextBlock(ctx, msg); @@ -151,38 +155,38 @@ void twister_large_lastBlock(twister_large_ctx_t* ctx, const void* msg, uint16_t /*********************************************************************/ -void twister_large_ctx2hash(void* dest, twister_large_ctx_t* ctx, uint16_t hashsize_b){ +void twister_large_ctx2hash(void *dest, twister_large_ctx_t *ctx, uint16_t hashsize_b){ twister_ctx2hash(dest, &(ctx->state), hashsize_b); } /*********************************************************************/ /*********************************************************************/ -void twister384_init(twister384_ctx_t* ctx){ +void twister384_init(twister384_ctx_t *ctx){ twister_large_init(ctx, 384); } /*********************************************************************/ -void twister384_nextBlock(twister384_ctx_t* ctx, const void* msg){ +void twister384_nextBlock(twister384_ctx_t *ctx, const void *msg){ twister_large_nextBlock(ctx, msg); } /*********************************************************************/ -void twister384_lastBlock(twister384_ctx_t* ctx, const void* msg, uint16_t length_b){ +void twister384_lastBlock(twister384_ctx_t *ctx, const void *msg, uint16_t length_b){ twister_large_lastBlock(ctx, msg, length_b); } /*********************************************************************/ -void twister384_ctx2hash(void* dest, twister384_ctx_t* ctx){ +void twister384_ctx2hash(void *dest, twister384_ctx_t *ctx){ twister_large_ctx2hash(dest, ctx, 384); } /*********************************************************************/ -void twister384(void* dest, const void* msg, uint32_t msg_length_b){ +void twister384(void *dest, const void *msg, uint32_t msg_length_b){ twister_large_ctx_t ctx; twister_large_init(&ctx, 384); while(msg_length_b >=512){ @@ -198,31 +202,31 @@ void twister384(void* dest, const void* msg, uint32_t msg_length_b){ /*********************************************************************/ -void twister512_init(twister512_ctx_t* ctx){ +void twister512_init(twister512_ctx_t *ctx){ twister_large_init(ctx, 512); } /*********************************************************************/ -void twister512_nextBlock(twister512_ctx_t* ctx, const void* msg){ +void twister512_nextBlock(twister512_ctx_t *ctx, const void *msg){ twister_large_nextBlock(ctx, msg); } /*********************************************************************/ -void twister512_lastBlock(twister512_ctx_t* ctx, const void* msg, uint16_t length_b){ +void twister512_lastBlock(twister512_ctx_t *ctx, const void *msg, uint16_t length_b){ twister_large_lastBlock(ctx, msg, length_b); } /*********************************************************************/ -void twister512_ctx2hash(void* dest, twister512_ctx_t* ctx){ +void twister512_ctx2hash(void *dest, twister512_ctx_t *ctx){ twister_large_ctx2hash(dest, ctx, 512); } /*********************************************************************/ -void twister512(void* dest, const void* msg, uint32_t msg_length_b){ +void twister512(void *dest, const void *msg, uint32_t msg_length_b){ twister_large_ctx_t ctx; twister_large_init(&ctx, 512); while(msg_length_b >=512){