12 #include "nessie_bc_test.h"
14 #include "performance_test.h"
19 #include <avr/pgmspace.h>
21 char* algo_name = "CAST-256";
23 /*****************************************************************************
24 * additional validation-functions *
25 *****************************************************************************/
28 void testrun_nessie_cast6(void){
30 nessie_bc_ctx.blocksize_B = 16;
31 nessie_bc_ctx.keysize_b = 128;
32 nessie_bc_ctx.name = algo_name;
33 nessie_bc_ctx.ctx_size_B = sizeof(cast6_ctx_t);
34 nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)cast6_enc;
35 nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)cast6_dec;
36 nessie_bc_ctx.cipher_genctx = (nessie_bc_gen_fpt)cast6_init;
40 nessie_bc_ctx.keysize_b = 192;
43 nessie_bc_ctx.keysize_b = 256;
47 void testrun_rfc_cast6(void){
48 cli_putstr_P(PSTR("\r\n testvalues from rfc-2612\r\n"));
49 uint8_t key[32], data[16];
51 memcpy_P(key, PSTR("\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
52 "\x0a\xf7\x56\x47\xf2\x9f\x61\x5d"), 16);
55 cli_putstr_P(PSTR("\r\n key: "));
57 cli_putstr_P(PSTR("\r\n PT: "));
58 cli_hexdump(data, 16);
59 cast6_init(key, 128, &ctx);
60 cast6_enc(data, &ctx);
61 cli_putstr_P(PSTR("\r\n CT: "));
62 cli_hexdump(data, 16);
63 cast6_dec(data, &ctx);
64 cli_putstr_P(PSTR("\r\n PT: "));
65 cli_hexdump(data, 16);
67 cli_putstr_P(PSTR("\r\n\r\n"));
69 memcpy_P(key, PSTR("\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
70 "\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
71 "\xba\xc7\x7a\x77\x17\x94\x28\x63"), 24);
73 cli_putstr_P(PSTR("\r\n key: "));
75 cli_putstr_P(PSTR("\r\n PT: "));
76 cli_hexdump(data, 16);
77 cast6_init(key, 192, &ctx);
78 cast6_enc(data, &ctx);
79 cli_putstr_P(PSTR("\r\n CT: "));
80 cli_hexdump(data, 16);
81 cast6_dec(data, &ctx);
82 cli_putstr_P(PSTR("\r\n PT: "));
83 cli_hexdump(data, 16);
85 cli_putstr_P(PSTR("\r\n\r\n"));
87 memcpy_P(key, PSTR("\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
88 "\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
89 "\x8d\x7c\x47\xce\x26\x49\x08\x46"
90 "\x1c\xc1\xb5\x13\x7a\xe6\xb6\x04"), 32);
91 cli_putstr_P(PSTR("\r\n key: "));
93 cli_putstr_P(PSTR("\r\n PT: "));
94 cli_hexdump(data, 16);
95 cast6_init(key, 256, &ctx);
96 cast6_enc(data, &ctx);
97 cli_putstr_P(PSTR("\r\n CT: "));
98 cli_hexdump(data, 16);
99 cast6_dec(data, &ctx);
100 cli_putstr_P(PSTR("\r\n PT: "));
101 cli_hexdump(data, 16);
103 cli_putstr_P(PSTR("\r\n\r\n"));
106 void testrun_performance_cast6(void){
109 uint8_t key[16], data[16];
119 cast6_init(key, 128, &ctx);
121 cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
122 ultoa((unsigned long)t, str, 10);
126 cast6_enc(data, &ctx);
128 cli_putstr_P(PSTR("\r\n\tencrypt time: "));
129 ultoa((unsigned long)t, str, 10);
133 cast6_dec(data, &ctx);
135 cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
136 ultoa((unsigned long)t, str, 10);
138 cli_putstr_P(PSTR("\r\n"));
140 /*****************************************************************************
142 *****************************************************************************/
144 const char nessie_str[] PROGMEM = "nessie";
145 const char test_str[] PROGMEM = "test";
146 const char performance_str[] PROGMEM = "performance";
147 const char echo_str[] PROGMEM = "echo";
149 cmdlist_entry_t cmdlist[] PROGMEM = {
150 { nessie_str, NULL, testrun_nessie_cast6 },
151 { test_str, NULL, testrun_rfc_cast6},
152 { performance_str, NULL, testrun_performance_cast6},
153 { echo_str, (void*)1, (void_fpt)echo_ctrl},
159 cli_rx = (cli_rx_fpt)uart0_getc;
160 cli_tx = (cli_tx_fpt)uart0_putc;
162 cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
163 cli_putstr(algo_name);
164 cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
165 cmd_interface(cmdlist);