12 #include "uart_lowlevel.h"
17 #include "nessie_bc_test.h"
19 #include "performance_test.h"
20 #include "bcal-performance.h"
21 #include "bcal_cast6.h"
23 char* algo_name = "CAST-256";
25 void uart0_putc(char byte){
26 uart_putc(UART_0, byte);
29 char uart0_getc(void){
30 return uart_getc(UART_0);
33 const bcdesc_t* algolist[] = {
34 (bcdesc_t*)&cast6_desc,
38 /*****************************************************************************
39 * additional validation-functions *
40 *****************************************************************************/
43 void testrun_nessie_cast6(void){
45 nessie_bc_ctx.blocksize_B = 16;
46 nessie_bc_ctx.keysize_b = 128;
47 nessie_bc_ctx.name = algo_name;
48 nessie_bc_ctx.ctx_size_B = sizeof(cast6_ctx_t);
49 nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)cast6_enc;
50 nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)cast6_dec;
51 nessie_bc_ctx.cipher_genctx = (nessie_bc_gen_fpt)cast6_init;
55 nessie_bc_ctx.keysize_b = 192;
58 nessie_bc_ctx.keysize_b = 256;
62 void testrun_rfc_cast6(void){
63 cli_putstr("\r\n testvalues from rfc-2612\r\n");
64 uint8_t key[32], data[16];
66 memcpy(key, "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
67 "\x0a\xf7\x56\x47\xf2\x9f\x61\x5d", 16);
70 cli_putstr("\r\n key: ");
72 cli_putstr("\r\n PT: ");
73 cli_hexdump(data, 16);
74 cast6_init(key, 128, &ctx);
75 cast6_enc(data, &ctx);
76 cli_putstr("\r\n CT: ");
77 cli_hexdump(data, 16);
78 cast6_dec(data, &ctx);
79 cli_putstr("\r\n PT: ");
80 cli_hexdump(data, 16);
82 cli_putstr("\r\n\r\n");
84 memcpy(key, "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
85 "\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
86 "\xba\xc7\x7a\x77\x17\x94\x28\x63", 24);
88 cli_putstr("\r\n key: ");
90 cli_putstr("\r\n PT: ");
91 cli_hexdump(data, 16);
92 cast6_init(key, 192, &ctx);
93 cast6_enc(data, &ctx);
94 cli_putstr("\r\n CT: ");
95 cli_hexdump(data, 16);
96 cast6_dec(data, &ctx);
97 cli_putstr("\r\n PT: ");
98 cli_hexdump(data, 16);
100 cli_putstr("\r\n\r\n");
102 memcpy(key, "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
103 "\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
104 "\x8d\x7c\x47\xce\x26\x49\x08\x46"
105 "\x1c\xc1\xb5\x13\x7a\xe6\xb6\x04", 32);
106 cli_putstr("\r\n key: ");
107 cli_hexdump(key, 32);
108 cli_putstr("\r\n PT: ");
109 cli_hexdump(data, 16);
110 cast6_init(key, 256, &ctx);
111 cast6_enc(data, &ctx);
112 cli_putstr("\r\n CT: ");
113 cli_hexdump(data, 16);
114 cast6_dec(data, &ctx);
115 cli_putstr("\r\n PT: ");
116 cli_hexdump(data, 16);
118 cli_putstr("\r\n\r\n");
121 void testrun_performance_cast6(void){
122 bcal_performance_multiple(algolist);
125 /*****************************************************************************
127 *****************************************************************************/
129 const char nessie_str[] = "nessie";
130 const char test_str[] = "test";
131 const char performance_str[] = "performance";
132 const char echo_str[] = "echo";
134 const cmdlist_entry_t cmdlist[] = {
135 { nessie_str, NULL, testrun_nessie_cast6 },
136 { test_str, NULL, testrun_rfc_cast6},
137 { performance_str, NULL, testrun_performance_cast6},
138 { echo_str, (void*)1, (void_fpt)echo_ctrl},
143 sysclk_set_freq(SYS_FREQ);
144 sysclk_mosc_verify_enable();
145 uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
146 gptm_set_timer_32periodic(TIMER0);
148 cli_rx = (cli_rx_fpt)uart0_getc;
149 cli_tx = (cli_tx_fpt)uart0_putc;
151 cli_putstr("\r\n\r\nARM-Crypto-Lib VS (");
152 cli_putstr(algo_name);
154 cli_putstr(__DATE__);
156 cli_putstr(__TIME__);
157 cli_putstr(")\r\nloaded and running\r\n");
158 cmd_interface(cmdlist);