From: bg Date: Sat, 20 Feb 2010 20:45:42 +0000 (+0000) Subject: changing performance measurment of blockciphers to bcal X-Git-Url: https://git.cryptolib.org/?a=commitdiff_plain;h=6483e60140be5fe4ab60de85cdf679fc0518dc99;p=avr-crypto-lib.git changing performance measurment of blockciphers to bcal --- diff --git a/bcal-eax.c b/bcal-eax.c index 78ddd51..9dceccd 100644 --- a/bcal-eax.c +++ b/bcal-eax.c @@ -24,6 +24,7 @@ #include "bcal-cmac.h" #include "bcal-ctr.h" #include "bcal-eax.h" +#include "memxor.h" uint8_t bcal_eax_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, bcal_eax_ctx_t* ctx){ uint8_t r; diff --git a/bcal-performance.c b/bcal-performance.c new file mode 100644 index 0000000..447e4d1 --- /dev/null +++ b/bcal-performance.c @@ -0,0 +1,152 @@ +/* bcal-performance.c */ +/* + This file is part of the AVR-Crypto-Lib. + Copyright (C) 2010 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 . +*/ + +/* + * \file bcal-performance.c + * \author Daniel Otte + * \email daniel.otte@rub.de + * \date 2010-02-16 + * \license GPLv3 or later + * + */ + +#include "bcal-performance.h" +#include "keysize_descriptor.h" +#include "blockcipher_descriptor.h" +#include "performance_test.h" +#include "cli.h" +#include +#include +#include +#include + + + + +static +void printvalue(unsigned long v){ + char str[20]; + int i; + ultoa(v, str, 10); + for(i=0; i<10-strlen(str); ++i){ + cli_putc(' '); + } + cli_putstr(str); +} + +void bcal_performance(const bcdesc_t* bcd){ + bcdesc_t bc; + memcpy_P(&bc, bcd, sizeof(bcdesc_t)); + uint8_t ctx[bc.ctxsize_B]; + uint8_t data[(bc.blocksize_b+7)/8]; + uint16_t keysize = get_keysize(bc.valid_keysize_desc); + uint8_t key[(keysize+7)/8]; + uint64_t t; + uint8_t i; + + if(bc.type!=BCDESC_TYPE_BLOCKCIPHER) + return; + calibrateTimer(); + print_overhead(); + cli_putstr_P(PSTR("\r\n\r\n === ")); + cli_putstr_P(bc.name); + cli_putstr_P(PSTR(" performance === " + "\r\n type: blockcipher" + "\r\n keysize (bits): ")); + printvalue(keysize); + + cli_putstr_P(PSTR("\r\n ctxsize (bytes): ")); + printvalue(bc.ctxsize_B); + + cli_putstr_P(PSTR("\r\n blocksize (bits): ")); + printvalue(bc.blocksize_b); + + + + t=0; + if(bc.init.init1){ + if((bc.flags&BC_INIT_TYPE)==BC_INIT_TYPE_1){ + for(i=0; i<32; ++i){ + startTimer(0); + START_TIMER; + (bc.init.init1)(key, &ctx); + STOP_TIMER; + t += stopTimer(); + if(i!=31 && bc.free){ + bc.free(&ctx); + } + } + } else { + for(i=0; i<32; ++i){ + startTimer(0); + START_TIMER; + (bc.init.init2)(key, keysize, &ctx); + STOP_TIMER; + t += stopTimer(); + if(i!=31 && bc.free){ + bc.free(&ctx); + } + } + } + t>>=5; + cli_putstr_P(PSTR("\r\n init (cycles): ")); + printvalue(t); + } + t=0; + for(i=0; i<32; ++i){ + startTimer(0); + START_TIMER; + bc.enc.enc1(data, &ctx); + STOP_TIMER; + t += stopTimer(); + } + t>>=5; + cli_putstr_P(PSTR("\r\n encrypt (cycles): ")); + printvalue(t); + + t=0; + for(i=0; i<32; ++i){ + startTimer(0); + START_TIMER; + bc.dec.dec1(data, &ctx); + STOP_TIMER; + t += stopTimer(); + } + t>>=5; + cli_putstr_P(PSTR("\r\n decrypt (cycles): ")); + printvalue(t); + + if(bc.free){ + bc.free(&ctx); + } +} + + +void bcal_performance_multiple(const bcdesc_t** bcd_list){ + const bcdesc_t* bcd; + for(;;){ + bcd = (void*)pgm_read_word(bcd_list); + if(!bcd){ + cli_putstr_P(PSTR("\r\n\r\n End of performance figures\r\n")); + return; + } + bcal_performance(bcd); + bcd_list = (void*)((uint8_t*)bcd_list + 2); + } +} diff --git a/bcal-performance.h b/bcal-performance.h new file mode 100644 index 0000000..b8c5666 --- /dev/null +++ b/bcal-performance.h @@ -0,0 +1,38 @@ +/* bcal-performance.h */ +/* + This file is part of the AVR-Crypto-Lib. + Copyright (C) 2010 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 . +*/ + +/* + * \file bcal-performance.h + * \author Daniel Otte + * \email daniel.otte@rub.de + * \date 2010-02-16 + * \license GPLv3 or later + * + */ + +#ifndef BCAL_PERFORMANCE_H_ +#define BCAL_PERFORMANCE_H_ + +#include "blockcipher_descriptor.h" + +void bcal_performance(const bcdesc_t* hd); +void bcal_performance_multiple(const bcdesc_t** hd_list); + + +#endif /* BCAL_PERFORMANCE_H_ */ diff --git a/bcal_des.c b/bcal_des.c index 601469c..04ed5e5 100644 --- a/bcal_des.c +++ b/bcal_des.c @@ -36,12 +36,12 @@ const char des_str[] PROGMEM = "DES"; const uint8_t des_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(64), KS_TYPE_TERMINATOR }; static -void des_dummy_enc(void* block, coid* key){ +void des_dummy_enc(void* block, void* key){ des_enc(block, block, key); } static -void des_dummy_dec(void* block, coid* key){ +void des_dummy_dec(void* block, void* key){ des_dec(block, block, key); } diff --git a/bcal_threefish1024.c b/bcal_threefish1024.c new file mode 100644 index 0000000..8f1a108 --- /dev/null +++ b/bcal_threefish1024.c @@ -0,0 +1,56 @@ +/* bcal_threefish1024.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 . +*/ +/** + * \file bcal_threefish1024.c + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2010-02-20 + * \license GPLv3 or later + * + */ + +#include +#include +#include "blockcipher_descriptor.h" +#include "threefish.h" +#include "keysize_descriptor.h" + +const char threefish1024_str[] PROGMEM = "Threefish-1024"; + +const uint8_t threefish1024_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(1024), + KS_TYPE_TERMINATOR }; + +static void threefish1024_dummy_init(void* key, void* ctx){ + threefish1024_init(key, NULL, ctx); +} + +const bcdesc_t threefish1024_desc PROGMEM = { + BCDESC_TYPE_BLOCKCIPHER, + BC_INIT_TYPE_1, + threefish1024_str, + sizeof(threefish1024_ctx_t), + 1024, + {(void_fpt)threefish1024_dummy_init}, + {(void_fpt)threefish1024_enc}, + {(void_fpt)threefish1024_dec}, + (bc_free_fpt)NULL, + threefish1024_keysize_desc +}; + + diff --git a/bcal_threefish1024.h b/bcal_threefish1024.h new file mode 100644 index 0000000..67c9b3c --- /dev/null +++ b/bcal_threefish1024.h @@ -0,0 +1,33 @@ +/* bcal_threefis1024.h */ +/* + 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 . +*/ +/** + * \file bcal_threefish1024.h + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2010-02-20 + * \license GPLv3 or later + * + */ + +#include +#include "blockcipher_descriptor.h" +#include "threefish.h" +#include "keysize_descriptor.h" + +extern const bcdesc_t threefish1024_desc; diff --git a/bcal_threefish256.c b/bcal_threefish256.c new file mode 100644 index 0000000..f95f1a2 --- /dev/null +++ b/bcal_threefish256.c @@ -0,0 +1,56 @@ +/* bcal_threefish256.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 . +*/ +/** + * \file bcal_threefish256.c + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2010-02-20 + * \license GPLv3 or later + * + */ + +#include +#include +#include "blockcipher_descriptor.h" +#include "threefish.h" +#include "keysize_descriptor.h" + +const char threefish256_str[] PROGMEM = "Threefish-256"; + +const uint8_t threefish256_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(256), + KS_TYPE_TERMINATOR }; + +static void threefish256_dummy_init(void* key, void* ctx){ + threefish256_init(key, NULL, ctx); +} + +const bcdesc_t threefish256_desc PROGMEM = { + BCDESC_TYPE_BLOCKCIPHER, + BC_INIT_TYPE_1, + threefish256_str, + sizeof(threefish256_ctx_t), + 256, + {(void_fpt)threefish256_dummy_init}, + {(void_fpt)threefish256_enc}, + {(void_fpt)threefish256_dec}, + (bc_free_fpt)NULL, + threefish256_keysize_desc +}; + + diff --git a/bcal_threefish256.h b/bcal_threefish256.h new file mode 100644 index 0000000..d2819bf --- /dev/null +++ b/bcal_threefish256.h @@ -0,0 +1,33 @@ +/* bcal_threefis256.h */ +/* + 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 . +*/ +/** + * \file bcal_threefish256.h + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2010-02-20 + * \license GPLv3 or later + * + */ + +#include +#include "blockcipher_descriptor.h" +#include "threefish.h" +#include "keysize_descriptor.h" + +extern const bcdesc_t threefish256_desc; diff --git a/bcal_threefish512.c b/bcal_threefish512.c new file mode 100644 index 0000000..ff61a74 --- /dev/null +++ b/bcal_threefish512.c @@ -0,0 +1,56 @@ +/* bcal_threefish512.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 . +*/ +/** + * \file bcal_threefish512.c + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2010-02-20 + * \license GPLv3 or later + * + */ + +#include +#include +#include "blockcipher_descriptor.h" +#include "threefish.h" +#include "keysize_descriptor.h" + +const char threefish512_str[] PROGMEM = "Threefish-512"; + +const uint8_t threefish512_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(512), + KS_TYPE_TERMINATOR }; + +static void threefish512_dummy_init(void* key, void* ctx){ + threefish512_init(key, NULL, ctx); +} + +const bcdesc_t threefish512_desc PROGMEM = { + BCDESC_TYPE_BLOCKCIPHER, + BC_INIT_TYPE_1, + threefish512_str, + sizeof(threefish512_ctx_t), + 512, + {(void_fpt)threefish512_dummy_init}, + {(void_fpt)threefish512_enc}, + {(void_fpt)threefish512_dec}, + (bc_free_fpt)NULL, + threefish512_keysize_desc +}; + + diff --git a/bcal_threefish512.h b/bcal_threefish512.h new file mode 100644 index 0000000..8f87d65 --- /dev/null +++ b/bcal_threefish512.h @@ -0,0 +1,33 @@ +/* bcal_threefis512.h */ +/* + 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 . +*/ +/** + * \file bcal_threefish512.h + * \email daniel.otte@rub.de + * \author Daniel Otte + * \date 2010-02-20 + * \license GPLv3 or later + * + */ + +#include +#include "blockcipher_descriptor.h" +#include "threefish.h" +#include "keysize_descriptor.h" + +extern const bcdesc_t threefish512_desc; diff --git a/hfal-performance.c b/hfal-performance.c index 8c5b36d..c64e7e9 100644 --- a/hfal-performance.c +++ b/hfal-performance.c @@ -79,6 +79,9 @@ void hfal_performance(const hfdesc_t* hd){ hf.init(&ctx); STOP_TIMER; t += stopTimer(); + if(i!=31 && hf.free){ + hf.free(&ctx) + } } t>>=5; cli_putstr_P(PSTR("\r\n init (cycles): ")); @@ -119,6 +122,10 @@ void hfal_performance(const hfdesc_t* hd){ t>>=5; cli_putstr_P(PSTR("\r\n ctx2hash (cycles): ")); printvalue(t); + + if(hf.free){ + hf.free(&ctx); + } } diff --git a/hfal-test.c b/hfal-test.c index 2879331..9efce38 100644 --- a/hfal-test.c +++ b/hfal-test.c @@ -25,7 +25,6 @@ * */ -#include "nessie_hash_test.h" #include "hfal-basic.h" #include "hashfunction_descriptor.h" #include "cli.h" diff --git a/host/fix-wiki-size.rb b/host/fix-wiki-size.rb index 2bc08c8..53a480e 100644 --- a/host/fix-wiki-size.rb +++ b/host/fix-wiki-size.rb @@ -19,6 +19,10 @@ along with this program. If not, see . =end + +require 'rubygems' +require 'getopt/std' + =begin | Blake-28 || C || C | 10916
@@ -32,7 +36,7 @@ memxor: 24 =end -def fix_file(fin, fout) +def fix_file(fin, fout, supress) loop do return if fin.eof() comp = Array.new @@ -45,9 +49,13 @@ def fix_file(fin, fout) end until comp[i-1].match(/^\|/) sum = 0 (i-1).times{ |j| sum += comp[j].match(/[^:]*:[\s]*([\d]*)/)[1].to_i} - fout.puts(lb1) - fout.printf("| %d
\n", sum) - comp.each{ |s| fout.puts(s)} + fout.print(lb1.chomp) + if supress + fout.printf(" || %d |%s", sum, comp.last) + else + fout.printf("\n| %d
\n", sum) + comp.each{ |s| fout.puts(s)} + end begin lb1 = fin.readline() fout.puts(lb1) @@ -62,11 +70,12 @@ end fin = STDIN fout = STDOUT +opts = Getopt::Std.getopts("s") fin = File.open(ARGV[0], "r") if ARGV.size > 0 fout = File.open(ARGV[1], "w") if ARGV.size > 1 -fix_file(fin, fout) +fix_file(fin, fout, opts["s"]) fin.close if ARGV.size > 0 fout.close if ARGV.size > 1 diff --git a/keysize_descriptor.c b/keysize_descriptor.c index 5dcdcc0..045ff65 100644 --- a/keysize_descriptor.c +++ b/keysize_descriptor.c @@ -72,4 +72,15 @@ uint8_t is_valid_keysize_P(PGM_VOID_P ks_desc, uint16_t keysize){ return is_valid_keysize_P((uint8_t*)ks_desc+1, keysize); /* search the next record */ } +uint16_t get_keysize(PGM_VOID_P ks_desc){ + uint8_t type; + uint16_t keysize; + type = pgm_read_byte(ks_desc); + if(type==KS_TYPE_LIST) + ks_desc = (uint8_t*)ks_desc + 1; + ks_desc = (uint8_t*)ks_desc + 1; + keysize = pgm_read_word(ks_desc); + return keysize; +} + diff --git a/keysize_descriptor.h b/keysize_descriptor.h index e256ddf..dd91254 100644 --- a/keysize_descriptor.h +++ b/keysize_descriptor.h @@ -55,5 +55,5 @@ typedef struct{ /* keysize is valid if min<=keysize<=max and if keysize mod dist }keysize_desc_arg_range_t; uint8_t is_valid_keysize_P(PGM_VOID_P ks_desc, uint16_t keysize); - +uint16_t get_keysize(PGM_VOID_P ks_desc); #endif /* KEYSIZE_DESCRIPTOR_H_ */ diff --git a/mkfiles/001_bcal_std.mk b/mkfiles/001_bcal_std.mk new file mode 100644 index 0000000..7045a5f --- /dev/null +++ b/mkfiles/001_bcal_std.mk @@ -0,0 +1,2 @@ +BCAL_STD = nessie_common.o nessie_bc_test.o performance_test.o \ + bcal-basic.o bcal-performance.o keysize_descriptor.o diff --git a/mkfiles/aes.mk b/mkfiles/aes.mk index ebe67b6..18bf9fa 100644 --- a/mkfiles/aes.mk +++ b/mkfiles/aes.mk @@ -12,7 +12,7 @@ $(ALGO_NAME)_TEST_BIN := main-aes-test.o $(CLI_STD) \ bcal_aes128.o bcal_aes192.o bcal_aes256.o bcal-basic.o bcal-cbc.o \ keysize_descriptor.o dump-asm.o dump-decl.o bcal-cfb_byte.o \ bcal-cfb_bit.o bcal-ofb.o bcal-ctr.o bcal-cmac.o cmacvs.o \ - bcal-eax.o + bcal-eax.o bcal-performance.o $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/camellia.mk b/mkfiles/camellia.mk index 4b0213c..988b29a 100644 --- a/mkfiles/camellia.mk +++ b/mkfiles/camellia.mk @@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := camellia/ $(ALGO_NAME)_OBJ := camellia128-stub.o camellia-asm.o -$(ALGO_NAME)_TEST_BIN := main-camellia-test.o $(CLI_STD) nessie_bc_test.o \ - nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-camellia-test.o $(CLI_STD) $(BCAL_STD) \ + bcal_camellia128.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/cast5.mk b/mkfiles/cast5.mk index 318a0e5..a2e5fd7 100644 --- a/mkfiles/cast5.mk +++ b/mkfiles/cast5.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := cast5/ $(ALGO_NAME)_OBJ := cast5.o -$(ALGO_NAME)_TEST_BIN := main-cast5-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-cast5-test.o bcal_cast5.o $(CLI_STD) $(BCAL_STD) $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/cast6.mk b/mkfiles/cast6.mk index f28800a..6d035b5 100644 --- a/mkfiles/cast6.mk +++ b/mkfiles/cast6.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := cast6/ $(ALGO_NAME)_OBJ := cast6.o -$(ALGO_NAME)_TEST_BIN := main-cast6-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-cast6-test.o bcal_cast6.o $(CLI_STD) $(BCAL_STD) $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/des.mk b/mkfiles/des.mk index 180d9e1..ae283d3 100644 --- a/mkfiles/des.mk +++ b/mkfiles/des.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := des/ $(ALGO_NAME)_OBJ := des.o -$(ALGO_NAME)_TEST_BIN := main-des-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-des-test.o bcal_des.o $(CLI_STD) $(BCAL_STD) $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/noekeon.mk b/mkfiles/noekeon.mk index 0863162..6427479 100644 --- a/mkfiles/noekeon.mk +++ b/mkfiles/noekeon.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := noekeon_asm.o -$(ALGO_NAME)_TEST_BIN := main-noekeon-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-noekeon-test.o bcal_noekeon.o $(CLI_STD) $(BCAL_STD) $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/noekeon_c.mk b/mkfiles/noekeon_c.mk index 0f7f087..a106a05 100644 --- a/mkfiles/noekeon_c.mk +++ b/mkfiles/noekeon_c.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := noekeon.o -$(ALGO_NAME)_TEST_BIN := main-noekeon-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-noekeon-test.o bcal_noekeon.o $(CLI_STD) $(BCAL_STD) $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/present.mk b/mkfiles/present.mk index 3c73f82..3fd2d91 100644 --- a/mkfiles/present.mk +++ b/mkfiles/present.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := present/ $(ALGO_NAME)_OBJ := present.o -$(ALGO_NAME)_TEST_BIN := main-present-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-present-test.o bcal_present.o $(CLI_STD) $(BCAL_STD) $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/rc5.mk b/mkfiles/rc5.mk index be82175..fe006e3 100644 --- a/mkfiles/rc5.mk +++ b/mkfiles/rc5.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := rc5/ $(ALGO_NAME)_OBJ := rc5.o -$(ALGO_NAME)_TEST_BIN := main-rc5-test.o $(CLI_STD) nessie_bc_test.o \ - nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-rc5-test.o bcal_rc5.o $(CLI_STD) $(BCAL_STD) $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/rc6.mk b/mkfiles/rc6.mk index a58b138..75742c1 100644 --- a/mkfiles/rc6.mk +++ b/mkfiles/rc6.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := rc6/ $(ALGO_NAME)_OBJ := rc6.o -$(ALGO_NAME)_TEST_BIN := main-rc6-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-rc6-test.o bcal_rc6.o $(CLI_STD) $(BCAL_STD) $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/seed.mk b/mkfiles/seed.mk index 07ceb3e..7d532d1 100644 --- a/mkfiles/seed.mk +++ b/mkfiles/seed.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := seed/ $(ALGO_NAME)_OBJ := seed-asm.o -$(ALGO_NAME)_TEST_BIN := main-seed-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-seed-test.o bcal_seed.o $(CLI_STD) $(BCAL_STD) $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/seed_C.mk b/mkfiles/seed_C.mk index 7c77666..2bd3802 100644 --- a/mkfiles/seed_C.mk +++ b/mkfiles/seed_C.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := seed/ $(ALGO_NAME)_OBJ := seed_C.o -$(ALGO_NAME)_TEST_BIN := main-seed-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-seed-test.o bcal_seed.o $(CLI_STD) $(BCAL_STD) $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/serpent-bitslice.mk b/mkfiles/serpent-bitslice.mk index 5719143..500de49 100644 --- a/mkfiles/serpent-bitslice.mk +++ b/mkfiles/serpent-bitslice.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := serpent/ $(ALGO_NAME)_OBJ := serpent-asm.o serpent-sboxes-bitslice-asm.o memxor.o -$(ALGO_NAME)_TEST_BIN := main-serpent-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-serpent-test.o bcal_serpent.o $(CLI_STD) $(BCAL_STD) $(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 a5956c3..a36fe02 100644 --- a/mkfiles/serpent_asm_bitslice.mk +++ b/mkfiles/serpent_asm_bitslice.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := serpent/ $(ALGO_NAME)_OBJ := serpent-sboxes-bitslice-asm.o serpent-asm.o memxor.o -$(ALGO_NAME)_TEST_BIN := main-serpent-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-serpent-test.o bcal_serpent.o $(CLI_STD) $(BCAL_STD) $(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 d9ff725..d0dbc5c 100644 --- a/mkfiles/serpent_asm_fast.mk +++ b/mkfiles/serpent_asm_fast.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := serpent/ $(ALGO_NAME)_OBJ := serpent-asm.o serpent-sboxes-fast.o memxor.o -$(ALGO_NAME)_TEST_BIN := main-serpent-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-serpent-test.o bcal_serpent.o $(CLI_STD) $(BCAL_STD) $(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 4d6750e..61854eb 100644 --- a/mkfiles/serpent_asm_small.mk +++ b/mkfiles/serpent_asm_small.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := serpent/ $(ALGO_NAME)_OBJ := serpent-asm.o serpent-sboxes-small.o memxor.o -$(ALGO_NAME)_TEST_BIN := main-serpent-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-serpent-test.o bcal_serpent.o $(CLI_STD) $(BCAL_STD) $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/serpent_c.mk b/mkfiles/serpent_c.mk index f52ced4..1f912dc 100644 --- a/mkfiles/serpent_c.mk +++ b/mkfiles/serpent_c.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := serpent/ $(ALGO_NAME)_OBJ := serpent.o serpent-sboxes_c.o memxor.o -$(ALGO_NAME)_TEST_BIN := main-serpent-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-serpent-test.o bcal_serpent.o $(CLI_STD) $(BCAL_STD) $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/skipjack.mk b/mkfiles/skipjack.mk index ef859df..94d0195 100644 --- a/mkfiles/skipjack.mk +++ b/mkfiles/skipjack.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := skipjack/ $(ALGO_NAME)_OBJ := skipjack.o -$(ALGO_NAME)_TEST_BIN := main-skipjack-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-skipjack-test.o bcal_skipjack.o $(CLI_STD) $(BCAL_STD) $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/tdes.mk b/mkfiles/tdes.mk index 09bb96c..c893bfc 100644 --- a/mkfiles/tdes.mk +++ b/mkfiles/tdes.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := des/ $(ALGO_NAME)_OBJ := des.o -$(ALGO_NAME)_TEST_BIN := main-tdes-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-tdes-test.o bcal_tdes.o bcal_tdes2.o $(CLI_STD) $(BCAL_STD) $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/threefish.mk b/mkfiles/threefish.mk index 4e7abc3..f38cad1 100644 --- a/mkfiles/threefish.mk +++ b/mkfiles/threefish.mk @@ -8,8 +8,7 @@ $(ALGO_NAME)_DIR := skein/ $(ALGO_NAME)_OBJ := threefish256_enc_asm.o threefish512_enc_asm.o threefish1024_enc_asm.o\ threefish_mix.o threefish_invmix.o \ threefish256_dec_asm.o threefish512_dec_asm.o threefish1024_dec_asm.o -$(ALGO_NAME)_TEST_BIN := main-threefish-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-threefish-test.o bcal_threefish256.o bcal_threefish512.o bcal_threefish1024.o $(CLI_STD) $(BCAL_STD) $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/threefish_C.mk b/mkfiles/threefish_C.mk index 78bfab2..8f0ab70 100644 --- a/mkfiles/threefish_C.mk +++ b/mkfiles/threefish_C.mk @@ -7,8 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := skein/ $(ALGO_NAME)_OBJ := threefish256_enc.o threefish512_enc.o threefish1024_enc.o threefish_mix_c.o \ threefish_invmix_c.o threefish256_dec.o threefish512_dec.o threefish1024_dec.o -$(ALGO_NAME)_TEST_BIN := main-threefish-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-threefish-test.o bcal_threefish256.o bcal_threefish512.o bcal_threefish1024.o $(CLI_STD) $(BCAL_STD) $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/threefish_small.mk b/mkfiles/threefish_small.mk index 9899f21..bdb0438 100644 --- a/mkfiles/threefish_small.mk +++ b/mkfiles/threefish_small.mk @@ -8,8 +8,7 @@ $(ALGO_NAME)_DIR := skein/ $(ALGO_NAME)_OBJ := threefish256_enc_small.o threefish512_enc.o threefish1024_enc.o\ threefish_mix.o threefish_mix_4c.o threefish_invmix_c.o \ threefish256_dec.o threefish512_dec.o threefish1024_dec.o -$(ALGO_NAME)_TEST_BIN := main-threefish-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-threefish-test.o bcal_threefish256.o bcal_threefish512.o bcal_threefish1024.o $(CLI_STD) $(BCAL_STD) $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/xtea.mk b/mkfiles/xtea.mk index f2d1169..9b61ba8 100644 --- a/mkfiles/xtea.mk +++ b/mkfiles/xtea.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := xtea/ $(ALGO_NAME)_OBJ := xtea-asm.o -$(ALGO_NAME)_TEST_BIN := main-xtea-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-xtea-test.o bcal_xtea.o $(CLI_STD) $(BCAL_STD) $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/xtea_c.mk b/mkfiles/xtea_c.mk index 5bbd680..4f89a4e 100644 --- a/mkfiles/xtea_c.mk +++ b/mkfiles/xtea_c.mk @@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := xtea/ $(ALGO_NAME)_OBJ := xtea.o -$(ALGO_NAME)_TEST_BIN := main-xtea-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-xtea-test.o bcal_xtea.o $(CLI_STD) $(BCAL_STD) $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/test_src/main-aes-test.c b/test_src/main-aes-test.c index b17382a..9ec7056 100644 --- a/test_src/main-aes-test.c +++ b/test_src/main-aes-test.c @@ -44,6 +44,7 @@ #include "bcal-cmac.h" #include "bcal-eax.h" #include "cmacvs.h" +#include "bcal-performance.h" #include #include @@ -670,131 +671,10 @@ void testrun_aes128_eax(void){ /*****************************************************************************/ -void testrun_performance_aes128(void){ - uint64_t t; - char str[16]; - uint8_t key[32], data[16]; - aes128_ctx_t ctx; - - calibrateTimer(); - print_overhead(); - - memset(key, 0, 32); - memset(data, 0, 16); - - startTimer(1); - aes128_init(key, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - aes128_enc(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tencrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - aes128_dec(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tdecrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - cli_putstr_P(PSTR("\r\n")); -} - - -void testrun_performance_aes192(void){ - uint64_t t; - char str[16]; - uint8_t key[32], data[16]; - aes192_ctx_t ctx; - - calibrateTimer(); - print_overhead(); - - memset(key, 0, 32); - memset(data, 0, 16); - - startTimer(1); - aes192_init(key, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - aes192_enc(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tencrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - aes192_dec(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tdecrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - cli_putstr_P(PSTR("\r\n")); -} - - -void testrun_performance_aes256(void){ - uint64_t t; - char str[16]; - uint8_t key[32], data[16]; - aes256_ctx_t ctx; - - calibrateTimer(); - print_overhead(); - - memset(key, 0, 32); - memset(data, 0, 16); - - startTimer(1); - aes256_init(key, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - aes256_enc(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tencrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - aes256_dec(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tdecrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - cli_putstr_P(PSTR("\r\n")); -} - void testrun_performance_aes(void){ - cli_putstr_P(PSTR("\r\n -=AES Performance Test=-\r\n")); - cli_putstr_P(PSTR("\r\n AES-128\r\n")); - testrun_performance_aes128(); - cli_putstr_P(PSTR("\r\n AES-192\r\n")); - testrun_performance_aes192(); - cli_putstr_P(PSTR("\r\n AES-256\r\n")); - testrun_performance_aes256(); + bcal_performance_multiple(algolist); } + /***************************************************************************** * main * *****************************************************************************/ diff --git a/test_src/main-camellia-test.c b/test_src/main-camellia-test.c index 2cc6439..fb9f881 100644 --- a/test_src/main-camellia-test.c +++ b/test_src/main-camellia-test.c @@ -30,15 +30,19 @@ #include "nessie_bc_test.h" #include "performance_test.h" #include "cli.h" - -char* algo_name = "Camellia"; - - +#include "bcal_camellia128.h" +#include "bcal-performance.h" #include #include #include #include +char* algo_name = "Camellia"; + +const bcdesc_t* algolist[] PROGMEM = { + (bcdesc_t*)&camellia128_desc, + NULL +}; /***************************************************************************** * additional validation-functions * @@ -59,45 +63,77 @@ void testrun_nessie_camellia(void){ nessie_bc_run(); } +/* + * P No.001 : 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + */ -void test_performance_camellia(void){ - uint64_t t; - char str[6]; - uint8_t key[16], data[16]; - camellia128_ctx_t ctx; - - calibrateTimer(); - print_overhead(); - - memset(key, 0, 16); - memset(data, 0, 16); - - startTimer(1); - camellia128_init(key, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - camellia128_enc(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tencrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - camellia128_dec(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tdecrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - cli_putstr_P(PSTR("\r\n")); +uint8_t test_keys[] PROGMEM = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, + 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, + 0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, 0x99, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00, + 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, + 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, + 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, 0xEF, 0xCD, 0xAB, 0x89, 0x67, 0x45, 0x23, 0x01, + 0xEF, 0xCD, 0xAB, 0x89, 0x67, 0x45, 0x23, 0x01, 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE +}; + +void hexdump128(void* data){ + uint8_t i; + for(i=0; i<16; ++i){ + cli_hexdump(data, 1); + cli_putc(' '); + data = (uint8_t*)data +1; + } +} + +void testrun_camellia128(void){ + uint8_t data[16]; + uint8_t data2[16]; + uint8_t key[16]; + char str[4]; + uint8_t i,j; + str[3]= '\0'; + for(j=0; j<10; ++j){ + str[0] = ('0'+(j+1)/100); + str[1] = ('0'+((j+1)/10)%10); + str[2] = ('0'+(j+1)%10); + memcpy_P(key, test_keys+j*16, 16); + cli_putstr_P(PSTR("\r\nK No.")); + cli_putstr(str); + cli_putstr_P(PSTR(" : ")); + hexdump128(key); + camellia128_ctx_t ctx; + camellia128_init(key, &ctx); + for(i=0; i<128; ++i){ + memset(data, 0x00, 16); + data[i/8] = 0x80>>i%8; + memcpy(data2, data, 16); + str[0] = ('0'+(i+1)/100); + str[1] = ('0'+((i+1)/10)%10); + str[2] = ('0'+(i+1)%10); + cli_putstr_P(PSTR("\r\nP No.")); + cli_putstr(str); + cli_putstr_P(PSTR(" : ")); + hexdump128(data); + camellia128_enc(data, &ctx); + cli_putstr_P(PSTR("\r\nC No.")); + cli_putstr(str); + cli_putstr_P(PSTR(" : ")); + hexdump128(data); + camellia128_dec(data, &ctx); + if(memcmp(data, data2, 16)){ + cli_putstr_P(PSTR("\r\n DECRYPTION ERROR !!!")); + } + } + } } +void test_performance_camellia(void){ + bcal_performance_multiple(algolist); +} /***************************************************************************** @@ -139,17 +175,19 @@ void testrun_camellia(void){ /***************************************************************************** - * main * + * main * *****************************************************************************/ const char nessie_str[] PROGMEM = "nessie"; const char test_str[] PROGMEM = "test"; +const char test128_str[] PROGMEM = "test128"; const char performance_str[] PROGMEM = "performance"; const char echo_str[] PROGMEM = "echo"; cmdlist_entry_t cmdlist[] PROGMEM = { { nessie_str, NULL, testrun_nessie_camellia }, { test_str, NULL, testrun_camellia}, + { test128_str, NULL, testrun_camellia128}, { performance_str, NULL, test_performance_camellia}, { echo_str, (void*)1, (void_fpt)echo_ctrl}, { NULL, NULL, NULL} diff --git a/test_src/main-cast5-test.c b/test_src/main-cast5-test.c index a8f8890..3db72a7 100644 --- a/test_src/main-cast5-test.c +++ b/test_src/main-cast5-test.c @@ -29,6 +29,8 @@ #include #include "nessie_bc_test.h" #include "performance_test.h" +#include "bcal-performance.h" +#include "bcal_cast5.h" #include "cli.h" #include @@ -37,6 +39,11 @@ char* algo_name = "cast-128 (cast5)"; +const bcdesc_t* algolist[] PROGMEM = { + (bcdesc_t*)&cast5_desc, + NULL +}; + /***************************************************************************** * additional validation-functions * *****************************************************************************/ @@ -152,41 +159,7 @@ void testrun_cast5(void){ } void testrun_performance_cast5(void){ - uint64_t t; - char str[6]; - uint8_t key[16], data[16]; - cast5_ctx_t ctx; - - calibrateTimer(); - print_overhead(); - - memset(key, 0, 16); - memset(data, 0, 16); - - startTimer(1); - cast5_init(key, 128, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - cast5_enc(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tencrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - cast5_dec(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tdecrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - cli_putstr_P(PSTR("\r\n")); + bcal_performance_multiple(algolist); } /***************************************************************************** diff --git a/test_src/main-cast6-test.c b/test_src/main-cast6-test.c index 27e0478..c295b69 100644 --- a/test_src/main-cast6-test.c +++ b/test_src/main-cast6-test.c @@ -12,6 +12,8 @@ #include "nessie_bc_test.h" #include "cli.h" #include "performance_test.h" +#include "bcal-performance.h" +#include "bcal_cast6.h" #include #include @@ -20,6 +22,11 @@ char* algo_name = "CAST-256"; +const bcdesc_t* algolist[] PROGMEM = { + (bcdesc_t*)&cast6_desc, + NULL +}; + /***************************************************************************** * additional validation-functions * *****************************************************************************/ @@ -104,39 +111,9 @@ void testrun_rfc_cast6(void){ } void testrun_performance_cast6(void){ - uint64_t t; - char str[16]; - uint8_t key[16], data[16]; - cast6_ctx_t ctx; - - calibrateTimer(); - print_overhead(); - - memset(key, 0, 16); - memset(data, 0, 16); - - startTimer(1); - cast6_init(key, 128, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - cast6_enc(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tencrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - cast6_dec(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tdecrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - cli_putstr_P(PSTR("\r\n")); + bcal_performance_multiple(algolist); } + /***************************************************************************** * main * *****************************************************************************/ diff --git a/test_src/main-des-test.c b/test_src/main-des-test.c index a674d6e..f6d237c 100644 --- a/test_src/main-des-test.c +++ b/test_src/main-des-test.c @@ -30,6 +30,8 @@ #include "nessie_bc_test.h" #include "cli.h" #include "performance_test.h" +#include "bcal-performance.h" +#include "bcal_des.h" #include #include @@ -37,6 +39,10 @@ char* algo_name = "DES"; +const bcdesc_t* algolist[] PROGMEM = { + (bcdesc_t*)&des_desc, + NULL +}; /***************************************************************************** * additional validation-functions * *****************************************************************************/ @@ -67,31 +73,7 @@ void testrun_nessie_des(void){ void testrun_performance_des(void){ - uint64_t t; - char str[16]; - uint8_t key[8], data[8]; - - - calibrateTimer(); - print_overhead(); - - memset(key, 0, 8); - memset(data, 0, 8); - - startTimer(1); - des_enc(data, data, key); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tencrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - des_dec(data, data, key); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tdecrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - cli_putstr_P(PSTR("\r\n")); + bcal_performance_multiple(algolist); } /***************************************************************************** * main diff --git a/test_src/main-noekeon-test.c b/test_src/main-noekeon-test.c index fa0c323..47f9661 100644 --- a/test_src/main-noekeon-test.c +++ b/test_src/main-noekeon-test.c @@ -30,6 +30,8 @@ #include "nessie_bc_test.h" #include "cli.h" #include "performance_test.h" +#include "bcal-performance.h" +#include "bcal_noekeon.h" #include #include @@ -37,6 +39,11 @@ char* algo_name = "Noekeon"; +const bcdesc_t* algolist[] PROGMEM = { + (bcdesc_t*)&noekeon_direct_desc, + (bcdesc_t*)&noekeon_indirect_desc, + NULL +}; /***************************************************************************** * additional validation-functions * *****************************************************************************/ @@ -173,39 +180,7 @@ void testrun_stdtest_noekeon(void){ } void testrun_performance_noekeon(void){ - uint64_t t; - char str[16]; - uint8_t key[16], data[16]; - noekeon_ctx_t ctx; - - calibrateTimer(); - print_overhead(); - - memset(key, 0, 16); - memset(data, 0, 16); - - startTimer(1); - noekeon_init(key, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - noekeon_enc(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tencrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - noekeon_dec(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tdecrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - cli_putstr_P(PSTR("\r\n")); + bcal_performance_multiple(algolist); } /***************************************************************************** * main * diff --git a/test_src/main-present-test.c b/test_src/main-present-test.c index c7c65d2..96b0ff7 100644 --- a/test_src/main-present-test.c +++ b/test_src/main-present-test.c @@ -30,6 +30,8 @@ #include "nessie_bc_test.h" #include "cli.h" #include "performance_test.h" +#include "bcal-performance.h" +#include "bcal_present.h" #include #include @@ -37,6 +39,10 @@ char* algo_name = "Present"; +const bcdesc_t* algolist[] PROGMEM = { + (bcdesc_t*)&present_desc, + NULL +}; /***************************************************************************** * additional validation-functions * *****************************************************************************/ @@ -95,32 +101,7 @@ void testrun_self_present(void){ } void testrun_performance_present(void){ - uint64_t t; - uint8_t key[10], data[8]; - present_ctx_t ctx; - - calibrateTimer(); - print_overhead(); - - memset(key, 0, 10); - memset(data, 0, 8); - - startTimer(1); - present_init(key, 80, &ctx); - t = stopTimer(); - print_time_P(PSTR("\tctx-gen time: "),t); - - startTimer(1); - present_enc(data, &ctx); - t = stopTimer(); - print_time_P(PSTR("\tencrypt time: "), t); - - startTimer(1); - present_dec(data, &ctx); - t = stopTimer(); - print_time_P(PSTR("\tdecrypt time: "), t); - - cli_putstr_P(PSTR("\r\n")); + bcal_performance_multiple(algolist); } /***************************************************************************** diff --git a/test_src/main-rc5-test.c b/test_src/main-rc5-test.c index 640c65f..95a3e06 100644 --- a/test_src/main-rc5-test.c +++ b/test_src/main-rc5-test.c @@ -30,6 +30,8 @@ #include "nessie_bc_test.h" #include "cli.h" #include "performance_test.h" +#include "bcal-performance.h" +#include "bcal_rc5.h" #include #include @@ -38,6 +40,11 @@ #define RC5_ROUNDS 12 char* algo_name = "RC5-32/12/16"; +const bcdesc_t* algolist[] PROGMEM = { + (bcdesc_t*)&rc5_desc, + NULL +}; + /***************************************************************************** * additional validation-functions * *****************************************************************************/ @@ -61,45 +68,7 @@ void testrun_nessie_rc5(void){ void testrun_performance_rc5(void){ - uint64_t t; - char str[16]; - uint8_t key[16], data[16]; - rc5_ctx_t ctx; - - calibrateTimer(); - print_overhead(); - - memset(key, 0, 16); - memset(data, 0, 16); - - startTimer(1); - rc5_init(key, 128, RC5_ROUNDS, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - rc5_enc(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tencrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - rc5_dec(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tdecrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - rc5_free(&ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tfree time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - cli_putstr_P(PSTR("\r\n")); + bcal_performance_multiple(algolist); } /***************************************************************************** * main * diff --git a/test_src/main-rc6-test.c b/test_src/main-rc6-test.c index c3bb0f0..67513ad 100644 --- a/test_src/main-rc6-test.c +++ b/test_src/main-rc6-test.c @@ -30,6 +30,8 @@ #include "nessie_bc_test.h" #include "cli.h" #include "performance_test.h" +#include "bcal-performance.h" +#include "bcal_rc6.h" #include #include @@ -38,6 +40,10 @@ #define RC6_ROUNDS 20 char* algo_name = "RC6-32/20/16"; +const bcdesc_t* algolist[] PROGMEM = { + (bcdesc_t*)&rc6_desc, + NULL +}; /***************************************************************************** * additional validation-functions * *****************************************************************************/ @@ -68,45 +74,7 @@ void testrun_nessie_rc6(void){ void testrun_performance_rc6(void){ - uint64_t t; - char str[16]; - uint8_t key[16], data[16]; - rc6_ctx_t ctx; - - calibrateTimer(); - print_overhead(); - - memset(key, 0, 16); - memset(data, 0, 16); - - startTimer(1); - rc6_init(key, 128, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - rc6_enc(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tencrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - rc6_dec(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tdecrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - rc6_free(&ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tfree time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - cli_putstr_P(PSTR("\r\n")); + bcal_performance_multiple(algolist); } /***************************************************************************** * main * diff --git a/test_src/main-seed-test.c b/test_src/main-seed-test.c index 4e06559..9ff4b3f 100644 --- a/test_src/main-seed-test.c +++ b/test_src/main-seed-test.c @@ -35,6 +35,8 @@ #include "nessie_bc_test.h" #include "cli.h" #include "performance_test.h" +#include "bcal-performance.h" +#include "bcal_seed.h" #include #include @@ -42,6 +44,10 @@ char* algo_name = "Seed"; +const bcdesc_t* algolist[] PROGMEM = { + (bcdesc_t*)&seed_desc, + NULL +}; /***************************************************************************** * additional validation-functions * *****************************************************************************/ @@ -64,41 +70,7 @@ void testrun_nessie_seed(void){ void testrun_performance_seed(void){ - uint64_t t; - char str[16]; - uint8_t key[16], data[16]; - seed_ctx_t ctx; - - calibrateTimer(); - print_overhead(); - - memset(key, 0, 16); - memset(data, 0, 16); - - startTimer(1); - seed_init(key, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - seed_enc(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tencrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - seed_dec(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tdecrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - cli_putstr_P(PSTR("\r\n")); + bcal_performance_multiple(algolist); } /***************************************************************************** diff --git a/test_src/main-serpent-test.c b/test_src/main-serpent-test.c index 896d879..51575b9 100644 --- a/test_src/main-serpent-test.c +++ b/test_src/main-serpent-test.c @@ -30,6 +30,8 @@ #include "nessie_bc_test.h" #include "cli.h" #include "performance_test.h" +#include "bcal-performance.h" +#include "bcal_serpent.h" #include #include @@ -37,6 +39,11 @@ char* algo_name = "Serpent"; +const bcdesc_t* algolist[] PROGMEM = { + (bcdesc_t*)&serpent_desc, + NULL +}; + /***************************************************************************** * additional validation-functions * *****************************************************************************/ @@ -77,41 +84,7 @@ void testrun_test_serpent(void){ } void testrun_performance_serpent(void){ - uint64_t t; - char str[16]; - uint8_t key[32], data[16]; - serpent_ctx_t ctx; - - calibrateTimer(); - print_overhead(); - - memset(key, 0, 32); - memset(data, 0, 16); - - startTimer(1); - serpent_init(key, 0, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - serpent_enc(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tencrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - serpent_dec(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tdecrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - cli_putstr_P(PSTR("\r\n")); + bcal_performance_multiple(algolist); } /***************************************************************************** * main * diff --git a/test_src/main-skipjack-test.c b/test_src/main-skipjack-test.c index c37f2bc..3f1c75f 100644 --- a/test_src/main-skipjack-test.c +++ b/test_src/main-skipjack-test.c @@ -30,6 +30,8 @@ #include "nessie_bc_test.h" #include "cli.h" #include "performance_test.h" +#include "bcal-performance.h" +#include "bcal_skipjack.h" #include #include @@ -38,6 +40,10 @@ char* algo_name = "Skipjack"; +const bcdesc_t* algolist[] PROGMEM = { + (bcdesc_t*)&skipjack_desc, + NULL +}; /***************************************************************************** * additional validation-functions * *****************************************************************************/ @@ -59,32 +65,7 @@ void testrun_nessie_skipjack(void){ void testrun_performance_skipjack(void){ - uint64_t t; - char str[16]; - uint8_t key[10], data[8]; - - calibrateTimer(); - print_overhead(); - - memset(key, 0, 10); - memset(data, 0, 8); - - startTimer(1); - skipjack_enc(data, key); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tencrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - - startTimer(1); - skipjack_dec(data, key); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tdecrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - cli_putstr_P(PSTR("\r\n")); + bcal_performance_multiple(algolist); } /***************************************************************************** diff --git a/test_src/main-tdes-test.c b/test_src/main-tdes-test.c index ab6cd5e..7adc19e 100644 --- a/test_src/main-tdes-test.c +++ b/test_src/main-tdes-test.c @@ -30,6 +30,9 @@ #include "nessie_bc_test.h" #include "cli.h" #include "performance_test.h" +#include "bcal-performance.h" +#include "bcal_tdes.h" +#include "bcal_tdes2.h" #include #include @@ -37,6 +40,12 @@ char* algo_name = "TDES"; +const bcdesc_t* algolist[] PROGMEM = { + (bcdesc_t*)&tdes_desc, + (bcdesc_t*)&tdes2_desc, + NULL +}; + /***************************************************************************** * additional validation-functions * *****************************************************************************/ @@ -67,31 +76,7 @@ void testrun_nessie_tdes(void){ void testrun_performance_tdes(void){ - uint64_t t; - char str[16]; - uint8_t key[8*3], data[8]; - - - calibrateTimer(); - print_overhead(); - - memset(key, 0, 8*3); - memset(data, 0, 8); - - startTimer(1); - tdes_enc(data, data, key); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tencrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - tdes_dec(data, data, key); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tdecrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - cli_putstr_P(PSTR("\r\n")); + bcal_performance_multiple(algolist); } /***************************************************************************** * main * diff --git a/test_src/main-threefish-test.c b/test_src/main-threefish-test.c index fd233bd..31748e4 100644 --- a/test_src/main-threefish-test.c +++ b/test_src/main-threefish-test.c @@ -30,6 +30,10 @@ #include "nessie_bc_test.h" #include "cli.h" #include "performance_test.h" +#include "bcal-performance.h" +#include "bcal_threefish256.h" +#include "bcal_threefish512.h" +#include "bcal_threefish1024.h" #include #include @@ -37,6 +41,12 @@ char* algo_name = "Threefish"; +const bcdesc_t* algolist[] PROGMEM = { + (bcdesc_t*)&threefish256_desc, + (bcdesc_t*)&threefish512_desc, + (bcdesc_t*)&threefish1024_desc, + NULL +}; /***************************************************************************** * additional validation-functions * *****************************************************************************/ @@ -267,129 +277,8 @@ void testrun_stdtest_threefish(void){ testrun_stdtest_threefish1024(); } -void testrun_performance_threefish256(void){ - uint64_t t; - char str[16]; - uint8_t key[THREEFISH256_BLOCKSIZE_B]; - uint8_t data[THREEFISH256_BLOCKSIZE_B]; - uint8_t tweak[16]; - threefish256_ctx_t ctx; - - cli_putstr_P(PSTR("\r\nThreefish-256 performance:")); - - calibrateTimer(); - print_overhead(); - -// memset(key, 0, THREEFISH256_BLOCKSIZE_B); -// memset(tweak, 0, 16); - - startTimer(1); - threefish256_init(key, tweak, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - threefish256_enc(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tencrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - threefish256_dec(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tdecrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - cli_putstr_P(PSTR("\r\n")); -} - -void testrun_performance_threefish512(void){ - uint64_t t; - char str[16]; - uint8_t key[THREEFISH512_BLOCKSIZE_B]; - uint8_t data[THREEFISH512_BLOCKSIZE_B]; - uint8_t tweak[16]; - threefish512_ctx_t ctx; - - cli_putstr_P(PSTR("\r\nThreefish-512 performance:")); - - calibrateTimer(); - print_overhead(); - -// memset(key, 0, THREEFISH512_BLOCKSIZE_B); -// memset(tweak, 0, 16); - - startTimer(1); - threefish512_init(key, tweak, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - threefish512_enc(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tencrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - threefish512_dec(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tdecrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - cli_putstr_P(PSTR("\r\n")); -} - -void testrun_performance_threefish1024(void){ - uint64_t t; - char str[16]; - uint8_t key[THREEFISH1024_BLOCKSIZE_B]; - uint8_t data[THREEFISH1024_BLOCKSIZE_B]; - uint8_t tweak[16]; - threefish1024_ctx_t ctx; - - cli_putstr_P(PSTR("\r\nThreefish-1024 performance:")); - - calibrateTimer(); - print_overhead(); - -// memset(key, 0, THREEFISH1024_BLOCKSIZE_B); -// memset(tweak, 0, 16); - - startTimer(1); - threefish1024_init(key, tweak, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tctx-gen time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - threefish1024_enc(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tencrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - startTimer(1); - threefish1024_dec(data, &ctx); - t = stopTimer(); - cli_putstr_P(PSTR("\r\n\tdecrypt time: ")); - ultoa((unsigned long)t, str, 10); - cli_putstr(str); - - cli_putstr_P(PSTR("\r\n")); -} - void testrun_performance_threefish(void){ - testrun_performance_threefish256(); - testrun_performance_threefish512(); - testrun_performance_threefish1024(); + bcal_performance_multiple(algolist); } void init_test(void){ diff --git a/test_src/main-xtea-test.c b/test_src/main-xtea-test.c index aaebdf3..c40046f 100644 --- a/test_src/main-xtea-test.c +++ b/test_src/main-xtea-test.c @@ -29,6 +29,8 @@ #include "xtea.h" #include "nessie_bc_test.h" #include "performance_test.h" +#include "bcal-performance.h" +#include "bcal_xtea.h" #include "cli.h" #include @@ -36,6 +38,13 @@ char* algo_name = "XTEA"; +const bcdesc_t* algolist[] PROGMEM = { + (bcdesc_t*)&xtea_desc, + NULL +}; + +/******************************************************************************/ + void xtea_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){ memcpy(ctx, key, (keysize+7)/8); } @@ -61,26 +70,7 @@ void testrun_nessie_xtea(void){ } void testrun_performance_xtea(void){ - uint64_t t; - uint8_t key[16], data[8]; - - calibrateTimer(); - print_overhead(); - - memset(key, 0, 16); - memset(data, 0, 8); - - startTimer(1); - xtea_enc(data, data, key); - t = stopTimer(); - print_time_P(PSTR("\tencrypt time: "), t); - - startTimer(1); - xtea_dec(data, data, key); - t = stopTimer(); - print_time_P(PSTR("\tdecrypt time: "), t); - - cli_putstr_P(PSTR("\r\n")); + bcal_performance_multiple(algolist); } /*****************************************************************************