]> git.cryptolib.org Git - avr-crypto-lib.git/blob - test_src/main-bmw-test.c
modifyed build system (removed some redundance)
[avr-crypto-lib.git] / test_src / main-bmw-test.c
1 /* main-bmw-test.c */
2 /*
3     This file is part of the AVR-Crypto-Lib.
4     Copyright (C) 2008  Daniel Otte (daniel.otte@rub.de)
5
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.
10
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.
15
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/>.
18 */
19 /*
20  * BlueMidnightWish test-suit
21  * 
22 */
23
24 #include "config.h"
25 #include "serial-tools.h"
26 #include "uart.h"
27 #include "debug.h"
28
29 #include "bmw_small.h"
30 #include "bmw_large.h"
31 #include "cli.h"
32 #include "hfal_bmw_small.h"
33 #include "hfal_bmw_large.h"
34 #include "shavs.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"
40
41 #include <stdint.h>
42 #include <string.h>
43 #include <stdlib.h>
44
45 char* algo_name = "BlueMidnightWish";
46
47
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,
53         NULL
54 };
55
56 /*****************************************************************************
57  *  additional validation-functions                                                                                      *
58  *****************************************************************************/
59
60 void performance_bmw(void){
61         hfal_performance_multiple(algolist);
62 }
63
64 void testrun_nessie_bmw(void){
65         hfal_nessie_multiple(algolist);
66 }
67
68 void bmw224_test(void* msg, uint32_t length_b){
69         hfal_test(&bmw224_desc, msg, length_b);
70 }
71
72 void bmw256_test(void* msg, uint32_t length_b){
73         hfal_test(&bmw256_desc, msg, length_b);
74 }
75
76 void bmw384_test(void* msg, uint32_t length_b){
77         hfal_test(&bmw384_desc, msg, length_b);
78 }
79
80 void bmw512_test(void* msg, uint32_t length_b){
81         hfal_test(&bmw512_desc, msg, length_b);
82 }
83
84 void testrun_stdtest_bmw(void){
85         char* msg0 = "abc";
86         char* msg1 = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; 
87         bmw224_test(msg0, strlen(msg0)*8);
88         bmw224_test(msg1, strlen(msg1)*8);
89         bmw256_test(msg0, strlen(msg0)*8);
90         bmw256_test(msg1, strlen(msg1)*8);
91         bmw384_test(msg0, strlen(msg0)*8);
92         bmw384_test(msg1, strlen(msg1)*8);
93         bmw512_test(msg0, strlen(msg0)*8);
94         bmw512_test(msg1, strlen(msg1)*8);
95 }
96
97 void testshort(void){
98         char* msg0 = "abc";
99         bmw224_test(msg0, strlen(msg0)*8);
100 }
101
102 void testlshort(void){
103         char* msg0 = "abc";
104         bmw384_test(msg0, strlen(msg0)*8);
105 }
106
107 /*****************************************************************************
108  *  main                                                                                                                                         *
109  *****************************************************************************/
110
111 const char nessie_str[]      PROGMEM = "nessie";
112 const char test_str[]        PROGMEM = "test";
113 const char testshort_str[]   PROGMEM = "short";
114 const char testlshort_str[]  PROGMEM = "lshort";
115 const char performance_str[] PROGMEM = "performance";
116 const char echo_str[]        PROGMEM = "echo";
117 const char shavs_list_str[]  PROGMEM = "shavs_list";
118 const char shavs_set_str[]   PROGMEM = "shavs_set";
119 const char shavs_test1_str[] PROGMEM = "shavs_test1";
120
121 cmdlist_entry_t cmdlist[] PROGMEM = {
122         { nessie_str,          NULL, testrun_nessie_bmw},
123         { test_str,            NULL, testrun_stdtest_bmw},
124         { testshort_str,       NULL, testshort},
125         { testlshort_str,      NULL, testlshort},
126         { performance_str,     NULL, performance_bmw},
127         { shavs_list_str,      NULL, shavs_listalgos},
128         { shavs_set_str,   (void*)1, (void_fpt)shavs_setalgo},
129         { shavs_test1_str,     NULL, shavs_test1},
130         { echo_str,        (void*)1, (void_fpt)echo_ctrl},
131         { NULL,                NULL, NULL}
132 };
133
134 int main (void){
135         DEBUG_INIT();
136         
137         cli_rx = uart_getc;
138         cli_tx = uart_putc;             
139         shavs_algolist=(hfdesc_t**)algolist;
140         shavs_algo=(hfdesc_t*)&bmw256_desc;
141         for(;;){
142                 cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
143                 cli_putstr(algo_name);
144                 cli_putstr_P(PSTR("; "));
145                 cli_putstr(__DATE__);
146                 cli_putstr_P(PSTR(" "));
147                 cli_putstr(__TIME__);
148                 cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
149                 
150                 cmd_interface(cmdlist);
151         }
152 }