]> git.cryptolib.org Git - avr-crypto-lib.git/commitdiff
fixed bug in shabea
authorbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Mon, 21 Jul 2008 02:40:18 +0000 (02:40 +0000)
committerbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Mon, 21 Jul 2008 02:40:18 +0000 (02:40 +0000)
memxor.c [new file with mode: 0644]
memxor.h [new file with mode: 0644]
mkfiles/shabea.mk
shabea.c

diff --git a/memxor.c b/memxor.c
new file mode 100644 (file)
index 0000000..1fbde5a
--- /dev/null
+++ b/memxor.c
@@ -0,0 +1,8 @@
+#include <stdint.h>
+
+void memxor(void * dest, const void * src, uint16_t n){
+  while(n--){
+    ((uint8_t*)dest)[n] ^= ((uint8_t*)src)[n];
+  }
+}
+
diff --git a/memxor.h b/memxor.h
new file mode 100644 (file)
index 0000000..d84f335
--- /dev/null
+++ b/memxor.h
@@ -0,0 +1,7 @@
+#ifndef MEMXOR_H_
+#define MEMXOR_H_
+#include <stdint.h>
+
+void memxor(void * dest, const void * src, uint16_t n);
+
+#endif
index 8c9cc951f2cea5fb88189354d824bd66d8e1f53d..ee749ff7f2f3128392e28788bcbf0c8e7135f9d2 100644 (file)
@@ -7,7 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 $(ALGO_NAME)_OBJ      := shabea.o sha256-asm.o
 $(ALGO_NAME)_TEST_BIN := main-shabea-test.o debug.o uart.o serial-tools.o \
                          shabea.o sha256-asm.o nessie_bc_test.o \
-                        nessie_common.o cli.o performance_test.o
+                        nessie_common.o cli.o performance_test.o memxor.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index 49a13215b18de29dfa8827504f46aef574ea257a..52c9461c0ba00152f99cd4762ec7ed845491807b 100644 (file)
--- a/shabea.c
+++ b/shabea.c
 #include "config.h"
 #include "uart.h"
 #include "debug.h"
-/*
- * 
- */
-void memxor(uint8_t * dest, uint8_t * src, uint8_t length){
-       while(length--){
-               *dest++ ^= *src++;
-       }
-} 
+#include "memxor.h"
+
 
 /*
  * SHABEA256-n
@@ -77,7 +71,7 @@ void shabea256(void * block, void * key, uint16_t keysize_b, uint8_t enc, uint8_
                        memcpy(R, hash, HALFSIZEB);
                } else {
                        /* no swap */
-                       memxor(L, hash, HALFSIZE);      
+                       memxor(L, hash, HALFSIZEB);     
                }
        }
 }