From 2159c273c9d3361571a6ff1ab63d9bc76582fbab Mon Sep 17 00:00:00 2001 From: bg Date: Sat, 2 Aug 2008 10:37:02 +0000 Subject: [PATCH] modification to the build system --- Makefile | 32 +++++++++++++------ avr-makefile.inc | 3 +- deps/test_src | 1 + mkfiles/a5_1.mk | 2 +- mkfiles/arcfour.mk | 2 +- mkfiles/arcfour_c.mk | 2 +- mkfiles/camellia.mk | 5 ++- mkfiles/cast5.mk | 2 +- mkfiles/des.mk | 2 +- mkfiles/entropium.mk | 2 +- mkfiles/grain.mk | 4 +-- mkfiles/hmac-sha1.mk | 2 +- mkfiles/hmac-sha256.mk | 2 +- mkfiles/md5.mk | 2 +- mkfiles/noekeon.mk | 3 +- mkfiles/noekeon_c.mk | 3 +- mkfiles/present.mk | 3 +- mkfiles/rc5.mk | 2 +- mkfiles/rc6.mk | 3 +- mkfiles/seed.mk | 2 +- mkfiles/serpent-bitslice.mk | 5 ++- mkfiles/serpent.mk | 5 ++- mkfiles/sha1.mk | 3 +- mkfiles/sha1_c.mk | 2 +- mkfiles/sha256.mk | 3 +- mkfiles/sha256_c.mk | 3 +- mkfiles/shabea.mk | 5 ++- mkfiles/shacal1enc.mk | 3 +- mkfiles/shacal2enc.mk | 3 +- mkfiles/skipjack.mk | 2 +- mkfiles/tdes.mk | 2 +- mkfiles/trivium.mk | 4 +-- mkfiles/xtea.mk | 3 +- mkfiles/xtea_c.mk | 3 +- serpent.c | 19 +++-------- serpent.h | 16 +++++----- cli.c => test_src/cli.c | 0 cli.h => test_src/cli.h | 0 debug.c => test_src/debug.c | 0 .../main-arcfour-test.c | 0 .../main-camellia-test.c | 0 .../main-cast5-test.c | 0 main-des-test.c => test_src/main-des-test.c | 0 .../main-entropium-test.c | 0 .../main-grain-test.c | 0 .../main-hmac-sha1-test.c | 0 .../main-hmac-sha256-test.c | 0 main-md5-test.c => test_src/main-md5-test.c | 0 .../main-noekeon-test.c | 0 .../main-present-test.c | 0 main-rc5-test.c => test_src/main-rc5-test.c | 0 main-rc6-test.c => test_src/main-rc6-test.c | 0 main-seed-test.c => test_src/main-seed-test.c | 0 .../main-serpent-test.c | 0 main-sha1-test.c => test_src/main-sha1-test.c | 0 .../main-sha256-test.c | 0 .../main-shabea-test.c | 0 .../main-shacal1_enc-test.c | 0 .../main-shacal2_enc-test.c | 0 .../main-skipjack-test.c | 0 main-tdes-test.c => test_src/main-tdes-test.c | 0 .../main-trivium-test.c | 0 main-xtea-test.c => test_src/main-xtea-test.c | 0 nessie_bc_test.c => test_src/nessie_bc_test.c | 0 nessie_bc_test.h => test_src/nessie_bc_test.h | 0 nessie_common.c => test_src/nessie_common.c | 0 nessie_common.h => test_src/nessie_common.h | 0 .../nessie_hash_test.c | 0 .../nessie_hash_test.h | 0 .../nessie_mac_test.c | 0 .../nessie_mac_test.h | 0 .../nessie_stream_test.c | 0 .../nessie_stream_test.h | 0 .../performance_test.c | 0 .../performance_test.h | 0 serial-tools.c => test_src/serial-tools.c | 0 serial-tools.h => test_src/serial-tools.h | 0 uart.c => test_src/uart.c | 0 78 files changed, 76 insertions(+), 84 deletions(-) create mode 120000 deps/test_src rename cli.c => test_src/cli.c (100%) rename cli.h => test_src/cli.h (100%) rename debug.c => test_src/debug.c (100%) rename main-arcfour-test.c => test_src/main-arcfour-test.c (100%) rename main-camellia-test.c => test_src/main-camellia-test.c (100%) rename main-cast5-test.c => test_src/main-cast5-test.c (100%) rename main-des-test.c => test_src/main-des-test.c (100%) rename main-entropium-test.c => test_src/main-entropium-test.c (100%) rename main-grain-test.c => test_src/main-grain-test.c (100%) rename main-hmac-sha1-test.c => test_src/main-hmac-sha1-test.c (100%) rename main-hmac-sha256-test.c => test_src/main-hmac-sha256-test.c (100%) rename main-md5-test.c => test_src/main-md5-test.c (100%) rename main-noekeon-test.c => test_src/main-noekeon-test.c (100%) rename main-present-test.c => test_src/main-present-test.c (100%) rename main-rc5-test.c => test_src/main-rc5-test.c (100%) rename main-rc6-test.c => test_src/main-rc6-test.c (100%) rename main-seed-test.c => test_src/main-seed-test.c (100%) rename main-serpent-test.c => test_src/main-serpent-test.c (100%) rename main-sha1-test.c => test_src/main-sha1-test.c (100%) rename main-sha256-test.c => test_src/main-sha256-test.c (100%) rename main-shabea-test.c => test_src/main-shabea-test.c (100%) rename main-shacal1_enc-test.c => test_src/main-shacal1_enc-test.c (100%) rename main-shacal2_enc-test.c => test_src/main-shacal2_enc-test.c (100%) rename main-skipjack-test.c => test_src/main-skipjack-test.c (100%) rename main-tdes-test.c => test_src/main-tdes-test.c (100%) rename main-trivium-test.c => test_src/main-trivium-test.c (100%) rename main-xtea-test.c => test_src/main-xtea-test.c (100%) rename nessie_bc_test.c => test_src/nessie_bc_test.c (100%) rename nessie_bc_test.h => test_src/nessie_bc_test.h (100%) rename nessie_common.c => test_src/nessie_common.c (100%) rename nessie_common.h => test_src/nessie_common.h (100%) rename nessie_hash_test.c => test_src/nessie_hash_test.c (100%) rename nessie_hash_test.h => test_src/nessie_hash_test.h (100%) rename nessie_mac_test.c => test_src/nessie_mac_test.c (100%) rename nessie_mac_test.h => test_src/nessie_mac_test.h (100%) rename nessie_stream_test.c => test_src/nessie_stream_test.c (100%) rename nessie_stream_test.h => test_src/nessie_stream_test.h (100%) rename performance_test.c => test_src/performance_test.c (100%) rename performance_test.h => test_src/performance_test.h (100%) rename serial-tools.c => test_src/serial-tools.c (100%) rename serial-tools.h => test_src/serial-tools.h (100%) rename uart.c => test_src/uart.c (100%) diff --git a/Makefile b/Makefile index 8033ad2..00d1f5f 100644 --- a/Makefile +++ b/Makefile @@ -19,10 +19,7 @@ $(1) = $(2) endef $(foreach a, $(ALGORITHMS_OBJ), $(eval $(call OBJinBINDIR_TEMPLATE, $(a), $(patsubst %.o,$(BIN_DIR)%.o,$($(a)))))) ALGORITHMS_TEST_BIN = $(patsubst %,%_TEST_BIN, $(ALGORITHMS)) -$(foreach a, $(ALGORITHMS_TEST_BIN), $(eval $(call OBJinBINDIR_TEMPLATE, $(a), $(patsubst %.o,$(BIN_DIR)%.o,$($(a)))))) -#ALGORITHMS_TEST_BIN_MAIN = $(foreach a, $(ALGORITHMS_TEST_BIN), $(firstword $($(a)))) -#ALGORITHMS_TEST_BIN_MAIN_ELF = $(patsubst $(BIN_DIR)%.o, $(TESTBIN_DIR)%.elf, $(ALGORITHMS_TEST_BIN_MAIN)) -#ALGORITHMS_TEST_BIN_MAIN_HEX = $(patsubst $(BIN_DIR)%.o, $(TESTBIN_DIR)%.hex, $(ALGORITHMS_TEST_BIN_MAIN)) +$(foreach a, $(ALGORITHMS_TEST_BIN), $(eval $(call OBJinBINDIR_TEMPLATE, $(a), $(patsubst %.o,$(TESTBIN_DIR)%.o,$($(a)))))) ALGORITHMS_TEST_BIN_IMM = $(foreach a, $(ALGORITHMS_TEST_BIN), $($(a))) @@ -41,18 +38,24 @@ all: $(foreach algo, $(ALGORITHMS), $(algo)_OBJ) #------------------------------------------------------------------------------- -define BLA_TEMPLATE2 -$(2): $(3) +define MAIN_OBJ_TEMPLATE +$(2): $(3) $(4) @echo "[gcc]: $$@" # echo $$^ @$(CC) $(CFLAGS) $(LDFLAGS)$(patsubst %.elf,%.map,$(2)) -o \ $(2) \ - $(3) \ + $(3) $(4) \ $(LIBS) endef -#$(foreach algo, $(ALGORITHMS), $(eval $(call BLA_TEMPLATE2, $(algo), $(patsubst $(BIN_DIR)%.o,$(TESTBIN_DIR)%.elf,$(firstword $($(algo)_TEST_BIN))), $(patsubst %.o,%.o,$($(algo)_TEST_BIN)) ))) -$(foreach algo, $(ALGORITHMS), $(eval $(call BLA_TEMPLATE2, $(algo), $(TESTBIN_DIR)main-$(call lc,$(algo))-test.elf, $(patsubst %.o,%.o,$($(algo)_TEST_BIN)) ))) +$(foreach algo, $(ALGORITHMS), $(eval $(call MAIN_OBJ_TEMPLATE, \ + $(algo), \ + $(TESTBIN_DIR)main-$(call lc,$(algo))-test.elf, \ + $(patsubst %.o,%.o,$($(algo)_TEST_BIN)), \ + $(patsubst %.o,%.o,$($(algo)_OBJ)) ))) + + + #------------------------------------------------------------------------------- .PHONY: help @@ -70,6 +73,8 @@ info: @echo " $(MACS)" @echo " PRNG functions:" @echo " $(PRNGS)" + @echo " ALGORITHMS_TEST_BIN" + @echo " $(ALGORITHMS_TEST_BIN)" @echo " ALGORITHMS_TEST_TARGET_ELF:" @echo " $(ALGORITHMS_TEST_TARGET_ELF)" @@ -82,6 +87,15 @@ $(BIN_DIR)%.o: %.S @echo "[as] : $@" @$(CC) $(ASFLAGS) -c -o $@ $< +$(TESTBIN_DIR)%.o: $(TESTSRC_DIR)%.c + @echo "[gcc]: $@" + @$(CC) $(CFLAGS) -c -o $@ $< + +$(TESTBIN_DIR)%.o: $(TESTSRC_DIR)%.S + @echo "[as] : $@" + @$(CC) $(ASFLAGS) -c -o $@ $< + + %.o: %.c @echo "[gcc]: $@" @$(CC) $(CFLAGS) -c -o $@ $< diff --git a/avr-makefile.inc b/avr-makefile.inc index 3585afe..0e09617 100644 --- a/avr-makefile.inc +++ b/avr-makefile.inc @@ -7,6 +7,7 @@ FLASHCMD = avrdude -p $(MCU_TARGET) -P /dev/ttyUSB0 -c avr911 -U flash:w:# DEP_DIR = deps/ BIN_DIR = bin/ TESTBIN_DIR = test_bin/ +TESTSRC_DIR = test_src/ #uisp -dprog=bsd -dlpt=/dev/parport1 --upload if=$(PRG).hex ERASECMD = TESTPORT = /dev/ttyUSB1 @@ -15,7 +16,7 @@ TESTLOG_DIR = testlog/ TESTPREFIX = nessie- CC = avr-gcc -override CFLAGS = -MMD -MF$(DEP_DIR)$(patsubst %.c,%.d,$<) -pedantic -std=c99 -Wall -Wstrict-prototypes $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) +override CFLAGS = -MMD -MF$(DEP_DIR)$(patsubst %.c,%.d,$<) -I. -pedantic -std=c99 -Wall -Wstrict-prototypes $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) override LDFLAGS = -Wl,-Map, override ASFLAGS = -mmcu=$(MCU_TARGET) diff --git a/deps/test_src b/deps/test_src new file mode 120000 index 0000000..945c9b4 --- /dev/null +++ b/deps/test_src @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/mkfiles/a5_1.mk b/mkfiles/a5_1.mk index 6d89b62..e4264be 100644 --- a/mkfiles/a5_1.mk +++ b/mkfiles/a5_1.mk @@ -6,7 +6,7 @@ STREAM_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := A5_1.o $(ALGO_NAME)_TEST_BIN := main-a5_1-test.o debug.o uart.o serial-tools.o \ - nessie_stream_test.o nessie_common.o A5_1.o + nessie_stream_test.o nessie_common.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/arcfour.mk b/mkfiles/arcfour.mk index a05f236..f5b4089 100644 --- a/mkfiles/arcfour.mk +++ b/mkfiles/arcfour.mk @@ -6,7 +6,7 @@ STREAM_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := arcfour-asm.o $(ALGO_NAME)_TEST_BIN := main-arcfour-test.o debug.o uart.o serial-tools.o \ - nessie_stream_test.o nessie_common.o arcfour-asm.o + nessie_stream_test.o nessie_common.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/arcfour_c.mk b/mkfiles/arcfour_c.mk index 8e70754..21061a5 100644 --- a/mkfiles/arcfour_c.mk +++ b/mkfiles/arcfour_c.mk @@ -6,7 +6,7 @@ STREAM_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := arcfour.o $(ALGO_NAME)_TEST_BIN := main-arcfour-test.o debug.o uart.o serial-tools.o \ - nessie_stream_test.o nessie_common.o arcfour.o + nessie_stream_test.o nessie_common.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/camellia.mk b/mkfiles/camellia.mk index a34d538..1e304a9 100644 --- a/mkfiles/camellia.mk +++ b/mkfiles/camellia.mk @@ -1,13 +1,12 @@ # Makefile for camellia ALGO_NAME := CAMELLIA -# comment out the following line for removement of serpent from the build process +# comment out the following line for removement of Camellia from the build process BLOCK_CIPHERS += $(ALGO_NAME) -# main-camellia-test.o debug.o uart.o serial-tools.o camellia.o camellia-asm.o $(ALGO_NAME)_OBJ := camellia.o camellia-asm.o $(ALGO_NAME)_TEST_BIN := main-camellia-test.o debug.o uart.o serial-tools.o \ - camellia.o camellia-asm.o nessie_bc_test.o \ + nessie_bc_test.o \ nessie_common.o cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/cast5.mk b/mkfiles/cast5.mk index b2b671b..33c32ba 100644 --- a/mkfiles/cast5.mk +++ b/mkfiles/cast5.mk @@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := cast5.o $(ALGO_NAME)_TEST_BIN := main-cast5-test.o debug.o uart.o serial-tools.o cli.o\ - cast5.o nessie_bc_test.o nessie_common.o performance_test.o + nessie_bc_test.o nessie_common.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/des.mk b/mkfiles/des.mk index 2cc8d7c..15c16ec 100644 --- a/mkfiles/des.mk +++ b/mkfiles/des.mk @@ -5,7 +5,7 @@ ALGO_NAME := DES BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := des.o -$(ALGO_NAME)_TEST_BIN := main-des-test.o debug.o uart.o serial-tools.o des.o \ +$(ALGO_NAME)_TEST_BIN := main-des-test.o debug.o uart.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/entropium.mk b/mkfiles/entropium.mk index 589ff6f..e5806c3 100644 --- a/mkfiles/entropium.mk +++ b/mkfiles/entropium.mk @@ -6,7 +6,7 @@ PRNGS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := entropium.o sha256-asm.o $(ALGO_NAME)_TEST_BIN := main-entropium-test.o debug.o uart.o serial-tools.o \ - sha256-asm.o entropium.o cli.o performance_test.o + cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/grain.mk b/mkfiles/grain.mk index ed330a6..4f026a9 100644 --- a/mkfiles/grain.mk +++ b/mkfiles/grain.mk @@ -6,8 +6,8 @@ STREAM_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := grain.o $(ALGO_NAME)_TEST_BIN := main-grain-test.o debug.o uart.o serial-tools.o \ - nessie_stream_test.o nessie_common.o grain.o cli.o \ - performance_test.o + nessie_stream_test.o nessie_common.o cli.o \ + performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/hmac-sha1.mk b/mkfiles/hmac-sha1.mk index 8d5c90a..b63308f 100644 --- a/mkfiles/hmac-sha1.mk +++ b/mkfiles/hmac-sha1.mk @@ -6,7 +6,7 @@ MACS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := hmac-sha1.o sha1-asm.o $(ALGO_NAME)_TEST_BIN := main-hmac-sha1-test.o debug.o uart.o serial-tools.o cli.o \ - hmac-sha1.o sha1-asm.o nessie_mac_test.o nessie_common.o + nessie_mac_test.o nessie_common.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/hmac-sha256.mk b/mkfiles/hmac-sha256.mk index 6d957b3..fe14892 100644 --- a/mkfiles/hmac-sha256.mk +++ b/mkfiles/hmac-sha256.mk @@ -6,7 +6,7 @@ MACS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := hmac-sha256.o sha256-asm.o $(ALGO_NAME)_TEST_BIN := main-hmac-sha256-test.o debug.o uart.o serial-tools.o \ - hmac-sha256.o sha256-asm.o nessie_mac_test.o nessie_common.o + nessie_mac_test.o nessie_common.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/md5.mk b/mkfiles/md5.mk index b3d3de0..3fb9d65 100644 --- a/mkfiles/md5.mk +++ b/mkfiles/md5.mk @@ -5,7 +5,7 @@ ALGO_NAME := MD5 HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := md5.o -$(ALGO_NAME)_TEST_BIN := main-md5-test.o debug.o uart.o serial-tools.o md5.o \ +$(ALGO_NAME)_TEST_BIN := main-md5-test.o debug.o uart.o serial-tools.o \ nessie_hash_test.o nessie_common.o cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/noekeon.mk b/mkfiles/noekeon.mk index 3f1a313..359aef3 100644 --- a/mkfiles/noekeon.mk +++ b/mkfiles/noekeon.mk @@ -7,8 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := noekeon_asm.o $(ALGO_NAME)_TEST_BIN := main-noekeon-test.o debug.o uart.o serial-tools.o \ - noekeon_asm.o nessie_bc_test.o \ - nessie_common.o cli.o performance_test.o + nessie_bc_test.o nessie_common.o cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PEROFRMANCE_TEST := performance diff --git a/mkfiles/noekeon_c.mk b/mkfiles/noekeon_c.mk index 48571d0..90d378d 100644 --- a/mkfiles/noekeon_c.mk +++ b/mkfiles/noekeon_c.mk @@ -7,8 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := noekeon.o $(ALGO_NAME)_TEST_BIN := main-noekeon-test.o debug.o uart.o serial-tools.o \ - noekeon.o nessie_bc_test.o \ - nessie_common.o cli.o performance_test.o + nessie_bc_test.o nessie_common.o cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PEROFRMANCE_TEST := performance diff --git a/mkfiles/present.mk b/mkfiles/present.mk index 764acef..e30c506 100644 --- a/mkfiles/present.mk +++ b/mkfiles/present.mk @@ -7,8 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := present.o $(ALGO_NAME)_TEST_BIN := main-present-test.o debug.o uart.o serial-tools.o \ - present.o nessie_bc_test.o nessie_common.o cli.o \ - performance_test.o + nessie_bc_test.o nessie_common.o cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/rc5.mk b/mkfiles/rc5.mk index b45a610..ff20873 100644 --- a/mkfiles/rc5.mk +++ b/mkfiles/rc5.mk @@ -7,7 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := rc5.o $(ALGO_NAME)_TEST_BIN := main-rc5-test.o debug.o uart.o serial-tools.o \ - rc5.o nessie_bc_test.o \ + nessie_bc_test.o \ nessie_common.o cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PEROFRMANCE_TEST := performance diff --git a/mkfiles/rc6.mk b/mkfiles/rc6.mk index 893b34f..47e2f00 100644 --- a/mkfiles/rc6.mk +++ b/mkfiles/rc6.mk @@ -7,8 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := rc6.o $(ALGO_NAME)_TEST_BIN := main-rc6-test.o debug.o uart.o serial-tools.o \ - rc6.o nessie_bc_test.o \ - nessie_common.o cli.o performance_test.o + nessie_bc_test.o nessie_common.o cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PEROFRMANCE_TEST := performance diff --git a/mkfiles/seed.mk b/mkfiles/seed.mk index 515597c..35724f2 100644 --- a/mkfiles/seed.mk +++ b/mkfiles/seed.mk @@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := seed.o seed-asm.o $(ALGO_NAME)_TEST_BIN := main-seed-test.o debug.o uart.o serial-tools.o \ - seed.o seed-asm.o nessie_bc_test.o nessie_common.o \ + nessie_bc_test.o nessie_common.o \ cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/serpent-bitslice.mk b/mkfiles/serpent-bitslice.mk index 5ddb0c4..e17ab28 100644 --- a/mkfiles/serpent-bitslice.mk +++ b/mkfiles/serpent-bitslice.mk @@ -5,10 +5,9 @@ ALGO_NAME := SERPENT_BITSLICE BLOCK_CIPHERS += $(ALGO_NAME) -$(ALGO_NAME)_OBJ := serpent.o serpent-sboxes-bitslice.o +$(ALGO_NAME)_OBJ := serpent.o serpent-sboxes-bitslice.o memxor.o $(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o serial-tools.o \ - serpent.o serpent-sboxes-bitslice.o nessie_bc_test.o \ - nessie_common.o cli.o performance_test.o + nessie_bc_test.o nessie_common.o cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/serpent.mk b/mkfiles/serpent.mk index 03dad5b..5959aea 100644 --- a/mkfiles/serpent.mk +++ b/mkfiles/serpent.mk @@ -5,10 +5,9 @@ ALGO_NAME := SERPENT BLOCK_CIPHERS += $(ALGO_NAME) -$(ALGO_NAME)_OBJ := serpent.o serpent-sboxes.o +$(ALGO_NAME)_OBJ := serpent.o serpent-sboxes.o memxor.o $(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o serial-tools.o \ - serpent.o serpent-sboxes.o nessie_bc_test.o \ - nessie_common.o cli.o performance_test.o + nessie_bc_test.o nessie_common.o cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/sha1.mk b/mkfiles/sha1.mk index dc2eade..eb2d919 100644 --- a/mkfiles/sha1.mk +++ b/mkfiles/sha1.mk @@ -6,8 +6,7 @@ HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := sha1-asm.o $(ALGO_NAME)_TEST_BIN := main-sha1-test.o debug.o uart.o serial-tools.o \ - sha1-asm.o nessie_hash_test.o nessie_common.o cli.o \ - performance_test.o + nessie_hash_test.o nessie_common.o cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/sha1_c.mk b/mkfiles/sha1_c.mk index bdfedf7..061f7a9 100644 --- a/mkfiles/sha1_c.mk +++ b/mkfiles/sha1_c.mk @@ -6,7 +6,7 @@ HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := sha1.o $(ALGO_NAME)_TEST_BIN := main-sha1-test.o debug.o uart.o serial-tools.o \ - sha1.o nessie_hash_test.o nessie_common.o cli.o \ + nessie_hash_test.o nessie_common.o cli.o \ performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/sha256.mk b/mkfiles/sha256.mk index 0a2fe1c..dcea21f 100644 --- a/mkfiles/sha256.mk +++ b/mkfiles/sha256.mk @@ -6,8 +6,7 @@ HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := sha256-asm.o $(ALGO_NAME)_TEST_BIN := main-sha256-test.o debug.o uart.o serial-tools.o \ - sha256-asm.o nessie_hash_test.o nessie_common.o cli.o \ - performance_test.o + nessie_hash_test.o nessie_common.o cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/sha256_c.mk b/mkfiles/sha256_c.mk index 8175ddc..cf850fc 100644 --- a/mkfiles/sha256_c.mk +++ b/mkfiles/sha256_c.mk @@ -6,8 +6,7 @@ HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := sha256.o $(ALGO_NAME)_TEST_BIN := main-sha256-test.o debug.o uart.o serial-tools.o \ - sha256.o nessie_hash_test.o nessie_common.o cli.o \ - performance_test.o + nessie_hash_test.o nessie_common.o cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/shabea.mk b/mkfiles/shabea.mk index ee749ff..4e9acaf 100644 --- a/mkfiles/shabea.mk +++ b/mkfiles/shabea.mk @@ -4,10 +4,9 @@ ALGO_NAME := SHABEA # comment out the following line for removement of SHABEA from the build process BLOCK_CIPHERS += $(ALGO_NAME) -$(ALGO_NAME)_OBJ := shabea.o sha256-asm.o +$(ALGO_NAME)_OBJ := shabea.o sha256-asm.o memxor.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 memxor.o + nessie_bc_test.o nessie_common.o cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/shacal1enc.mk b/mkfiles/shacal1enc.mk index 1e19794..d329db7 100644 --- a/mkfiles/shacal1enc.mk +++ b/mkfiles/shacal1enc.mk @@ -7,8 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := shacal1_enc.o sha1-asm.o $(ALGO_NAME)_TEST_BIN := main-shacal1_enc-test.o debug.o uart.o serial-tools.o \ - nessie_bc_test.o nessie_common.o cli.o \ - performance_test.o shacal1_enc.o sha1-asm.o + nessie_bc_test.o nessie_common.o cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/shacal2enc.mk b/mkfiles/shacal2enc.mk index 44ba529..739d9eb 100644 --- a/mkfiles/shacal2enc.mk +++ b/mkfiles/shacal2enc.mk @@ -7,8 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := shacal2_enc.o sha256-asm.o $(ALGO_NAME)_TEST_BIN := main-shacal2_enc-test.o debug.o uart.o serial-tools.o \ - nessie_bc_test.o nessie_common.o cli.o \ - performance_test.o shacal2_enc.o sha256-asm.o + nessie_bc_test.o nessie_common.o cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/skipjack.mk b/mkfiles/skipjack.mk index 2a117a9..e48d8b9 100644 --- a/mkfiles/skipjack.mk +++ b/mkfiles/skipjack.mk @@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := skipjack.o $(ALGO_NAME)_TEST_BIN := main-skipjack-test.o debug.o uart.o serial-tools.o \ - skipjack.o nessie_bc_test.o nessie_common.o cli.o \ + nessie_bc_test.o nessie_common.o cli.o \ performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/tdes.mk b/mkfiles/tdes.mk index 66b5168..f0b43e5 100644 --- a/mkfiles/tdes.mk +++ b/mkfiles/tdes.mk @@ -5,7 +5,7 @@ ALGO_NAME := TDES BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := des.o -$(ALGO_NAME)_TEST_BIN := main-tdes-test.o debug.o uart.o serial-tools.o des.o \ +$(ALGO_NAME)_TEST_BIN := main-tdes-test.o debug.o uart.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/trivium.mk b/mkfiles/trivium.mk index e2e3484..45ee4f3 100644 --- a/mkfiles/trivium.mk +++ b/mkfiles/trivium.mk @@ -6,8 +6,8 @@ STREAM_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := trivium.o $(ALGO_NAME)_TEST_BIN := main-trivium-test.o debug.o uart.o serial-tools.o \ - nessie_stream_test.o nessie_common.o trivium.o cli.o \ - performance_test.o + nessie_stream_test.o nessie_common.o cli.o \ + performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/xtea.mk b/mkfiles/xtea.mk index 38f485b..b4edc30 100644 --- a/mkfiles/xtea.mk +++ b/mkfiles/xtea.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := xtea-asm.o $(ALGO_NAME)_TEST_BIN := main-xtea-test.o debug.o uart.o serial-tools.o \ - xtea-asm.o nessie_bc_test.o nessie_common.o \ - cli.o performance_test.o + nessie_bc_test.o nessie_common.o cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/mkfiles/xtea_c.mk b/mkfiles/xtea_c.mk index 157df87..7ebbded 100644 --- a/mkfiles/xtea_c.mk +++ b/mkfiles/xtea_c.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := xtea.o $(ALGO_NAME)_TEST_BIN := main-xtea-test.o debug.o uart.o serial-tools.o \ - xtea.o nessie_bc_test.o nessie_common.o \ - cli.o performance_test.o + nessie_bc_test.o nessie_common.o cli.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PEROFRMANCE_TEST := "performance" diff --git a/serpent.c b/serpent.c index 8c33bbe..8056eb4 100644 --- a/serpent.c +++ b/serpent.c @@ -26,21 +26,12 @@ #include #include /* memset() */ #include +#include "memxor.h" #include "serpent.h" #include "serpent-sboxes.h" /******************************************************************************/ -void memxor(void * dest, void * src, uint8_t size){ - while(size--){ - *((uint8_t*)dest) ^= *((uint8_t*)src); - dest = (uint8_t*)dest +1; - src = (uint8_t*)src +1; - } -} - -/******************************************************************************/ - uint32_t rotl32(uint32_t a, uint8_t n){ return ((a<>(32-n))); } @@ -92,10 +83,10 @@ static uint32_t gen_w(uint32_t * b, uint8_t i){ } /* key must be 256bit (32 byte) large! */ -void serpent_init(void * key, uint8_t keysize, serpent_ctx_t * ctx){ +void serpent_init(const void* key, uint16_t keysize, serpent_ctx_t* ctx){ uint32_t buffer[8]; uint8_t i,j; - if(keysize){ + if(keysize<256){ /* keysize is less than 256 bit, padding needed */ memset(buffer, 0, 32); memcpy(buffer, key, (keysize+7)/8); @@ -117,7 +108,7 @@ void serpent_init(void * key, uint8_t keysize, serpent_ctx_t * ctx){ } -void serpent_enc(void* buffer, serpent_ctx_t * ctx){ +void serpent_enc(void* buffer, const serpent_ctx_t* ctx){ uint8_t i; for(i=0; i<31; ++i){ memxor((uint8_t*)buffer, ctx->k[i], 16); @@ -130,7 +121,7 @@ void serpent_enc(void* buffer, serpent_ctx_t * ctx){ memxor((uint8_t*)buffer, ctx->k[i], 16); } -void serpent_dec(void* buffer, serpent_ctx_t * ctx){ +void serpent_dec(void* buffer, const serpent_ctx_t* ctx){ int8_t i=32; memxor((uint8_t*)buffer, ctx->k[i], 16); diff --git a/serpent.h b/serpent.h index 084b87a..3e90253 100644 --- a/serpent.h +++ b/serpent.h @@ -16,10 +16,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* serpent.h - * a bitsliced implementation of the serpent cipher for avr microcontrollers - * author: Daniel Otte - * license: GPLv3 +/** \file serpent.h + * \author Daniel Otte + * \license GPLv3 + * \brief a implementation of the serpent cipher for avr microcontrollers */ #ifndef SERPENT_H_ @@ -35,13 +35,13 @@ typedef struct serpent_ctx_st { #define SERPENT_KEY128 128 #define SERPENT_KEY192 192 -#define SERPENT_KEY256 0 +#define SERPENT_KEY256 256 /* key must be 256bit (32 byte) large! */ -void serpent_init(void * key, uint8_t keysize, serpent_ctx_t * ctx); -void serpent_enc(void * buffer, serpent_ctx_t * ctx); -void serpent_dec(void * buffer, serpent_ctx_t * ctx); +void serpent_init(const void* key, uint16_t keysize, serpent_ctx_t* ctx); +void serpent_enc(void* buffer, const serpent_ctx_t* ctx); +void serpent_dec(void* buffer, const serpent_ctx_t* ctx); #endif /*SERPENT_H_*/ diff --git a/cli.c b/test_src/cli.c similarity index 100% rename from cli.c rename to test_src/cli.c diff --git a/cli.h b/test_src/cli.h similarity index 100% rename from cli.h rename to test_src/cli.h diff --git a/debug.c b/test_src/debug.c similarity index 100% rename from debug.c rename to test_src/debug.c diff --git a/main-arcfour-test.c b/test_src/main-arcfour-test.c similarity index 100% rename from main-arcfour-test.c rename to test_src/main-arcfour-test.c diff --git a/main-camellia-test.c b/test_src/main-camellia-test.c similarity index 100% rename from main-camellia-test.c rename to test_src/main-camellia-test.c diff --git a/main-cast5-test.c b/test_src/main-cast5-test.c similarity index 100% rename from main-cast5-test.c rename to test_src/main-cast5-test.c diff --git a/main-des-test.c b/test_src/main-des-test.c similarity index 100% rename from main-des-test.c rename to test_src/main-des-test.c diff --git a/main-entropium-test.c b/test_src/main-entropium-test.c similarity index 100% rename from main-entropium-test.c rename to test_src/main-entropium-test.c diff --git a/main-grain-test.c b/test_src/main-grain-test.c similarity index 100% rename from main-grain-test.c rename to test_src/main-grain-test.c diff --git a/main-hmac-sha1-test.c b/test_src/main-hmac-sha1-test.c similarity index 100% rename from main-hmac-sha1-test.c rename to test_src/main-hmac-sha1-test.c diff --git a/main-hmac-sha256-test.c b/test_src/main-hmac-sha256-test.c similarity index 100% rename from main-hmac-sha256-test.c rename to test_src/main-hmac-sha256-test.c diff --git a/main-md5-test.c b/test_src/main-md5-test.c similarity index 100% rename from main-md5-test.c rename to test_src/main-md5-test.c diff --git a/main-noekeon-test.c b/test_src/main-noekeon-test.c similarity index 100% rename from main-noekeon-test.c rename to test_src/main-noekeon-test.c diff --git a/main-present-test.c b/test_src/main-present-test.c similarity index 100% rename from main-present-test.c rename to test_src/main-present-test.c diff --git a/main-rc5-test.c b/test_src/main-rc5-test.c similarity index 100% rename from main-rc5-test.c rename to test_src/main-rc5-test.c diff --git a/main-rc6-test.c b/test_src/main-rc6-test.c similarity index 100% rename from main-rc6-test.c rename to test_src/main-rc6-test.c diff --git a/main-seed-test.c b/test_src/main-seed-test.c similarity index 100% rename from main-seed-test.c rename to test_src/main-seed-test.c diff --git a/main-serpent-test.c b/test_src/main-serpent-test.c similarity index 100% rename from main-serpent-test.c rename to test_src/main-serpent-test.c diff --git a/main-sha1-test.c b/test_src/main-sha1-test.c similarity index 100% rename from main-sha1-test.c rename to test_src/main-sha1-test.c diff --git a/main-sha256-test.c b/test_src/main-sha256-test.c similarity index 100% rename from main-sha256-test.c rename to test_src/main-sha256-test.c diff --git a/main-shabea-test.c b/test_src/main-shabea-test.c similarity index 100% rename from main-shabea-test.c rename to test_src/main-shabea-test.c diff --git a/main-shacal1_enc-test.c b/test_src/main-shacal1_enc-test.c similarity index 100% rename from main-shacal1_enc-test.c rename to test_src/main-shacal1_enc-test.c diff --git a/main-shacal2_enc-test.c b/test_src/main-shacal2_enc-test.c similarity index 100% rename from main-shacal2_enc-test.c rename to test_src/main-shacal2_enc-test.c diff --git a/main-skipjack-test.c b/test_src/main-skipjack-test.c similarity index 100% rename from main-skipjack-test.c rename to test_src/main-skipjack-test.c diff --git a/main-tdes-test.c b/test_src/main-tdes-test.c similarity index 100% rename from main-tdes-test.c rename to test_src/main-tdes-test.c diff --git a/main-trivium-test.c b/test_src/main-trivium-test.c similarity index 100% rename from main-trivium-test.c rename to test_src/main-trivium-test.c diff --git a/main-xtea-test.c b/test_src/main-xtea-test.c similarity index 100% rename from main-xtea-test.c rename to test_src/main-xtea-test.c diff --git a/nessie_bc_test.c b/test_src/nessie_bc_test.c similarity index 100% rename from nessie_bc_test.c rename to test_src/nessie_bc_test.c diff --git a/nessie_bc_test.h b/test_src/nessie_bc_test.h similarity index 100% rename from nessie_bc_test.h rename to test_src/nessie_bc_test.h diff --git a/nessie_common.c b/test_src/nessie_common.c similarity index 100% rename from nessie_common.c rename to test_src/nessie_common.c diff --git a/nessie_common.h b/test_src/nessie_common.h similarity index 100% rename from nessie_common.h rename to test_src/nessie_common.h diff --git a/nessie_hash_test.c b/test_src/nessie_hash_test.c similarity index 100% rename from nessie_hash_test.c rename to test_src/nessie_hash_test.c diff --git a/nessie_hash_test.h b/test_src/nessie_hash_test.h similarity index 100% rename from nessie_hash_test.h rename to test_src/nessie_hash_test.h diff --git a/nessie_mac_test.c b/test_src/nessie_mac_test.c similarity index 100% rename from nessie_mac_test.c rename to test_src/nessie_mac_test.c diff --git a/nessie_mac_test.h b/test_src/nessie_mac_test.h similarity index 100% rename from nessie_mac_test.h rename to test_src/nessie_mac_test.h diff --git a/nessie_stream_test.c b/test_src/nessie_stream_test.c similarity index 100% rename from nessie_stream_test.c rename to test_src/nessie_stream_test.c diff --git a/nessie_stream_test.h b/test_src/nessie_stream_test.h similarity index 100% rename from nessie_stream_test.h rename to test_src/nessie_stream_test.h diff --git a/performance_test.c b/test_src/performance_test.c similarity index 100% rename from performance_test.c rename to test_src/performance_test.c diff --git a/performance_test.h b/test_src/performance_test.h similarity index 100% rename from performance_test.h rename to test_src/performance_test.h diff --git a/serial-tools.c b/test_src/serial-tools.c similarity index 100% rename from serial-tools.c rename to test_src/serial-tools.c diff --git a/serial-tools.h b/test_src/serial-tools.h similarity index 100% rename from serial-tools.h rename to test_src/serial-tools.h diff --git a/uart.c b/test_src/uart.c similarity index 100% rename from uart.c rename to test_src/uart.c -- 2.39.5