X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=host%2Fgf256mul.c;h=b3dd4605a44b1bd7adcffe983b8b12556077ccf2;hb=69d6349f8ad9d35c2acdb4e4e38ad42cd28b426c;hp=3da67cb53fc0e6a8087124dce458aa1c702ce723;hpb=b3daeff2bc9d451afc9c311034a122c6495cc1ab;p=avr-crypto-lib.git diff --git a/host/gf256mul.c b/host/gf256mul.c index 3da67cb..b3dd460 100644 --- a/host/gf256mul.c +++ b/host/gf256mul.c @@ -1,6 +1,6 @@ /* gf256mul.c */ /* - This file is part of the Crypto-avr-lib/microcrypt-lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -28,15 +28,16 @@ #include "gf256mul.h" uint8_t gf256mul(uint8_t a, uint8_t b, uint8_t reducer){ - uint8_t t,ret=0; - while(a){ - if(a&1) - ret ^= b; + uint8_t i; + uint8_t p=0,t; + for(i=0; i<8; ++i){ + if(b&1) + p ^= a; t=a&0x80; - b<<=1; + a<<=1; if(t) - b^=reducer; - a>>=1; + a ^= reducer; + b>>=1; } - return ret; + return p; }