]> git.cryptolib.org Git - avr-crypto-lib.git/blob - test_src/main-mugi-test.c
fixing E-Mail-Address & Copyright
[avr-crypto-lib.git] / test_src / main-mugi-test.c
1 /* main-mugi-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  * MUGI test-suit
21  * 
22 */
23
24 #include "main-test-common.h"
25
26 #include "mugi.h"
27 #include "nessie_stream_test.h"
28 #include "performance_test.h"
29
30 char *algo_name = "MUGI";
31
32 /*****************************************************************************
33  *  additional validation-functions                                                                                      *
34  *****************************************************************************/
35
36 void testrun_performance_mugi(void){
37         uint64_t t;
38         char str[16];
39         uint8_t key[16];
40         uint8_t iv[16];
41         mugi_ctx_t ctx;
42         
43         calibrateTimer();
44         print_overhead();       
45         
46         memset(key, 0, 16);
47         memset(iv,  0, 16);
48         
49         startTimer(1);
50         mugi_init(key, iv, &ctx);
51         t = stopTimer();
52         cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
53         ultoa((unsigned long)t, str, 10);
54         cli_putstr(str);        
55         
56         startTimer(1);
57         mugi_gen(&ctx);
58         t = stopTimer();
59         cli_putstr_P(PSTR("\r\n\tencrypt time: "));
60         ultoa((unsigned long)t, str, 10);
61         cli_putstr(str);        
62         
63         cli_putstr_P(PSTR("\r\n"));     
64 }
65
66
67 void testrun_mugi(void){
68         uint8_t key[]={  0x00, 0x01, 0x02, 0x03,
69                          0x04, 0x05, 0x06, 0x07,
70                                          0x08, 0x09, 0x0a, 0x0b,
71                                          0x0c, 0x0d, 0x0e, 0x0f };
72         uint8_t iv[]= {  0xf0, 0xe0, 0xd0, 0xc0,
73                          0xb0, 0xa0, 0x90, 0x80,
74                                          0x70, 0x60, 0x50, 0x40,
75                                          0x30, 0x20, 0x10, 0x00 };
76         mugi_ctx_t ctx;
77         uint64_t output;
78         uint8_t i;
79         mugi_init(key, iv, &ctx);
80         cli_putstr_P(PSTR("\r\nkey = "));
81         cli_hexdump2(key, 16);
82         cli_putstr_P(PSTR("\r\niv  = "));
83         cli_hexdump2(iv, 16);
84         for(i=0; i<8; ++i){
85                 output = mugi_gen(&ctx);
86                 cli_putstr_P(PSTR("\r\nMUGI output: "));
87                 cli_hexdump(&output, 8);                                 
88         }                
89         
90         memset(key, 0, 16);
91         memset(iv,  0, 16);
92         mugi_init(key, iv, &ctx);
93         cli_putstr_P(PSTR("\r\nkey = "));
94         cli_hexdump2(key, 16);
95         cli_putstr_P(PSTR("\r\niv  = "));
96         cli_hexdump2(iv, 16);
97         for(i=0; i<8; ++i){
98                 output = mugi_gen(&ctx);
99                 cli_putstr_P(PSTR("\r\nMUGI output: "));
100                 cli_hexdump(&output, 8);                                 
101         }                
102 }
103
104 /*****************************************************************************
105  *  main                                                                                                                                         *
106  *****************************************************************************/
107
108 const char nessie_str[]      PROGMEM = "nessie";
109 const char test_str[]        PROGMEM = "test";
110 const char performance_str[] PROGMEM = "performance";
111 const char echo_str[]        PROGMEM = "echo";
112
113 const cmdlist_entry_t cmdlist[] PROGMEM = {
114 //      { nessie_str,      NULL, testrun_nessie_arcfour },
115         { test_str,        NULL, testrun_mugi},
116         { performance_str, NULL, testrun_performance_mugi},
117         { echo_str,    (void*)1, (void_fpt)echo_ctrl},
118         { NULL,            NULL, NULL}
119 };
120
121 int main (void){
122     main_setup();
123
124     for(;;){
125         welcome_msg(algo_name);
126         cmd_interface(cmdlist);
127         }
128 }
129