X-Git-Url: https://git.cryptolib.org/?p=avr-crypto-lib.git;a=blobdiff_plain;f=jh%2Fjh_simple_speed_core.c;h=1835902355f9248d00245c8774a67c9b9a06274c;hp=6ff0072af7333d12ea246fc30d8d3ac18df77da8;hb=4b5da1dc27a791b5c448274a3db09cd035b33493;hpb=e2a5b474634f8c07d75119c2affdc6bb7f4e7848 diff --git a/jh/jh_simple_speed_core.c b/jh/jh_simple_speed_core.c index 6ff0072..1835902 100644 --- a/jh/jh_simple_speed_core.c +++ b/jh/jh_simple_speed_core.c @@ -1,7 +1,7 @@ /* jh_simple_speed.c */ /* This file is part of the AVR-Crypto-Lib. - Copyright (C) 2006-2010 Daniel Otte (daniel.otte@rub.de) + Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -32,9 +32,9 @@ #endif static -void jh_round(uint8_t* a, uint8_t roundno){ +void jh_round(uint8_t *a, uint8_t roundno){ uint8_t b[128]; - uint8_t i,r,u,v,x,y; + uint8_t i,r=0,u,v,x,y; uint8_t *pr; pr = jh_round_const + 32*roundno; for(i=0; i<128; ++i){ @@ -63,6 +63,7 @@ void jh_round(uint8_t* a, uint8_t roundno){ } } +/* static uint8_t jh_l_inv(uint8_t a){ uint8_t v,w; @@ -72,6 +73,7 @@ uint8_t jh_l_inv(uint8_t a){ w ^= ((v<<1)^(v>>3)^((v>>2)&2))&0xf; return w|(v<<4); } +*/ static inline void group(uint8_t *a){ @@ -111,7 +113,7 @@ void degroup(uint8_t *a){ memcpy(a,b,128); } -void jh_encrypt(uint8_t* a){ +void jh_encrypt(uint8_t *a){ uint8_t i; /* grouping */ #if DEBUG @@ -119,20 +121,10 @@ void jh_encrypt(uint8_t* a){ cli_hexdump_block(a, 128, 4, 16); #endif group(a); - for(i=0;i<35;++i){ + for(i=0;i<42;++i){ jh_round(a, i); } - uint8_t r; - uint8_t *pr; - pr = jh_round_const + 32*35; - for(i=0; i<128; ++i){ - if(i%4==0){ - r = pgm_read_byte(pr++); - } - a[i]=jh_l_inv(pgm_read_byte(&(jh_lutbox[((r&0xC0)<<2)|a[i]]))); - r<<=2; - } /* degrouping */ #if DEBUG cli_putstr_P(PSTR("\r\n== pre degroup ==\r\n"));