1 /* main-noekeon-test.c */
3 This file is part of the AVR-Crypto-Lib.
4 Copyright (C) 2008 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/>.
30 #include "nessie_bc_test.h"
31 #include "bcal-nessie.h"
32 #include "performance_test.h"
33 #include "bcal-performance.h"
34 #include "bcal_noekeon.h"
41 char* algo_name = "Noekeon";
43 const bcdesc_t* algolist[] PROGMEM = {
44 (bcdesc_t*)&noekeon_direct_desc,
45 (bcdesc_t*)&noekeon_indirect_desc,
48 /*****************************************************************************
49 * additional validation-functions *
50 *****************************************************************************/
52 void testrun_nessie_noekeon(void){
53 bcal_nessie_multiple(&algolist);
57 void testrun_stdtest_rundirect(void* data, void* key){
58 cli_putstr_P(PSTR("\r\n "));
59 cli_putstr_P(PSTR("k = "));
62 cli_putstr_P(PSTR("\r\n "));
63 cli_putstr_P(PSTR("a = "));
66 noekeon_enc(data, key);
67 cli_putstr_P(PSTR("\r\nafter NESSIEencrypt, b = "));
70 noekeon_dec(data, key);
71 cli_putstr_P(PSTR("\r\nafter NESSIEdecrypt, a?= "));
73 cli_putstr_P(PSTR("\r\n"));
76 void testrun_stdtest_runindirect(void* data, void* key){
78 cli_putstr_P(PSTR("\r\n "));
79 cli_putstr_P(PSTR("k = "));
82 cli_putstr_P(PSTR("\r\n "));
83 cli_putstr_P(PSTR("a = "));
85 noekeon_init(key, &ctx);
86 noekeon_enc(data, &ctx);
87 cli_putstr_P(PSTR("\r\nafter NESSIEencrypt, b = "));
90 noekeon_dec(data, &ctx);
91 cli_putstr_P(PSTR("\r\nafter NESSIEdecrypt, a?= "));
93 cli_putstr_P(PSTR("\r\n"));
96 void testrun_stdtest_noekeon(void){
97 uint8_t key[16], data[16];
101 cli_putstr_P(PSTR("\r\nTest vectors for block cipher Noekeon in Indirect-Key Mode:\r\n"));
105 testrun_stdtest_runindirect(data, key);
107 memset(key, 0xFF, 16);
108 memset(data, 0xFF, 16);
109 testrun_stdtest_runindirect(data, key);
113 noekeon_init(key, &ctx);
114 noekeon_enc(data, &ctx);
115 memcpy(key3, data, 16);
116 memset(key, 0xFF, 16);
117 memset(data, 0xFF, 16);
118 noekeon_init(key, &ctx);
119 noekeon_enc(data, &ctx);
120 testrun_stdtest_runindirect(data, key3);
122 cli_putstr_P(PSTR("\r\nTest vectors for block cipher Noekeon in Direct-Key Mode:\r\n"));
126 testrun_stdtest_rundirect(data, key);
128 memset(key, 0xFF, 16);
129 memset(data, 0xFF, 16);
130 testrun_stdtest_rundirect(data, key);
134 noekeon_enc(data, key);
135 memcpy(key3, data, 16);
136 memset(key, 0xFF, 16);
137 memset(data, 0xFF, 16);
138 noekeon_enc(data, key);
139 testrun_stdtest_rundirect(data, key3);
143 void testrun_performance_noekeon(void){
144 bcal_performance_multiple(algolist);
146 /*****************************************************************************
148 *****************************************************************************/
150 const char nessie_str[] PROGMEM = "nessie";
151 const char test_str[] PROGMEM = "test";
152 const char direct_str[] PROGMEM = "direct";
153 const char indirect_str[] PROGMEM = "indirect";
154 const char performance_str[] PROGMEM = "performance";
155 const char echo_str[] PROGMEM = "echo";
157 cmdlist_entry_t cmdlist[] PROGMEM = {
158 { nessie_str, NULL, testrun_nessie_noekeon},
159 { test_str, NULL, testrun_stdtest_noekeon},
160 // { direct_str, NULL, testrun_nessie_noekeon_direct},
161 // { indirect_str, NULL, testrun_nessie_noekeon_indirect},
162 { performance_str, NULL, testrun_performance_noekeon},
163 { echo_str, (void*)1, (void_fpt)echo_ctrl},
170 cli_rx = (cli_rx_fpt)uart0_getc;
171 cli_tx = (cli_tx_fpt)uart0_putc;
173 cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
174 cli_putstr(algo_name);
175 cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
176 cmd_interface(cmdlist);