1 /* main-rabbit-test.c */
3 This file is part of the AVR-Crypto-Lib.
4 Copyright (C) 2006-2011 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/>.
28 #include "performance_test.h"
30 #include "scal_rabbit.h"
31 #include "scal-basic.h"
32 #include "scal-nessie.h"
38 char* algo_name = "Rabbit";
40 /*****************************************************************************
41 * additional validation-functions *
42 *****************************************************************************/
44 void test_vector(void* key, void* iv){
46 cli_putstr_P(PSTR("\r\n testing with key: "));
48 cli_putstr_P(PSTR("\r\n iv: "));
52 cli_putstr_P(PSTR("[no iv]"));
54 rabbit_init(key, 128, iv, &ctx);
55 cli_putstr_P(PSTR("\r\n S[0]: "));
57 cli_hexdump(ctx.buffer, 16);
58 cli_putstr_P(PSTR("\r\n S[1]: "));
61 cli_hexdump(ctx.buffer, 16);
62 cli_putstr_P(PSTR("\r\n S[2]: "));
65 cli_hexdump(ctx.buffer, 16);
70 cli_putstr_P(PSTR("\r\n S[3]: "));
71 cli_hexdump(ctx.buffer, 16);
74 cli_putstr_P(PSTR("\r\n S[4]: "));
75 cli_hexdump(ctx.buffer, 16);
76 cli_putstr_P(PSTR("\r\n"));
79 void nessie_first(void){
95 const uint8_t spec_key1[] PROGMEM = {
96 0x91, 0x28, 0x13, 0x29, 0x2E, /* 0xED */ 0x3D, 0x36, 0xFE,
97 0x3B, 0xFC, 0x62, 0xF1, 0xDC, 0x51, 0xC3, 0xAC
100 const uint8_t spec_key2[] PROGMEM = {
101 0x83, 0x95, 0x74, 0x15, 0x87, 0xE0, 0xC7, 0x33,
102 0xE9, 0xE9, 0xAB, 0x01, 0xC0, 0x9B, 0x00, 0x43
105 const uint8_t spec_iv1[] PROGMEM = {
106 0xC3, 0x73, 0xF5, 0x75, 0xC1, 0x26, 0x7E, 0x59
109 const uint8_t spec_iv2[] PROGMEM = {
110 0xA6, 0xEB, 0x56, 0x1A, 0xD2, 0xF4, 0x17, 0x27
113 void spec_test(void){
118 test_vector(key, NULL);
119 memcpy_P(key, spec_key1, 16);
120 test_vector(key, NULL);
121 memcpy_P(key, spec_key2, 16);
122 test_vector(key, NULL);
127 test_vector(key, iv);
128 memcpy_P(iv, spec_iv1, 8);
129 test_vector(key, iv);
130 memcpy_P(iv, spec_iv2, 8);
131 test_vector(key, iv);
135 void testrun_nessie_rabbit(void){
136 scal_nessie_set_estream(1);
137 scal_nessie_run(&rabbit_desc);
142 void testrun_performance_rabbit(void){
154 rabbit_init(key, 128, NULL, &ctx);
156 cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
157 ultoa((unsigned long)t, str, 10);
163 cli_putstr_P(PSTR("\r\n\tencrypt time: "));
164 ultoa((unsigned long)t, str, 10);
167 cli_putstr_P(PSTR("\r\n"));
171 /*****************************************************************************
173 *****************************************************************************/
175 const char nessie_str[] PROGMEM = "nessie";
176 const char first_str[] PROGMEM = "first";
177 const char test_str[] PROGMEM = "test";
178 const char performance_str[] PROGMEM = "performance";
179 const char echo_str[] PROGMEM = "echo";
181 cmdlist_entry_t cmdlist[] PROGMEM = {
182 { nessie_str, NULL, testrun_nessie_rabbit},
183 { performance_str, NULL, testrun_performance_rabbit},
184 { first_str, NULL, nessie_first},
185 { test_str, NULL, spec_test},
186 { echo_str, (void*)1, (void_fpt)echo_ctrl},
193 cli_rx = (cli_rx_fpt)uart0_getc;
194 cli_tx = (cli_tx_fpt)uart0_putc;
196 cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
197 cli_putstr(algo_name);
198 cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
199 cmd_interface(cmdlist);