CC = avr-gcc
CSTD = c99
-override CFLAGS = -MMD -MF$(DEP_DIR)$(patsubst %.c,%.d,$(patsubst $(TESTSRC_DIR)%,%,$<)) -I. -gdwarf-2 -pedantic -std=$(CSTD) -Wall -Wstrict-prototypes $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
+override CFLAGS = -MMD -MF$(DEP_DIR)$(patsubst %.c,%.d,$(patsubst $(TESTSRC_DIR)%,%,$<)) -I. -Itest_src -gdwarf-2 -pedantic -std=$(CSTD) -Wall -Wstrict-prototypes $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
override LDFLAGS = -gdwarf-2 -Wl,-Map,
override ASFLAGS = -mmcu=$(MCU_TARGET) -Wa,--gdwarf-2
STREAM_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := A5_1.o
-$(ALGO_NAME)_TEST_BIN := main-a5_1-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-a5_1-test.o debug.o uart.o hexdigit_tab.o \
nessie_stream_test.o dbz_strings.o nessie_common.o cli.o string-extras.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
$(ALGO_NAME)_OBJ := aes_enc-asm.o aes_dec-asm.o aes_sbox-asm.o aes_invsbox-asm.o \
aes_keyschedule-asm.o
-$(ALGO_NAME)_TEST_BIN := main-aes-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-aes-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
$(ALGO_NAME)_OBJ := aes_enc-asm.o aes_dec-asm_faster.o aes_sbox-asm.o aes_invsbox-asm.o \
aes_keyschedule-asm.o
-$(ALGO_NAME)_TEST_BIN := main-aes-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-aes-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
aes_keyschedule.o gf256mul.o \
aes128_enc.o aes128_dec.o aes192_enc.o aes192_dec.o \
aes256_enc.o aes256_dec.o
-$(ALGO_NAME)_TEST_BIN := main-aes-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-aes-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
STREAM_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := arcfour-asm.o
-$(ALGO_NAME)_TEST_BIN := main-arcfour-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-arcfour-test.o debug.o uart.o hexdigit_tab.o \
nessie_stream_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
STREAM_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := arcfour.o
-$(ALGO_NAME)_TEST_BIN := main-arcfour-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-arcfour-test.o debug.o uart.o hexdigit_tab.o \
nessie_stream_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_OBJ := base64_enc.o base64_dec.o
-$(ALGO_NAME)_TEST_BIN := main-base64-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-base64-test.o debug.o uart.o hexdigit_tab.o \
cli.o string-extras.o performance_test.o noekeon_asm.o noekeon_prng.o \
memxor.o
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := camellia128-stub.o camellia-asm.o
-$(ALGO_NAME)_TEST_BIN := main-camellia-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-camellia-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o \
dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := cast5.o
-$(ALGO_NAME)_TEST_BIN := main-cast5-test.o debug.o uart.o hexdigit_tab.o serial-tools.o cli.o string-extras.o\
+$(ALGO_NAME)_TEST_BIN := main-cast5-test.o debug.o uart.o hexdigit_tab.o cli.o string-extras.o\
nessie_bc_test.o dbz_strings.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := des.o
-$(ALGO_NAME)_TEST_BIN := main-des-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-des-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
PRNGS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := entropium.o sha256-asm.o
-$(ALGO_NAME)_TEST_BIN := main-entropium-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-entropium-test.o debug.o uart.o hexdigit_tab.o \
cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
STREAM_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := grain.o
-$(ALGO_NAME)_TEST_BIN := main-grain-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-grain-test.o debug.o uart.o hexdigit_tab.o \
nessie_stream_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
MACS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := hmac-md5.o md5-asm.o
-$(ALGO_NAME)_TEST_BIN := main-hmac-md5-test.o debug.o uart.o hexdigit_tab.o serial-tools.o cli.o string-extras.o \
+$(ALGO_NAME)_TEST_BIN := main-hmac-md5-test.o debug.o uart.o hexdigit_tab.o cli.o string-extras.o \
nessie_mac_test.o dbz_strings.o nessie_common.o base64_enc.o base64_dec.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
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 hexdigit_tab.o serial-tools.o cli.o string-extras.o \
+$(ALGO_NAME)_TEST_BIN := main-hmac-sha1-test.o debug.o uart.o hexdigit_tab.o cli.o string-extras.o \
nessie_mac_test.o dbz_strings.o nessie_common.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
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 hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-hmac-sha256-test.o debug.o uart.o hexdigit_tab.o \
nessie_mac_test.o dbz_strings.o nessie_common.o cli.o string-extras.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := md5.o
-$(ALGO_NAME)_TEST_BIN := main-md5-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-md5-test.o debug.o uart.o hexdigit_tab.o \
nessie_hash_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := md5-asm.o
-$(ALGO_NAME)_TEST_BIN := main-md5-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-md5-test.o debug.o uart.o hexdigit_tab.o \
nessie_hash_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
STREAM_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := mugi.o gf256mul.o aes_sbox.o
-$(ALGO_NAME)_TEST_BIN := main-mugi-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-mugi-test.o debug.o uart.o hexdigit_tab.o \
nessie_stream_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_OBJ := noekeon_asm.o
-$(ALGO_NAME)_TEST_BIN := main-noekeon-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-noekeon-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
$(ALGO_NAME)_OBJ := noekeon.o
-$(ALGO_NAME)_TEST_BIN := main-noekeon-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-noekeon-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
$(ALGO_NAME)_OBJ := noekeon_asm.o omac_noekeon.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-omac-noekeon-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-omac-noekeon-test.o debug.o uart.o hexdigit_tab.o \
nessie_mac_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
$(ALGO_NAME)_OBJ := noekeon_asm.o omac_noekeon_C.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-omac-noekeon-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-omac-noekeon-test.o debug.o uart.o hexdigit_tab.o \
nessie_mac_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
$(ALGO_NAME)_OBJ := present.o
-$(ALGO_NAME)_TEST_BIN := main-present-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-present-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
$(ALGO_NAME)_OBJ := rc5.o
-$(ALGO_NAME)_TEST_BIN := main-rc5-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-rc5-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o \
dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_OBJ := rc6.o
-$(ALGO_NAME)_TEST_BIN := main-rc6-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-rc6-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := seed-asm.o
-$(ALGO_NAME)_TEST_BIN := main-seed-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-seed-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o \
cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := seed_C.o
-$(ALGO_NAME)_TEST_BIN := main-seed-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-seed-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o \
cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_OBJ := serpent-asm.o serpent-sboxes-bitslice-asm.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
$(ALGO_NAME)_OBJ := serpent-sboxes-bitslice-asm.o serpent-asm.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
$(ALGO_NAME)_OBJ := serpent-asm.o serpent-sboxes-fast.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
$(ALGO_NAME)_OBJ := serpent-asm.o serpent-sboxes-small.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
$(ALGO_NAME)_OBJ := serpent.o serpent-sboxes_c.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := sha1-asm.o
-$(ALGO_NAME)_TEST_BIN := main-sha1-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-sha1-test.o debug.o uart.o hexdigit_tab.o \
nessie_hash_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
performance_test.o hfal-basic.o hfal_sha1.o shavs.o dump.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := sha1.o
-$(ALGO_NAME)_TEST_BIN := main-sha1-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-sha1-test.o debug.o uart.o hexdigit_tab.o \
nessie_hash_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
performance_test.o hfal-basic.o hfal_sha1.o shavs.o dump.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := sha256-asm.o
-$(ALGO_NAME)_TEST_BIN := main-sha256-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-sha256-test.o debug.o uart.o hexdigit_tab.o \
nessie_hash_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o \
hfal-basic.o hfal_sha256.o shavs.o dump.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := sha256.o
-$(ALGO_NAME)_TEST_BIN := main-sha256-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-sha256-test.o debug.o uart.o hexdigit_tab.o \
nessie_hash_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o \
hfal-basic.o hfal_sha256.o shavs.o dump.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := shabea.o sha256-asm.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-shabea-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-shabea-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
$(ALGO_NAME)_OBJ := shacal1_enc.o sha1-asm.o
-$(ALGO_NAME)_TEST_BIN := main-shacal1_enc-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-shacal1_enc-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
$(ALGO_NAME)_OBJ := shacal2_enc.o sha256-asm.o
-$(ALGO_NAME)_TEST_BIN := main-shacal2_enc-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-shacal2_enc-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := skipjack.o
-$(ALGO_NAME)_TEST_BIN := main-skipjack-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-skipjack-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := des.o
-$(ALGO_NAME)_TEST_BIN := main-tdes-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-tdes-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
--- /dev/null
+# Makefile for noekeon
+ALGO_NAME := THREEFISH_C
+
+# comment out the following line for removement of threefish from the build process
+BLOCK_CIPHERS += $(ALGO_NAME)
+
+
+$(ALGO_NAME)_OBJ := threefish256_enc.o threefish512_enc.o threefish1024_enc.o
+$(ALGO_NAME)_TEST_BIN := main-threefish-test.o debug.o uart.o hexdigit_tab.o \
+ nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_NESSIE_TEST := test nessie
+$(ALGO_NAME)_PERFORMANCE_TEST := performance
+
STREAM_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := trivium.o
-$(ALGO_NAME)_TEST_BIN := main-trivium-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-trivium-test.o debug.o uart.o hexdigit_tab.o \
nessie_stream_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := twister-small-asm.o twister-asm.o twister224.o
-$(ALGO_NAME)_TEST_BIN := main-twister224-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-twister224-test.o debug.o uart.o hexdigit_tab.o \
nessie_hash_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := twister.o twister-small.o memxor.o gf256mul.o
-$(ALGO_NAME)_TEST_BIN := main-twister224-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-twister224-test.o debug.o uart.o hexdigit_tab.o \
nessie_hash_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := twister-asm.o twister-small-asm.o twister256.o
-$(ALGO_NAME)_TEST_BIN := main-twister256-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-twister256-test.o debug.o uart.o hexdigit_tab.o \
nessie_hash_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := twister.o twister-small.o memxor.o gf256mul.o
-$(ALGO_NAME)_TEST_BIN := main-twister256-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-twister256-test.o debug.o uart.o hexdigit_tab.o \
nessie_hash_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := twister-asm.o twister-big-asm.o twister384.o
-$(ALGO_NAME)_TEST_BIN := main-twister384-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-twister384-test.o debug.o uart.o hexdigit_tab.o \
nessie_hash_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := twister.o twister-big.o memxor.o gf256mul.o
-$(ALGO_NAME)_TEST_BIN := main-twister384-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-twister384-test.o debug.o uart.o hexdigit_tab.o \
nessie_hash_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := twister-asm.o twister-big-asm.o twister512.o
-$(ALGO_NAME)_TEST_BIN := main-twister512-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-twister512-test.o debug.o uart.o hexdigit_tab.o \
nessie_hash_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := twister.o twister-big.o memxor.o gf256mul.o
-$(ALGO_NAME)_TEST_BIN := main-twister512-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-twister512-test.o debug.o uart.o hexdigit_tab.o \
nessie_hash_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
--- /dev/null
+# Makefile for noekeon
+ALGO_NAME := UBI_C
+
+# comment out the following line for removement of threefish from the build process
+BLOCK_CIPHERS += $(ALGO_NAME)
+
+
+$(ALGO_NAME)_OBJ := threefish256_enc.o threefish512_enc.o threefish1024_enc.o \
+ ubi256.o ubi512.o ubi1024.o memxor.o
+$(ALGO_NAME)_TEST_BIN := main-ubi-test.o debug.o uart.o hexdigit_tab.o \
+ dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_NESSIE_TEST := test nessie
+$(ALGO_NAME)_PERFORMANCE_TEST := performance
+
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := xtea-asm.o
-$(ALGO_NAME)_TEST_BIN := main-xtea-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-xtea-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := xtea.o
-$(ALGO_NAME)_TEST_BIN := main-xtea-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
+$(ALGO_NAME)_TEST_BIN := main-xtea-test.o debug.o uart.o hexdigit_tab.o \
nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
+/*
+ This file is part of the AVR-Crypto-Lib.
+ Copyright (C) 2008, 2009 Daniel Otte (daniel.otte@rub.de)
+
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ * \author Daniel Otte
+ * \email daniel.otte@rub.de
+ * \license GPLv3 or later
+ *
+ *
+ *
+ */
+
#ifndef NOEKEON_OMAC_H_
#define NOEKEON_OMAC_H_
/** \fn uint8_t dbz_strcount(const char* str)
* \brief count stings in dbz-terminated string
*
- * Count the single zero terminated string in a
+ * Count the single zero terminated strings in a
* double terminated string
* \param str pointer to the double-zero-terminated string
*/
--- /dev/null
+/* main-threefish-test.c */
+/*
+ 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
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ * threefish test-suit
+ *
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "threefish.h"
+#include "nessie_bc_test.h"
+#include "cli.h"
+#include "performance_test.h"
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+char* algo_name = "Threefish";
+
+/*****************************************************************************
+ * additional validation-functions *
+ *****************************************************************************/
+void testrun_stdtest_threefish256(void){
+ uint8_t key[32], data[32];
+ uint8_t tweak[16];
+ uint8_t i;
+ threefish256_ctx_t ctx;
+
+ cli_putstr_P(PSTR("\r\n\r\nTest vectors for block cipher Threefish (256 bits):"));
+ memset(key, 0, 32);
+ memset(data, 0, 32);
+ memset(tweak, 0, 16);
+
+ cli_putstr_P(PSTR("\r\nkey: "));
+ cli_hexdump(key, 32);
+ cli_putstr_P(PSTR("\r\ntweak: "));
+ cli_hexdump(tweak, 16);
+ cli_putstr_P(PSTR("\r\nplain: "));
+ cli_hexdump(data, 32);
+ threefish256_init(key, tweak, &ctx);
+ threefish256_enc(data, &ctx);
+ cli_putstr_P(PSTR("\r\ncipher: "));
+ cli_hexdump(data, 32);
+
+ for(i=0; i<32; ++i){
+ key[i] = 0x10+i;
+ data[i] = 0xFF-i;
+ }
+ for(i=0; i<16; ++i){
+ tweak[i] = i;
+ }
+ cli_putstr_P(PSTR("\r\n\r\nkey: "));
+ cli_hexdump(key, 32);
+ cli_putstr_P(PSTR("\r\ntweak: "));
+ cli_hexdump(tweak, 16);
+ cli_putstr_P(PSTR("\r\nplain: "));
+ cli_hexdump(data, 32);
+ threefish256_init(key, tweak, &ctx);
+ threefish256_enc(data, &ctx);
+ cli_putstr_P(PSTR("\r\ncipher: "));
+ cli_hexdump(data, 32);
+}
+
+void testrun_stdtest_threefish512(void){
+ uint8_t key[64], data[64];
+ uint8_t tweak[16];
+ uint8_t i;
+ threefish512_ctx_t ctx;
+
+ cli_putstr_P(PSTR("\r\n\r\nTest vectors for block cipher Threefish (512 bits) :"));
+ memset(key, 0, 64);
+ memset(data, 0, 64);
+ memset(tweak, 0, 16);
+
+ cli_putstr_P(PSTR("\r\nkey: "));
+ cli_hexdump(key, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(key+32, 32);
+ cli_putstr_P(PSTR("\r\ntweak: "));
+ cli_hexdump(tweak, 16);
+ cli_putstr_P(PSTR("\r\nplain: "));
+ cli_hexdump(data, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(data+32, 32);
+ threefish512_init(key, tweak, &ctx);
+ threefish512_enc(data, &ctx);
+ cli_putstr_P(PSTR("\r\ncipher: "));
+ cli_hexdump(data, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(data+32, 32);
+
+ for(i=0; i<64; ++i){
+ key[i] = 0x10+i;
+ data[i] = 0xFF-i;
+ }
+ for(i=0; i<16; ++i){
+ tweak[i] = i;
+ }
+ cli_putstr_P(PSTR("\r\n\r\nkey: "));
+ cli_hexdump(key, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(key+32, 32);
+ cli_putstr_P(PSTR("\r\ntweak: "));
+ cli_hexdump(tweak, 16);
+ cli_putstr_P(PSTR("\r\nplain: "));
+ cli_hexdump(data, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(data+32, 32);
+ threefish512_init(key, tweak, &ctx);
+ threefish512_enc(data, &ctx);
+ cli_putstr_P(PSTR("\r\ncipher: "));
+ cli_hexdump(data, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(data+32, 32);
+}
+
+void testrun_stdtest_threefish1024(void){
+ uint8_t key[128], data[128];
+ uint8_t tweak[16];
+ uint8_t i;
+ threefish1024_ctx_t ctx;
+
+ cli_putstr_P(PSTR("\r\n\r\nTest vectors for block cipher Threefish (1024 bits) :"));
+ memset(key, 0, 128);
+ memset(data, 0, 128);
+ memset(tweak, 0, 16);
+
+ cli_putstr_P(PSTR("\r\nkey: "));
+ cli_hexdump(key, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(key+32, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(key+64, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(key+96, 32);
+ cli_putstr_P(PSTR("\r\ntweak: "));
+ cli_hexdump(tweak, 16);
+ cli_putstr_P(PSTR("\r\nplain: "));
+ cli_hexdump(data, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(data+32, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(data+64, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(data+96, 32);
+ threefish1024_init(key, tweak, &ctx);
+ threefish1024_enc(data, &ctx);
+ cli_putstr_P(PSTR("\r\ncipher: "));
+ cli_hexdump(data, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(data+32, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(data+64, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(data+96, 32);
+
+ for(i=0; i<128; ++i){
+ key[i] = 0x10+i;
+ data[i] = 0xFF-i;
+ }
+ for(i=0; i<16; ++i){
+ tweak[i] = i;
+ }
+ cli_putstr_P(PSTR("\r\n\r\nkey: "));
+ cli_hexdump(key, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(key+32, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(key+64, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(key+96, 32);
+ cli_putstr_P(PSTR("\r\ntweak: "));
+ cli_hexdump(tweak, 16);
+ cli_putstr_P(PSTR("\r\nplain: "));
+ cli_hexdump(data, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(data+32, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(data+64, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(data+96, 32);
+ threefish1024_init(key, tweak, &ctx);
+ threefish1024_enc(data, &ctx);
+ cli_putstr_P(PSTR("\r\ncipher: "));
+ cli_hexdump(data, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(data+32, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(data+64, 32);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump(data+96, 32);
+ }
+
+
+void testrun_stdtest_threefish(void){
+ testrun_stdtest_threefish256();
+ testrun_stdtest_threefish512();
+ testrun_stdtest_threefish1024();
+}
+/*****************************************************************************
+ * main *
+ *****************************************************************************/
+
+const char nessie_str[] PROGMEM = "nessie";
+const char test_str[] PROGMEM = "test";
+const char performance_str[] PROGMEM = "performance";
+const char echo_str[] PROGMEM = "echo";
+
+cmdlist_entry_t cmdlist[] PROGMEM = {
+// { nessie_str, NULL, testrun_nessie_noekeon},
+ { test_str, NULL, testrun_stdtest_threefish},
+// { performance_str, NULL, testrun_performance_noekeon},
+ { echo_str, (void*)1, (void_fpt)echo_ctrl},
+ { NULL, NULL, NULL}
+};
+
+int main (void){
+ DEBUG_INIT();
+
+ cli_rx = uart_getc;
+ cli_tx = uart_putc;
+ for(;;){
+ cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+ cli_putstr(algo_name);
+ cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ cmd_interface(cmdlist);
+ }
+}
--- /dev/null
+/* main-threefish-test.c */
+/*
+ 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
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ * threefish test-suit
+ *
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "ubi.h"
+#include "cli.h"
+#include "performance_test.h"
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+char* algo_name = "UBI-Threefish";
+
+/*****************************************************************************
+ * additional validation-functions *
+ *****************************************************************************/
+void testrun_stdtest_ubi256(uint16_t outsize){
+ ubi256_ctx_t ctx;
+ skein_config_t conf;
+ uint64_t iv[4];
+
+ cli_putstr_P(PSTR("\r\n\r\nTest vectors for UBI (256 bits):"));
+ memset(&conf, 0, sizeof(skein_config_t));
+
+ ubi256_init(&ctx, &conf, UBI_TYPE_CFG);
+ conf.schema[0] = 'S';
+ conf.schema[1] = 'H';
+ conf.schema[2] = 'A';
+ conf.schema[3] = '3';
+ conf.version = 1;
+ conf.out_length = outsize;
+ ubi256_lastBlock(&ctx, &conf, 256);
+ ubi256_ctx2hash(iv, &ctx);
+
+ cli_putstr_P(PSTR("\r\nIV: "));
+ cli_hexdump_rev(&(iv[0]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[1]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[2]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[3]), 8);
+}
+
+void testrun_stdtest_ubi512(uint16_t outsize){
+ ubi512_ctx_t ctx;
+ skein_config_t conf;
+ uint64_t iv[8];
+ uint8_t null[UBI512_BLOCKSIZE_B];
+
+ cli_putstr_P(PSTR("\r\n\r\nTest vectors for UBI (512 bits):"));
+ memset(&conf, 0, sizeof(skein_config_t));
+ memset(null, 0, UBI512_BLOCKSIZE_B);
+ ubi512_init(&ctx, null, UBI_TYPE_CFG);
+ conf.schema[0] = 'S';
+ conf.schema[1] = 'H';
+ conf.schema[2] = 'A';
+ conf.schema[3] = '3';
+ conf.version = 1;
+ conf.out_length = outsize;
+ ubi512_lastBlock(&ctx, &conf, 256);
+ ubi512_ctx2hash(iv, &ctx);
+
+ cli_putstr_P(PSTR("\r\nIV: "));
+ cli_hexdump_rev(&(iv[0]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[1]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[2]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[3]), 8);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump_rev(&(iv[4]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[5]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[6]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[7]), 8);
+}
+
+void testrun_stdtest_ubi1024(uint16_t outsize){
+ ubi1024_ctx_t ctx;
+ skein_config_t conf;
+ uint64_t iv[16];
+ uint8_t null[UBI1024_BLOCKSIZE_B];
+
+ cli_putstr_P(PSTR("\r\n\r\nTest vectors for UBI (1024 bits):"));
+ memset(&conf, 0, sizeof(skein_config_t));
+
+ memset(null, 0, UBI1024_BLOCKSIZE_B);
+ ubi1024_init(&ctx, null, UBI_TYPE_CFG);
+ conf.schema[0] = 'S';
+ conf.schema[1] = 'H';
+ conf.schema[2] = 'A';
+ conf.schema[3] = '3';
+ conf.version = 1;
+ conf.out_length = outsize;
+ ubi1024_lastBlock(&ctx, &conf, 256);
+ ubi1024_ctx2hash(iv, &ctx);
+
+ cli_putstr_P(PSTR("\r\nIV: "));
+ cli_hexdump_rev(&(iv[0]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[1]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[2]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[3]), 8);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump_rev(&(iv[4]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[5]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[6]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[7]), 8);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump_rev(&(iv[8]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[9]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[10]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[11]), 8);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_hexdump_rev(&(iv[12]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[13]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[14]), 8);
+ cli_putstr_P(PSTR(" "));
+ cli_hexdump_rev(&(iv[15]), 8);
+}
+
+void testrun_stdtest_ubi(void){
+ testrun_stdtest_ubi256(128);
+ testrun_stdtest_ubi256(160);
+ testrun_stdtest_ubi256(224);
+ testrun_stdtest_ubi256(256);
+
+ testrun_stdtest_ubi512(128);
+ testrun_stdtest_ubi512(160);
+ testrun_stdtest_ubi512(224);
+ testrun_stdtest_ubi512(256);
+ testrun_stdtest_ubi512(384);
+ testrun_stdtest_ubi512(512);
+
+ testrun_stdtest_ubi1024(384);
+ testrun_stdtest_ubi1024(512);
+ testrun_stdtest_ubi1024(1024);
+}
+
+/*****************************************************************************
+ * main *
+ *****************************************************************************/
+
+const char nessie_str[] PROGMEM = "nessie";
+const char test_str[] PROGMEM = "test";
+const char performance_str[] PROGMEM = "performance";
+const char echo_str[] PROGMEM = "echo";
+
+cmdlist_entry_t cmdlist[] PROGMEM = {
+// { nessie_str, NULL, testrun_nessie_noekeon},
+ { test_str, NULL, testrun_stdtest_ubi},
+// { performance_str, NULL, testrun_performance_noekeon},
+ { echo_str, (void*)1, (void_fpt)echo_ctrl},
+ { NULL, NULL, NULL}
+};
+
+int main (void){
+ DEBUG_INIT();
+
+ cli_rx = uart_getc;
+ cli_tx = uart_putc;
+ for(;;){
+ cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+ cli_putstr(algo_name);
+ cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ cmd_interface(cmdlist);
+ }
+}
--- /dev/null
+/* threefish.c */
+/*
+ This file is part of the AVR-Crypto-Lib.
+ Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
+
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ * \author Daniel Otte
+ * \email daniel.otte@rub.de
+ * \date 2009-03-12
+ * \license GPLv3 or later
+ */
+
+#ifndef THREEFISH_H_
+#define THREEFISH_H_
+
+#include <stdint.h>
+
+typedef struct{
+ uint64_t k[5];
+ uint64_t t[3];
+} threefish256_ctx_t;
+
+
+typedef struct{
+ uint64_t k[9];
+ uint64_t t[3];
+} threefish512_ctx_t;
+
+
+typedef struct{
+ uint64_t k[17];
+ uint64_t t[3];
+} threefish1024_ctx_t;
+
+
+
+void threefish256_init(void* key, void* tweak, threefish256_ctx_t* ctx);
+void threefish512_init(void* key, void* tweak, threefish512_ctx_t* ctx);
+void threefish1024_init(void* key, void* tweak, threefish1024_ctx_t* ctx);
+
+void threefish256_enc(void* data, threefish256_ctx_t* ctx);
+void threefish512_enc(void* data, threefish512_ctx_t* ctx);
+void threefish1024_enc(void* data, threefish1024_ctx_t* ctx);
+
+#endif /* THREEFISH_H_ */
--- /dev/null
+/* threefish1024_enc.c */
+/*
+ This file is part of the AVR-Crypto-Lib.
+ Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
+
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ * \author Daniel Otte
+ * \email daniel.otte@rub.de
+ * \date 2009-03-12
+ * \license GPLv3 or later
+ *
+ *
+ *
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include "threefish.h"
+
+#define X0 (((uint64_t*)data)[0])
+#define X1 (((uint64_t*)data)[1])
+static
+void mix(void* data, uint8_t rot){
+ uint64_t x;
+ x = X1;
+ X0 += x;
+ X1 = ((x<<rot)|(x>>(64-rot))) ^ X0;
+}
+
+#define X(a) (((uint64_t*)data)[(a)])
+
+static
+void permute_16(void* data){
+ uint64_t t;
+ t = X(1);
+ X(1) = X(9);
+ X(9) = X(7);
+ X(7) = X(15);
+ X(15) = t;
+ t = X(3);
+ X(3) = X(13);
+ X(13) = X(5);
+ X(5) = X(11);
+ X(11) = t;
+ t = X(4);
+ X(4) = X(6);
+ X(6) = t;
+ t = X(8);
+ X(8) = X(10);
+ X(10) = X(12);
+ X(12) = X(14);
+ X(14) = t;
+}
+
+#define THREEFISH_KEY_CONST 0x5555555555555555LL /* 2**64/3 */
+
+#define K(s) (((uint64_t*)key)[(s)])
+#define T(s) (((uint64_t*)tweak)[(s)])
+
+void threefish1024_init(void* key, void* tweak, threefish1024_ctx_t* ctx){
+ memcpy(ctx->k, key, 16*8);
+ memcpy(ctx->t, tweak, 2*8);
+ uint8_t i;
+ ctx->k[16] = THREEFISH_KEY_CONST;
+ for(i=0; i<16; ++i){
+ ctx->k[16] ^= K(i);
+ }
+ ctx->t[2] = T(0) ^ T(1);
+}
+
+static
+void add_key_16(void* data, threefish1024_ctx_t* ctx, uint8_t s){
+ uint8_t i;
+ for(i=0; i<13; ++i){
+ X(i) += ctx->k[(s+i)%17];
+ }
+ X(13) += ctx->k[(s+13)%17] + ctx->t[s%3];
+ X(14) += ctx->k[(s+14)%17] + ctx->t[(s+1)%3];
+ X(15) += ctx->k[(s+15)%17] + s;
+}
+
+void threefish1024_enc(void* data, threefish1024_ctx_t* ctx){
+ uint8_t i=0,s=0;
+ uint8_t r0[8] = {55, 25, 33, 34, 28, 17, 58, 47};
+ uint8_t r1[8] = {43, 25, 8, 43, 7, 6, 7, 49};
+ uint8_t r2[8] = {37, 46, 18, 25, 47, 18, 32, 27};
+ uint8_t r3[8] = {40, 13, 57, 60, 48, 25, 45, 58};
+ uint8_t r4[8] = {16, 14, 21, 44, 51, 43, 19, 37};
+ uint8_t r5[8] = {22, 13, 12, 9, 9, 42, 18, 48};
+ uint8_t r6[8] = {38, 52, 32, 59, 35, 40, 2, 53};
+ uint8_t r7[8] = {12, 57, 54, 34, 41, 15, 56, 56};
+
+ do{
+ if(i%4==0){
+ add_key_16(data, ctx, s);
+ ++s;
+ }
+ mix((uint8_t*)data + 0, r0[i%8]);
+ mix((uint8_t*)data + 16, r1[i%8]);
+ mix((uint8_t*)data + 32, r2[i%8]);
+ mix((uint8_t*)data + 48, r3[i%8]);
+ mix((uint8_t*)data + 64, r4[i%8]);
+ mix((uint8_t*)data + 80, r5[i%8]);
+ mix((uint8_t*)data + 96, r6[i%8]);
+ mix((uint8_t*)data +112, r7[i%8]);
+ permute_16(data);
+ ++i;
+ }while(i!=80);
+ add_key_16(data, ctx, s);
+}
--- /dev/null
+/* threefish256_enc.c */
+/*
+ This file is part of the AVR-Crypto-Lib.
+ Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
+
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ * \author Daniel Otte
+ * \email daniel.otte@rub.de
+ * \date 2009-03-12
+ * \license GPLv3 or later
+ *
+ *
+ *
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include "threefish.h"
+
+#define X0 (((uint64_t*)data)[0])
+#define X1 (((uint64_t*)data)[1])
+static
+void mix(void* data, uint8_t rot){
+ uint64_t x;
+ x = X1;
+ X0 += x;
+ X1 = ((x<<rot)|(x>>(64-rot))) ^ X0;
+}
+
+#define X(a) (((uint64_t*)data)[(a)])
+static
+void permute_4(void* data){
+ uint64_t t;
+ t = X(1);
+ X(1) = X(3);
+ X(3) = t;
+}
+
+#define THREEFISH_KEY_CONST 0x5555555555555555LL /* 2**64/3 */
+
+#define K(s) (((uint64_t*)key)[(s)])
+#define T(s) (((uint64_t*)tweak)[(s)])
+
+void threefish256_init(void* key, void* tweak, threefish256_ctx_t* ctx){
+ memcpy(ctx->k, key, 4*8);
+ memcpy(ctx->t, tweak, 2*8);
+ uint8_t i;
+ ctx->k[4] = THREEFISH_KEY_CONST;
+ for(i=0; i<4; ++i){
+ ctx->k[4] ^= K(i);
+ }
+ ctx->t[2] = T(0) ^ T(1);
+}
+
+static
+void add_key_4(void* data, threefish256_ctx_t* ctx, uint8_t s){
+ X(0) += ctx->k[(s+0)%5];
+ X(1) += ctx->k[(s+1)%5] + ctx->t[s%3];
+ X(2) += ctx->k[(s+2)%5] + ctx->t[(s+1)%3];
+ X(3) += ctx->k[(s+3)%5] + s;
+}
+
+void threefish256_enc(void* data, threefish256_ctx_t* ctx){
+ uint8_t i=0,s=0;
+ uint8_t r0[8] = { 5, 36, 13, 58, 26, 53, 11, 59};
+ uint8_t r1[8] = {56, 28, 46, 44, 20, 35, 42, 50};
+ do{
+ if(i%4==0){
+ add_key_4(data, ctx, s);
+ ++s;
+ }
+ mix(data, r0[i%8]);
+ mix((uint8_t*)data + 16, r1[i%8]);
+ permute_4(data);
+ ++i;
+ }while(i!=72);
+ add_key_4(data, ctx, s);
+}
+
--- /dev/null
+/* threefish512_enc.c */
+/*
+ This file is part of the AVR-Crypto-Lib.
+ Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
+
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ * \author Daniel Otte
+ * \email daniel.otte@rub.de
+ * \date 2009-03-12
+ * \license GPLv3 or later
+ *
+ *
+ *
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include "threefish.h"
+
+#define X0 (((uint64_t*)data)[0])
+#define X1 (((uint64_t*)data)[1])
+static
+void mix(void* data, uint8_t rot){
+ uint64_t x;
+ x = X1;
+ X0 += x;
+ X1 = ((x<<rot)|(x>>(64-rot))) ^ X0;
+}
+
+#define X(a) (((uint64_t*)data)[(a)])
+
+static
+void permute_8(void* data){
+ uint64_t t;
+ t = X(0);
+ X(0) = X(2);
+ X(2) = X(4);
+ X(4) = X(6);
+ X(6) = t;
+ t = X(3);
+ X(3) = X(7);
+ X(7) = t;
+}
+/*
+static
+void permute_inv8(void* data){
+ uint64_t t;
+ t = X(6);
+ X(6) = X(4);
+ X(4) = X(2);
+ X(2) = X(0);
+ X(0) = t;
+ t = X(7);
+ X(7) = X(3);
+ X(3) = t;
+}
+*/
+
+#define THREEFISH_KEY_CONST 0x5555555555555555LL /* 2**64/3 */
+
+#define K(s) (((uint64_t*)key)[(s)])
+#define T(s) (((uint64_t*)tweak)[(s)])
+
+void threefish512_init(void* key, void* tweak, threefish512_ctx_t* ctx){
+ memcpy(ctx->k, key, 8*8);
+ memcpy(ctx->t, tweak, 2*8);
+ uint8_t i;
+ ctx->k[8] = THREEFISH_KEY_CONST;
+ for(i=0; i<8; ++i){
+ ctx->k[8] ^= K(i);
+ }
+ ctx->t[2] = T(0) ^ T(1);
+}
+
+static
+void add_key_8(void* data, threefish512_ctx_t* ctx, uint8_t s){
+ uint8_t i;
+ for(i=0; i<5; ++i){
+ X(i) += ctx->k[(s+i)%9];
+ }
+ X(5) += ctx->k[(s+5)%9] + ctx->t[s%3];
+ X(6) += ctx->k[(s+6)%9] + ctx->t[(s+1)%3];
+ X(7) += ctx->k[(s+7)%9] + s;
+}
+
+void threefish512_enc(void* data, threefish512_ctx_t* ctx){
+ uint8_t i=0,s=0;
+ uint8_t r0[8] = {38, 48, 34, 26, 33, 39, 29, 33};
+ uint8_t r1[8] = {30, 20, 14, 12, 49, 27, 26, 51};
+ uint8_t r2[8] = {50, 43, 15, 58, 8, 41, 11, 39};
+ uint8_t r3[8] = {53, 31, 27, 7, 42, 14, 9, 35};
+ do{
+ if(i%4==0){
+ add_key_8(data, ctx, s);
+ ++s;
+ }
+ mix((uint8_t*)data + 0, r0[i%8]);
+ mix((uint8_t*)data + 16, r1[i%8]);
+ mix((uint8_t*)data + 32, r2[i%8]);
+ mix((uint8_t*)data + 48, r3[i%8]);
+ permute_8(data);
+ ++i;
+ }while(i!=72);
+ add_key_8(data, ctx, s);
+}
+
--- /dev/null
+/* ubi.h */
+/*
+ This file is part of the AVR-Crypto-Lib.
+ Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
+
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ * \author Daniel Otte
+ * \email daniel.otte@rub.de
+ * \date 2009-03-12
+ * \license GPLv3 or later
+ *
+ */
+
+#ifndef UBI_H_
+#define UBI_H_
+
+#include <stdint.h>
+
+#define UBI_TYPE_KEY 0
+#define UBI_TYPE_CFG 4
+#define UBI_TYPE_PRS 8
+#define UBI_TYPE_PK 12
+#define UBI_TYPE_KDF 16
+#define UBI_TYPE_NON 20
+#define UBI_TYPE_MSG 48
+#define UBI_TYPE_OUT 63
+
+#define UBI256_BLOCKSIZE 256
+#define UBI256_BLOCKSIZE_B ((UBI256_BLOCKSIZE+7)/8)
+
+#define UBI512_BLOCKSIZE 512
+#define UBI512_BLOCKSIZE_B ((UBI512_BLOCKSIZE+7)/8)
+
+#define UBI1024_BLOCKSIZE 1024
+#define UBI1024_BLOCKSIZE_B ((UBI1024_BLOCKSIZE+7)/8)
+
+
+typedef struct{
+ uint8_t tweak[16];
+ uint8_t g[32];
+}ubi256_ctx_t;
+
+typedef struct{
+ uint8_t tweak[16];
+ uint8_t g[64];
+}ubi512_ctx_t;
+
+typedef struct{
+ uint8_t tweak[16];
+ uint8_t g[128];
+}ubi1024_ctx_t;
+
+void ubi256_init(ubi256_ctx_t* ctx, void* g, uint8_t type);
+void ubi256_nextBlock(ubi256_ctx_t* ctx, void* block);
+void ubi256_lastBlock(ubi256_ctx_t* ctx, void* block, uint16_t length_b);
+void ubi256_ctx2hash(void* dest, ubi256_ctx_t* ctx);
+
+void ubi512_init(ubi512_ctx_t* ctx, void* g, uint8_t type);
+void ubi512_nextBlock(ubi512_ctx_t* ctx, void* block);
+void ubi512_lastBlock(ubi512_ctx_t* ctx, void* block, uint16_t length_b);
+void ubi512_ctx2hash(void* dest, ubi512_ctx_t* ctx);
+
+void ubi1024_init(ubi1024_ctx_t* ctx, void* g, uint8_t type);
+void ubi1024_nextBlock(ubi1024_ctx_t* ctx, void* block);
+void ubi1024_lastBlock(ubi1024_ctx_t* ctx, void* block, uint16_t length_b);
+void ubi1024_ctx2hash(void* dest, ubi1024_ctx_t* ctx);
+
+typedef struct{
+ char schema[4];
+ uint16_t version;
+ uint16_t reserved1;
+ uint64_t out_length;
+ uint8_t tree_leaf_size;
+ uint8_t tree_fan_out;
+ uint8_t tree_max_height;
+ uint8_t reserved2[13];
+}skein_config_t;
+
+
+#endif /* UBI_H_ */
--- /dev/null
+/* ubi1024.c */
+/*
+ This file is part of the AVR-Crypto-Lib.
+ Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
+
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ * \author Daniel Otte
+ * \email daniel.otte@rub.de
+ * \date 2009-03-12
+ * \license GPLv3 or later
+ *
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include "threefish.h"
+#include "memxor.h"
+#include "ubi.h"
+
+void ubi1024_init(ubi1024_ctx_t* ctx, void* g, uint8_t type){
+ memset(ctx->tweak, 0, 15);
+ ctx->tweak[15] = 0x40+type;
+ memcpy(ctx->g, g, UBI1024_BLOCKSIZE_B);
+}
+
+void ubi1024_nextBlock(ubi1024_ctx_t* ctx, void* block){
+ threefish1024_ctx_t tfctx;
+ ((uint64_t*)(ctx->tweak))[0] += UBI1024_BLOCKSIZE_B;
+ threefish1024_init(ctx->g, ctx->tweak, &tfctx);
+ memcpy(ctx->g, block, UBI1024_BLOCKSIZE_B);
+ threefish1024_enc(ctx->g, &tfctx);
+ memxor(ctx->g, block, UBI1024_BLOCKSIZE_B);
+ ctx->tweak[15] &= (uint8_t)~0x40;
+}
+
+
+void ubi1024_lastBlock(ubi1024_ctx_t* ctx, void* block, uint16_t length_b){
+ threefish1024_ctx_t tfctx;
+ while(length_b>UBI1024_BLOCKSIZE){
+ ubi1024_nextBlock(ctx, block);
+ block = (uint8_t*)block + UBI1024_BLOCKSIZE_B;
+ length_b -= UBI1024_BLOCKSIZE;
+ }
+ ctx->tweak[15] |= 0x80;
+ ((uint64_t*)(ctx->tweak))[0] += (length_b+7)/8;
+ if(length_b & 0x07)
+ ctx->tweak[14] |= 0x80;
+ threefish1024_init(ctx->g, ctx->tweak, &tfctx);
+ memset(ctx->g, 0, UBI1024_BLOCKSIZE_B);
+ memcpy(ctx->g, block, (length_b+7)/8);
+ if(length_b & 0x07)
+ ctx->g[(length_b+7)/8-1] |= 0x80>>(length_b&7);
+ threefish1024_enc(ctx->g, &tfctx);
+ memxor(ctx->g, block, (length_b+7)/8);
+}
+
+void ubi1024_ctx2hash(void* dest, ubi1024_ctx_t* ctx){
+ memcpy(dest, ctx->g, UBI1024_BLOCKSIZE_B);
+}
+
--- /dev/null
+/* ubi256.c */
+/*
+ This file is part of the AVR-Crypto-Lib.
+ Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
+
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ * \author Daniel Otte
+ * \email daniel.otte@rub.de
+ * \date 2009-03-12
+ * \license GPLv3 or later
+ *
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include "threefish.h"
+#include "memxor.h"
+#include "ubi.h"
+
+void ubi256_init(ubi256_ctx_t* ctx, void* g, uint8_t type){
+ memset(ctx->tweak, 0, 15);
+ ctx->tweak[15] = 0x40+type;
+ memcpy(ctx->g, g, 32);
+}
+
+void ubi256_nextBlock(ubi256_ctx_t* ctx, void* block){
+ threefish256_ctx_t tfctx;
+ ((uint64_t*)(ctx->tweak))[0] += UBI256_BLOCKSIZE_B;
+ threefish256_init(ctx->g, ctx->tweak, &tfctx);
+ memcpy(ctx->g, block, UBI256_BLOCKSIZE_B);
+ threefish256_enc(ctx->g, &tfctx);
+ memxor(ctx->g, block, UBI256_BLOCKSIZE_B);
+ ctx->tweak[15] &= (uint8_t)~0x40;
+}
+
+
+void ubi256_lastBlock(ubi256_ctx_t* ctx, void* block, uint16_t length_b){
+ threefish256_ctx_t tfctx;
+ while(length_b>UBI256_BLOCKSIZE){
+ ubi256_nextBlock(ctx, block);
+ block = (uint8_t*)block + UBI256_BLOCKSIZE_B;
+ length_b -= UBI256_BLOCKSIZE;
+ }
+ ctx->tweak[15] |= 0x80;
+ ((uint64_t*)(ctx->tweak))[0] += (length_b+7)/8;
+ if(length_b & 0x07)
+ ctx->tweak[14] |= 0x80;
+ threefish256_init(ctx->g, ctx->tweak, &tfctx);
+ memset(ctx->g, 0, UBI256_BLOCKSIZE_B);
+ memcpy(ctx->g, block, (length_b+7)/8);
+ if(length_b & 0x07)
+ ctx->g[(length_b+7)/8-1] |= 0x80>>(length_b&7);
+ threefish256_enc(ctx->g, &tfctx);
+ memxor(ctx->g, block, (length_b+7)/8);
+}
+
+void ubi256_ctx2hash(void* dest, ubi256_ctx_t* ctx){
+ memcpy(dest, ctx->g, UBI256_BLOCKSIZE_B);
+}
+
--- /dev/null
+/* ubi512.c */
+/*
+ This file is part of the AVR-Crypto-Lib.
+ Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
+
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ * \author Daniel Otte
+ * \email daniel.otte@rub.de
+ * \date 2009-03-12
+ * \license GPLv3 or later
+ *
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include "threefish.h"
+#include "memxor.h"
+#include "ubi.h"
+
+void ubi512_init(ubi512_ctx_t* ctx, void* g, uint8_t type){
+ memset(ctx->tweak, 0, 15);
+ ctx->tweak[15] = 0x40+type;
+ memcpy(ctx->g, g, UBI512_BLOCKSIZE_B);
+}
+
+void ubi512_nextBlock(ubi512_ctx_t* ctx, void* block){
+ threefish512_ctx_t tfctx;
+ ((uint64_t*)(ctx->tweak))[0] += UBI512_BLOCKSIZE_B;
+ threefish512_init(ctx->g, ctx->tweak, &tfctx);
+ memcpy(ctx->g, block, UBI512_BLOCKSIZE_B);
+ threefish512_enc(ctx->g, &tfctx);
+ memxor(ctx->g, block, UBI512_BLOCKSIZE_B);
+ ctx->tweak[15] &= (uint8_t)~0x40;
+}
+
+
+void ubi512_lastBlock(ubi512_ctx_t* ctx, void* block, uint16_t length_b){
+ threefish512_ctx_t tfctx;
+ while(length_b>UBI512_BLOCKSIZE){
+ ubi512_nextBlock(ctx, block);
+ block = (uint8_t*)block + UBI512_BLOCKSIZE_B;
+ length_b -= UBI512_BLOCKSIZE;
+ }
+ ctx->tweak[15] |= 0x80;
+ ((uint64_t*)(ctx->tweak))[0] += (length_b+7)/8;
+ if(length_b & 0x07)
+ ctx->tweak[14] |= 0x80;
+ threefish512_init(ctx->g, ctx->tweak, &tfctx);
+ memset(ctx->g, 0, UBI512_BLOCKSIZE_B);
+ memcpy(ctx->g, block, (length_b+7)/8);
+ if(length_b & 0x07)
+ ctx->g[(length_b+7)/8-1] |= 0x80>>(length_b&7);
+ threefish512_enc(ctx->g, &tfctx);
+ memxor(ctx->g, block, (length_b+7)/8);
+}
+
+void ubi512_ctx2hash(void* dest, ubi512_ctx_t* ctx){
+ memcpy(dest, ctx->g, UBI512_BLOCKSIZE_B);
+}
+