]> git.cryptolib.org Git - avr-crypto-lib.git/blob - test_src/main-groestl-test.c
clean up
[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
26 #include "uart_i.h"
27 #include "debug.h"
28
29 #include "groestl_small.h"
30 #include "groestl_large.h"
31 #include "hfal/hfal_groestl_small.h"
32 #include "hfal/hfal_groestl_large.h"
33 #include "hfal/hfal-nessie.h"
34 #include "hfal/hfal-test.h"
35 #include "hfal/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         groestl384_test("", 8);
88         groestl384_test(msg1, 1152);
89         groestl512_test("", 8);
90         groestl512_test(msg1, 1152);
91 }
92
93 void testshort(void){
94         groestl256_test("abc", 24);
95 }
96
97 void testlshort(void){
98         groestl512_test("abc", 24);
99 }
100
101 void test505(void){
102         uint8_t data[] = {
103                 0x84, 0x73, 0xDC, 0x53, 0x82, 0xDE, 0x32, 0x95,
104                 0x7E, 0x3A, 0x15, 0xCA, 0x3D, 0x79, 0x1C, 0x67,
105                 0xD2, 0x0C, 0xF9, 0xEF, 0xBE, 0x3E, 0x46, 0x40,
106                 0x7D, 0xCA, 0x5D, 0x02, 0x63, 0x5A, 0xC8, 0x6D,
107                 0x2E, 0x0B, 0x22, 0xC7, 0x6D, 0x7D, 0x08, 0x0D,
108                 0x36, 0x2E, 0x82, 0x75, 0x89, 0x14, 0xCC, 0x0A,
109                 0xE2, 0xB8, 0x9B, 0xD3, 0x5F, 0x71, 0xD8, 0x44,
110                 0x92, 0xD9, 0x43, 0x07, 0x42, 0x78, 0x9C, 0x80 };
111         groestl224_test(data, 505);
112 }
113
114
115 void performance_groestl(void){
116         hfal_performance_multiple(algolist);
117 }
118
119 /*****************************************************************************
120  *  main                                                                                                                                         *
121  *****************************************************************************/
122
123
124 const char nessie_str[]       PROGMEM = "nessie";
125 const char test_str[]         PROGMEM = "test";
126 const char testshort_str[]    PROGMEM = "short";
127 const char testlshort_str[]   PROGMEM = "lshort";
128 const char test505_str[]      PROGMEM = "test505";
129 const char performance_str[]  PROGMEM = "performance";
130 const char echo_str[]         PROGMEM = "echo";
131 const char shavs_list_str[]   PROGMEM = "shavs_list";
132 const char shavs_set_str[]    PROGMEM = "shavs_set";
133 const char shavs_test1_str[]  PROGMEM = "shavs_test1";
134
135 cmdlist_entry_t cmdlist[] PROGMEM = {
136         { nessie_str,          NULL, testrun_nessie_groestl},
137         { test_str,            NULL, testrun_stdtest_groestl},
138         { testshort_str,       NULL, testshort},
139         { testlshort_str,      NULL, testlshort},
140         { test505_str,         NULL, test505},
141         { performance_str,     NULL, performance_groestl},
142         { shavs_list_str,      NULL, shavs_listalgos},
143         { shavs_set_str,   (void*)1, (void_fpt)shavs_setalgo},
144         { shavs_test1_str,     NULL, shavs_test1},
145         { echo_str,        (void*)1, (void_fpt)echo_ctrl},
146         { NULL,                NULL, NULL}
147 };
148
149 int main (void){
150         DEBUG_INIT();
151
152         cli_rx = (cli_rx_fpt)uart0_getc;
153         cli_tx = (cli_tx_fpt)uart0_putc;
154         shavs_algolist=(hfdesc_t**)algolist;
155         shavs_algo=(hfdesc_t*)&groestl256_desc;
156         for(;;){
157                 cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
158                 cli_putstr(algo_name);
159                 cli_putstr_P(PSTR("; "));
160                 cli_putstr(__DATE__);
161                 cli_putstr_P(PSTR(" "));
162                 cli_putstr(__TIME__);
163                 cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
164
165                 cmd_interface(cmdlist);
166         }
167 }