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/>.
20 * BlueMidnightWish test-suit
25 #include "serial-tools.h"
29 #include "bmw_small.h"
30 #include "bmw_large.h"
32 #include "hfal_bmw_small.h"
33 #include "hfal_bmw_large.h"
35 #include "nessie_hash_test.h"
36 #include "performance_test.h"
37 #include "hfal-nessie.h"
38 #include "hfal-performance.h"
39 #include "hfal-test.h"
45 char* algo_name = "BlueMidnightWish";
48 const hfdesc_t* algolist[] PROGMEM = {
49 (hfdesc_t*)&bmw224_desc,
50 (hfdesc_t*)&bmw256_desc,
51 (hfdesc_t*)&bmw384_desc,
52 (hfdesc_t*)&bmw512_desc,
56 /*****************************************************************************
57 * additional validation-functions *
58 *****************************************************************************/
60 void performance_bmw(void){
61 hfal_performance_multiple(algolist);
64 void testrun_nessie_bmw(void){
65 hfal_nessie_multiple(algolist);
68 void bmw224_test(void* msg, uint32_t length_b){
69 hfal_test(&bmw224_desc, msg, length_b);
72 void bmw256_test(void* msg, uint32_t length_b){
73 hfal_test(&bmw256_desc, msg, length_b);
75 void bmw384_test(void* msg, uint32_t length_b){
76 hfal_test(&bmw384_desc, msg, length_b);
79 void bmw512_test(void* msg, uint32_t length_b){
80 hfal_test(&bmw512_desc, msg, length_b);
84 /* Testvector of length = 506 from short KAT */
86 0xB9, 0xE3, 0xE2, 0x75, 0x5E, 0xD1, 0x21, 0x53,
87 0x81, 0xB2, 0x45, 0x57, 0xEE, 0x14, 0xF8, 0xCD,
88 0x26, 0x87, 0xA0, 0x71, 0xAE, 0xB3, 0xC7, 0x4F,
89 0x42, 0x1C, 0xFE, 0xA3, 0xCF, 0xF8, 0xA6, 0xEA,
90 0x0D, 0x4B, 0xDA, 0x2A, 0xD4, 0xBD, 0x82, 0x43,
91 0xCB, 0xA7, 0x2B, 0x48, 0x1C, 0xBD, 0x52, 0x6E,
92 0x1E, 0xFA, 0x1D, 0x9F, 0xD4, 0x32, 0xB9, 0x87,
93 0xE8, 0x12, 0x65, 0x82, 0x44, 0x29, 0xBA, 0xC0 };
98 /* Testvector of length = 506 from short KAT */
100 0xE8, 0x33, 0x25, 0x35, 0xE9, 0xA2, 0x05, 0x24,
101 0x67, 0xA1, 0x02, 0x05, 0xC8, 0x70, 0x00, 0xBF,
102 0xC6, 0xA6, 0x8D, 0x73, 0x96, 0x2E, 0x69, 0xE4,
103 0xE5, 0x6F, 0x10, 0xBC, 0x79, 0xC6, 0x33, 0xC5,
104 0x2F, 0x4D, 0x00, 0x74, 0xD6, 0x07, 0x75, 0x95,
105 0xB6, 0x60, 0x07, 0x2E, 0x10, 0x74, 0x0D, 0xFA,
106 0x66, 0xBC, 0x13, 0x20, 0x46, 0x9A, 0x31, 0x96,
107 0xE0, 0x21, 0xE1, 0x32, 0x7C, 0xC0, 0x3A, 0xE0 };
111 void testrun_stdtest_bmw(void){
113 char* msg1 = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
114 bmw224_test(msg0, strlen(msg0)*8);
115 bmw224_test(msg1, strlen(msg1)*8);
116 bmw256_test(msg0, strlen(msg0)*8);
117 bmw256_test(msg1, strlen(msg1)*8);
118 bmw384_test(msg0, strlen(msg0)*8);
119 bmw384_test(msg1, strlen(msg1)*8);
120 bmw512_test(msg0, strlen(msg0)*8);
121 bmw512_test(msg1, strlen(msg1)*8);
124 void bmw256_short_test(void* msg, uint32_t length_b){
125 bmw256_test("abc", 3*8);
129 void testshort(void){
131 bmw224_test(msg0, strlen(msg0)*8);
134 void testlshort(void){
136 bmw384_test(msg0, strlen(msg0)*8);
139 /*****************************************************************************
141 *****************************************************************************/
143 const char nessie_str[] PROGMEM = "nessie";
144 const char test_str[] PROGMEM = "test";
145 const char test224_str[] PROGMEM = "test224";
146 const char test256_str[] PROGMEM = "test256";
147 const char test384_str[] PROGMEM = "test384";
148 const char test512_str[] PROGMEM = "test512";
149 const char test506_str[] PROGMEM = "506";
150 const char test507_str[] PROGMEM = "507";
151 const char testshort_str[] PROGMEM = "short";
152 const char testlshort_str[] PROGMEM = "lshort";
153 const char performance_str[] PROGMEM = "performance";
154 const char echo_str[] PROGMEM = "echo";
155 const char shavs_list_str[] PROGMEM = "shavs_list";
156 const char shavs_set_str[] PROGMEM = "shavs_set";
157 const char shavs_test1_str[] PROGMEM = "shavs_test1";
159 cmdlist_entry_t cmdlist[] PROGMEM = {
160 { nessie_str, NULL, testrun_nessie_bmw},
161 { test_str, NULL, testrun_stdtest_bmw},
162 { testshort_str, NULL, testshort},
163 { testlshort_str, NULL, testlshort},
164 { test506_str, NULL, test506},
165 { test507_str, NULL, test507},
166 { performance_str, NULL, performance_bmw},
167 { shavs_list_str, NULL, shavs_listalgos},
168 { shavs_set_str, (void*)1, (void_fpt)shavs_setalgo},
169 { shavs_test1_str, NULL, shavs_test1},
170 { echo_str, (void*)1, (void_fpt)echo_ctrl},
177 cli_rx = (cli_rx_fpt)uart0_getc;
178 cli_tx = (cli_tx_fpt)uart0_putc;
179 shavs_algolist=(hfdesc_t**)algolist;
180 shavs_algo=(hfdesc_t*)&bmw256_desc;
182 cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
183 cli_putstr(algo_name);
184 cli_putstr_P(PSTR("; "));
185 cli_putstr(__DATE__);
186 cli_putstr_P(PSTR(" "));
187 cli_putstr(__TIME__);
188 cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
190 cmd_interface(cmdlist);