X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=groestl%2Fgroestl_small.c;h=87156cfab4d2e2d773c7df3c145750edd266ba4a;hb=41e9e95f07e04170b8732426b2c5d73400b4a2bd;hp=7e59ca42313da80b80084b1579cd62136de4d9c6;hpb=7b5401ab9ce23a5da1de8b6c7de3a1aa20ac4cf8;p=avr-crypto-lib.git diff --git a/groestl/groestl_small.c b/groestl/groestl_small.c index 7e59ca4..87156cf 100644 --- a/groestl/groestl_small.c +++ b/groestl/groestl_small.c @@ -26,9 +26,9 @@ */ #include "groestl_small.h" -#include "aes/aes_sbox.h" -#include "gf256mul/gf256mul.h" -#include "memxor/memxor.h" +#include "aes_sbox.h" +#include "gf256mul.h" +#include "memxor.h" #include #include #include @@ -65,30 +65,72 @@ static uint8_t matrix[] PROGMEM = { 2, 3, 4, 5, 3, 5, 7, 2 }; + +static const uint8_t p_shifts[] PROGMEM = { + 0, 1, 2, 3, 4, 5, 6, 7 +}; + +static const uint8_t q_shifts[] PROGMEM = { + 1, 3, 5, 7, 0, 2, 4, 6 +}; + + +static +void shift_columns(uint8_t *a, PGM_VOID_P shifts){ + uint8_t s; + uint8_t tmp[8]; + uint8_t i,j; + for(i=0; i<8; ++i){ + s = pgm_read_byte(shifts); + shifts = (uint8_t*)shifts + 1; + if(s==0){ + continue; + } + for(j=0;j<8;++j){ + tmp[j] = a[i+j*8]; + } + for(j=0; j<8; ++j){ + a[i+((j-s+8)%8)*8] = tmp[j]; + } + } +} + + + void groestl_small_rounds(uint8_t *m, uint8_t q){ uint8_t r,i,j; uint8_t tmp[8]; +#if DEBUG + cli_putstr_P(PSTR("\r\n:: BEGIN ")); + cli_putc(q?'Q':'P'); +#endif + for(r=0; r