1 /* main-cubehash-test.c */
3 This file is part of the ARM-Crypto-Lib.
4 Copyright (C) 2006-2010 Daniel Otte (daniel.otte@rub.de)
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.
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.
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/>.
29 #include "uart_lowlevel.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"
41 #include "hfal_cubehash.h"
47 const char* algo_name = "CubeHash";
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,
58 void uart0_putc(char byte){
59 uart_putc(UART_0, byte);
62 char uart0_getc(void){
63 return uart_getc(UART_0);
66 /*****************************************************************************
67 * additional validation-functions *
68 *****************************************************************************/
70 void cubehash256_test0(void){
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);
82 void performance_cubehash(void){
83 hfal_performance_multiple(algolist);
86 void testrun_nessie_cubehash(void){
87 hfal_nessie_multiple(algolist);
89 /*****************************************************************************
91 *****************************************************************************/
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";
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 },
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);
124 shavs_algolist=(hfdesc_t**)algolist;
125 shavs_algo=(hfdesc_t*)&cubehash256_desc;
128 cli_putstr("\r\n\r\nARM-Crypto-Lib VS (");
129 cli_putstr(algo_name);
131 cli_putstr(__DATE__);
133 cli_putstr(__TIME__);
134 cli_putstr(")\r\nloaded and running\r\n");
135 cmd_interface(cmdlist);