1 /* main-whirlpool-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/>.
24 #include "main-test-common.h"
26 #include "whirlpool.h"
27 #include "nessie_hash_test.h"
28 #include "performance_test.h"
29 #include "hfal-performance.h"
30 #include "hfal-nessie.h"
33 #include "hfal_whirlpool.h"
36 char *algo_name = "Whirlpool";
38 const hfdesc_t *const algolist[] PROGMEM = {
39 (hfdesc_t*)&whirlpool_desc,
43 /*****************************************************************************
44 * additional validation-functions *
45 *****************************************************************************/
47 void testrun_nessie_whirlpool(void){
48 hfal_nessie_multiple(algolist);
51 void testrun_whirlpool(void){
60 whirlpool_lastBlock(&ctx, data, 3*8);
61 whirlpool_ctx2hash(hash, &ctx);
62 cli_putstr_P(PSTR("\r\nEmpty message hash:"));
63 cli_hexdump_block(hash, 64, 4, 16);
66 void testrun_performance_whirlpool(void){
67 hfal_performance_multiple(algolist);
70 void testrun_nessie2(void){
73 uint8_t data[128], hash[64];
77 cli_putstr_P(PSTR("\r\nMessage digests of strings of 0-bits and length L:"));
78 for(i=0; i<1024; ++i){
79 cli_putstr_P(PSTR("\r\n L = "));
90 cli_putstr_P(PSTR(": "));
92 whirlpool_lastBlock(&ctx, data, i);
93 whirlpool_ctx2hash(hash, &ctx);
94 cli_hexdump(hash, 64);
96 cli_putstr_P(PSTR("\r\nMessage digests of all 512-bit strings S containing a single 1-bit:"));
98 cli_putstr_P(PSTR("\r\n S = "));
99 data[i/8] = 0x80>>(i&7);
100 cli_hexdump(data, 64);
101 cli_putstr_P(PSTR(": "));
102 whirlpool_init(&ctx);
103 whirlpool_lastBlock(&ctx, data, 512);
104 whirlpool_ctx2hash(hash, &ctx);
106 cli_hexdump(hash, 64);
108 cli_putstr_P(PSTR("\r\nIterated message digest computation (100000000 times): "));
111 for(c=0; c<1000000; ++c){
112 whirlpool_init(&ctx);
113 whirlpool_lastBlock(&ctx, hash, 512);
114 whirlpool_ctx2hash(hash, &ctx);
116 cli_hexdump(hash, 64);
117 cli_putstr_P(PSTR("\r\n/* finish generating testvectors */\r\n"));
120 /*****************************************************************************
122 *****************************************************************************/
124 const char nessie_str[] PROGMEM = "nessie";
125 const char nessie2_str[] PROGMEM = "nessie2";
126 const char test_str[] PROGMEM = "test";
127 const char performance_str[] PROGMEM = "performance";
128 const char echo_str[] PROGMEM = "echo";
129 const char shavs_list_str[] PROGMEM = "shavs_list";
130 const char shavs_set_str[] PROGMEM = "shavs_set";
131 const char shavs_test1_str[] PROGMEM = "shavs_test1";
132 const char shavs_test2_str[] PROGMEM = "shavs_test2";
133 const char shavs_test3_str[] PROGMEM = "shavs_test3";
134 const char dump_str[] PROGMEM = "dump";
136 const cmdlist_entry_t cmdlist[] PROGMEM = {
137 { nessie_str, NULL, testrun_nessie_whirlpool },
138 { nessie2_str, NULL, testrun_nessie2 },
139 { test_str, NULL, testrun_whirlpool },
140 { performance_str, NULL, testrun_performance_whirlpool },
141 { echo_str, (void*)1, (void_fpt)echo_ctrl },
142 { shavs_list_str, NULL, shavs_listalgos },
143 { shavs_set_str, (void*)1, (void_fpt)shavs_setalgo },
144 { shavs_test1_str, NULL, shavs_test1 },
145 { shavs_test2_str, NULL, shavs_test2 },
146 { shavs_test3_str, NULL, shavs_test3 },
147 { dump_str, (void*)1, (void_fpt)dump },
154 shavs_algolist=(hfdesc_t**)algolist;
155 shavs_algo=(hfdesc_t*)&whirlpool_desc;
157 welcome_msg(algo_name);
158 cmd_interface(cmdlist);