]> git.cryptolib.org Git - avr-crypto-lib.git/blob - test_src/main-noekeon-test.c
fixing E-Mail-Address & Copyright
[avr-crypto-lib.git] / test_src / main-noekeon-test.c
1 /* main-noekeon-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  * noekeon test-suit
21  * 
22 */
23
24 #include "main-test-common.h"
25
26 #include "noekeon.h"
27 #include "bcal-nessie.h"
28 #include "performance_test.h"
29 #include "bcal-performance.h"
30 #include "bcal_noekeon.h"
31
32 char *algo_name = "Noekeon";
33
34 const bcdesc_t *const algolist[] PROGMEM = {
35         (bcdesc_t*)&noekeon_direct_desc,
36         (bcdesc_t*)&noekeon_indirect_desc,
37         NULL
38 };
39 /*****************************************************************************
40  *  additional validation-functions                                                                                      *
41  *****************************************************************************/
42
43 void testrun_nessie_noekeon(void){
44         bcal_nessie_multiple(algolist);
45 }
46
47
48 void testrun_stdtest_rundirect(void *data, void *key){
49         cli_putstr_P(PSTR("\r\n                     "));
50         cli_putstr_P(PSTR("k = "));
51         cli_hexdump(key,16);
52
53         cli_putstr_P(PSTR("\r\n                     "));
54         cli_putstr_P(PSTR("a = "));
55         cli_hexdump(data,16);
56         
57         noekeon_enc(data, key);
58         cli_putstr_P(PSTR("\r\nafter NESSIEencrypt, b = "));
59         cli_hexdump(data,16);
60         
61         noekeon_dec(data, key);
62         cli_putstr_P(PSTR("\r\nafter NESSIEdecrypt, a?= "));
63         cli_hexdump(data,16);
64         cli_putstr_P(PSTR("\r\n"));
65 }
66
67 void testrun_stdtest_runindirect(void *data, void *key){
68         noekeon_ctx_t ctx;
69         cli_putstr_P(PSTR("\r\n                     "));
70         cli_putstr_P(PSTR("k = "));
71         cli_hexdump(key,16);
72         
73         cli_putstr_P(PSTR("\r\n                     "));
74         cli_putstr_P(PSTR("a = "));
75         cli_hexdump(data,16);
76         noekeon_init(key, &ctx);
77         noekeon_enc(data, &ctx);
78         cli_putstr_P(PSTR("\r\nafter NESSIEencrypt, b = "));
79         cli_hexdump(data,16);
80         
81         noekeon_dec(data, &ctx);
82         cli_putstr_P(PSTR("\r\nafter NESSIEdecrypt, a?= "));
83         cli_hexdump(data,16);
84         cli_putstr_P(PSTR("\r\n"));
85 }
86
87 void testrun_stdtest_noekeon(void){
88         uint8_t key[16], data[16];
89         uint8_t key3[16];
90         noekeon_ctx_t ctx;
91         
92         cli_putstr_P(PSTR("\r\nTest vectors for block cipher Noekeon in Indirect-Key Mode:\r\n"));
93         
94         memset(key,  0, 16);
95         memset(data, 0, 16);
96         testrun_stdtest_runindirect(data, key);
97         
98         memset(key,  0xFF, 16);
99         memset(data, 0xFF, 16);
100         testrun_stdtest_runindirect(data, key);
101         
102         memset(key,  0, 16);
103         memset(data, 0, 16);
104         noekeon_init(key, &ctx);
105         noekeon_enc(data, &ctx);
106         memcpy(key3, data, 16);
107         memset(key,  0xFF, 16);
108         memset(data, 0xFF, 16);
109         noekeon_init(key, &ctx);
110         noekeon_enc(data, &ctx);
111         testrun_stdtest_runindirect(data, key3);
112         
113         cli_putstr_P(PSTR("\r\nTest vectors for block cipher Noekeon in Direct-Key Mode:\r\n"));
114         
115         memset(key,  0, 16);
116         memset(data, 0, 16);
117         testrun_stdtest_rundirect(data, key);
118         
119         memset(key,  0xFF, 16);
120         memset(data, 0xFF, 16);
121         testrun_stdtest_rundirect(data, key);
122         
123         memset(key,  0, 16);
124         memset(data, 0, 16);
125         noekeon_enc(data, key);
126         memcpy(key3, data, 16);
127         memset(key,  0xFF, 16);
128         memset(data, 0xFF, 16);
129         noekeon_enc(data, key);
130         testrun_stdtest_rundirect(data, key3);
131         
132 }
133
134 void testrun_performance_noekeon(void){
135         bcal_performance_multiple(algolist);
136 }
137 /*****************************************************************************
138  *  main                                                                                                                                         *
139  *****************************************************************************/
140
141 const char nessie_str[]      PROGMEM = "nessie";
142 const char test_str[]        PROGMEM = "test";
143 const char direct_str[]      PROGMEM = "direct";
144 const char indirect_str[]    PROGMEM = "indirect";
145 const char performance_str[] PROGMEM = "performance";
146 const char echo_str[]        PROGMEM = "echo";
147
148 const cmdlist_entry_t cmdlist[] PROGMEM = {
149         { nessie_str,      NULL, testrun_nessie_noekeon},
150         { test_str,        NULL, testrun_stdtest_noekeon},
151 //      { direct_str,      NULL, testrun_nessie_noekeon_direct},
152 //      { indirect_str,    NULL, testrun_nessie_noekeon_indirect},
153         { performance_str, NULL, testrun_performance_noekeon},
154         { echo_str,    (void*)1, (void_fpt)echo_ctrl},
155         { NULL,            NULL, NULL}
156 };
157
158 int main (void){
159     main_setup();
160
161     for(;;){
162         welcome_msg(algo_name);
163         cmd_interface(cmdlist);
164         }
165 }