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