]> git.cryptolib.org Git - avr-crypto-lib.git/blob - test_src/main-groestl-test.c
grøstl, a first impression
[avr-crypto-lib.git] / test_src / main-groestl-test.c
1 /* main-groestl-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  * groestl 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 "groestl_small.h"
30 //#include "groestl_large.h"
31 #include "hfal_groestl_small.h"
32 //#include "hfal_groestl_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 = "Groestl";
46
47
48 const hfdesc_t* algolist[] PROGMEM = {
49         (hfdesc_t*)&groestl224_desc,
50         (hfdesc_t*)&groestl256_desc,
51 //      (hfdesc_t*)&groestl384_desc,
52 //      (hfdesc_t*)&groestl512_desc,
53         NULL
54 };
55
56 /*****************************************************************************
57  *  additional validation-functions                                                                                      *
58  *****************************************************************************/
59
60 void testrun_nessie_groestl(void){
61         hfal_nessie_multiple(algolist);
62 }
63 void groestl224_test(void* msg, uint32_t length_b){
64         hfal_test(&groestl224_desc, msg, length_b);
65 }
66
67 void groestl256_test(void* msg, uint32_t length_b){
68         hfal_test(&groestl256_desc, msg, length_b);
69 }
70 /*
71 void groestl384_test(void* msg, uint32_t length_b){
72         hfal_test(&groestl384_desc, msg, length_b);
73 }
74
75 void groestl512_test(void* msg, uint32_t length_b){
76         hfal_test(&groestl512_desc, msg, length_b);
77 }
78 */
79
80 void testrun_stdtest_groestl(void){
81         uint8_t msg1[144]; 
82         memset(msg1, 0, 144);
83         groestl224_test("", 8);
84         groestl224_test(msg1, 576);
85         groestl256_test("", 8);
86         groestl256_test(msg1, 576);
87 /*
88         groestl384_test("", 8);
89         groestl384_test(msg1, 1152);
90         groestl512_test("", 8);
91         groestl512_test(msg1, 1152);
92 */
93 }
94
95 void testshort(void){
96         groestl256_test("abc", 24);
97 }
98
99 void testlshort(void){
100 //      groestl512_test("", 8);
101 }
102
103
104 void performance_groestl(void){
105         hfal_performance_multiple(algolist);
106 }
107
108 /*****************************************************************************
109  *  main                                                                                                                                         *
110  *****************************************************************************/
111
112
113 const char nessie_str[]       PROGMEM = "nessie";
114 const char test_str[]         PROGMEM = "test";
115 const char testshort_str[]    PROGMEM = "short";
116 const char testlshort_str[]   PROGMEM = "lshort";
117 const char performance_str[]  PROGMEM = "performance";
118 const char echo_str[]         PROGMEM = "echo";
119 const char shavs_list_str[]   PROGMEM = "shavs_list";
120 const char shavs_set_str[]    PROGMEM = "shavs_set";
121 const char shavs_test1_str[]  PROGMEM = "shavs_test1";
122
123 cmdlist_entry_t cmdlist[] PROGMEM = {
124         { nessie_str,          NULL, testrun_nessie_groestl},
125         { test_str,            NULL, testrun_stdtest_groestl},
126         { testshort_str,       NULL, testshort},
127         { testlshort_str,      NULL, testlshort},
128         { performance_str,     NULL, performance_groestl},
129         { shavs_list_str,      NULL, shavs_listalgos},
130         { shavs_set_str,   (void*)1, (void_fpt)shavs_setalgo},
131         { shavs_test1_str,     NULL, shavs_test1},
132         { echo_str,        (void*)1, (void_fpt)echo_ctrl},
133         { NULL,                NULL, NULL}
134 };
135
136 int main (void){
137         DEBUG_INIT();
138         
139         cli_rx = uart_getc;
140         cli_tx = uart_putc;             
141         shavs_algolist=(hfdesc_t**)algolist;
142         shavs_algo=(hfdesc_t*)&groestl256_desc;
143         for(;;){
144                 cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
145                 cli_putstr(algo_name);
146                 cli_putstr_P(PSTR("; "));
147                 cli_putstr(__DATE__);
148                 cli_putstr_P(PSTR(" "));
149                 cli_putstr(__TIME__);
150                 cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
151                 
152                 cmd_interface(cmdlist);
153         }
154 }