1 /* main-whirlpool-0-test.c */
3 This file is part of the AVR-Crypto-Lib.
4 Copyright (C) 2011 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/>.
20 * Whirlpool-0 test-suit
29 #include "whirlpool.h"
30 #include "nessie_hash_test.h"
31 #include "performance_test.h"
32 #include "hfal-performance.h"
33 #include "hfal-nessie.h"
40 #include "hfal_whirlpool_0.h"
43 char* algo_name = "Whirlpool-0";
45 const hfdesc_t* const algolist[] PROGMEM = {
46 (hfdesc_t*)&whirlpool_0_desc,
50 /*****************************************************************************
51 * additional validation-functions *
52 *****************************************************************************/
54 void testrun_nessie_whirlpool(void){
55 hfal_nessie_multiple(algolist);
58 void testrun_whirlpool(void){
67 whirlpool_lastBlock(&ctx, data, 3*8);
68 whirlpool_ctx2hash(hash, &ctx);
69 cli_putstr_P(PSTR("\r\nEmpty message hash:"));
70 cli_hexdump_block(hash, 64, 4, 16);
73 void testrun_performance_whirlpool(void){
74 hfal_performance_multiple(algolist);
77 void testrun_nessie2(void){
80 uint8_t data[128], hash[64];
84 cli_putstr_P(PSTR("\r\nMessage digests of strings of 0-bits and length L:"));
85 for(i=0; i<1024; ++i){
86 cli_putstr_P(PSTR("\r\n L = "));
97 cli_putstr_P(PSTR(": "));
99 whirlpool_lastBlock(&ctx, data, i);
100 whirlpool_ctx2hash(hash, &ctx);
101 cli_hexdump(hash, 64);
103 cli_putstr_P(PSTR("\r\nMessage digests of all 512-bit strings S containing a single 1-bit:"));
104 for(i=0; i<512; ++i){
105 cli_putstr_P(PSTR("\r\n S = "));
106 data[i/8] = 0x80>>(i&7);
107 cli_hexdump(data, 64);
108 cli_putstr_P(PSTR(": "));
109 whirlpool_init(&ctx);
110 whirlpool_lastBlock(&ctx, data, 512);
111 whirlpool_ctx2hash(hash, &ctx);
113 cli_hexdump(hash, 64);
115 cli_putstr_P(PSTR("\r\nIterated message digest computation (100000000 times): "));
118 for(c=0; c<1000000; ++c){
119 whirlpool_init(&ctx);
120 whirlpool_lastBlock(&ctx, hash, 512);
121 whirlpool_ctx2hash(hash, &ctx);
123 cli_hexdump(hash, 64);
124 cli_putstr_P(PSTR("\r\n/* finish generating testvectors */\r\n"));
127 /*****************************************************************************
129 *****************************************************************************/
131 const char nessie_str[] PROGMEM = "nessie";
132 const char nessie2_str[] PROGMEM = "nessie2";
133 const char test_str[] PROGMEM = "test";
134 const char performance_str[] PROGMEM = "performance";
135 const char echo_str[] PROGMEM = "echo";
136 const char shavs_list_str[] PROGMEM = "shavs_list";
137 const char shavs_set_str[] PROGMEM = "shavs_set";
138 const char shavs_test1_str[] PROGMEM = "shavs_test1";
139 const char shavs_test2_str[] PROGMEM = "shavs_test2";
140 const char shavs_test3_str[] PROGMEM = "shavs_test3";
141 const char dump_str[] PROGMEM = "dump";
143 const cmdlist_entry_t cmdlist[] PROGMEM = {
144 { nessie_str, NULL, testrun_nessie_whirlpool },
145 { nessie2_str, NULL, testrun_nessie2 },
146 { test_str, NULL, testrun_whirlpool },
147 { performance_str, NULL, testrun_performance_whirlpool },
148 { echo_str, (void*)1, (void_fpt)echo_ctrl },
149 { shavs_list_str, NULL, shavs_listalgos },
150 { shavs_set_str, (void*)1, (void_fpt)shavs_setalgo },
151 { shavs_test1_str, NULL, shavs_test1 },
152 { shavs_test2_str, NULL, shavs_test2 },
153 { shavs_test3_str, NULL, shavs_test3 },
154 { dump_str, (void*)1, (void_fpt)dump },
161 cli_rx = (cli_rx_fpt)uart0_getc;
162 cli_tx = (cli_tx_fpt)uart0_putc;
163 shavs_algolist=(hfdesc_t**)algolist;
164 shavs_algo=(hfdesc_t*)&whirlpool_0_desc;
166 cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
167 cli_putstr(algo_name);
168 cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
169 cmd_interface(cmdlist);