1 /* hfal-performance.c */
3 This file is part of the AVR-Crypto-Lib.
4 Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * \file hfal-performance.c
22 * \email daniel.otte@rub.de
24 * \license GPLv3 or later
28 #include "hfal-performance.h"
29 #include "hashfunction_descriptor.h"
31 #include "performance_test.h"
35 #include <avr/pgmspace.h>
39 void printvalue(unsigned long v){
43 for(i=0; i<10-strlen(str); ++i){
49 void hfal_performance(const hfdesc_t* hd){
51 memcpy_P(&hf, hd, sizeof(hfdesc_t));
52 uint8_t ctx[hf.ctxsize_B];
53 uint8_t data[(hf.blocksize_b+7)/8];
54 uint8_t digest[(hf.hashsize_b+7)/8];
58 if(hf.type!=HFDESC_TYPE_HASHFUNCTION)
62 cli_putstr_P(PSTR("\r\n\r\n === "));
63 cli_putstr_P(hf.name);
64 cli_putstr_P(PSTR(" performance === "
65 "\r\n type: hashfunction"
66 "\r\n hashsize (bits): "));
67 printvalue(hf.hashsize_b);
69 cli_putstr_P(PSTR("\r\n ctxsize (bytes): "));
70 printvalue(hf.ctxsize_B);
72 cli_putstr_P(PSTR("\r\n blocksize (bits): "));
73 printvalue(hf.blocksize_b);
87 cli_putstr_P(PSTR("\r\n init (cycles): "));
94 hf.nextBlock(&ctx, data);
99 cli_putstr_P(PSTR("\r\n nextBlock (cycles): "));
106 hf.lastBlock(&ctx, data, 0);
111 cli_putstr_P(PSTR("\r\n lastBlock (cycles): "));
118 hf.ctx2hash(digest, &ctx);
123 cli_putstr_P(PSTR("\r\n ctx2hash (cycles): "));
132 void hfal_performance_multiple(const hfdesc_t** hd_list){
135 hd = (void*)pgm_read_word(hd_list);
137 cli_putstr_P(PSTR("\r\n\r\n End of performance figures\r\n"));
140 hfal_performance(hd);
141 hd_list = (void*)((uint8_t*)hd_list + 2);