]> git.cryptolib.org Git - avr-crypto-lib.git/blob - test_src/main-sha256-test.c
backporting uart_i and cli
[avr-crypto-lib.git] / test_src / main-sha256-test.c
1 /* main-sha256-test.c */
2 /*
3     This file is part of the AVR-Crypto-Lib.
4     Copyright (C) 2008  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  * SHA-256 test-suit
21  * 
22 */
23
24 #include "config.h"
25 #include "serial-tools.h"
26 #include "uart_i.h"
27 #include "debug.h"
28
29 #include "sha256.h"
30 #include "nessie_hash_test.h"
31 #include "performance_test.h"
32 #include "hfal-performance.h"
33 #include "hfal-nessie.h"
34
35 #include <stdint.h>
36 #include <string.h>
37 #include <stdlib.h>
38 #include "cli.h"
39 #include "shavs.h"
40 #include "hfal_sha256.h"
41 #include "dump.h"
42
43 char* algo_name = "SHA-256";
44
45 const hfdesc_t* algolist[] PROGMEM = {
46         (hfdesc_t*)&sha256_desc,
47         NULL
48 };
49
50 /*****************************************************************************
51  *  additional validation-functions                                                                                      *
52  *****************************************************************************/
53
54 void testrun_nessie_sha256(void){
55         hfal_nessie_multiple(algolist);
56 }
57
58 void testrun_performance_sha256(void){
59         hfal_performance_multiple(algolist);
60 }
61
62 /*****************************************************************************
63  *  main                                                                                                                                         *
64  *****************************************************************************/
65
66 const char nessie_str[]      PROGMEM = "nessie";
67 const char test_str[]        PROGMEM = "test";
68 const char performance_str[] PROGMEM = "performance";
69 const char echo_str[]        PROGMEM = "echo";
70 const char shavs_list_str[]  PROGMEM = "shavs_list";
71 const char shavs_set_str[]   PROGMEM = "shavs_set";
72 const char shavs_test1_str[] PROGMEM = "shavs_test1";
73 const char dump_str[]        PROGMEM = "dump";
74
75 cmdlist_entry_t cmdlist[] PROGMEM = {
76         { nessie_str,          NULL, testrun_nessie_sha256},
77         { test_str,            NULL, testrun_nessie_sha256},
78         { performance_str,     NULL, testrun_performance_sha256},
79         { echo_str,        (void*)1, (void_fpt)echo_ctrl},
80         { shavs_list_str,      NULL, shavs_listalgos},
81         { shavs_set_str,   (void*)1, (void_fpt)shavs_setalgo},
82         { shavs_test1_str,     NULL, shavs_test1},
83         { dump_str,        (void*)1, (void_fpt)dump},
84         { NULL,                NULL, NULL}
85 };
86
87 int main (void){
88         DEBUG_INIT();
89         
90         cli_rx = (cli_rx_fpt)uart0_getc;
91         cli_tx = (cli_tx_fpt)uart0_putc;                
92         shavs_algolist=(hfdesc_t**)algolist;
93         shavs_algo=(hfdesc_t*)&sha256_desc;
94         for(;;){
95                 cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
96                 cli_putstr(algo_name);
97                 cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
98                 cmd_interface(cmdlist);
99         }
100 }