1 /* bcal-performance.c */
3 This file is part of the ARM-Crypto-Lib.
4 Copyright (C) 2006-2010 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/>.
21 * \file bcal-performance.c
23 * \email daniel.otte@rub.de
25 * \license GPLv3 or later
29 #include "bcal-performance.h"
30 #include "keysize_descriptor.h"
31 #include "blockcipher_descriptor.h"
32 #include "performance_test.h"
40 void printvalue(unsigned long v){
44 for(i=0; i<10-strlen(str); ++i){
50 void bcal_performance(const bcdesc_t* bcd){
52 memcpy(&bc, bcd, sizeof(bcdesc_t));
53 uint8_t ctx[bc.ctxsize_B];
54 uint8_t data[(bc.blocksize_b+7)/8];
55 uint16_t keysize = get_keysize(bc.valid_keysize_desc);
56 uint8_t key[(keysize+7)/8];
60 if(bc.type!=BCDESC_TYPE_BLOCKCIPHER)
64 cli_putstr("\r\n\r\n === ");
66 cli_putstr(" performance === "
67 "\r\n type: blockcipher"
68 "\r\n keysize (bits): ");
71 cli_putstr("\r\n ctxsize (bytes): ");
72 printvalue(bc.ctxsize_B);
74 cli_putstr("\r\n blocksize (bits): ");
75 printvalue(bc.blocksize_b);
79 if((bc.flags&BC_INIT_TYPE)==BC_INIT_TYPE_1){
83 (bc.init.init1)(key, &ctx);
94 (bc.init.init2)(key, keysize, &ctx);
103 cli_putstr("\r\n init (cycles): ");
111 bc.enc.enc1(data, &ctx);
116 cli_putstr("\r\n encrypt (cycles): ");
123 bc.dec.dec1(data, &ctx);
128 cli_putstr("\r\n decrypt (cycles): ");
138 void bcal_performance_multiple(const bcdesc_t** bcd_list){
143 cli_putstr("\r\n\r\n End of performance figures\r\n");
146 bcal_performance(bcd++);