From: bg Date: Thu, 14 May 2009 00:31:18 +0000 (+0000) Subject: modifyed build system (removed some redundance) X-Git-Url: https://git.cryptolib.org/?a=commitdiff_plain;h=dca8c6894a08717979d3e4f64908702620171dee;p=avr-crypto-lib.git modifyed build system (removed some redundance) --- diff --git a/hfal-performance.c b/hfal-performance.c index 5108f25..26fd891 100644 --- a/hfal-performance.c +++ b/hfal-performance.c @@ -60,6 +60,7 @@ void hfal_performance(const hfdesc_t* hd){ cli_putstr_P(PSTR("\r\n\r\n === ")); cli_putstr_P(hf.name); cli_putstr_P(PSTR(" performance === " + "\r\n type: hash" "\r\n hashsize (bits): ")); printvalue(hf.hashsize_b); diff --git a/hfal_blake_small.c b/hfal_blake_small.c index f63cea5..1d890f6 100644 --- a/hfal_blake_small.c +++ b/hfal_blake_small.c @@ -1,7 +1,7 @@ /* hfal_blake_small.c */ /* This file is part of the AVR-Crypto-Lib. - Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + 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 diff --git a/host/get_test.rb b/host/get_test.rb index 0c3eb1b..337ef3f 100644 --- a/host/get_test.rb +++ b/host/get_test.rb @@ -2,7 +2,7 @@ # get_test.rb =begin This file is part of the AVR-Crypto-Lib. - Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + 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 diff --git a/mkfiles/001_cli_std.mk b/mkfiles/001_cli_std.mk new file mode 100644 index 0000000..a13bf72 --- /dev/null +++ b/mkfiles/001_cli_std.mk @@ -0,0 +1 @@ +CLI_STD = debug.o uart.o hexdigit_tab.o dbz_strings.o cli.o string-extras.o diff --git a/mkfiles/001_hfal_std.mk b/mkfiles/001_hfal_std.mk new file mode 100644 index 0000000..0404803 --- /dev/null +++ b/mkfiles/001_hfal_std.mk @@ -0,0 +1,2 @@ +HFAL_STD = nessie_common.o nessie_hash_test.o performance_test.o \ + hfal-basic.o hfal-performance.o hfal-nessie.o hfal-test.o shavs.o diff --git a/mkfiles/blake_c.mk b/mkfiles/blake_c.mk index 4dc8349..cee2547 100644 --- a/mkfiles/blake_c.mk +++ b/mkfiles/blake_c.mk @@ -6,10 +6,7 @@ HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := blake_small.o blake_large.o blake_common.o memxor.o -$(ALGO_NAME)_TEST_BIN := main-blake-test.o debug.o uart.o hexdigit_tab.o \ - dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o \ - nessie_hash_test.o hfal-basic.o hfal_blake_small.o hfal_blake_large.o \ - shavs.o hfal-nessie.o hfal-test.o hfal-performance.o +$(ALGO_NAME)_TEST_BIN := main-blake-test.o hfal_blake_small.o hfal_blake_large.o $(CLI_STD) $(HFAL_STD) $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/bmw_c.mk b/mkfiles/bmw_c.mk index bb65d9c..6305932 100644 --- a/mkfiles/bmw_c.mk +++ b/mkfiles/bmw_c.mk @@ -6,9 +6,7 @@ HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := bmw_small.o bmw_large.o -$(ALGO_NAME)_TEST_BIN := main-bmw-test.o debug.o uart.o hexdigit_tab.o \ - dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o \ - nessie_hash_test.o hfal-basic.o hfal_bmw_small.o hfal_bmw_large.o shavs.o +$(ALGO_NAME)_TEST_BIN := main-bmw-test.o hfal_bmw_small.o hfal_bmw_large.o $(CLI_STD) $(HFAL_STD) $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/md5.mk b/mkfiles/md5.mk index 1f73755..025e9eb 100644 --- a/mkfiles/md5.mk +++ b/mkfiles/md5.mk @@ -4,9 +4,8 @@ ALGO_NAME := MD5 # comment out the following line for removement of MD5 from the build process HASHES += $(ALGO_NAME) -$(ALGO_NAME)_OBJ := md5.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)_OBJ := md5-asm.o +$(ALGO_NAME)_TEST_BIN := main-md5-test.o hfal_md5.o $(CLI_STD) $(HFAL_STD) $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/sha1.mk b/mkfiles/sha1.mk index f8400be..434697e 100644 --- a/mkfiles/sha1.mk +++ b/mkfiles/sha1.mk @@ -5,9 +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 \ - 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)_TEST_BIN := main-sha1-test.o hfal_sha1.o $(CLI_STD) $(HFAL_STD) dump.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/sha1_c.mk b/mkfiles/sha1_c.mk index 3b8776c..4ce9f0a 100644 --- a/mkfiles/sha1_c.mk +++ b/mkfiles/sha1_c.mk @@ -5,9 +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 \ - 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)_TEST_BIN := main-sha1-test.o hfal_sha1.o dump.o $(CLI_STD) $(HFAL_STD) $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/sha256.mk b/mkfiles/sha256.mk index 60925ed..92dc0bc 100644 --- a/mkfiles/sha256.mk +++ b/mkfiles/sha256.mk @@ -5,9 +5,9 @@ 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 \ - 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)_TEST_BIN := main-sha256-test.o dump.o hfal_sha256.o $(CLI_STD) $(HFAL_STD) + + $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/sha256_c.mk b/mkfiles/sha256_c.mk index fa9ca75..0e172db 100644 --- a/mkfiles/sha256_c.mk +++ b/mkfiles/sha256_c.mk @@ -5,9 +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 \ - 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)_TEST_BIN := main-sha256-test.o $(CLI_STD) $(HFAL_STD) hfal_sha256.o dump.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/shabal.mk b/mkfiles/shabal.mk index 20ab49e..15ed875 100644 --- a/mkfiles/shabal.mk +++ b/mkfiles/shabal.mk @@ -7,10 +7,7 @@ HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := shabal-asm.o shabal192-asm.o shabal224-asm.o \ shabal256-asm.o shabal384-asm.o shabal512-asm.o -$(ALGO_NAME)_TEST_BIN := main-shabal-test.o debug.o uart.o hexdigit_tab.o \ - dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o \ - nessie_hash_test.o hfal-basic.o hfal_shabal.o shavs.o \ - hfal-nessie.o hfal-performance.o hfal-test.o +$(ALGO_NAME)_TEST_BIN := main-shabal-test.o hfal_shabal.o $(CLI_STD) $(HFAL_STD) $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/shabal_c.mk b/mkfiles/shabal_c.mk index 7d1d66b..427afa7 100644 --- a/mkfiles/shabal_c.mk +++ b/mkfiles/shabal_c.mk @@ -6,10 +6,7 @@ HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := shabal.o shabal192.o shabal224.o shabal256.o shabal384.o shabal512.o -$(ALGO_NAME)_TEST_BIN := main-shabal-test.o debug.o uart.o hexdigit_tab.o \ - dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o \ - nessie_hash_test.o hfal-basic.o hfal_shabal.o shavs.o \ - hfal-nessie.o hfal-performance.o hfal-test.o +$(ALGO_NAME)_TEST_BIN := main-shabal-test.o hfal_shabal.o $(CLI_STD) $(HFAL_STD) $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/skein.mk b/mkfiles/skein.mk index 2e8851e..537988e 100644 --- a/mkfiles/skein.mk +++ b/mkfiles/skein.mk @@ -9,10 +9,7 @@ $(ALGO_NAME)_OBJ := threefish_mix.o \ threefish256_enc_asm.o ubi256_asm.o skein256_asm.o \ threefish512_enc_asm.o ubi512_asm.o skein512_asm.o \ threefish1024_enc_asm.o ubi1024_asm.o skein1024_asm.o -$(ALGO_NAME)_TEST_BIN := main-skein-test.o debug.o uart.o hexdigit_tab.o \ - dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o \ - hfal-basic.o hfal_skein256.o hfal_skein512.o hfal_skein1024.o shavs.o \ - hfal-performance.o hfal-nessie.o nessie_hash_test.o +$(ALGO_NAME)_TEST_BIN := main-skein-test.o hfal_skein256.o hfal_skein512.o hfal_skein1024.o $(CLI_STD) $(HFAL_STD) $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/test_src/main-bmw-test.c b/test_src/main-bmw-test.c index 74aa8ff..22a370d 100644 --- a/test_src/main-bmw-test.c +++ b/test_src/main-bmw-test.c @@ -34,6 +34,9 @@ #include "shavs.h" #include "nessie_hash_test.h" #include "performance_test.h" +#include "hfal-nessie.h" +#include "hfal-performance.h" +#include "hfal-test.h" #include #include @@ -41,189 +44,41 @@ char* algo_name = "BlueMidnightWish"; + +const hfdesc_t* algolist[] PROGMEM = { + (hfdesc_t*)&bmw224_desc, + (hfdesc_t*)&bmw256_desc, + (hfdesc_t*)&bmw384_desc, + (hfdesc_t*)&bmw512_desc, + NULL +}; + /***************************************************************************** * additional validation-functions * *****************************************************************************/ void performance_bmw(void){ - uint64_t t; - char str[16]; - uint8_t data[128]; - uint8_t hash[512/8]; - bmw_small_ctx_t ctx1; - bmw_large_ctx_t ctx2; - - calibrateTimer(); - print_overhead(); - - memset(data, 0, 64); - - startTimer(1); - bmw224_init(&ctx1); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time (224): ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - bmw256_init(&ctx1); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time (256): ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - bmw384_init(&ctx2); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time (384): ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - bmw512_init(&ctx2); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time (512): ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - bmw_small_nextBlock(&ctx1, data); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tone-block (small) time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - bmw_large_nextBlock(&ctx2, data); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tone-block (large) time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - bmw_small_lastBlock(&ctx1, data, 0); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tlast block (small) time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - bmw_large_lastBlock(&ctx2, data, 0); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tlast block (large) time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - bmw224_ctx2hash(hash, &ctx1); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx2hash time (224): ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - bmw256_ctx2hash(hash, &ctx1); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx2hash time (256): ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - bmw384_ctx2hash(hash, &ctx2); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx2hash time (384): ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - bmw512_ctx2hash(hash, &ctx2); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx2hash time (512): ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - cli_putstr_P(PSTR("\r\n")); + hfal_performance_multiple(algolist); } void testrun_nessie_bmw(void){ - nessie_hash_ctx.hashsize_b = 224; - nessie_hash_ctx.name = "BlueMidnigthWish-224"; - nessie_hash_ctx.blocksize_B = 512/8; - nessie_hash_ctx.ctx_size_B = sizeof(bmw224_ctx_t); - nessie_hash_ctx.hash_init = (nessie_hash_init_fpt)bmw224_init; - nessie_hash_ctx.hash_next = (nessie_hash_next_fpt)bmw224_nextBlock; - nessie_hash_ctx.hash_last = (nessie_hash_last_fpt)bmw224_lastBlock; - nessie_hash_ctx.hash_conv = (nessie_hash_conv_fpt)bmw224_ctx2hash; - - nessie_hash_run(); - - nessie_hash_ctx.hashsize_b = 256; - nessie_hash_ctx.name = "BlueMidnigthWish-256"; - nessie_hash_ctx.blocksize_B = 512/8; - nessie_hash_ctx.ctx_size_B = sizeof(bmw256_ctx_t); - nessie_hash_ctx.hash_init = (nessie_hash_init_fpt)bmw256_init; - nessie_hash_ctx.hash_next = (nessie_hash_next_fpt)bmw256_nextBlock; - nessie_hash_ctx.hash_last = (nessie_hash_last_fpt)bmw256_lastBlock; - nessie_hash_ctx.hash_conv = (nessie_hash_conv_fpt)bmw256_ctx2hash; - - nessie_hash_run(); - - nessie_hash_ctx.hashsize_b = 384; - nessie_hash_ctx.name = "BlueMidnigthWish-384"; - nessie_hash_ctx.blocksize_B = 1024/8; - nessie_hash_ctx.ctx_size_B = sizeof(bmw384_ctx_t); - nessie_hash_ctx.hash_init = (nessie_hash_init_fpt)bmw384_init; - nessie_hash_ctx.hash_next = (nessie_hash_next_fpt)bmw384_nextBlock; - nessie_hash_ctx.hash_last = (nessie_hash_last_fpt)bmw384_lastBlock; - nessie_hash_ctx.hash_conv = (nessie_hash_conv_fpt)bmw384_ctx2hash; - - nessie_hash_run(); - - nessie_hash_ctx.hashsize_b = 512; - nessie_hash_ctx.name = "BlueMidnigthWish-512"; - nessie_hash_ctx.blocksize_B = 1024/8; - nessie_hash_ctx.ctx_size_B = sizeof(bmw512_ctx_t); - nessie_hash_ctx.hash_init = (nessie_hash_init_fpt)bmw512_init; - nessie_hash_ctx.hash_next = (nessie_hash_next_fpt)bmw512_nextBlock; - nessie_hash_ctx.hash_last = (nessie_hash_last_fpt)bmw512_lastBlock; - nessie_hash_ctx.hash_conv = (nessie_hash_conv_fpt)bmw512_ctx2hash; - - nessie_hash_run(); + hfal_nessie_multiple(algolist); } + void bmw224_test(void* msg, uint32_t length_b){ - uint8_t diggest[224/8]; - cli_putstr_P(PSTR("\r\n=== BMW224 test ===\r\n message:\r\n")); - cli_hexdump_block(msg, (length_b+7)/8, 4, 16); - bmw224(diggest, msg, length_b); - cli_putstr_P(PSTR("\r\n diggest:\r\n")); - cli_hexdump_block(diggest, 224/8, 4, 16); + hfal_test(&bmw224_desc, msg, length_b); } void bmw256_test(void* msg, uint32_t length_b){ - uint8_t diggest[256/8]; - cli_putstr_P(PSTR("\r\n=== BMW256 test ===\r\n message:\r\n")); - cli_hexdump_block(msg, (length_b+7)/8, 4, 16); - bmw256(diggest, msg, length_b); - cli_putstr_P(PSTR("\r\n diggest:\r\n")); - cli_hexdump_block(diggest, 256/8, 4, 16); + hfal_test(&bmw256_desc, msg, length_b); } void bmw384_test(void* msg, uint32_t length_b){ - uint8_t diggest[384/8]; - cli_putstr_P(PSTR("\r\n=== BMW384 test ===\r\n message:\r\n")); - cli_hexdump_block(msg, (length_b+7)/8, 4, 16); - bmw384(diggest, msg, length_b); - cli_putstr_P(PSTR("\r\n diggest:\r\n")); - cli_hexdump_block(diggest, 384/8, 4, 16); + hfal_test(&bmw384_desc, msg, length_b); } void bmw512_test(void* msg, uint32_t length_b){ - uint8_t diggest[512/8]; - cli_putstr_P(PSTR("\r\n=== BMW512 test ===\r\n message:\r\n")); - cli_hexdump_block(msg, (length_b+7)/8, 4, 16); - bmw512(diggest, msg, length_b); - cli_putstr_P(PSTR("\r\n diggest:\r\n")); - cli_hexdump_block(diggest, 512/8, 4, 16); + hfal_test(&bmw512_desc, msg, length_b); } void testrun_stdtest_bmw(void){ @@ -253,14 +108,6 @@ void testlshort(void){ * main * *****************************************************************************/ -const hfdesc_t* algolist[] PROGMEM = { - (hfdesc_t*)&bmw224_desc, - (hfdesc_t*)&bmw256_desc, - (hfdesc_t*)&bmw384_desc, - (hfdesc_t*)&bmw512_desc, - NULL -}; - const char nessie_str[] PROGMEM = "nessie"; const char test_str[] PROGMEM = "test"; const char testshort_str[] PROGMEM = "short"; diff --git a/test_src/main-md5-test.c b/test_src/main-md5-test.c index be4f692..7cd6049 100644 --- a/test_src/main-md5-test.c +++ b/test_src/main-md5-test.c @@ -29,6 +29,8 @@ #include "md5.h" #include "nessie_hash_test.h" #include "performance_test.h" +#include "hfal_md5.h" +#include "hfal-performance.h" #include #include @@ -37,6 +39,11 @@ char* algo_name = "MD5"; +const hfdesc_t* algolist[] PROGMEM = { + (hfdesc_t*)&md5_desc, + NULL +}; + /***************************************************************************** * additional validation-functions * *****************************************************************************/ @@ -111,40 +118,7 @@ void testrun_md5(void){ void testrun_performance_md5(void){ - uint64_t t; - char str[16]; - uint8_t data[32]; - md5_ctx_t ctx; - - calibrateTimer(); - print_overhead(); - - memset(data, 0, 32); - - startTimer(1); - md5_init(&ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - md5_nextBlock(&ctx, data); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tone-block time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - md5_lastBlock(&ctx, data, 0); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tlast block time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - cli_putstr_P(PSTR("\r\n")); + hfal_performance_multiple(algolist); } diff --git a/test_src/main-sha1-test.c b/test_src/main-sha1-test.c index 1dc476c..77104b9 100644 --- a/test_src/main-sha1-test.c +++ b/test_src/main-sha1-test.c @@ -28,7 +28,8 @@ #include "sha1.h" #include "nessie_hash_test.h" -#include "performance_test.h" +#include "hfal_sha1.h" +#include "hfal-performance.h" #include #include @@ -40,6 +41,10 @@ char* algo_name = "SHA-1"; +const hfdesc_t* algolist[] PROGMEM = { + (hfdesc_t*)&sha1_desc, + NULL +}; /***************************************************************************** * additional validation-functions * *****************************************************************************/ @@ -119,40 +124,7 @@ void testrun_sha1_2(void){ void testrun_performance_sha1(void){ - uint64_t t; - char str[16]; - uint8_t data[32]; - sha1_ctx_t ctx; - - calibrateTimer(); - print_overhead(); - - memset(data, 0, 32); - - startTimer(1); - sha1_init(&ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - sha1_nextBlock(&ctx, data); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tone-block time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - sha1_lastBlock(&ctx, data, 0); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tlast block time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - cli_putstr_P(PSTR("\r\n")); + hfal_performance_multiple(algolist); } @@ -184,11 +156,6 @@ cmdlist_entry_t cmdlist[] PROGMEM = { { NULL, NULL, NULL} }; -const hfdesc_t* algolist[] PROGMEM = { - (hfdesc_t*)&sha1_desc, - NULL -}; - int main (void){ DEBUG_INIT(); diff --git a/test_src/main-sha256-test.c b/test_src/main-sha256-test.c index c52d9ed..80c864e 100644 --- a/test_src/main-sha256-test.c +++ b/test_src/main-sha256-test.c @@ -29,6 +29,8 @@ #include "sha256.h" #include "nessie_hash_test.h" #include "performance_test.h" +#include "hfal-performance.h" +#include "hfal-nessie.h" #include #include @@ -40,58 +42,21 @@ char* algo_name = "SHA-256"; +const hfdesc_t* algolist[] PROGMEM = { + (hfdesc_t*)&sha256_desc, + NULL +}; + /***************************************************************************** * additional validation-functions * *****************************************************************************/ void testrun_nessie_sha256(void){ - nessie_hash_ctx.hashsize_b = 256; - nessie_hash_ctx.blocksize_B = 512/8; - nessie_hash_ctx.ctx_size_B = sizeof(sha256_ctx_t); - nessie_hash_ctx.name = algo_name; - nessie_hash_ctx.hash_init = (nessie_hash_init_fpt)sha256_init; - nessie_hash_ctx.hash_next = (nessie_hash_next_fpt)sha256_nextBlock; - nessie_hash_ctx.hash_last = (nessie_hash_last_fpt)sha256_lastBlock; - nessie_hash_ctx.hash_conv = (nessie_hash_conv_fpt)sha256_ctx2hash; - - nessie_hash_run(); + hfal_nessie_multiple(algolist); } void testrun_performance_sha256(void){ - uint64_t t; - char str[16]; - uint8_t data[32]; - sha256_ctx_t ctx; - - calibrateTimer(); - print_overhead(); - - memset(data, 0, 32); - - startTimer(1); - sha256_init(&ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - sha256_nextBlock(&ctx, data); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tone-block time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - sha256_lastBlock(&ctx, data, 0); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tlast block time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - cli_putstr_P(PSTR("\r\n")); + hfal_performance_multiple(algolist); } /***************************************************************************** @@ -107,11 +72,6 @@ const char shavs_set_str[] PROGMEM = "shavs_set"; const char shavs_test1_str[] PROGMEM = "shavs_test1"; const char dump_str[] PROGMEM = "dump"; -const hfdesc_t* algolist[] PROGMEM = { - (hfdesc_t*)&sha256_desc, - NULL -}; - cmdlist_entry_t cmdlist[] PROGMEM = { { nessie_str, NULL, testrun_nessie_sha256}, { test_str, NULL, testrun_nessie_sha256},