1 /* main-bmw-test.c */
\r
3 This file is part of the ARM-Crypto-Lib.
\r
4 Copyright (C) 2006-2010 Daniel Otte (daniel.otte@rub.de)
\r
6 This program is free software: you can redistribute it and/or modify
\r
7 it under the terms of the GNU General Public License as published by
\r
8 the Free Software Foundation, either version 3 of the License, or
\r
9 (at your option) any later version.
\r
11 This program is distributed in the hope that it will be useful,
\r
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 GNU General Public License for more details.
\r
16 You should have received a copy of the GNU General Public License
\r
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
20 * BlueMidnightWish test-suit
\r
29 #include "uart_lowlevel.h"
\r
30 #include "sysclock.h"
\r
31 #include "hw_gptm.h"
\r
34 #include "nessie_hash_test.h"
\r
35 #include "performance_test.h"
\r
36 #include "hfal-nessie.h"
\r
37 #include "hfal-performance.h"
\r
38 #include "hfal-test.h"
\r
40 #include "hfal_bmw_small.h"
\r
41 #include "hfal_bmw_large.h"
\r
42 #include "bmw_small.h"
\r
43 #include "bmw_large.h"
\r
45 void uart0_putc(char byte){
\r
46 uart_putc(UART_0, byte);
\r
49 char uart0_getc(void){
\r
50 return uart_getc(UART_0);
\r
54 const char* algo_name = "BlueMidnightWish";
\r
57 const hfdesc_t* algolist[] = {
\r
58 (hfdesc_t*)&bmw224_desc,
\r
59 (hfdesc_t*)&bmw256_desc,
\r
60 (hfdesc_t*)&bmw384_desc,
\r
61 (hfdesc_t*)&bmw512_desc,
\r
65 /*****************************************************************************
\r
66 * additional validation-functions *
\r
67 *****************************************************************************/
\r
69 void performance_bmw(void){
\r
70 hfal_performance_multiple(algolist);
\r
73 void testrun_nessie_bmw(void){
\r
74 hfal_nessie_multiple(algolist);
\r
77 void bmw224_test(void* msg, uint32_t length_b){
\r
78 hfal_test(&bmw224_desc, msg, length_b);
\r
81 void bmw256_test(void* msg, uint32_t length_b){
\r
82 hfal_test(&bmw256_desc, msg, length_b);
\r
84 void bmw384_test(void* msg, uint32_t length_b){
\r
85 hfal_test(&bmw384_desc, msg, length_b);
\r
88 void bmw512_test(void* msg, uint32_t length_b){
\r
89 hfal_test(&bmw512_desc, msg, length_b);
\r
93 /* Testvector of length = 506 from short KAT */
\r
95 0xB9, 0xE3, 0xE2, 0x75, 0x5E, 0xD1, 0x21, 0x53,
\r
96 0x81, 0xB2, 0x45, 0x57, 0xEE, 0x14, 0xF8, 0xCD,
\r
97 0x26, 0x87, 0xA0, 0x71, 0xAE, 0xB3, 0xC7, 0x4F,
\r
98 0x42, 0x1C, 0xFE, 0xA3, 0xCF, 0xF8, 0xA6, 0xEA,
\r
99 0x0D, 0x4B, 0xDA, 0x2A, 0xD4, 0xBD, 0x82, 0x43,
\r
100 0xCB, 0xA7, 0x2B, 0x48, 0x1C, 0xBD, 0x52, 0x6E,
\r
101 0x1E, 0xFA, 0x1D, 0x9F, 0xD4, 0x32, 0xB9, 0x87,
\r
102 0xE8, 0x12, 0x65, 0x82, 0x44, 0x29, 0xBA, 0xC0 };
\r
103 bmw512_test(v, 506);
\r
106 void test507(void){
\r
107 /* Testvector of length = 506 from short KAT */
\r
109 0xE8, 0x33, 0x25, 0x35, 0xE9, 0xA2, 0x05, 0x24,
\r
110 0x67, 0xA1, 0x02, 0x05, 0xC8, 0x70, 0x00, 0xBF,
\r
111 0xC6, 0xA6, 0x8D, 0x73, 0x96, 0x2E, 0x69, 0xE4,
\r
112 0xE5, 0x6F, 0x10, 0xBC, 0x79, 0xC6, 0x33, 0xC5,
\r
113 0x2F, 0x4D, 0x00, 0x74, 0xD6, 0x07, 0x75, 0x95,
\r
114 0xB6, 0x60, 0x07, 0x2E, 0x10, 0x74, 0x0D, 0xFA,
\r
115 0x66, 0xBC, 0x13, 0x20, 0x46, 0x9A, 0x31, 0x96,
\r
116 0xE0, 0x21, 0xE1, 0x32, 0x7C, 0xC0, 0x3A, 0xE0 };
\r
117 bmw512_test(v, 507);
\r
120 void testrun_stdtest_bmw(void){
\r
121 char* msg0 = "abc";
\r
122 char* msg1 = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
\r
123 bmw224_test(msg0, strlen(msg0)*8);
\r
124 bmw224_test(msg1, strlen(msg1)*8);
\r
125 bmw256_test(msg0, strlen(msg0)*8);
\r
126 bmw256_test(msg1, strlen(msg1)*8);
\r
127 bmw384_test(msg0, strlen(msg0)*8);
\r
128 bmw384_test(msg1, strlen(msg1)*8);
\r
129 bmw512_test(msg0, strlen(msg0)*8);
\r
130 bmw512_test(msg1, strlen(msg1)*8);
\r
133 void bmw256_short_test(void* msg, uint32_t length_b){
\r
134 bmw256_test("abc", 3*8);
\r
138 void testshort(void){
\r
139 char* msg0 = "abc";
\r
140 bmw224_test(msg0, strlen(msg0)*8);
\r
143 void testlshort(void){
\r
144 char* msg0 = "abc";
\r
145 bmw384_test(msg0, strlen(msg0)*8);
\r
148 /*****************************************************************************
\r
149 * additional test-functions *
\r
150 *****************************************************************************/
\r
154 cmdlist_entry_t cmdlist[] = {
\r
155 { "nessie", NULL, testrun_nessie_bmw },
\r
156 { "test", NULL, testrun_stdtest_bmw },
\r
157 { "short", NULL, testshort },
\r
158 { "lshort", NULL, testlshort },
\r
159 { "test506", NULL, test506 },
\r
160 { "test507", NULL, test507 },
\r
161 { "performance", NULL, performance_bmw },
\r
162 { "shavs_list", NULL, shavs_listalgos },
\r
163 { "shavs_set", (void*)1, (void_fpt)shavs_setalgo },
\r
164 { "shavs_test1", NULL, shavs_test1 },
\r
165 { "shavs_test3", NULL, shavs_test3 },
\r
166 { "dump", (void*)1, (void_fpt)dump },
\r
167 { "echo", (void*)1, (void_fpt)echo_ctrl },
\r
168 { NULL, NULL, NULL }
\r
172 sysclk_set_freq(SYS_FREQ_40MHZ000);
\r
173 sysclk_mosc_verify_enable();
\r
174 uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
\r
175 gptm_set_timer_32periodic(TIMER0);
\r
177 cli_rx = uart0_getc;
\r
178 cli_tx = uart0_putc;
\r
180 shavs_algolist=(hfdesc_t**)algolist;
\r
181 shavs_algo=(hfdesc_t*)&bmw256_desc;
\r
184 cli_putstr("\r\n\r\nARM-Crypto-Lib VS (");
\r
185 cli_putstr(algo_name);
\r
187 cli_putstr(__DATE__);
\r
189 cli_putstr(__TIME__);
\r
190 cli_putstr(")\r\nloaded and running\r\n");
\r
191 cmd_interface(cmdlist);
\r