1 /* main-keccak-test.c */
3 This file is part of the AVR-Crypto-Lib.
4 Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org)
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"
27 #include "hfal_keccak.h"
29 #include "nessie_hash_test.h"
30 #include "performance_test.h"
31 #include "hfal-nessie.h"
32 #include "hfal-performance.h"
33 #include "hfal-test.h"
35 char *algo_name = "Keccak";
38 const hfdesc_t *const algolist[] PROGMEM = {
39 (hfdesc_t*)&keccak224_desc,
40 (hfdesc_t*)&keccak256_desc,
41 (hfdesc_t*)&keccak384_desc,
42 (hfdesc_t*)&keccak512_desc,
46 /*****************************************************************************
47 * additional validation-functions *
48 *****************************************************************************/
51 uint8_t null[KECCAK256_BLOCKSIZE_B];
52 memset(null, 0, KECCAK256_BLOCKSIZE_B);
55 keccak_nextBlock(&ctx, null);
56 keccak_lastBlock(&ctx, null, 29);
57 keccak256_ctx2hash(hash, &ctx);
58 cli_putstr_P(PSTR("\r\n testhash: "));
59 cli_hexdump(hash, 32);
63 void performance_keccak(void){
64 hfal_performance_multiple(algolist);
67 void testrun_nessie_keccak(void){
68 hfal_nessie_multiple(algolist);
70 /*****************************************************************************
72 *****************************************************************************/
74 const char nessie_str[] PROGMEM = "nessie";
75 const char test256_str[] PROGMEM = "test256";
76 const char performance_str[] PROGMEM = "performance";
77 const char echo_str[] PROGMEM = "echo";
78 const char shavs_list_str[] PROGMEM = "shavs_list";
79 const char shavs_set_str[] PROGMEM = "shavs_set";
80 const char shavs_test1_str[] PROGMEM = "shavs_test1";
81 const char shavs_test3_str[] PROGMEM = "shavs_test3";
83 const cmdlist_entry_t cmdlist[] PROGMEM = {
84 { nessie_str, NULL, testrun_nessie_keccak },
85 { performance_str, NULL, performance_keccak },
86 { test256_str, NULL, test_256 },
87 { shavs_list_str, NULL, shavs_listalgos },
88 { shavs_set_str, (void*)1, (void_fpt)shavs_setalgo },
89 { shavs_test1_str, NULL, shavs_test1 },
90 { shavs_test3_str, NULL, shavs_test3 },
91 { echo_str, (void*)1, (void_fpt)echo_ctrl },
98 shavs_algolist=(hfdesc_t**)algolist;
99 shavs_algo=(hfdesc_t*)&keccak256_desc;
101 welcome_msg(algo_name);
102 cmd_interface(cmdlist);