From a06c8ef821e04e0f6fe2e5e4fcd485f4f21a645e Mon Sep 17 00:00:00 2001 From: bg Date: Mon, 21 Jul 2008 02:40:18 +0000 Subject: [PATCH] fixed bug in shabea --- memxor.c | 8 ++++++++ memxor.h | 7 +++++++ mkfiles/shabea.mk | 2 +- shabea.c | 12 +++--------- 4 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 memxor.c create mode 100644 memxor.h diff --git a/memxor.c b/memxor.c new file mode 100644 index 0000000..1fbde5a --- /dev/null +++ b/memxor.c @@ -0,0 +1,8 @@ +#include + +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 index 0000000..d84f335 --- /dev/null +++ b/memxor.h @@ -0,0 +1,7 @@ +#ifndef MEMXOR_H_ +#define MEMXOR_H_ +#include + +void memxor(void * dest, const void * src, uint16_t n); + +#endif diff --git a/mkfiles/shabea.mk b/mkfiles/shabea.mk index 8c9cc95..ee749ff 100644 --- a/mkfiles/shabea.mk +++ b/mkfiles/shabea.mk @@ -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" diff --git a/shabea.c b/shabea.c index 49a1321..52c9461 100644 --- a/shabea.c +++ b/shabea.c @@ -35,14 +35,8 @@ #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); } } } -- 2.39.5