]> git.cryptolib.org Git - avr-crypto-lib.git/blob - test_src/main-entropium-test.c
fixing E-Mail-Address & Copyright
[avr-crypto-lib.git] / test_src / main-entropium-test.c
1 /* main-entropium-test.c */
2 /*
3     This file is part of the AVR-Crypto-Lib.
4     Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org)
5
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.
10
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.
15
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/>.
18 */
19 /*
20  * entropium test-suit
21  * 
22 */
23
24 #include "main-test-common.h"
25
26 #include "entropium.h"
27 #include "nessie_bc_test.h"
28 #include "performance_test.h"
29
30 char *algo_name = "Entropium";
31
32 /*****************************************************************************
33  *  additional validation-functions                                                                                      *
34  *****************************************************************************/
35
36 void testrun_entropium(void){
37         char c, str[16];
38         uint8_t data[32];
39         uint32_t i=0;
40         while('q'!=cli_getc()){
41                 entropium_getRandomBlock(data);
42                 cli_putstr_P(PSTR("\r\n "));
43                 ultoa(i, str, 10);
44                 for(c=strlen(str); c<11; ++c){
45                         cli_putc(' ');
46                 }
47                 cli_putstr(str);
48                 ++i;
49                 cli_putstr_P(PSTR(" : "));
50                 cli_hexdump(data, 32);
51         }
52         cli_putstr_P(PSTR("\r\n\r\n"));
53 }
54
55
56 void testrun_performance_entropium(void){
57         uint64_t t;
58         char str[16];
59         uint8_t data[32];
60         
61         calibrateTimer();
62         print_overhead();
63         
64         startTimer(1);
65         entropium_addEntropy(128, data);
66         t = stopTimer();
67         cli_putstr_P(PSTR("\r\n\tadd entropy time: "));
68         ultoa((unsigned long)t, str, 10);
69         cli_putstr(str);
70         
71         
72         startTimer(1);
73         entropium_getRandomBlock(data);
74         t = stopTimer();
75         cli_putstr_P(PSTR("\r\n\tget random time:  "));
76         ultoa((unsigned long)t, str, 10);
77         cli_putstr(str);
78         
79         cli_putstr_P(PSTR("\r\n"));
80 }
81 /*****************************************************************************
82  *  main                                                                                                                                         *
83  *****************************************************************************/
84
85 const char nessie_str[]      PROGMEM = "nessie";
86 const char test_str[]        PROGMEM = "test";
87 const char performance_str[] PROGMEM = "performance";
88 const char echo_str[]        PROGMEM = "echo";
89
90 const cmdlist_entry_t cmdlist[] PROGMEM = {
91         { nessie_str,      NULL, testrun_entropium},
92         { test_str,        NULL, testrun_entropium},
93         { performance_str, NULL, testrun_performance_entropium},
94         { echo_str,    (void*)1, (void_fpt)echo_ctrl},
95         { NULL,            NULL, NULL}
96 };
97  
98
99 int main (void){
100     main_setup();
101
102         for(;;){
103             welcome_msg(algo_name);
104             cmd_interface(cmdlist);
105         }
106 }