X-Git-Url: https://git.cryptolib.org/?p=avr-crypto-lib.git;a=blobdiff_plain;f=hfal%2Fhfal-performance.c;h=7f5dd2b67d26763de22c48a46011de0d200cb133;hp=481c3a2ece58fd3d0afca18750a4b28156d77f9f;hb=4b5da1dc27a791b5c448274a3db09cd035b33493;hpb=a707b2a401ed87cbeee4888bba923f605e951c89 diff --git a/hfal/hfal-performance.c b/hfal/hfal-performance.c index 481c3a2..7f5dd2b 100644 --- a/hfal/hfal-performance.c +++ b/hfal/hfal-performance.c @@ -1,7 +1,7 @@ /* hfal-performance.c */ /* This file is part of the AVR-Crypto-Lib. - Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de) + Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org) 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 @@ -19,7 +19,7 @@ /* * \file hfal-performance.c * \author Daniel Otte - * \email daniel.otte@rub.de + * \email bg@nerilex.org * \date 2009-05-10 * \license GPLv3 or later * @@ -34,7 +34,7 @@ #include "hashfunction_descriptor.h" #include "stack_measuring.h" #include "performance_test.h" -#include "uart_i.h" +#include "uart.h" #define PATTERN_A 0xAA #define PATTERN_B 0x55 @@ -43,12 +43,12 @@ void hfal_performance(const hfdesc_t *hd){ hfdesc_t hf; memcpy_P(&hf, hd, sizeof(hfdesc_t)); uint8_t ctx[hf.ctxsize_B]; - uint8_t data[(hf.blocksize_b+7)/8]; - uint8_t digest[(hf.hashsize_b+7)/8]; + uint8_t data[(hf.blocksize_b + 7) / 8]; + uint8_t digest[(hf.hashsize_b + 7) / 8]; uint32_t t; uint8_t i; - if(hf.type!=HFDESC_TYPE_HASHFUNCTION) + if(hf.type != HFDESC_TYPE_HASHFUNCTION) return; calibrateTimer(); print_overhead(); @@ -59,51 +59,51 @@ void hfal_performance(const hfdesc_t *hd){ "\tblocksize (bits): %10"PRIu16"\n"), hf.name, hf.hashsize_b, hf.ctxsize_B, hf.blocksize_b); uart0_flush(); - t=0; - for(i=0; i<32; ++i){ + t = 0; + for(i = 0; i < 32; ++i){ startTimer(0); START_TIMER; hf.init(&ctx); STOP_TIMER; t += stopTimer(); - if(i!=31 && hf.free){ + if(i != 31 && hf.free){ hf.free(&ctx); } } - t>>=5; + t >>= 5; printf_P(PSTR("\tinit (cycles): %10"PRIu32"\n"), t); - t=0; - for(i=0; i<32; ++i){ + t = 0; + for(i = 0; i < 32; ++i){ startTimer(0); START_TIMER; hf.nextBlock(&ctx, data); STOP_TIMER; t += stopTimer(); } - t>>=5; + t >>= 5; printf_P(PSTR("\tnextBlock (cycles): %10"PRIu32"\n"), t); - t=0; - for(i=0; i<32; ++i){ + t = 0; + for(i = 0; i < 32; ++i){ startTimer(0); START_TIMER; hf.lastBlock(&ctx, data, 0); STOP_TIMER; t += stopTimer(); } - t>>=5; + t >>= 5; printf_P(PSTR("\tlastBlock (cycles): %10"PRIu32"\n"), t); - t=0; - for(i=0; i<32; ++i){ + t = 0; + for(i = 0; i < 32; ++i){ startTimer(0); START_TIMER; hf.ctx2hash(digest, &ctx); STOP_TIMER; t += stopTimer(); } - t>>=5; + t >>= 5; printf_P(PSTR("\tctx2hash (cycles): %10"PRIu32"\n"), t); if(hf.free){ @@ -169,7 +169,7 @@ void hfal_stacksize(const hfdesc_t *hd){ t2 = stack_measure_final(&smctx); sei(); - t1 = (t1>t2)?t1:t2; + t1 = (t1 > t2) ? t1 : t2; printf_P(PSTR("\tctx2hash (bytes): %10"PRIu16"\n")); if(hf.free){