]> git.cryptolib.org Git - avr-crypto-lib.git/blob - test_src/main-blake-test.c
verification seems to work now...
[avr-crypto-lib.git] / test_src / main-blake-test.c
1 /* main-blake-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  * blake test-suit
21  * 
22 */
23
24 #include "config.h"
25
26 #include "uart_i.h"
27 #include "debug.h"
28
29 #include "blake_small.h"
30 #include "blake_large.h"
31 #include "hfal_blake_small.h"
32 #include "hfal_blake_large.h"
33 #include "hfal-nessie.h"
34 #include "hfal-test.h"
35 #include "hfal-performance.h"
36 #include "shavs.h"
37 #include "cli.h"
38 #include "nessie_hash_test.h"
39 #include "performance_test.h"
40
41 #include <stdint.h>
42 #include <string.h>
43 #include <stdlib.h>
44
45 char* algo_name = "Blake";
46
47
48 const hfdesc_t* algolist[] PROGMEM = {
49         (hfdesc_t*)&blake28_desc,
50         (hfdesc_t*)&blake32_desc,
51         (hfdesc_t*)&blake48_desc,
52         (hfdesc_t*)&blake64_desc,
53         NULL
54 };
55
56 /*****************************************************************************
57  *  additional validation-functions                                                                                      *
58  *****************************************************************************/
59
60 void testrun_nessie_blake(void){
61         hfal_nessie_multiple(algolist);
62 }
63 void blake28_test(void* msg, uint32_t length_b){
64         hfal_test(&blake28_desc, msg, length_b);
65 }
66
67 void blake32_test(void* msg, uint32_t length_b){
68         hfal_test(&blake32_desc, msg, length_b);
69 }
70
71 void blake48_test(void* msg, uint32_t length_b){
72         hfal_test(&blake48_desc, msg, length_b);
73 }
74
75 void blake64_test(void* msg, uint32_t length_b){
76         hfal_test(&blake64_desc, msg, length_b);
77 }
78 void testrun_stdtest_blake(void){
79         uint8_t msg1[144]; 
80         memset(msg1, 0, 144);
81         blake28_test("", 8);
82         blake28_test(msg1, 576);
83         blake32_test("", 8);
84         blake32_test(msg1, 576);
85         blake48_test("", 8);
86         blake48_test(msg1, 1152);
87         blake64_test("", 8);
88         blake64_test(msg1, 1152);
89 }
90
91 void testshort(void){
92         blake32_test("", 8);
93 }
94
95 void testlshort(void){
96         blake64_test("", 8);
97 }
98
99
100 void performance_blake(void){
101         hfal_performance_multiple(algolist);
102 }
103
104 /*****************************************************************************
105  *  main                                                                                                                                         *
106  *****************************************************************************/
107
108
109 const char nessie_str[]       PROGMEM = "nessie";
110 const char test_str[]         PROGMEM = "test";
111 const char testshort_str[]    PROGMEM = "short";
112 const char testlshort_str[]   PROGMEM = "lshort";
113 const char performance_str[]  PROGMEM = "performance";
114 const char echo_str[]         PROGMEM = "echo";
115 const char shavs_list_str[]   PROGMEM = "shavs_list";
116 const char shavs_set_str[]    PROGMEM = "shavs_set";
117 const char shavs_test1_str[]  PROGMEM = "shavs_test1";
118
119 cmdlist_entry_t cmdlist[] PROGMEM = {
120         { nessie_str,          NULL, testrun_nessie_blake},
121         { test_str,            NULL, testrun_stdtest_blake},
122         { testshort_str,       NULL, testshort},
123         { testlshort_str,      NULL, testlshort},
124         { performance_str,     NULL, performance_blake},
125         { shavs_list_str,      NULL, shavs_listalgos},
126         { shavs_set_str,   (void*)1, (void_fpt)shavs_setalgo},
127         { shavs_test1_str,     NULL, shavs_test1},
128         { echo_str,        (void*)1, (void_fpt)echo_ctrl},
129         { NULL,                NULL, NULL}
130 };
131
132 int main (void){
133         DEBUG_INIT();
134         
135         cli_rx = (cli_rx_fpt)uart0_getc;
136         cli_tx = (cli_tx_fpt)uart0_putc;                
137         shavs_algolist=(hfdesc_t**)algolist;
138         shavs_algo=(hfdesc_t*)&blake32_desc;
139         for(;;){
140                 cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
141                 cli_putstr(algo_name);
142                 cli_putstr_P(PSTR("; "));
143                 cli_putstr(__DATE__);
144                 cli_putstr_P(PSTR(" "));
145                 cli_putstr(__TIME__);
146                 cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
147                 
148                 cmd_interface(cmdlist);
149         }
150 }