X-Git-Url: https://git.cryptolib.org/avr-crypto-lib.git?a=blobdiff_plain;f=echo%2Fecho.c;h=6fbbbd8efe92918a2ac5dafe63939a11e597cef8;hb=701cee0d98aab48dd3192c8cc7c77eb42581bc56;hp=98ee47c771d51439f5a8dcdf577ac50c71657df0;hpb=21bfb1fb168b3114f675f34e257b6acc557b2de8;p=avr-crypto-lib.git diff --git a/echo/echo.c b/echo/echo.c index 98ee47c..6fbbbd8 100644 --- a/echo/echo.c +++ b/echo/echo.c @@ -21,6 +21,7 @@ #include "echo.h" #include "gf256mul.h" #include "memxor.h" +#include "aes_enc_round.h" #include #include @@ -35,7 +36,6 @@ #include "cli.h" #endif -void aes_encrypt_round(void* state, void* key); #define INDEX(c,r) ((c)*16*4+(r)*16) @@ -93,12 +93,15 @@ static void dump_state(void* s){ static void echo_compress(uint8_t* s, uint8_t iterations, uint64_t* c, void* salt){ uint8_t i, j; - uint8_t k[16]; + union { + uint8_t v8[16]; + uint64_t v64[2]; + } k; #if DEBUG uint8_t round=0; #endif - memcpy(k, c, 8); - memset(k+8, 0, 8); + memcpy(k.v8, c, 8); + memset(k.v8+8, 0, 8); do{ /* BIG.SubWords */ #if DEBUG @@ -110,9 +113,9 @@ static void echo_compress(uint8_t* s, uint8_t iterations, uint64_t* c, void* sal } #endif for(i=0; i<16; ++i){ - aes_encrypt_round(s+16*i, k); - aes_encrypt_round(s+16*i, salt); - *((uint64_t*)(k)) += 1; + aes_enc_round((aes_cipher_state_t*)(s+16*i), (aes_roundkey_t*)k.v8); + aes_enc_round((aes_cipher_state_t*)(s+16*i), (aes_roundkey_t*)salt); + k.v64[0] += 1; } #if DEBUG if(round