1 /* main-sha256-test.c */
3 This file is part of the AVR-Crypto-Lib.
4 Copyright (C) 2008 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/>.
25 #include "serial-tools.h"
30 #include "nessie_hash_test.h"
31 #include "performance_test.h"
38 #include "hfal_sha256.h"
41 char* algo_name = "SHA-256";
43 /*****************************************************************************
44 * additional validation-functions *
45 *****************************************************************************/
47 void testrun_nessie_sha256(void){
48 nessie_hash_ctx.hashsize_b = 256;
49 nessie_hash_ctx.blocksize_B = 512/8;
50 nessie_hash_ctx.ctx_size_B = sizeof(sha256_ctx_t);
51 nessie_hash_ctx.name = algo_name;
52 nessie_hash_ctx.hash_init = (nessie_hash_init_fpt)sha256_init;
53 nessie_hash_ctx.hash_next = (nessie_hash_next_fpt)sha256_nextBlock;
54 nessie_hash_ctx.hash_last = (nessie_hash_last_fpt)sha256_lastBlock;
55 nessie_hash_ctx.hash_conv = (nessie_hash_conv_fpt)sha256_ctx2hash;
60 void testrun_performance_sha256(void){
74 cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
75 ultoa((unsigned long)t, str, 10);
80 sha256_nextBlock(&ctx, data);
82 cli_putstr_P(PSTR("\r\n\tone-block time: "));
83 ultoa((unsigned long)t, str, 10);
88 sha256_lastBlock(&ctx, data, 0);
90 cli_putstr_P(PSTR("\r\n\tlast block time: "));
91 ultoa((unsigned long)t, str, 10);
94 cli_putstr_P(PSTR("\r\n"));
97 /*****************************************************************************
99 *****************************************************************************/
101 const char nessie_str[] PROGMEM = "nessie";
102 const char test_str[] PROGMEM = "test";
103 const char performance_str[] PROGMEM = "performance";
104 const char echo_str[] PROGMEM = "echo";
105 const char shavs_list_str[] PROGMEM = "shavs_list";
106 const char shavs_set_str[] PROGMEM = "shavs_set";
107 const char shavs_test1_str[] PROGMEM = "shavs_test1";
108 const char dump_str[] PROGMEM = "dump";
110 const hfdesc_t* algolist[] PROGMEM = {
111 (hfdesc_t*)&sha256_desc,
115 cmdlist_entry_t cmdlist[] PROGMEM = {
116 { nessie_str, NULL, testrun_nessie_sha256},
117 { test_str, NULL, testrun_nessie_sha256},
118 { performance_str, NULL, testrun_performance_sha256},
119 { echo_str, (void*)1, (void_fpt)echo_ctrl},
120 { shavs_list_str, NULL, shavs_listalgos},
121 { shavs_set_str, (void*)1, (void_fpt)shavs_setalgo},
122 { shavs_test1_str, NULL, shavs_test1},
123 { dump_str, (void*)1, (void_fpt)dump},
132 shavs_algolist=(hfdesc_t**)algolist;
133 shavs_algo=(hfdesc_t*)&sha256_desc;
135 cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
136 cli_putstr(algo_name);
137 cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
138 cmd_interface(cmdlist);