]> git.cryptolib.org Git - arm-crypto-lib.git/blob - test_src/main-cubehash-test.c
switching to dedicated endian switching function
[arm-crypto-lib.git] / test_src / main-cubehash-test.c
1 /* main-cubehash-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  * CubeHash test-suit
21  *
22 */
23 #include <stdint.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include "config.h"
27 #include "cli.h"
28 #include "dump.h"
29 #include "uart_lowlevel.h"
30 #include "sysclock.h"
31 #include "hw_gptm.h"
32
33 #include "shavs.h"
34 #include "nessie_hash_test.h"
35 #include "performance_test.h"
36 #include "hfal-nessie.h"
37 #include "hfal-performance.h"
38 #include "hfal-test.h"
39
40 #include "cubehash.h"
41 #include "hfal_cubehash.h"
42
43 #include <stdint.h>
44 #include <string.h>
45 #include <stdlib.h>
46
47 const char* algo_name = "CubeHash";
48
49
50 const hfdesc_t* algolist[] = {
51         (hfdesc_t*)&cubehash224_desc,
52         (hfdesc_t*)&cubehash256_desc,
53         (hfdesc_t*)&cubehash384_desc,
54         (hfdesc_t*)&cubehash512_desc,
55         NULL
56 };
57
58 void uart0_putc(char byte){
59         uart_putc(UART_0, byte);
60 }
61
62 char uart0_getc(void){
63         return uart_getc(UART_0);
64 }
65
66 /*****************************************************************************
67  *  additional validation-functions                                                                                      *
68  *****************************************************************************/
69
70 void cubehash256_test0(void){
71         cubehash_ctx_t ctx;
72         uint8_t hash[32];
73         cubehash256_init(&ctx);
74         cli_putstr("\r\ninit done ");
75         cubehash_lastBlock(&ctx, NULL, 0);
76         cli_putstr("\r\nlastblock done ");
77         cubehash256_ctx2hash(hash, &ctx);
78         cli_putstr("\r\nhash = ");
79         cli_hexdump(hash, 32);
80 }
81
82 void performance_cubehash(void){
83         hfal_performance_multiple(algolist);
84 }
85
86 void testrun_nessie_cubehash(void){
87         hfal_nessie_multiple(algolist);
88 }
89 /*****************************************************************************
90  *  main                                                                                                                                         *
91  *****************************************************************************/
92
93 const char nessie_str[]       = "nessie";
94 const char test256_str[]      = "test256";
95 const char performance_str[]  = "performance";
96 const char echo_str[]         = "echo";
97 const char shavs_list_str[]   = "shavs_list";
98 const char shavs_set_str[]    = "shavs_set";
99 const char shavs_test1_str[]  = "shavs_test1";
100 const char shavs_test3_str[]  = "shavs_test3";
101
102 cmdlist_entry_t cmdlist[]  = {
103         { nessie_str,                NULL, testrun_nessie_cubehash     },
104         { test256_str,               NULL, cubehash256_test0           },
105         { performance_str,           NULL, performance_cubehash        },
106         { shavs_list_str,            NULL, shavs_listalgos             },
107         { shavs_set_str,         (void*)1, (void_fpt)shavs_setalgo     },
108         { shavs_test1_str,           NULL, shavs_test1                 },
109         { shavs_test3_str,           NULL, shavs_test3                 },
110         { echo_str,              (void*)1, (void_fpt)echo_ctrl         },
111         { NULL,                      NULL, NULL                        }
112 };
113
114
115 int main(void) {
116         sysclk_set_freq(SYS_FREQ);
117         sysclk_mosc_verify_enable();
118     uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
119     gptm_set_timer_32periodic(TIMER0);
120
121         cli_rx = uart0_getc;
122     cli_tx = uart0_putc;
123
124         shavs_algolist=(hfdesc_t**)algolist;
125         shavs_algo=(hfdesc_t*)&cubehash256_desc;
126
127         for(;;){
128                 cli_putstr("\r\n\r\nARM-Crypto-Lib VS (");
129                 cli_putstr(algo_name);
130                 cli_putstr("; ");
131                 cli_putstr(__DATE__);
132                 cli_putc(' ');
133                 cli_putstr(__TIME__);
134                 cli_putstr(")\r\nloaded and running\r\n");
135         cmd_interface(cmdlist);
136     }
137
138 }