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 *****************************************************************************/
46 void sha256_next_dummy(void* buffer, void* ctx){
47 sha256_nextBlock(ctx, buffer);
50 void sha256_last_dummy(void* buffer, uint16_t size_b, void* ctx){
51 sha256_lastBlock(ctx, buffer, size_b);
54 void testrun_nessie_sha256(void){
55 nessie_hash_ctx.hashsize_b = 256;
56 nessie_hash_ctx.blocksize_B = 512/8;
57 nessie_hash_ctx.ctx_size_B = sizeof(sha256_ctx_t);
58 nessie_hash_ctx.name = algo_name;
59 nessie_hash_ctx.hash_init = (nessie_hash_init_fpt)sha256_init;
60 nessie_hash_ctx.hash_next = (nessie_hash_next_fpt)sha256_next_dummy;
61 nessie_hash_ctx.hash_last = (nessie_hash_last_fpt)sha256_last_dummy;
62 nessie_hash_ctx.hash_conv = (nessie_hash_conv_fpt)sha256_ctx2hash;
67 void testrun_performance_sha256(void){
81 uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
82 ultoa((unsigned long)t, str, 10);
87 sha256_nextBlock(&ctx, data);
89 uart_putstr_P(PSTR("\r\n\tone-block time: "));
90 ultoa((unsigned long)t, str, 10);
95 sha256_lastBlock(&ctx, data, 0);
97 uart_putstr_P(PSTR("\r\n\tlast block time: "));
98 ultoa((unsigned long)t, str, 10);
101 uart_putstr_P(PSTR("\r\n"));
104 /*****************************************************************************
106 *****************************************************************************/
108 const char nessie_str[] PROGMEM = "nessie";
109 const char test_str[] PROGMEM = "test";
110 const char performance_str[] PROGMEM = "performance";
111 const char echo_str[] PROGMEM = "echo";
112 const char shavs_list_str[] PROGMEM = "shavs_list";
113 const char shavs_set_str[] PROGMEM = "shavs_set";
114 const char dump_str[] PROGMEM = "dump";
116 const hfdesc_t* algo_list[] PROGMEM = {
117 (hfdesc_t*)&sha256_desc,
121 cmdlist_entry_t cmdlist[] PROGMEM = {
122 { nessie_str, NULL, testrun_nessie_sha256},
123 { test_str, NULL, testrun_nessie_sha256},
124 { performance_str, NULL, testrun_performance_sha256},
125 { echo_str, (void*)1, (void_fpt)echo_ctrl},
126 { shavs_list_str, NULL, shavs_listalgos},
127 { shavs_set_str, (void*)1, (void_fpt)shavs_setalgo},
128 { dump_str, (void*)1, (void_fpt)dump},
139 uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
140 uart_putstr(algo_name);
141 uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
142 cmd_interface(cmdlist);