From 56a151edecefbaeab43dac22c89a3bb9fe4f470e Mon Sep 17 00:00:00 2001 From: bg Date: Thu, 12 Mar 2009 16:28:45 +0000 Subject: [PATCH] +threefish +ubi --- avr-makefile.inc | 2 +- mkfiles/a5_1.mk | 2 +- mkfiles/aes.mk | 2 +- mkfiles/aes_asm_faster.mk | 2 +- mkfiles/aes_c.mk | 2 +- mkfiles/arcfour.mk | 2 +- mkfiles/arcfour_c.mk | 2 +- mkfiles/base64.mk | 2 +- mkfiles/camellia.mk | 2 +- mkfiles/cast5.mk | 2 +- mkfiles/des.mk | 2 +- mkfiles/entropium.mk | 2 +- mkfiles/grain.mk | 2 +- mkfiles/hmac-md5.mk | 2 +- mkfiles/hmac-sha1.mk | 2 +- mkfiles/hmac-sha256.mk | 2 +- mkfiles/md5.mk | 2 +- mkfiles/md5_asm.mk | 2 +- mkfiles/mugi.mk | 2 +- mkfiles/noekeon.mk | 2 +- mkfiles/noekeon_c.mk | 2 +- mkfiles/omac_noekeon.mk | 2 +- mkfiles/omac_noekeon_c.mk | 2 +- mkfiles/present.mk | 2 +- mkfiles/rc5.mk | 2 +- mkfiles/rc6.mk | 2 +- mkfiles/seed.mk | 2 +- mkfiles/seed_C.mk | 2 +- mkfiles/serpent-bitslice.mk | 2 +- mkfiles/serpent_asm_bitslice.mk | 2 +- mkfiles/serpent_asm_fast.mk | 2 +- mkfiles/serpent_asm_small.mk | 2 +- mkfiles/serpent_c.mk | 2 +- mkfiles/sha1.mk | 2 +- mkfiles/sha1_c.mk | 2 +- mkfiles/sha256.mk | 2 +- mkfiles/sha256_c.mk | 2 +- mkfiles/shabea.mk | 2 +- mkfiles/shacal1enc.mk | 2 +- mkfiles/shacal2enc.mk | 2 +- mkfiles/skipjack.mk | 2 +- mkfiles/tdes.mk | 2 +- mkfiles/threefish.mk | 13 ++ mkfiles/trivium.mk | 2 +- mkfiles/twister224.mk | 2 +- mkfiles/twister224_c.mk | 2 +- mkfiles/twister256.mk | 2 +- mkfiles/twister256_c.mk | 2 +- mkfiles/twister384.mk | 2 +- mkfiles/twister384_c.mk | 2 +- mkfiles/twister512.mk | 2 +- mkfiles/twister512_c.mk | 2 +- mkfiles/ubi.mk | 14 ++ mkfiles/xtea.mk | 2 +- mkfiles/xtea_c.mk | 2 +- omac_noekeon.h | 26 ++++ test_src/dbz_strings.h | 2 +- test_src/main-threefish-test.c | 248 ++++++++++++++++++++++++++++++++ test_src/main-ubi-test.c | 207 ++++++++++++++++++++++++++ threefish.h | 58 ++++++++ threefish1024_enc.c | 123 ++++++++++++++++ threefish256_enc.c | 92 ++++++++++++ threefish512_enc.c | 119 +++++++++++++++ ubi.h | 93 ++++++++++++ ubi1024.c | 73 ++++++++++ ubi256.c | 73 ++++++++++ ubi512.c | 73 ++++++++++ 67 files changed, 1266 insertions(+), 54 deletions(-) create mode 100644 mkfiles/threefish.mk create mode 100644 mkfiles/ubi.mk create mode 100644 test_src/main-threefish-test.c create mode 100644 test_src/main-ubi-test.c create mode 100644 threefish.h create mode 100644 threefish1024_enc.c create mode 100644 threefish256_enc.c create mode 100644 threefish512_enc.c create mode 100644 ubi.h create mode 100644 ubi1024.c create mode 100644 ubi256.c create mode 100644 ubi512.c diff --git a/avr-makefile.inc b/avr-makefile.inc index 77cae4d..95e0228 100644 --- a/avr-makefile.inc +++ b/avr-makefile.inc @@ -20,7 +20,7 @@ STAT_DIR = stats/ 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 diff --git a/mkfiles/a5_1.mk b/mkfiles/a5_1.mk index 078d982..63f59ec 100644 --- a/mkfiles/a5_1.mk +++ b/mkfiles/a5_1.mk @@ -5,7 +5,7 @@ ALGO_NAME := A51 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" diff --git a/mkfiles/aes.mk b/mkfiles/aes.mk index 71ab1d7..871434b 100644 --- a/mkfiles/aes.mk +++ b/mkfiles/aes.mk @@ -7,7 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(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 diff --git a/mkfiles/aes_asm_faster.mk b/mkfiles/aes_asm_faster.mk index 71f1de7..ad5acb5 100644 --- a/mkfiles/aes_asm_faster.mk +++ b/mkfiles/aes_asm_faster.mk @@ -7,7 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(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 diff --git a/mkfiles/aes_c.mk b/mkfiles/aes_c.mk index 8bec133..dcc6c62 100644 --- a/mkfiles/aes_c.mk +++ b/mkfiles/aes_c.mk @@ -9,7 +9,7 @@ $(ALGO_NAME)_OBJ := aes_enc.o aes_dec.o aes_sbox.o aes_invsbox.o \ 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 diff --git a/mkfiles/arcfour.mk b/mkfiles/arcfour.mk index 6a6e24b..7cc4c8e 100644 --- a/mkfiles/arcfour.mk +++ b/mkfiles/arcfour.mk @@ -5,7 +5,7 @@ ALGO_NAME := ARCFOUR 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" diff --git a/mkfiles/arcfour_c.mk b/mkfiles/arcfour_c.mk index d677061..23a4135 100644 --- a/mkfiles/arcfour_c.mk +++ b/mkfiles/arcfour_c.mk @@ -5,7 +5,7 @@ ALGO_NAME := ARCFOUR_C 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" diff --git a/mkfiles/base64.mk b/mkfiles/base64.mk index 339238b..ef652aa 100644 --- a/mkfiles/base64.mk +++ b/mkfiles/base64.mk @@ -6,7 +6,7 @@ ENCODINGS += $(ALGO_NAME) $(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 diff --git a/mkfiles/camellia.mk b/mkfiles/camellia.mk index 9b27fe6..2cd0581 100644 --- a/mkfiles/camellia.mk +++ b/mkfiles/camellia.mk @@ -5,7 +5,7 @@ ALGO_NAME := CAMELLIA 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" diff --git a/mkfiles/cast5.mk b/mkfiles/cast5.mk index e2472a9..df2fd13 100644 --- a/mkfiles/cast5.mk +++ b/mkfiles/cast5.mk @@ -5,7 +5,7 @@ ALGO_NAME := CAST5 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" diff --git a/mkfiles/des.mk b/mkfiles/des.mk index f786210..17c5709 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 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" diff --git a/mkfiles/entropium.mk b/mkfiles/entropium.mk index 14cc8bd..f6c16f6 100644 --- a/mkfiles/entropium.mk +++ b/mkfiles/entropium.mk @@ -5,7 +5,7 @@ ALGO_NAME := ENTROPIUM 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" diff --git a/mkfiles/grain.mk b/mkfiles/grain.mk index a8373c2..a79076d 100644 --- a/mkfiles/grain.mk +++ b/mkfiles/grain.mk @@ -5,7 +5,7 @@ ALGO_NAME := GRAIN 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" diff --git a/mkfiles/hmac-md5.mk b/mkfiles/hmac-md5.mk index a79e9bb..a816ed3 100644 --- a/mkfiles/hmac-md5.mk +++ b/mkfiles/hmac-md5.mk @@ -5,7 +5,7 @@ ALGO_NAME := HMAC-MD5 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" diff --git a/mkfiles/hmac-sha1.mk b/mkfiles/hmac-sha1.mk index 7998afa..3c75921 100644 --- a/mkfiles/hmac-sha1.mk +++ b/mkfiles/hmac-sha1.mk @@ -5,7 +5,7 @@ ALGO_NAME := HMAC-SHA1 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" diff --git a/mkfiles/hmac-sha256.mk b/mkfiles/hmac-sha256.mk index 8714440..2dd2973 100644 --- a/mkfiles/hmac-sha256.mk +++ b/mkfiles/hmac-sha256.mk @@ -5,7 +5,7 @@ ALGO_NAME := HMAC-SHA256 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" diff --git a/mkfiles/md5.mk b/mkfiles/md5.mk index 1fee357..1f73755 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 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" diff --git a/mkfiles/md5_asm.mk b/mkfiles/md5_asm.mk index ed2905f..179d2e6 100644 --- a/mkfiles/md5_asm.mk +++ b/mkfiles/md5_asm.mk @@ -5,7 +5,7 @@ ALGO_NAME := MD5_ASM 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" diff --git a/mkfiles/mugi.mk b/mkfiles/mugi.mk index c5f64f3..0e1e61f 100644 --- a/mkfiles/mugi.mk +++ b/mkfiles/mugi.mk @@ -5,7 +5,7 @@ ALGO_NAME := MUGI_C 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" diff --git a/mkfiles/noekeon.mk b/mkfiles/noekeon.mk index 52cb730..9c70942 100644 --- a/mkfiles/noekeon.mk +++ b/mkfiles/noekeon.mk @@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(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 diff --git a/mkfiles/noekeon_c.mk b/mkfiles/noekeon_c.mk index 504a266..700e8c2 100644 --- a/mkfiles/noekeon_c.mk +++ b/mkfiles/noekeon_c.mk @@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(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 diff --git a/mkfiles/omac_noekeon.mk b/mkfiles/omac_noekeon.mk index 365e056..3429a4a 100644 --- a/mkfiles/omac_noekeon.mk +++ b/mkfiles/omac_noekeon.mk @@ -6,7 +6,7 @@ MACS += $(ALGO_NAME) $(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 diff --git a/mkfiles/omac_noekeon_c.mk b/mkfiles/omac_noekeon_c.mk index 290fc7d..e704b1e 100644 --- a/mkfiles/omac_noekeon_c.mk +++ b/mkfiles/omac_noekeon_c.mk @@ -6,7 +6,7 @@ MACS += $(ALGO_NAME) $(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 diff --git a/mkfiles/present.mk b/mkfiles/present.mk index 1dd39b0..2c8e9d1 100644 --- a/mkfiles/present.mk +++ b/mkfiles/present.mk @@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(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" diff --git a/mkfiles/rc5.mk b/mkfiles/rc5.mk index 0b1befe..f948b62 100644 --- a/mkfiles/rc5.mk +++ b/mkfiles/rc5.mk @@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(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 diff --git a/mkfiles/rc6.mk b/mkfiles/rc6.mk index a02f17c..f6729e3 100644 --- a/mkfiles/rc6.mk +++ b/mkfiles/rc6.mk @@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(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 diff --git a/mkfiles/seed.mk b/mkfiles/seed.mk index 12d8d59..28b437a 100644 --- a/mkfiles/seed.mk +++ b/mkfiles/seed.mk @@ -5,7 +5,7 @@ ALGO_NAME := SEED 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" diff --git a/mkfiles/seed_C.mk b/mkfiles/seed_C.mk index 0cc6ea3..7ec687f 100644 --- a/mkfiles/seed_C.mk +++ b/mkfiles/seed_C.mk @@ -5,7 +5,7 @@ ALGO_NAME := SEED_C 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" diff --git a/mkfiles/serpent-bitslice.mk b/mkfiles/serpent-bitslice.mk index dbea67e..d1e5a9a 100644 --- a/mkfiles/serpent-bitslice.mk +++ b/mkfiles/serpent-bitslice.mk @@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(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" diff --git a/mkfiles/serpent_asm_bitslice.mk b/mkfiles/serpent_asm_bitslice.mk index e731cff..f8cb7b7 100644 --- a/mkfiles/serpent_asm_bitslice.mk +++ b/mkfiles/serpent_asm_bitslice.mk @@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(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" diff --git a/mkfiles/serpent_asm_fast.mk b/mkfiles/serpent_asm_fast.mk index 71f2a99..d9c3760 100644 --- a/mkfiles/serpent_asm_fast.mk +++ b/mkfiles/serpent_asm_fast.mk @@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(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" diff --git a/mkfiles/serpent_asm_small.mk b/mkfiles/serpent_asm_small.mk index 7d5a1c3..52cfda2 100644 --- a/mkfiles/serpent_asm_small.mk +++ b/mkfiles/serpent_asm_small.mk @@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(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" diff --git a/mkfiles/serpent_c.mk b/mkfiles/serpent_c.mk index 63b498d..e8c7be4 100644 --- a/mkfiles/serpent_c.mk +++ b/mkfiles/serpent_c.mk @@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(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" diff --git a/mkfiles/sha1.mk b/mkfiles/sha1.mk index 818a91b..f8400be 100644 --- a/mkfiles/sha1.mk +++ b/mkfiles/sha1.mk @@ -5,7 +5,7 @@ ALGO_NAME := SHA1 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" diff --git a/mkfiles/sha1_c.mk b/mkfiles/sha1_c.mk index 6674a3e..3b8776c 100644 --- a/mkfiles/sha1_c.mk +++ b/mkfiles/sha1_c.mk @@ -5,7 +5,7 @@ ALGO_NAME := SHA1_C 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" diff --git a/mkfiles/sha256.mk b/mkfiles/sha256.mk index fee84e0..60925ed 100644 --- a/mkfiles/sha256.mk +++ b/mkfiles/sha256.mk @@ -5,7 +5,7 @@ ALGO_NAME := SHA256 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" diff --git a/mkfiles/sha256_c.mk b/mkfiles/sha256_c.mk index 6952ca7..fa9ca75 100644 --- a/mkfiles/sha256_c.mk +++ b/mkfiles/sha256_c.mk @@ -5,7 +5,7 @@ ALGO_NAME := SHA256_C 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" diff --git a/mkfiles/shabea.mk b/mkfiles/shabea.mk index 7747998..fb65dd4 100644 --- a/mkfiles/shabea.mk +++ b/mkfiles/shabea.mk @@ -5,7 +5,7 @@ ALGO_NAME := SHABEA 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" diff --git a/mkfiles/shacal1enc.mk b/mkfiles/shacal1enc.mk index 4a57970..728116e 100644 --- a/mkfiles/shacal1enc.mk +++ b/mkfiles/shacal1enc.mk @@ -6,7 +6,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 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" diff --git a/mkfiles/shacal2enc.mk b/mkfiles/shacal2enc.mk index 99dae33..fe24aba 100644 --- a/mkfiles/shacal2enc.mk +++ b/mkfiles/shacal2enc.mk @@ -6,7 +6,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 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" diff --git a/mkfiles/skipjack.mk b/mkfiles/skipjack.mk index 9f4eb35..a325577 100644 --- a/mkfiles/skipjack.mk +++ b/mkfiles/skipjack.mk @@ -5,7 +5,7 @@ ALGO_NAME := SKIPJACK 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" diff --git a/mkfiles/tdes.mk b/mkfiles/tdes.mk index 96ccaba..34740e9 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 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" diff --git a/mkfiles/threefish.mk b/mkfiles/threefish.mk new file mode 100644 index 0000000..71a4da4 --- /dev/null +++ b/mkfiles/threefish.mk @@ -0,0 +1,13 @@ +# 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 + diff --git a/mkfiles/trivium.mk b/mkfiles/trivium.mk index 7b8dd3f..1478cb6 100644 --- a/mkfiles/trivium.mk +++ b/mkfiles/trivium.mk @@ -5,7 +5,7 @@ ALGO_NAME := TRIVIUM 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" diff --git a/mkfiles/twister224.mk b/mkfiles/twister224.mk index e33e28a..93567ff 100644 --- a/mkfiles/twister224.mk +++ b/mkfiles/twister224.mk @@ -5,7 +5,7 @@ ALGO_NAME := TWISTER224 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" diff --git a/mkfiles/twister224_c.mk b/mkfiles/twister224_c.mk index be880e0..948a113 100644 --- a/mkfiles/twister224_c.mk +++ b/mkfiles/twister224_c.mk @@ -5,7 +5,7 @@ ALGO_NAME := TWISTER224_C 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" diff --git a/mkfiles/twister256.mk b/mkfiles/twister256.mk index feb8ac5..dcbf7a6 100644 --- a/mkfiles/twister256.mk +++ b/mkfiles/twister256.mk @@ -5,7 +5,7 @@ ALGO_NAME := TWISTER256 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" diff --git a/mkfiles/twister256_c.mk b/mkfiles/twister256_c.mk index 8b1717e..bfa070d 100644 --- a/mkfiles/twister256_c.mk +++ b/mkfiles/twister256_c.mk @@ -5,7 +5,7 @@ ALGO_NAME := TWISTER256_C 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" diff --git a/mkfiles/twister384.mk b/mkfiles/twister384.mk index c4f2f95..aa07161 100644 --- a/mkfiles/twister384.mk +++ b/mkfiles/twister384.mk @@ -5,7 +5,7 @@ ALGO_NAME := TWISTER384 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" diff --git a/mkfiles/twister384_c.mk b/mkfiles/twister384_c.mk index 56511de..f3ac76c 100644 --- a/mkfiles/twister384_c.mk +++ b/mkfiles/twister384_c.mk @@ -5,7 +5,7 @@ ALGO_NAME := TWISTER384_C 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" diff --git a/mkfiles/twister512.mk b/mkfiles/twister512.mk index 484cc56..23168f7 100644 --- a/mkfiles/twister512.mk +++ b/mkfiles/twister512.mk @@ -5,7 +5,7 @@ ALGO_NAME := TWISTER512 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" diff --git a/mkfiles/twister512_c.mk b/mkfiles/twister512_c.mk index 1dc2ec0..3f405bb 100644 --- a/mkfiles/twister512_c.mk +++ b/mkfiles/twister512_c.mk @@ -5,7 +5,7 @@ ALGO_NAME := TWISTER512_C 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" diff --git a/mkfiles/ubi.mk b/mkfiles/ubi.mk new file mode 100644 index 0000000..06ca291 --- /dev/null +++ b/mkfiles/ubi.mk @@ -0,0 +1,14 @@ +# 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 + diff --git a/mkfiles/xtea.mk b/mkfiles/xtea.mk index 67abbe6..a26ec22 100644 --- a/mkfiles/xtea.mk +++ b/mkfiles/xtea.mk @@ -5,7 +5,7 @@ ALGO_NAME := XTEA 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" diff --git a/mkfiles/xtea_c.mk b/mkfiles/xtea_c.mk index 711db83..9779aff 100644 --- a/mkfiles/xtea_c.mk +++ b/mkfiles/xtea_c.mk @@ -5,7 +5,7 @@ ALGO_NAME := XTEA_C 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" diff --git a/omac_noekeon.h b/omac_noekeon.h index c56b3a0..a4db052 100644 --- a/omac_noekeon.h +++ b/omac_noekeon.h @@ -1,3 +1,29 @@ +/* + 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 . +*/ +/* + * \author Daniel Otte + * \email daniel.otte@rub.de + * \license GPLv3 or later + * + * + * + */ + #ifndef NOEKEON_OMAC_H_ #define NOEKEON_OMAC_H_ diff --git a/test_src/dbz_strings.h b/test_src/dbz_strings.h index 7fc09e9..76c8b75 100644 --- a/test_src/dbz_strings.h +++ b/test_src/dbz_strings.h @@ -37,7 +37,7 @@ /** \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 */ diff --git a/test_src/main-threefish-test.c b/test_src/main-threefish-test.c new file mode 100644 index 0000000..6197e63 --- /dev/null +++ b/test_src/main-threefish-test.c @@ -0,0 +1,248 @@ +/* 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 . +*/ +/* + * 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 +#include +#include + +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); + } +} diff --git a/test_src/main-ubi-test.c b/test_src/main-ubi-test.c new file mode 100644 index 0000000..140362d --- /dev/null +++ b/test_src/main-ubi-test.c @@ -0,0 +1,207 @@ +/* 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 . +*/ +/* + * 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 +#include +#include + +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); + } +} diff --git a/threefish.h b/threefish.h new file mode 100644 index 0000000..73871a4 --- /dev/null +++ b/threefish.h @@ -0,0 +1,58 @@ +/* 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 . +*/ +/* + * \author Daniel Otte + * \email daniel.otte@rub.de + * \date 2009-03-12 + * \license GPLv3 or later + */ + +#ifndef THREEFISH_H_ +#define THREEFISH_H_ + +#include + +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_ */ diff --git a/threefish1024_enc.c b/threefish1024_enc.c new file mode 100644 index 0000000..2fa1957 --- /dev/null +++ b/threefish1024_enc.c @@ -0,0 +1,123 @@ +/* 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 . +*/ +/* + * \author Daniel Otte + * \email daniel.otte@rub.de + * \date 2009-03-12 + * \license GPLv3 or later + * + * + * + */ + +#include +#include +#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<>(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); +} diff --git a/threefish256_enc.c b/threefish256_enc.c new file mode 100644 index 0000000..be0d5db --- /dev/null +++ b/threefish256_enc.c @@ -0,0 +1,92 @@ +/* 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 . +*/ +/* + * \author Daniel Otte + * \email daniel.otte@rub.de + * \date 2009-03-12 + * \license GPLv3 or later + * + * + * + */ + +#include +#include +#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<>(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); +} + diff --git a/threefish512_enc.c b/threefish512_enc.c new file mode 100644 index 0000000..abd1afc --- /dev/null +++ b/threefish512_enc.c @@ -0,0 +1,119 @@ +/* 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 . +*/ +/* + * \author Daniel Otte + * \email daniel.otte@rub.de + * \date 2009-03-12 + * \license GPLv3 or later + * + * + * + */ + +#include +#include +#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<>(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); +} + diff --git a/ubi.h b/ubi.h new file mode 100644 index 0000000..582a54e --- /dev/null +++ b/ubi.h @@ -0,0 +1,93 @@ +/* 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 . +*/ +/* + * \author Daniel Otte + * \email daniel.otte@rub.de + * \date 2009-03-12 + * \license GPLv3 or later + * + */ + +#ifndef UBI_H_ +#define UBI_H_ + +#include + +#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_ */ diff --git a/ubi1024.c b/ubi1024.c new file mode 100644 index 0000000..6287e68 --- /dev/null +++ b/ubi1024.c @@ -0,0 +1,73 @@ +/* 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 . +*/ +/* + * \author Daniel Otte + * \email daniel.otte@rub.de + * \date 2009-03-12 + * \license GPLv3 or later + * + */ + +#include +#include +#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); +} + diff --git a/ubi256.c b/ubi256.c new file mode 100644 index 0000000..8adfda8 --- /dev/null +++ b/ubi256.c @@ -0,0 +1,73 @@ +/* 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 . +*/ +/* + * \author Daniel Otte + * \email daniel.otte@rub.de + * \date 2009-03-12 + * \license GPLv3 or later + * + */ + +#include +#include +#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); +} + diff --git a/ubi512.c b/ubi512.c new file mode 100644 index 0000000..c5e6f51 --- /dev/null +++ b/ubi512.c @@ -0,0 +1,73 @@ +/* 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 . +*/ +/* + * \author Daniel Otte + * \email daniel.otte@rub.de + * \date 2009-03-12 + * \license GPLv3 or later + * + */ + +#include +#include +#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); +} + -- 2.39.5