X-Git-Url: https://git.cryptolib.org/?p=avr-crypto-lib.git;a=blobdiff_plain;f=host%2Fgf256mul.c;h=fe6548652483220d4b63d9e9ef6385911a0f758e;hp=3da67cb53fc0e6a8087124dce458aa1c702ce723;hb=4b5da1dc27a791b5c448274a3db09cd035b33493;hpb=b3daeff2bc9d451afc9c311034a122c6495cc1ab diff --git a/host/gf256mul.c b/host/gf256mul.c index 3da67cb..fe65486 100644 --- a/host/gf256mul.c +++ b/host/gf256mul.c @@ -1,7 +1,7 @@ /* gf256mul.c */ /* - This file is part of the Crypto-avr-lib/microcrypt-lib. - Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + This file is part of the AVR-Crypto-Lib. + 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 @@ -18,7 +18,7 @@ */ /** * \file gf256mul.c - * \email daniel.otte@rub.de + * \email bg@nerilex.org * \author Daniel Otte * \date 2009-01-13 * \license GPLv3 or later @@ -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; }