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/>.
24 #include "main-test-common.h"
27 #include "bcal-nessie.h"
28 #include "performance_test.h"
29 #include "bcal-performance.h"
30 #include "bcal_noekeon.h"
32 char *algo_name = "Noekeon";
34 const bcdesc_t *const algolist[] PROGMEM = {
35 (bcdesc_t*)&noekeon_direct_desc,
36 (bcdesc_t*)&noekeon_indirect_desc,
39 /*****************************************************************************
40 * additional validation-functions *
41 *****************************************************************************/
43 void testrun_nessie_noekeon(void){
44 bcal_nessie_multiple(algolist);
48 void testrun_stdtest_rundirect(void *data, void *key){
49 cli_putstr_P(PSTR("\r\n "));
50 cli_putstr_P(PSTR("k = "));
53 cli_putstr_P(PSTR("\r\n "));
54 cli_putstr_P(PSTR("a = "));
57 noekeon_enc(data, key);
58 cli_putstr_P(PSTR("\r\nafter NESSIEencrypt, b = "));
61 noekeon_dec(data, key);
62 cli_putstr_P(PSTR("\r\nafter NESSIEdecrypt, a?= "));
64 cli_putstr_P(PSTR("\r\n"));
67 void testrun_stdtest_runindirect(void *data, void *key){
69 cli_putstr_P(PSTR("\r\n "));
70 cli_putstr_P(PSTR("k = "));
73 cli_putstr_P(PSTR("\r\n "));
74 cli_putstr_P(PSTR("a = "));
76 noekeon_init(key, &ctx);
77 noekeon_enc(data, &ctx);
78 cli_putstr_P(PSTR("\r\nafter NESSIEencrypt, b = "));
81 noekeon_dec(data, &ctx);
82 cli_putstr_P(PSTR("\r\nafter NESSIEdecrypt, a?= "));
84 cli_putstr_P(PSTR("\r\n"));
87 void testrun_stdtest_noekeon(void){
88 uint8_t key[16], data[16];
92 cli_putstr_P(PSTR("\r\nTest vectors for block cipher Noekeon in Indirect-Key Mode:\r\n"));
96 testrun_stdtest_runindirect(data, key);
98 memset(key, 0xFF, 16);
99 memset(data, 0xFF, 16);
100 testrun_stdtest_runindirect(data, key);
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);
113 cli_putstr_P(PSTR("\r\nTest vectors for block cipher Noekeon in Direct-Key Mode:\r\n"));
117 testrun_stdtest_rundirect(data, key);
119 memset(key, 0xFF, 16);
120 memset(data, 0xFF, 16);
121 testrun_stdtest_rundirect(data, key);
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);
134 void testrun_performance_noekeon(void){
135 bcal_performance_multiple(algolist);
137 /*****************************************************************************
139 *****************************************************************************/
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";
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},
162 welcome_msg(algo_name);
163 cmd_interface(cmdlist);