]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - host/gf256mul.c
adjusting make-system for AEAD-Ciphers
[avr-crypto-lib.git] / host / gf256mul.c
index 3da67cb53fc0e6a8087124dce458aa1c702ce723..b3dd4605a44b1bd7adcffe983b8b12556077ccf2 100644 (file)
@@ -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
 #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;
 }