1 /* main-whirlpool-t-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/>.
25 #include "main-test-common.h"
27 #include "whirlpool.h"
28 #include "nessie_hash_test.h"
29 #include "performance_test.h"
30 #include "hfal-performance.h"
31 #include "hfal-nessie.h"
34 #include "hfal_whirlpool_t.h"
37 char* algo_name = "Whirlpool-T";
39 const hfdesc_t* const algolist[] PROGMEM = {
40 (hfdesc_t*)&whirlpool_t_desc,
44 /*****************************************************************************
45 * additional validation-functions *
46 *****************************************************************************/
48 void testrun_nessie_whirlpool(void){
49 hfal_nessie_multiple(algolist);
52 void testrun_whirlpool(void){
61 whirlpool_lastBlock(&ctx, data, 3*8);
62 whirlpool_ctx2hash(hash, &ctx);
63 cli_putstr_P(PSTR("\r\nEmpty message hash:"));
64 cli_hexdump_block(hash, 64, 4, 16);
67 void testrun_performance_whirlpool(void){
68 hfal_performance_multiple(algolist);
71 void testrun_nessie2(void){
74 uint8_t data[128], hash[64];
78 cli_putstr_P(PSTR("\r\nMessage digests of strings of 0-bits and length L:"));
79 for(i=0; i<1024; ++i){
80 cli_putstr_P(PSTR("\r\n L = "));
91 cli_putstr_P(PSTR(": "));
93 whirlpool_lastBlock(&ctx, data, i);
94 whirlpool_ctx2hash(hash, &ctx);
95 cli_hexdump(hash, 64);
97 cli_putstr_P(PSTR("\r\nMessage digests of all 512-bit strings S containing a single 1-bit:"));
99 cli_putstr_P(PSTR("\r\n S = "));
100 data[i/8] = 0x80>>(i&7);
101 cli_hexdump(data, 64);
102 cli_putstr_P(PSTR(": "));
103 whirlpool_init(&ctx);
104 whirlpool_lastBlock(&ctx, data, 512);
105 whirlpool_ctx2hash(hash, &ctx);
107 cli_hexdump(hash, 64);
109 cli_putstr_P(PSTR("\r\nIterated message digest computation (100000000 times): "));
112 for(c=0; c<1000000; ++c){
113 whirlpool_init(&ctx);
114 whirlpool_lastBlock(&ctx, hash, 512);
115 whirlpool_ctx2hash(hash, &ctx);
117 cli_hexdump(hash, 64);
118 cli_putstr_P(PSTR("\r\n/* finish generating testvectors */\r\n"));
121 /*****************************************************************************
123 *****************************************************************************/
125 const char nessie_str[] PROGMEM = "nessie";
126 const char nessie2_str[] PROGMEM = "nessie2";
127 const char test_str[] PROGMEM = "test";
128 const char performance_str[] PROGMEM = "performance";
129 const char echo_str[] PROGMEM = "echo";
130 const char shavs_list_str[] PROGMEM = "shavs_list";
131 const char shavs_set_str[] PROGMEM = "shavs_set";
132 const char shavs_test1_str[] PROGMEM = "shavs_test1";
133 const char shavs_test2_str[] PROGMEM = "shavs_test2";
134 const char shavs_test3_str[] PROGMEM = "shavs_test3";
135 const char dump_str[] PROGMEM = "dump";
137 const cmdlist_entry_t cmdlist[] PROGMEM = {
138 { nessie_str, NULL, testrun_nessie_whirlpool },
139 { nessie2_str, NULL, testrun_nessie2 },
140 { test_str, NULL, testrun_whirlpool },
141 { performance_str, NULL, testrun_performance_whirlpool },
142 { echo_str, (void*)1, (void_fpt)echo_ctrl },
143 { shavs_list_str, NULL, shavs_listalgos },
144 { shavs_set_str, (void*)1, (void_fpt)shavs_setalgo },
145 { shavs_test1_str, NULL, shavs_test1 },
146 { shavs_test2_str, NULL, shavs_test2 },
147 { shavs_test3_str, NULL, shavs_test3 },
148 { dump_str, (void*)1, (void_fpt)dump },
155 shavs_algolist=(hfdesc_t**)algolist;
156 shavs_algo=(hfdesc_t*)&whirlpool_t_desc;
159 welcome_msg(algo_name);
160 cmd_interface(cmdlist);