1 /* main-blake-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/>.
28 #include "uart_lowlevel.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"
39 #include "blake_small.h"
40 #include "blake_large.h"
41 #include "hfal_blake_small.h"
42 #include "hfal_blake_large.h"
45 char* algo_name = "Blake";
47 void uart0_putc(char byte){
48 uart_putc(UART_0, byte);
51 char uart0_getc(void){
52 return uart_getc(UART_0);
56 const hfdesc_t* algolist[] = {
57 (hfdesc_t*)&blake28_desc,
58 (hfdesc_t*)&blake32_desc,
59 (hfdesc_t*)&blake48_desc,
60 (hfdesc_t*)&blake64_desc,
64 /*****************************************************************************
65 * additional validation-functions *
66 *****************************************************************************/
68 void testrun_nessie_blake(void){
69 hfal_nessie_multiple(algolist);
71 void blake28_test(void* msg, uint32_t length_b){
72 hfal_test(&blake28_desc, msg, length_b);
75 void blake32_test(void* msg, uint32_t length_b){
76 hfal_test(&blake32_desc, msg, length_b);
79 void blake48_test(void* msg, uint32_t length_b){
80 hfal_test(&blake48_desc, msg, length_b);
83 void blake64_test(void* msg, uint32_t length_b){
84 hfal_test(&blake64_desc, msg, length_b);
86 void testrun_stdtest_blake(void){
90 blake28_test(msg1, 576);
92 blake32_test(msg1, 576);
94 blake48_test(msg1, 1152);
96 blake64_test(msg1, 1152);
103 void testlshort(void){
107 void test512_32(void){
108 uint8_t d[] = { 0xE9, 0x26, 0xAE, 0x8B, 0x0A, 0xF6, 0xE5, 0x31,
109 0x76, 0xDB, 0xFF, 0xCC, 0x2A, 0x6B, 0x88, 0xC6,
110 0xBD, 0x76, 0x5F, 0x93, 0x9D, 0x3D, 0x17, 0x8A,
111 0x9B, 0xDE, 0x9E, 0xF3, 0xAA, 0x13, 0x1C, 0x61,
112 0xE3, 0x1C, 0x1E, 0x42, 0xCD, 0xFA, 0xF4, 0xB4,
113 0xDC, 0xDE, 0x57, 0x9A, 0x37, 0xE1, 0x50, 0xEF,
114 0xBE, 0xF5, 0x55, 0x5B, 0x4C, 0x1C, 0xB4, 0x04,
115 0x39, 0xD8, 0x35, 0xA7, 0x24, 0xE2, 0xFA, 0xE7 };
116 blake32_test(d, 512);
119 void performance_blake(void){
120 hfal_performance_multiple(algolist);
123 /*****************************************************************************
125 *****************************************************************************/
128 const char nessie_str[] = "nessie";
129 const char test_str[] = "test";
130 const char testshort_str[] = "short";
131 const char testlshort_str[] = "lshort";
132 const char test512_str[] = "test512";
133 const char performance_str[] = "performance";
134 const char echo_str[] = "echo";
135 const char shavs_list_str[] = "shavs_list";
136 const char shavs_set_str[] = "shavs_set";
137 const char shavs_test1_str[] = "shavs_test1";
138 const char shavs_test3_str[] = "shavs_test3";
140 cmdlist_entry_t cmdlist[] = {
141 { nessie_str, NULL, testrun_nessie_blake},
142 { test_str, NULL, testrun_stdtest_blake},
143 { testshort_str, NULL, testshort},
144 { testlshort_str, NULL, testlshort},
145 { test512_str, NULL, test512_32},
146 { performance_str, NULL, performance_blake},
147 { shavs_list_str, NULL, shavs_listalgos},
148 { shavs_set_str, (void*)1, (void_fpt)shavs_setalgo},
149 { shavs_test1_str, NULL, shavs_test1},
150 { shavs_test3_str, NULL, shavs_test3},
151 { echo_str, (void*)1, (void_fpt)echo_ctrl},
157 sysclk_mosc_verify_enable();
158 uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
159 gptm_set_timer_32periodic(TIMER0);
164 shavs_algolist=(hfdesc_t**)algolist;
165 shavs_algo=(hfdesc_t*)&blake32_desc;
168 cli_putstr("\r\n\r\nARM-Crypto-Lib VS (");
169 cli_putstr(algo_name);
171 cli_putstr(__DATE__);
173 cli_putstr(__TIME__);
174 cli_putstr(")\r\nloaded and running\r\n");
175 cmd_interface(cmdlist);