X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=shabea.c;h=49a13215b18de29dfa8827504f46aef574ea257a;hb=91bece1f7822ccaae033989525ee08f613de3802;hp=62ff6b4a27e72b5af76223f3e8c06f09bd2df6de;hpb=33c19d7ea9dafc19b818dd8de984dcf1543d7b37;p=avr-crypto-lib.git diff --git a/shabea.c b/shabea.c index 62ff6b4..49a1321 100644 --- a/shabea.c +++ b/shabea.c @@ -55,26 +55,26 @@ void memxor(uint8_t * dest, uint8_t * src, uint8_t length){ #define L ((uint8_t*)block+ 0) #define R ((uint8_t*)block+16) -void shabea256(void * block, void * key, uint16_t keysize, uint8_t enc, uint8_t rounds){ +void shabea256(void * block, void * key, uint16_t keysize_b, uint8_t enc, uint8_t rounds){ int8_t r; /**/ - uint8_t tb[HALFSIZEB+2+(keysize+7)/8]; /**/ + uint8_t tb[HALFSIZEB+2+(keysize_b+7)/8]; /**/ uint16_t kbs; /* bytes used for the key / temporary block */ sha256_hash_t hash; r = (enc?0:(rounds-1)); - kbs = (keysize+7)/8; + kbs = (keysize_b+7)/8; memcpy(tb+HALFSIZEB+2, key, kbs); /* copy key to temporary block */ tb[HALFSIZEB+0] = 0; /* set round counter high value to zero */ for(;r!=(enc?(rounds):-1);enc?r++:r--){ /* enc: 0..(rounds-1) ; !enc: (rounds-1)..0 */ memcpy(tb, R, HALFSIZEB); /* copy right half into tb */ tb[HALFSIZEB+1] = r; - sha256(&hash, tb, HALFSIZE+16+keysize); + sha256(&hash, tb, HALFSIZE+16+keysize_b); if(!(r==(enc?(rounds-1):0))){ /* swap */ - memxor(hash, L, HALFSIZE); - memcpy(L, R, HALFSIZE); - memcpy(R, hash, HALFSIZE); + memxor(hash, L, HALFSIZEB); + memcpy(L, R, HALFSIZEB); + memcpy(R, hash, HALFSIZEB); } else { /* no swap */ memxor(L, hash, HALFSIZE);