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 "bcal-nessie.h"
31 #include "performance_test.h"
32 #include "bcal-performance.h"
33 #include "bcal_noekeon.h"
40 char* algo_name = "Noekeon";
42 const bcdesc_t* algolist[] PROGMEM = {
43 (bcdesc_t*)&noekeon_direct_desc,
44 (bcdesc_t*)&noekeon_indirect_desc,
47 /*****************************************************************************
48 * additional validation-functions *
49 *****************************************************************************/
51 void testrun_nessie_noekeon(void){
52 bcal_nessie_multiple(algolist);
56 void testrun_stdtest_rundirect(void* data, void* key){
57 cli_putstr_P(PSTR("\r\n "));
58 cli_putstr_P(PSTR("k = "));
61 cli_putstr_P(PSTR("\r\n "));
62 cli_putstr_P(PSTR("a = "));
65 noekeon_enc(data, key);
66 cli_putstr_P(PSTR("\r\nafter NESSIEencrypt, b = "));
69 noekeon_dec(data, key);
70 cli_putstr_P(PSTR("\r\nafter NESSIEdecrypt, a?= "));
72 cli_putstr_P(PSTR("\r\n"));
75 void testrun_stdtest_runindirect(void* data, void* key){
77 cli_putstr_P(PSTR("\r\n "));
78 cli_putstr_P(PSTR("k = "));
81 cli_putstr_P(PSTR("\r\n "));
82 cli_putstr_P(PSTR("a = "));
84 noekeon_init(key, &ctx);
85 noekeon_enc(data, &ctx);
86 cli_putstr_P(PSTR("\r\nafter NESSIEencrypt, b = "));
89 noekeon_dec(data, &ctx);
90 cli_putstr_P(PSTR("\r\nafter NESSIEdecrypt, a?= "));
92 cli_putstr_P(PSTR("\r\n"));
95 void testrun_stdtest_noekeon(void){
96 uint8_t key[16], data[16];
100 cli_putstr_P(PSTR("\r\nTest vectors for block cipher Noekeon in Indirect-Key Mode:\r\n"));
104 testrun_stdtest_runindirect(data, key);
106 memset(key, 0xFF, 16);
107 memset(data, 0xFF, 16);
108 testrun_stdtest_runindirect(data, key);
112 noekeon_init(key, &ctx);
113 noekeon_enc(data, &ctx);
114 memcpy(key3, data, 16);
115 memset(key, 0xFF, 16);
116 memset(data, 0xFF, 16);
117 noekeon_init(key, &ctx);
118 noekeon_enc(data, &ctx);
119 testrun_stdtest_runindirect(data, key3);
121 cli_putstr_P(PSTR("\r\nTest vectors for block cipher Noekeon in Direct-Key Mode:\r\n"));
125 testrun_stdtest_rundirect(data, key);
127 memset(key, 0xFF, 16);
128 memset(data, 0xFF, 16);
129 testrun_stdtest_rundirect(data, key);
133 noekeon_enc(data, key);
134 memcpy(key3, data, 16);
135 memset(key, 0xFF, 16);
136 memset(data, 0xFF, 16);
137 noekeon_enc(data, key);
138 testrun_stdtest_rundirect(data, key3);
142 void testrun_performance_noekeon(void){
143 bcal_performance_multiple(algolist);
145 /*****************************************************************************
147 *****************************************************************************/
149 const char nessie_str[] PROGMEM = "nessie";
150 const char test_str[] PROGMEM = "test";
151 const char direct_str[] PROGMEM = "direct";
152 const char indirect_str[] PROGMEM = "indirect";
153 const char performance_str[] PROGMEM = "performance";
154 const char echo_str[] PROGMEM = "echo";
156 cmdlist_entry_t cmdlist[] PROGMEM = {
157 { nessie_str, NULL, testrun_nessie_noekeon},
158 { test_str, NULL, testrun_stdtest_noekeon},
159 // { direct_str, NULL, testrun_nessie_noekeon_direct},
160 // { indirect_str, NULL, testrun_nessie_noekeon_indirect},
161 { performance_str, NULL, testrun_performance_noekeon},
162 { echo_str, (void*)1, (void_fpt)echo_ctrl},
169 cli_rx = (cli_rx_fpt)uart0_getc;
170 cli_tx = (cli_tx_fpt)uart0_putc;
172 cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
173 cli_putstr(algo_name);
174 cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
175 cmd_interface(cmdlist);