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/>.
25 #include "serial-tools.h"
31 #include "performance_test.h"
37 char* algo_name = "UBI-Threefish";
39 /*****************************************************************************
40 * additional validation-functions *
41 *****************************************************************************/
42 void testrun_stdtest_ubi256(uint16_t outsize){
47 cli_putstr_P(PSTR("\r\n\r\nTest vectors for UBI (256 bits):"));
48 memset(&conf, 0, sizeof(skein_config_t));
50 ubi256_init(&ctx, &conf, UBI_TYPE_CFG);
56 conf.out_length = outsize;
57 ubi256_lastBlock(&ctx, &conf, 256);
58 ubi256_ctx2hash(iv, &ctx);
60 cli_putstr_P(PSTR("\r\nIV: "));
61 cli_hexdump_rev(&(iv[0]), 8);
62 cli_putstr_P(PSTR(" "));
63 cli_hexdump_rev(&(iv[1]), 8);
64 cli_putstr_P(PSTR(" "));
65 cli_hexdump_rev(&(iv[2]), 8);
66 cli_putstr_P(PSTR(" "));
67 cli_hexdump_rev(&(iv[3]), 8);
70 void testrun_stdtest_ubi512(uint16_t outsize){
74 uint8_t null[UBI512_BLOCKSIZE_B];
76 cli_putstr_P(PSTR("\r\n\r\nTest vectors for UBI (512 bits):"));
77 memset(&conf, 0, sizeof(skein_config_t));
78 memset(null, 0, UBI512_BLOCKSIZE_B);
79 ubi512_init(&ctx, null, UBI_TYPE_CFG);
85 conf.out_length = outsize;
86 ubi512_lastBlock(&ctx, &conf, 256);
87 ubi512_ctx2hash(iv, &ctx);
89 cli_putstr_P(PSTR("\r\nIV: "));
90 cli_hexdump_rev(&(iv[0]), 8);
91 cli_putstr_P(PSTR(" "));
92 cli_hexdump_rev(&(iv[1]), 8);
93 cli_putstr_P(PSTR(" "));
94 cli_hexdump_rev(&(iv[2]), 8);
95 cli_putstr_P(PSTR(" "));
96 cli_hexdump_rev(&(iv[3]), 8);
97 cli_putstr_P(PSTR("\r\n "));
98 cli_hexdump_rev(&(iv[4]), 8);
99 cli_putstr_P(PSTR(" "));
100 cli_hexdump_rev(&(iv[5]), 8);
101 cli_putstr_P(PSTR(" "));
102 cli_hexdump_rev(&(iv[6]), 8);
103 cli_putstr_P(PSTR(" "));
104 cli_hexdump_rev(&(iv[7]), 8);
107 void testrun_stdtest_ubi1024(uint16_t outsize){
111 uint8_t null[UBI1024_BLOCKSIZE_B];
113 cli_putstr_P(PSTR("\r\n\r\nTest vectors for UBI (1024 bits):"));
114 memset(&conf, 0, sizeof(skein_config_t));
116 memset(null, 0, UBI1024_BLOCKSIZE_B);
117 ubi1024_init(&ctx, null, UBI_TYPE_CFG);
118 conf.schema[0] = 'S';
119 conf.schema[1] = 'H';
120 conf.schema[2] = 'A';
121 conf.schema[3] = '3';
123 conf.out_length = outsize;
124 ubi1024_lastBlock(&ctx, &conf, 256);
125 ubi1024_ctx2hash(iv, &ctx);
127 cli_putstr_P(PSTR("\r\nIV: "));
128 cli_hexdump_rev(&(iv[0]), 8);
129 cli_putstr_P(PSTR(" "));
130 cli_hexdump_rev(&(iv[1]), 8);
131 cli_putstr_P(PSTR(" "));
132 cli_hexdump_rev(&(iv[2]), 8);
133 cli_putstr_P(PSTR(" "));
134 cli_hexdump_rev(&(iv[3]), 8);
135 cli_putstr_P(PSTR("\r\n "));
136 cli_hexdump_rev(&(iv[4]), 8);
137 cli_putstr_P(PSTR(" "));
138 cli_hexdump_rev(&(iv[5]), 8);
139 cli_putstr_P(PSTR(" "));
140 cli_hexdump_rev(&(iv[6]), 8);
141 cli_putstr_P(PSTR(" "));
142 cli_hexdump_rev(&(iv[7]), 8);
143 cli_putstr_P(PSTR("\r\n "));
144 cli_hexdump_rev(&(iv[8]), 8);
145 cli_putstr_P(PSTR(" "));
146 cli_hexdump_rev(&(iv[9]), 8);
147 cli_putstr_P(PSTR(" "));
148 cli_hexdump_rev(&(iv[10]), 8);
149 cli_putstr_P(PSTR(" "));
150 cli_hexdump_rev(&(iv[11]), 8);
151 cli_putstr_P(PSTR("\r\n "));
152 cli_hexdump_rev(&(iv[12]), 8);
153 cli_putstr_P(PSTR(" "));
154 cli_hexdump_rev(&(iv[13]), 8);
155 cli_putstr_P(PSTR(" "));
156 cli_hexdump_rev(&(iv[14]), 8);
157 cli_putstr_P(PSTR(" "));
158 cli_hexdump_rev(&(iv[15]), 8);
161 void testrun_stdtest_ubi(void){
162 testrun_stdtest_ubi256(128);
163 testrun_stdtest_ubi256(160);
164 testrun_stdtest_ubi256(224);
165 testrun_stdtest_ubi256(256);
167 testrun_stdtest_ubi512(128);
168 testrun_stdtest_ubi512(160);
169 testrun_stdtest_ubi512(224);
170 testrun_stdtest_ubi512(256);
171 testrun_stdtest_ubi512(384);
172 testrun_stdtest_ubi512(512);
174 testrun_stdtest_ubi1024(384);
175 testrun_stdtest_ubi1024(512);
176 testrun_stdtest_ubi1024(1024);
179 /*****************************************************************************
181 *****************************************************************************/
183 const char nessie_str[] PROGMEM = "nessie";
184 const char test_str[] PROGMEM = "test";
185 const char performance_str[] PROGMEM = "performance";
186 const char echo_str[] PROGMEM = "echo";
188 cmdlist_entry_t cmdlist[] PROGMEM = {
189 // { nessie_str, NULL, testrun_nessie_noekeon},
190 { test_str, NULL, testrun_stdtest_ubi},
191 // { performance_str, NULL, testrun_performance_noekeon},
192 { echo_str, (void*)1, (void_fpt)echo_ctrl},
202 cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
203 cli_putstr(algo_name);
204 cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
205 cmd_interface(cmdlist);