1 /* main-threefish-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/>.
24 #include "main-test-common.h"
27 #include "performance_test.h"
29 char *algo_name = "UBI-Threefish";
31 /*****************************************************************************
32 * additional validation-functions *
33 *****************************************************************************/
34 void testrun_stdtest_ubi256(uint16_t outsize){
39 cli_putstr_P(PSTR("\r\n\r\nTest vectors for UBI (256 bits):"));
40 memset(&conf, 0, sizeof(skein_config_t));
42 ubi256_init(&ctx, &conf, UBI_TYPE_CFG);
48 conf.out_length = outsize;
49 ubi256_lastBlock(&ctx, &conf, 256);
50 ubi256_ctx2hash(iv, &ctx);
52 cli_putstr_P(PSTR("\r\nIV: "));
53 cli_hexdump_rev(&(iv[0]), 8);
54 cli_putstr_P(PSTR(" "));
55 cli_hexdump_rev(&(iv[1]), 8);
56 cli_putstr_P(PSTR(" "));
57 cli_hexdump_rev(&(iv[2]), 8);
58 cli_putstr_P(PSTR(" "));
59 cli_hexdump_rev(&(iv[3]), 8);
62 void testrun_stdtest_ubi512(uint16_t outsize){
66 uint8_t null[UBI512_BLOCKSIZE_B];
68 cli_putstr_P(PSTR("\r\n\r\nTest vectors for UBI (512 bits):"));
69 memset(&conf, 0, sizeof(skein_config_t));
70 memset(null, 0, UBI512_BLOCKSIZE_B);
71 ubi512_init(&ctx, null, UBI_TYPE_CFG);
77 conf.out_length = outsize;
78 ubi512_lastBlock(&ctx, &conf, 256);
79 ubi512_ctx2hash(iv, &ctx);
81 cli_putstr_P(PSTR("\r\nIV: "));
82 cli_hexdump_rev(&(iv[0]), 8);
83 cli_putstr_P(PSTR(" "));
84 cli_hexdump_rev(&(iv[1]), 8);
85 cli_putstr_P(PSTR(" "));
86 cli_hexdump_rev(&(iv[2]), 8);
87 cli_putstr_P(PSTR(" "));
88 cli_hexdump_rev(&(iv[3]), 8);
89 cli_putstr_P(PSTR("\r\n "));
90 cli_hexdump_rev(&(iv[4]), 8);
91 cli_putstr_P(PSTR(" "));
92 cli_hexdump_rev(&(iv[5]), 8);
93 cli_putstr_P(PSTR(" "));
94 cli_hexdump_rev(&(iv[6]), 8);
95 cli_putstr_P(PSTR(" "));
96 cli_hexdump_rev(&(iv[7]), 8);
99 void testrun_stdtest_ubi1024(uint16_t outsize){
103 uint8_t null[UBI1024_BLOCKSIZE_B];
105 cli_putstr_P(PSTR("\r\n\r\nTest vectors for UBI (1024 bits):"));
106 memset(&conf, 0, sizeof(skein_config_t));
108 memset(null, 0, UBI1024_BLOCKSIZE_B);
109 ubi1024_init(&ctx, null, UBI_TYPE_CFG);
110 conf.schema[0] = 'S';
111 conf.schema[1] = 'H';
112 conf.schema[2] = 'A';
113 conf.schema[3] = '3';
115 conf.out_length = outsize;
116 ubi1024_lastBlock(&ctx, &conf, 256);
117 ubi1024_ctx2hash(iv, &ctx);
119 cli_putstr_P(PSTR("\r\nIV: "));
120 cli_hexdump_rev(&(iv[0]), 8);
121 cli_putstr_P(PSTR(" "));
122 cli_hexdump_rev(&(iv[1]), 8);
123 cli_putstr_P(PSTR(" "));
124 cli_hexdump_rev(&(iv[2]), 8);
125 cli_putstr_P(PSTR(" "));
126 cli_hexdump_rev(&(iv[3]), 8);
127 cli_putstr_P(PSTR("\r\n "));
128 cli_hexdump_rev(&(iv[4]), 8);
129 cli_putstr_P(PSTR(" "));
130 cli_hexdump_rev(&(iv[5]), 8);
131 cli_putstr_P(PSTR(" "));
132 cli_hexdump_rev(&(iv[6]), 8);
133 cli_putstr_P(PSTR(" "));
134 cli_hexdump_rev(&(iv[7]), 8);
135 cli_putstr_P(PSTR("\r\n "));
136 cli_hexdump_rev(&(iv[8]), 8);
137 cli_putstr_P(PSTR(" "));
138 cli_hexdump_rev(&(iv[9]), 8);
139 cli_putstr_P(PSTR(" "));
140 cli_hexdump_rev(&(iv[10]), 8);
141 cli_putstr_P(PSTR(" "));
142 cli_hexdump_rev(&(iv[11]), 8);
143 cli_putstr_P(PSTR("\r\n "));
144 cli_hexdump_rev(&(iv[12]), 8);
145 cli_putstr_P(PSTR(" "));
146 cli_hexdump_rev(&(iv[13]), 8);
147 cli_putstr_P(PSTR(" "));
148 cli_hexdump_rev(&(iv[14]), 8);
149 cli_putstr_P(PSTR(" "));
150 cli_hexdump_rev(&(iv[15]), 8);
153 void testrun_stdtest_ubi(void){
154 testrun_stdtest_ubi256(128);
155 testrun_stdtest_ubi256(160);
156 testrun_stdtest_ubi256(224);
157 testrun_stdtest_ubi256(256);
159 testrun_stdtest_ubi512(128);
160 testrun_stdtest_ubi512(160);
161 testrun_stdtest_ubi512(224);
162 testrun_stdtest_ubi512(256);
163 testrun_stdtest_ubi512(384);
164 testrun_stdtest_ubi512(512);
166 testrun_stdtest_ubi1024(384);
167 testrun_stdtest_ubi1024(512);
168 testrun_stdtest_ubi1024(1024);
171 /*****************************************************************************
173 *****************************************************************************/
175 const char nessie_str[] PROGMEM = "nessie";
176 const char test_str[] PROGMEM = "test";
177 const char performance_str[] PROGMEM = "performance";
178 const char echo_str[] PROGMEM = "echo";
180 const cmdlist_entry_t cmdlist[] PROGMEM = {
181 // { nessie_str, NULL, testrun_nessie_noekeon},
182 { test_str, NULL, testrun_stdtest_ubi},
183 // { performance_str, NULL, testrun_performance_noekeon},
184 { echo_str, (void*)1, (void_fpt)echo_ctrl},
192 welcome_msg(algo_name);
193 cmd_interface(cmdlist);