From 794b705a0b4dedf4eab3aabcf39f76bf9856ee3f Mon Sep 17 00:00:00 2001 From: bg Date: Mon, 21 Jun 2010 21:08:03 +0000 Subject: [PATCH] some modifications in test suits --- Makefile | 49 +++++++++++++----------- bcal-performance.c | 75 ++++++++++++++++++++++++++++++++++++- bcal_present.c | 2 +- bmw/bmw_224-tinyasm.S | 63 +++++++++++-------------------- bmw/bmw_256-tinyasm.S | 63 +++++++++++-------------------- bmw/bmw_small-tinyasm.S | 62 +++++++++++------------------- mkfiles/001_bcal_std.mk | 3 +- mkfiles/aes.mk | 9 ++--- mkfiles/aes128.mk | 4 +- mkfiles/aes192.mk | 4 +- mkfiles/aes256.mk | 4 +- mkfiles/aes_asm_faster.mk | 8 +++- mkfiles/aes_c.mk | 9 ++--- mkfiles/camellia_c.mk | 4 +- mkfiles/shabea.mk | 2 +- test_src/main-aes128-test.c | 51 +++++-------------------- test_src/main-aes192-test.c | 53 ++++++-------------------- test_src/main-aes256-test.c | 52 +++++-------------------- 18 files changed, 223 insertions(+), 294 deletions(-) diff --git a/Makefile b/Makefile index 58b17e0..ebc4a6e 100644 --- a/Makefile +++ b/Makefile @@ -179,6 +179,8 @@ $(foreach algo, $(ALGORITHMS), $(eval $(call Speed_Template, \ .PHONY: hash_speed hash_speed: $(foreach algo, $(HASHES), $(algo)_SPEED) +.PHONY: blockcipher_speed +blockcipher_speed: $(foreach algo, $(BLOCK_CIPHERS), $(algo)_SPEED) #------------------------------------------------------------------------------- @@ -195,6 +197,9 @@ $(foreach algo, $(ALGORITHMS), $(eval $(call Size_Template, \ .PHONY: hash_size hash_size: $(foreach algo, $(HASHES), $(algo)_SIZE) +.PHONY: blockcipher_size +blockcipher_size: $(foreach algo, $(BLOCK_CIPHERS), $(algo)_SIZE) + #------------------------------------------------------------------------------- .PHONY: tests @@ -277,27 +282,29 @@ info: @echo " auxiliary functions:" @echo " $(AUX)" @echo " targets:" - @echo " all - all algorithm cores" - @echo " cores - all algorithm cores" - @echo " listings - all algorithm core listings" - @echo " tests - all algorithm test programs" - @echo " stats - all algorithm size statistics" - @echo " blockciphers - all blockcipher cores" - @echo " streamciphers - all streamcipher cores" - @echo " hashes - all hash cores" - @echo " macs - all MAC cores" - @echo " prngs - all PRNG cores" - @echo " all_testrun - testrun all algorithms" - @echo " hash_size - measure size of all hash functions" - @echo " hash_speed - measure performance of all hash functions" - @echo " docu - build doxygen documentation" - @echo " clean - remove a lot of builded files" - @echo " depclean - also remove dependency files" - @echo " *_TEST_BIN - build test program" - @echo " *_TESTRUN - run nessie test" - @echo " *_OBJ - build algorithm core" - @echo " *_FLASH - flash test program" - @echo " *_LIST - build assembler listing" + @echo " all - all algorithm cores" + @echo " cores - all algorithm cores" + @echo " listings - all algorithm core listings" + @echo " tests - all algorithm test programs" + @echo " stats - all algorithm size statistics" + @echo " blockciphers - all blockcipher cores" + @echo " streamciphers - all streamcipher cores" + @echo " hashes - all hash cores" + @echo " macs - all MAC cores" + @echo " prngs - all PRNG cores" + @echo " all_testrun - testrun all algorithms" + @echo " hash_size - measure size of all hash functions" + @echo " hash_speed - measure performance of all hash functions" + @echo " blockcipher_size - measure size of all blockciphers" + @echo " blockcipher_speed - measure performance of all blockciphers" + @echo " docu - build doxygen documentation" + @echo " clean - remove a lot of builded files" + @echo " depclean - also remove dependency files" + @echo " *_TEST_BIN - build test program" + @echo " *_TESTRUN - run nessie test" + @echo " *_OBJ - build algorithm core" + @echo " *_FLASH - flash test program" + @echo " *_LIST - build assembler listing" #------------------------------------------------------------------------------- diff --git a/bcal-performance.c b/bcal-performance.c index 447e4d1..36cc823 100644 --- a/bcal-performance.c +++ b/bcal-performance.c @@ -30,13 +30,15 @@ #include "keysize_descriptor.h" #include "blockcipher_descriptor.h" #include "performance_test.h" +#include "stack_measuring.h" #include "cli.h" #include #include #include #include - +#define PATTERN_A 0xAA +#define PATTERN_B 0x55 static @@ -137,6 +139,76 @@ void bcal_performance(const bcdesc_t* bcd){ } } +void bcal_stacksize(const bcdesc_t* bcd){ + bcdesc_t bc; + stack_measuring_ctx_t smctx; + 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]; + uint16_t t1, t2; + + if(bc.type!=BCDESC_TYPE_BLOCKCIPHER) + return; + cli_putstr_P(PSTR("\r\n\r\n === ")); + cli_putstr_P(bc.name); + cli_putstr_P(PSTR(" stack-usage === ")); + + if(bc.init.init1){ + if((bc.flags&BC_INIT_TYPE)==BC_INIT_TYPE_1){ + cli(); + stack_measure_init(&smctx, PATTERN_A); + bc.init.init1(&ctx, key); + t1 = stack_measure_final(&smctx); + stack_measure_init(&smctx, PATTERN_B); + bc.init.init1(&ctx, key); + t2 = stack_measure_final(&smctx); + sei(); + } else { + cli(); + stack_measure_init(&smctx, PATTERN_A); + bc.init.init2(&ctx, keysize, key); + t1 = stack_measure_final(&smctx); + stack_measure_init(&smctx, PATTERN_B); + bc.init.init2(&ctx, keysize, key); + t2 = stack_measure_final(&smctx); + sei(); + } + t1 = (t1>t2)?t1:t2; + cli_putstr_P(PSTR("\r\n init (bytes): ")); + printvalue((unsigned long)t1); + } + cli(); + stack_measure_init(&smctx, PATTERN_A); + bc.enc.enc1(data, &ctx); + t1 = stack_measure_final(&smctx); + stack_measure_init(&smctx, PATTERN_B); + bc.enc.enc1(data, &ctx); + t2 = stack_measure_final(&smctx); + sei(); + + t1 = (t1>t2)?t1:t2; + cli_putstr_P(PSTR("\r\n encBlock (bytes): ")); + printvalue((unsigned long)t1); + + cli(); + stack_measure_init(&smctx, PATTERN_A); + bc.dec.dec1(data, &ctx); + t1 = stack_measure_final(&smctx); + stack_measure_init(&smctx, PATTERN_B); + bc.dec.dec1(data, &ctx); + t2 = stack_measure_final(&smctx); + sei(); + + t1 = (t1>t2)?t1:t2; + cli_putstr_P(PSTR("\r\n decBlock (bytes): ")); + printvalue((unsigned long)t1); + + if(bc.free){ + bc.free(&ctx); + } +} void bcal_performance_multiple(const bcdesc_t** bcd_list){ const bcdesc_t* bcd; @@ -147,6 +219,7 @@ void bcal_performance_multiple(const bcdesc_t** bcd_list){ return; } bcal_performance(bcd); + bcal_stacksize(bcd); bcd_list = (void*)((uint8_t*)bcd_list + 2); } } diff --git a/bcal_present.c b/bcal_present.c index 945bd59..96842b1 100644 --- a/bcal_present.c +++ b/bcal_present.c @@ -38,7 +38,7 @@ const uint8_t present_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(80), const bcdesc_t present_desc PROGMEM = { BCDESC_TYPE_BLOCKCIPHER, - BC_INIT_TYPE_1, + BC_INIT_TYPE_2, present_str, sizeof(present_ctx_t), 64, diff --git a/bmw/bmw_224-tinyasm.S b/bmw/bmw_224-tinyasm.S index e01752c..5b3c657 100644 --- a/bmw/bmw_224-tinyasm.S +++ b/bmw/bmw_224-tinyasm.S @@ -41,6 +41,11 @@ acc1 = 15 param s: r20 */ shiftleft32: + tst r20 + brpl 10f + neg r20 + rjmp shiftright32 +10: clr r0 cpi r20, 8 brlo bitrotateleft_1 @@ -49,7 +54,7 @@ shiftleft32: mov r23, r22 clr r22 subi r20, 8 - rjmp shiftleft32 + rjmp 10b /******************************************************************************/ /* @@ -257,10 +262,11 @@ mov32_to_acc: f2_1_shift_table: ; .byte 0x2B, 0x64, 0x66, 0x03, 0x51, 0x55, 0x87, 0x55 - .byte 0x55, 0x87, 0x55, 0x51, 0x03, 0x66, 0x64, 0x2B +; .byte 0x55, 0x87, 0x55, 0x51, 0x03, 0x66, 0x64, 0x2B + .byte 5, -5, -7, 8, -5, 5, -1, 5, -3, 0, 6, -6, -4, 6, -11, 2 f2_2_shift_table: ; .byte (2<<1), (7<<1), (4<<1), (3<<1), (4<<1)+1, (6<<1)+1, (6<<1) - .byte (8<<1)+1, (6<<1), (6<<1)+1, (4<<1)+1, (3<<1), (4<<1), (7<<1), (2<<1) + .byte 8, -6, 6, 4, -3, -4, -7, -2 expand2_rot_table: .byte 3,7,13,16,19,23,27 @@ -737,40 +743,21 @@ f2: movw r26, h0 ldi r30, lo8(f2_1_shift_table) ldi r31, hi8(f2_1_shift_table) - ldi r17, 16 + ldi r17, 15 10: ;--- movw r22, xh0 movw r24, xh2 - cpi r17, 9 - brge 15f - clr r1 - rjmp 26f -15: lpm r20, Z+ - mov r1, r20 - andi r20, 0x0f - clt - cpi r17, 16 - breq 20f - cpi r17, 11 - brne 21f -20: set -21: brts 25f - rcall shiftright32 - rjmp 26f -25: rcall shiftleft32 -26: rcall mov32_to_acc + lpm r20, Z+ + sbrc r17, 3 + rcall shiftleft32 + rcall mov32_to_acc ;--- rcall load32_from_Y - mov r20, r1 - clr r1 - swap r20 - andi r20, 0x0f - brts 27f + lpm r20, Z+ + sbrc r17, 3 rcall shiftleft32 - rjmp 28f -27: rcall shiftright32 -28: rcall eor32_to_acc + rcall eor32_to_acc ;--- rcall load32_from_X rcall eor32_to_acc @@ -778,7 +765,7 @@ f2: adiw r26, 4 ;--- dec r17 - brne 10b + brpl 10b ;----- sbiw r28, 4*8 /* Y points to q[24] */ movw r30, r28 @@ -799,20 +786,13 @@ f2: movw r26, h0 ldi r17, 15 - ldi r30, lo8(f2_2_shift_table) - ldi r31, hi8(f2_2_shift_table) + ldi r30, lo8(f2_2_shift_table-8) + ldi r31, hi8(f2_2_shift_table-8) 10: movw r22, xl0 movw r24, xl2 - sbrc r17, 3 - rjmp 20f lpm r20, Z+ - lsr r20 - brcs 15f - rcall shiftright32 - rjmp 20f -15: + sbrs r17, 3 rcall shiftleft32 -20: rcall mov32_to_acc rcall load32_from_Y rcall eor32_to_acc @@ -1090,6 +1070,7 @@ bmw224: push_range 28, 29 push_range 8, 9 stack_alloc_large 64+4 + adiw r30, 1 10: movw ctx0, r30 movw dst0, r24 movw msg0, r22 diff --git a/bmw/bmw_256-tinyasm.S b/bmw/bmw_256-tinyasm.S index 6327bc1..ef23de2 100644 --- a/bmw/bmw_256-tinyasm.S +++ b/bmw/bmw_256-tinyasm.S @@ -41,6 +41,11 @@ acc1 = 15 param s: r20 */ shiftleft32: + tst r20 + brpl 10f + neg r20 + rjmp shiftright32 +10: clr r0 cpi r20, 8 brlo bitrotateleft_1 @@ -49,7 +54,7 @@ shiftleft32: mov r23, r22 clr r22 subi r20, 8 - rjmp shiftleft32 + rjmp 10b /******************************************************************************/ /* @@ -257,10 +262,11 @@ mov32_to_acc: f2_1_shift_table: ; .byte 0x2B, 0x64, 0x66, 0x03, 0x51, 0x55, 0x87, 0x55 - .byte 0x55, 0x87, 0x55, 0x51, 0x03, 0x66, 0x64, 0x2B +; .byte 0x55, 0x87, 0x55, 0x51, 0x03, 0x66, 0x64, 0x2B + .byte 5, -5, -7, 8, -5, 5, -1, 5, -3, 0, 6, -6, -4, 6, -11, 2 f2_2_shift_table: ; .byte (2<<1), (7<<1), (4<<1), (3<<1), (4<<1)+1, (6<<1)+1, (6<<1) - .byte (8<<1)+1, (6<<1), (6<<1)+1, (4<<1)+1, (3<<1), (4<<1), (7<<1), (2<<1) + .byte 8, -6, 6, 4, -3, -4, -7, -2 expand2_rot_table: .byte 3,7,13,16,19,23,27 @@ -738,40 +744,21 @@ f2: movw r26, h0 ldi r30, lo8(f2_1_shift_table) ldi r31, hi8(f2_1_shift_table) - ldi r17, 16 + ldi r17, 15 10: ;--- movw r22, xh0 movw r24, xh2 - cpi r17, 9 - brge 15f - clr r1 - rjmp 26f -15: lpm r20, Z+ - mov r1, r20 - andi r20, 0x0f - clt - cpi r17, 16 - breq 20f - cpi r17, 11 - brne 21f -20: set -21: brts 25f - rcall shiftright32 - rjmp 26f -25: rcall shiftleft32 -26: rcall mov32_to_acc + lpm r20, Z+ + sbrc r17, 3 + rcall shiftleft32 + rcall mov32_to_acc ;--- rcall load32_from_Y - mov r20, r1 - clr r1 - swap r20 - andi r20, 0x0f - brts 27f + lpm r20, Z+ + sbrc r17, 3 rcall shiftleft32 - rjmp 28f -27: rcall shiftright32 -28: rcall eor32_to_acc + rcall eor32_to_acc ;--- rcall load32_from_X rcall eor32_to_acc @@ -779,7 +766,7 @@ f2: adiw r26, 4 ;--- dec r17 - brne 10b + brpl 10b ;----- sbiw r28, 4*8 /* Y points to q[24] */ movw r30, r28 @@ -800,20 +787,13 @@ f2: movw r26, h0 ldi r17, 15 - ldi r30, lo8(f2_2_shift_table) - ldi r31, hi8(f2_2_shift_table) + ldi r30, lo8(f2_2_shift_table-8) + ldi r31, hi8(f2_2_shift_table-8) 10: movw r22, xl0 movw r24, xl2 - sbrc r17, 3 - rjmp 20f lpm r20, Z+ - lsr r20 - brcs 15f - rcall shiftright32 - rjmp 20f -15: + sbrs r17, 3 rcall shiftleft32 -20: rcall mov32_to_acc rcall load32_from_Y rcall eor32_to_acc @@ -1122,6 +1102,7 @@ bmw256: push_range 28, 29 push_range 8, 9 stack_alloc_large 64+4 + adiw r30, 1 10: movw ctx0, r30 movw dst0, r24 movw msg0, r22 diff --git a/bmw/bmw_small-tinyasm.S b/bmw/bmw_small-tinyasm.S index 2775ce5..fec6bb0 100644 --- a/bmw/bmw_small-tinyasm.S +++ b/bmw/bmw_small-tinyasm.S @@ -41,6 +41,11 @@ acc1 = 15 param s: r20 */ shiftleft32: + tst r20 + brpl 10f + neg r20 + rjmp shiftright32 +10: clr r0 cpi r20, 8 brlo bitrotateleft_1 @@ -49,7 +54,7 @@ shiftleft32: mov r23, r22 clr r22 subi r20, 8 - rjmp shiftleft32 + rjmp 10b /******************************************************************************/ /* @@ -257,10 +262,11 @@ mov32_to_acc: f2_1_shift_table: ; .byte 0x2B, 0x64, 0x66, 0x03, 0x51, 0x55, 0x87, 0x55 - .byte 0x55, 0x87, 0x55, 0x51, 0x03, 0x66, 0x64, 0x2B +; .byte 0x55, 0x87, 0x55, 0x51, 0x03, 0x66, 0x64, 0x2B + .byte 5, -5, -7, 8, -5, 5, -1, 5, -3, 0, 6, -6, -4, 6, -11, 2 f2_2_shift_table: ; .byte (2<<1), (7<<1), (4<<1), (3<<1), (4<<1)+1, (6<<1)+1, (6<<1) - .byte (8<<1)+1, (6<<1), (6<<1)+1, (4<<1)+1, (3<<1), (4<<1), (7<<1), (2<<1) + .byte 8, -6, 6, 4, -3, -4, -7, -2 expand2_rot_table: .byte 3,7,13,16,19,23,27 @@ -739,40 +745,21 @@ f2: movw r26, h0 ldi r30, lo8(f2_1_shift_table) ldi r31, hi8(f2_1_shift_table) - ldi r17, 16 + ldi r17, 15 10: ;--- movw r22, xh0 movw r24, xh2 - cpi r17, 9 - brge 15f - clr r1 - rjmp 26f -15: lpm r20, Z+ - mov r1, r20 - andi r20, 0x0f - clt - cpi r17, 16 - breq 20f - cpi r17, 11 - brne 21f -20: set -21: brts 25f - rcall shiftright32 - rjmp 26f -25: rcall shiftleft32 -26: rcall mov32_to_acc + lpm r20, Z+ + sbrc r17, 3 + rcall shiftleft32 + rcall mov32_to_acc ;--- rcall load32_from_Y - mov r20, r1 - clr r1 - swap r20 - andi r20, 0x0f - brts 27f + lpm r20, Z+ + sbrc r17, 3 rcall shiftleft32 - rjmp 28f -27: rcall shiftright32 -28: rcall eor32_to_acc + rcall eor32_to_acc ;--- rcall load32_from_X rcall eor32_to_acc @@ -780,7 +767,7 @@ f2: adiw r26, 4 ;--- dec r17 - brne 10b + brpl 10b ;----- sbiw r28, 4*8 /* Y points to q[24] */ movw r30, r28 @@ -801,20 +788,13 @@ f2: movw r26, h0 ldi r17, 15 - ldi r30, lo8(f2_2_shift_table) - ldi r31, hi8(f2_2_shift_table) + ldi r30, lo8(f2_2_shift_table-8) + ldi r31, hi8(f2_2_shift_table-8) 10: movw r22, xl0 movw r24, xl2 - sbrc r17, 3 - rjmp 20f lpm r20, Z+ - lsr r20 - brcs 15f - rcall shiftright32 - rjmp 20f -15: + sbrs r17, 3 rcall shiftleft32 -20: rcall mov32_to_acc rcall load32_from_Y rcall eor32_to_acc diff --git a/mkfiles/001_bcal_std.mk b/mkfiles/001_bcal_std.mk index 7045a5f..f47dc77 100644 --- a/mkfiles/001_bcal_std.mk +++ b/mkfiles/001_bcal_std.mk @@ -1,2 +1,3 @@ BCAL_STD = nessie_common.o nessie_bc_test.o performance_test.o \ - bcal-basic.o bcal-performance.o keysize_descriptor.o + bcal-basic.o bcal-performance.o keysize_descriptor.o \ + stack_measuring.o diff --git a/mkfiles/aes.mk b/mkfiles/aes.mk index 18bf9fa..ca4c587 100644 --- a/mkfiles/aes.mk +++ b/mkfiles/aes.mk @@ -7,12 +7,11 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := aes/ $(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 $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o memxor.o \ - 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 \ +$(ALGO_NAME)_TEST_BIN := main-aes-test.o $(CLI_STD) $(BCAL_STD) \ + bcal_aes128.o bcal_aes192.o bcal_aes256.o bcal-cbc.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-performance.o + bcal-eax.o memxor.o $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/aes128.mk b/mkfiles/aes128.mk index e10e32b..6afa9ab 100644 --- a/mkfiles/aes128.mk +++ b/mkfiles/aes128.mk @@ -7,8 +7,8 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := aes/ $(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 -$(ALGO_NAME)_TEST_BIN := main-aes128-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-aes128-test.o $(CLI_STD) $(BCAL_STD) \ + bcal_aes128.o $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/aes192.mk b/mkfiles/aes192.mk index 81dda2f..37b7d9b 100644 --- a/mkfiles/aes192.mk +++ b/mkfiles/aes192.mk @@ -7,8 +7,8 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := aes/ $(ALGO_NAME)_OBJ := aes_enc.o aes_dec.o aes_sbox.o aes_invsbox.o \ aes_keyschedule.o gf256mul.o aes192_enc.o aes192_dec.o -$(ALGO_NAME)_TEST_BIN := main-aes192-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-aes192-test.o $(CLI_STD) $(BCAL_STD) \ + bcal_aes192.o $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/aes256.mk b/mkfiles/aes256.mk index fdd7362..3a77f42 100644 --- a/mkfiles/aes256.mk +++ b/mkfiles/aes256.mk @@ -7,8 +7,8 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := aes/ $(ALGO_NAME)_OBJ := aes_enc.o aes_dec.o aes_sbox.o aes_invsbox.o \ aes_keyschedule.o gf256mul.o aes256_enc.o aes256_dec.o -$(ALGO_NAME)_TEST_BIN := main-aes256-test.o $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-aes256-test.o $(CLI_STD) $(BCAL_STD) \ + bcal_aes256.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 44ced8d..ee5c649 100644 --- a/mkfiles/aes_asm_faster.mk +++ b/mkfiles/aes_asm_faster.mk @@ -8,8 +8,12 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := aes/ $(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 $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o +$(ALGO_NAME)_TEST_BIN := main-aes-test.o $(CLI_STD) $(BCAL_STD) \ + bcal_aes128.o bcal_aes192.o bcal_aes256.o bcal-cbc.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 memxor.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 fa99606..a317624 100644 --- a/mkfiles/aes_c.mk +++ b/mkfiles/aes_c.mk @@ -10,12 +10,11 @@ $(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 $(CLI_STD) \ - nessie_bc_test.o nessie_common.o performance_test.o memxor.o \ - 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 \ +$(ALGO_NAME)_TEST_BIN := main-aes-test.o $(CLI_STD) $(BCAL_STD) \ + bcal_aes128.o bcal_aes192.o bcal_aes256.o bcal-cbc.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 memxor.o $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/camellia_c.mk b/mkfiles/camellia_c.mk index a1d4599..d754f0e 100644 --- a/mkfiles/camellia_c.mk +++ b/mkfiles/camellia_c.mk @@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_DIR := camellia/ $(ALGO_NAME)_OBJ := camellia_C.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/shabea.mk b/mkfiles/shabea.mk index 9c05cb3..3d11cea 100644 --- a/mkfiles/shabea.mk +++ b/mkfiles/shabea.mk @@ -2,7 +2,7 @@ ALGO_NAME := SHABEA # comment out the following line for removement of SHABEA from the build process -BLOCK_CIPHERS += $(ALGO_NAME) +BLOCK_CIPHERS_DONTUSE += $(ALGO_NAME) $(ALGO_NAME)_DIR := shabea/ $(ALGO_NAME)_OBJ := shabea.o sha256-asm.o memxor.o diff --git a/test_src/main-aes128-test.c b/test_src/main-aes128-test.c index 72e06f6..1934026 100644 --- a/test_src/main-aes128-test.c +++ b/test_src/main-aes128-test.c @@ -30,6 +30,9 @@ #include "nessie_bc_test.h" #include "cli.h" #include "performance_test.h" +#include "blockcipher_descriptor.h" +#include "bcal-performance.h" +#include "bcal_aes128.h" #include #include #include @@ -37,6 +40,12 @@ char* algo_name = "AES-128"; +const bcdesc_t* algolist[] PROGMEM = { + (bcdesc_t*)&aes128_desc, + NULL +}; + + /***************************************************************************** * additional validation-functions * *****************************************************************************/ @@ -102,48 +111,8 @@ void testrun_testkey_aes(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_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(); + bcal_performance_multiple(algolist); } /***************************************************************************** diff --git a/test_src/main-aes192-test.c b/test_src/main-aes192-test.c index 2324705..1274b28 100644 --- a/test_src/main-aes192-test.c +++ b/test_src/main-aes192-test.c @@ -27,17 +27,24 @@ #include "debug.h" #include "aes/aes.h" - #include "nessie_bc_test.h" #include "cli.h" #include "performance_test.h" - +#include "blockcipher_descriptor.h" +#include "bcal-performance.h" +#include "bcal_aes192.h" #include #include #include +#include char* algo_name = "AES-192"; +const bcdesc_t* algolist[] PROGMEM = { + (bcdesc_t*)&aes192_desc, + NULL +}; + /***************************************************************************** * additional validation-functions * *****************************************************************************/ @@ -80,50 +87,12 @@ void testrun_testkey_aes(void){ } /*****************************************************************************/ -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_aes(void){ - cli_putstr_P(PSTR("\r\n -=AES Performance Test=-\r\n")); - cli_putstr_P(PSTR("\r\n AES-192\r\n")); - testrun_performance_aes192(); + bcal_performance_multiple(algolist); } + /***************************************************************************** * main * *****************************************************************************/ diff --git a/test_src/main-aes256-test.c b/test_src/main-aes256-test.c index d75fc52..1715026 100644 --- a/test_src/main-aes256-test.c +++ b/test_src/main-aes256-test.c @@ -27,17 +27,23 @@ #include "debug.h" #include "aes/aes.h" - #include "nessie_bc_test.h" #include "cli.h" #include "performance_test.h" - +#include "blockcipher_descriptor.h" +#include "bcal-performance.h" +#include "bcal_aes256.h" #include #include #include +#include char* algo_name = "AES-256"; +const bcdesc_t* algolist[] PROGMEM = { + (bcdesc_t*)&aes256_desc, + NULL +}; /***************************************************************************** * additional validation-functions * *****************************************************************************/ @@ -82,48 +88,8 @@ void testrun_testkey_aes(void){ } /*****************************************************************************/ -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-256\r\n")); - testrun_performance_aes256(); + bcal_performance_multiple(algolist); } /***************************************************************************** -- 2.39.5