X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=twister.c;h=494a7a11f72cfd44bc7efad4d777ecf0bcf9cc50;hb=8ef8dfdc7299ac1c30869ec6ad4d11276f0cf5db;hp=9eae239609c390d68a70e2b98ddab150f1230acc;hpb=a679ca276cb4d603f337dc5cb1c9ab569e91c695;p=avr-crypto-lib.git diff --git a/twister.c b/twister.c index 9eae239..494a7a1 100644 --- a/twister.c +++ b/twister.c @@ -28,21 +28,17 @@ #ifndef TWISTER_MUL_TABLE # include "gf256mul.h" #endif - -static -void shiftrow(void* row, uint8_t shift){ - *((uint64_t*)row) = *((uint64_t*)row)>>(8*shift) | *((uint64_t*)row)<<(64-8*shift); -} #define MDS(a,b) pgm_read_byte(&(twister_mds[(a)][(b)])) #ifdef TWISTER_MUL_TABLE -# define MULT(a,b) pgm_read_byte(&(twister_multab[a][b])) +# define MULT(a,b) pgm_read_byte(&(twister_multab[(a)][(b)])) #else # define MULT(a,b) gf256mul((a),(b), 0x4D) #endif + void twister_blank_round(twister_state_t* ctx){ - uint8_t i,j,k=0; + uint8_t i,j,k; uint8_t tmp[8][8]; /* add twist counter */ for(i=0; i<8; ++i){ @@ -55,11 +51,7 @@ void twister_blank_round(twister_state_t* ctx){ tmp[i][j] = pgm_read_byte(twister_sbox+ctx->s[i][j]); } } - /* shift rows */ -// for(i=1;i<8; ++i){ -// shiftrow(&(tmp[i][0]), i); -// } - /* mix columns */ + /* mix columns with integrates shift rows */ for( i=0; i<8; i++ ){ // multiply with mds matrix for( j=0; j<8; j++ ){ @@ -78,7 +70,7 @@ void twister_blank_round(twister_state_t* ctx){ } } -void twister_mini_round(twister_state_t* ctx, void* msg){ +void twister_mini_round(twister_state_t* ctx, const void* msg){ /* inject message */ uint8_t i; for(i=0; i<8; ++i){