7 #include "serial-tools.h"
12 #include "nessie_bc_test.h"
14 #include "performance_test.h"
20 char* cipher_name = "Serpent";
22 /*****************************************************************************
23 * additional validation-functions *
24 *****************************************************************************/
25 void serpent_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
26 serpent_genctx(key, keysize&0xff, ctx);
29 void testrun_nessie_serpent(void){
30 nessie_bc_ctx.blocksize_B = 16;
31 nessie_bc_ctx.keysize_b = 128;
32 nessie_bc_ctx.name = cipher_name;
33 nessie_bc_ctx.ctx_size_B = sizeof(serpent_ctx_t);
34 nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)serpent_enc;
35 nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)serpent_dec;
36 nessie_bc_ctx.cipher_genctx = (nessie_bc_gen_fpt)serpent_genctx_dummy;
40 nessie_bc_ctx.keysize_b = 192;
43 nessie_bc_ctx.keysize_b = 256;
48 void testrun_performance_serpent(void){
52 uint8_t key[32], data[16];
57 uart_putstr_P(PSTR("\r\n\r\n=== benchmark ==="));
59 uart_putstr_P(PSTR("\r\n\tconst overhead: "));
62 uart_putstr_P(PSTR("\r\n\tinterrupt overhead: "));
69 serpent_genctx(key, 0, &ctx);
71 uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
72 ultoa((unsigned long)t, str, 10);
77 serpent_enc(data, &ctx);
79 uart_putstr_P(PSTR("\r\n\tencrypt time: "));
80 ultoa((unsigned long)t, str, 10);
85 serpent_dec(data, &ctx);
87 uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
88 ultoa((unsigned long)t, str, 10);
91 uart_putstr_P(PSTR("\r\n"));
93 /*****************************************************************************
95 *****************************************************************************/
97 typedef void(*void_fpt)(void);
104 uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
105 uart_putstr(cipher_name);
106 uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
108 PGM_P u = PSTR("nessie\0test\0performance\0");
109 void_fpt v[] = {testrun_nessie_serpent, testrun_nessie_serpent, testrun_performance_serpent};
112 if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;}
113 if(execcommand_d0_P(str, u, v)<0){
114 uart_putstr_P(PSTR("\r\nunknown command\r\n"));
118 uart_putstr("ERROR\r\n");