]> git.cryptolib.org Git - arm-crypto-lib.git/blob - test_src/main-groestl-test.c
switching to dedicated endian switching function
[arm-crypto-lib.git] / test_src / main-groestl-test.c
1 /* main-groestl-test.c */
2 /*
3     This file is part of the ARM-Crypto-Lib.
4     Copyright (C) 2006-2010  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 <stdint.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include "config.h"
28 #include "cli.h"
29 #include "dump.h"
30 #include "uart_lowlevel.h"
31 #include "sysclock.h"
32 #include "hw_gptm.h"
33
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 "groestl_small.h"
42 #include "groestl_large.h"
43 #include "hfal_groestl_small.h"
44 #include "hfal_groestl_large.h"
45
46 const char* algo_name = "Groestl";
47
48 void uart0_putc(char byte){
49         uart_putc(UART_0, byte);
50 }
51
52 char uart0_getc(void){
53         return uart_getc(UART_0);
54 }
55
56
57 const hfdesc_t* algolist[] = {
58         (hfdesc_t*)&groestl224_desc,
59         (hfdesc_t*)&groestl256_desc,
60         (hfdesc_t*)&groestl384_desc,
61         (hfdesc_t*)&groestl512_desc,
62         NULL
63 };
64
65 /*****************************************************************************
66  *  additional validation-functions                                                                                      *
67  *****************************************************************************/
68
69 void testrun_nessie_groestl(void){
70         hfal_nessie_multiple(algolist);
71 }
72 void groestl224_test(const void* msg, uint32_t length_b){
73         hfal_test(&groestl224_desc, msg, length_b);
74 }
75
76 void groestl256_test(const void* msg, uint32_t length_b){
77         hfal_test(&groestl256_desc, msg, length_b);
78 }
79
80 void groestl384_test(const void* msg, uint32_t length_b){
81         hfal_test(&groestl384_desc, msg, length_b);
82 }
83
84 void groestl512_test(const void* msg, uint32_t length_b){
85         hfal_test(&groestl512_desc, msg, length_b);
86 }
87
88
89 void testrun_stdtest_groestl(void){
90         uint8_t msg1[144];
91         memset(msg1, 0, 144);
92         groestl224_test("", 8);
93         groestl224_test(msg1, 576);
94         groestl256_test("", 8);
95         groestl256_test(msg1, 576);
96         groestl384_test("", 8);
97         groestl384_test(msg1, 1152);
98         groestl512_test("", 8);
99         groestl512_test(msg1, 1152);
100 }
101
102 void testshort(void){
103         groestl256_test("abc", 24);
104 }
105
106 void testlshort(void){
107         groestl512_test("abc", 24);
108 }
109
110 void test505(void){
111         const uint8_t data[] = {
112                 0x84, 0x73, 0xDC, 0x53, 0x82, 0xDE, 0x32, 0x95,
113                 0x7E, 0x3A, 0x15, 0xCA, 0x3D, 0x79, 0x1C, 0x67,
114                 0xD2, 0x0C, 0xF9, 0xEF, 0xBE, 0x3E, 0x46, 0x40,
115                 0x7D, 0xCA, 0x5D, 0x02, 0x63, 0x5A, 0xC8, 0x6D,
116                 0x2E, 0x0B, 0x22, 0xC7, 0x6D, 0x7D, 0x08, 0x0D,
117                 0x36, 0x2E, 0x82, 0x75, 0x89, 0x14, 0xCC, 0x0A,
118                 0xE2, 0xB8, 0x9B, 0xD3, 0x5F, 0x71, 0xD8, 0x44,
119                 0x92, 0xD9, 0x43, 0x07, 0x42, 0x78, 0x9C, 0x80 };
120         groestl224_test(data, 505);
121 }
122
123
124 void performance_groestl(void){
125         hfal_performance_multiple(algolist);
126 }
127
128 /*****************************************************************************
129  *  main                                                                                                                                         *
130  *****************************************************************************/
131
132
133 const char nessie_str[]        = "nessie";
134 const char test_str[]          = "test";
135 const char testshort_str[]     = "short";
136 const char testlshort_str[]    = "lshort";
137 const char test505_str[]       = "test505";
138 const char performance_str[]   = "performance";
139 const char echo_str[]          = "echo";
140 const char shavs_list_str[]    = "shavs_list";
141 const char shavs_set_str[]     = "shavs_set";
142 const char shavs_test1_str[]   = "shavs_test1";
143
144 cmdlist_entry_t cmdlist[]  = {
145         { nessie_str,          NULL, testrun_nessie_groestl},
146         { test_str,            NULL, testrun_stdtest_groestl},
147         { testshort_str,       NULL, testshort},
148         { testlshort_str,      NULL, testlshort},
149         { test505_str,         NULL, test505},
150         { performance_str,     NULL, performance_groestl},
151         { shavs_list_str,      NULL, shavs_listalgos},
152         { shavs_set_str,   (void*)1, (void_fpt)shavs_setalgo},
153         { shavs_test1_str,     NULL, shavs_test1},
154         { echo_str,        (void*)1, (void_fpt)echo_ctrl},
155         { NULL,                NULL, NULL}
156 };
157
158
159 int main(void) {
160         sysclk_set_freq(SYS_FREQ);
161         sysclk_mosc_verify_enable();
162     uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
163     gptm_set_timer_32periodic(TIMER0);
164
165         cli_rx = uart0_getc;
166     cli_tx = uart0_putc;
167
168         shavs_algolist=(hfdesc_t**)algolist;
169         shavs_algo=(hfdesc_t*)&groestl256_desc;
170
171         for(;;){
172                 cli_putstr("\r\n\r\nARM-Crypto-Lib VS (");
173                 cli_putstr(algo_name);
174                 cli_putstr("; ");
175                 cli_putstr(__DATE__);
176                 cli_putc(' ');
177                 cli_putstr(__TIME__);
178                 cli_putstr(")\r\nloaded and running\r\n");
179         cmd_interface(cmdlist);
180     }
181
182 }