]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - host/gf256mul.c
fixing E-Mail-Address & Copyright
[avr-crypto-lib.git] / host / gf256mul.c
index 3da67cb53fc0e6a8087124dce458aa1c702ce723..fe6548652483220d4b63d9e9ef6385911a0f758e 100644 (file)
@@ -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
 #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;
 }