From 572b35bb7409fb362441e0812cb62eab9f2411f0 Mon Sep 17 00:00:00 2001 From: bg Date: Fri, 30 Jan 2009 23:00:04 +0000 Subject: [PATCH] new cli system --- config.h | 1 - host/gf256_table_gen.c | 2 +- host/gf256mul.c | 2 +- host/gf256mul.h | 2 +- mkfiles/a5_1.mk | 2 +- test_src/cli.c | 304 +++++++++++++++++++++++++++++- test_src/cli.h | 29 ++- test_src/debug.c | 2 +- test_src/main-a5_1-test.c | 44 +++-- test_src/main-aes-test.c | 51 ++--- test_src/main-arcfour-test.c | 48 ++--- test_src/main-camellia-test.c | 45 ++--- test_src/main-cast5-test.c | 46 ++--- test_src/main-des-test.c | 45 ++--- test_src/main-entropium-test.c | 44 ++--- test_src/main-grain-test.c | 48 ++--- test_src/main-hmac-sha1-test.c | 42 ++--- test_src/main-hmac-sha256-test.c | 41 ++-- test_src/main-md5-test.c | 39 ++-- test_src/main-noekeon-test.c | 59 +++--- test_src/main-omac-noekeon-test.c | 43 +++-- test_src/main-present-test.c | 44 ++--- test_src/main-rc5-test.c | 45 ++--- test_src/main-rc6-test.c | 47 ++--- test_src/main-seed-test.c | 47 ++--- test_src/main-serpent-test.c | 45 ++--- test_src/main-sha1-test.c | 40 ++-- test_src/main-sha256-test.c | 40 ++-- test_src/main-shabea-test.c | 46 ++--- test_src/main-shacal1_enc-test.c | 46 ++--- test_src/main-shacal2_enc-test.c | 46 ++--- test_src/main-skipjack-test.c | 44 ++--- test_src/main-tdes-test.c | 45 ++--- test_src/main-trivium-test.c | 45 ++--- test_src/main-twister224-test.c | 45 +++-- test_src/main-twister256-test.c | 45 +++-- test_src/main-twister384-test.c | 45 +++-- test_src/main-twister512-test.c | 45 +++-- test_src/main-xtea-test.c | 43 +++-- test_src/nessie_bc_test.c | 2 +- test_src/nessie_bc_test.h | 2 +- test_src/nessie_common.c | 2 +- test_src/nessie_common.h | 2 +- test_src/nessie_hash_test.c | 2 +- test_src/nessie_hash_test.h | 2 +- test_src/nessie_mac_test.c | 2 +- test_src/nessie_mac_test.h | 2 +- test_src/nessie_stream_test.c | 2 +- test_src/nessie_stream_test.h | 2 +- test_src/performance_test.c | 2 +- test_src/performance_test.h | 2 +- test_src/serial-tools.c | 2 +- test_src/serial-tools.h | 2 +- test_src/uart.c | 2 +- 54 files changed, 1064 insertions(+), 708 deletions(-) diff --git a/config.h b/config.h index 3997f59..a813f10 100644 --- a/config.h +++ b/config.h @@ -20,7 +20,6 @@ #define __CONFIG_H__ #include - #define F_CPU 16000000 /* Oszillator-Frequenz in Hz */ // #define F_CPU 14745600 diff --git a/host/gf256_table_gen.c b/host/gf256_table_gen.c index a7512e7..b359411 100644 --- a/host/gf256_table_gen.c +++ b/host/gf256_table_gen.c @@ -1,6 +1,6 @@ /* gf256_table_gen.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify diff --git a/host/gf256mul.c b/host/gf256mul.c index 46e7d24..b3dd460 100644 --- a/host/gf256mul.c +++ b/host/gf256mul.c @@ -1,6 +1,6 @@ /* gf256mul.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify diff --git a/host/gf256mul.h b/host/gf256mul.h index 50ede5e..8cfea15 100644 --- a/host/gf256mul.h +++ b/host/gf256mul.h @@ -1,6 +1,6 @@ /* gf256mul.h */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify diff --git a/mkfiles/a5_1.mk b/mkfiles/a5_1.mk index 4305d0e..76692f0 100644 --- a/mkfiles/a5_1.mk +++ b/mkfiles/a5_1.mk @@ -6,7 +6,7 @@ STREAM_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := A5_1.o $(ALGO_NAME)_TEST_BIN := main-a5_1-test.o debug.o uart.o serial-tools.o \ - nessie_stream_test.o nessie_common.o + nessie_stream_test.o nessie_common.o cli.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/test_src/cli.c b/test_src/cli.c index d702699..47bd6ad 100644 --- a/test_src/cli.c +++ b/test_src/cli.c @@ -1,6 +1,6 @@ /* cli.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -26,9 +26,12 @@ * **/ +#include #include +#include #include #include +#include "cli.h" #include "config.h" int16_t findstring_d0(const char* str, const char* v){ @@ -43,6 +46,8 @@ int16_t findstring_d0(const char* str, const char* v){ } return -1; } + +#ifdef CLI_OLD int16_t findstring_d0_P(const char* str, PGM_P v){ uint8_t i=0; @@ -72,8 +77,6 @@ void cli_auto_help_P(PGM_P dbzstr){ uart_putstr_P(PSTR("\r\n")); } -#endif - int16_t execcommand_d0_P(const char* str, PGM_P v, void(*fpt[])(void) ){ int16_t i=0; i=findstring_d0_P(str, v); @@ -87,4 +90,299 @@ int16_t execcommand_d0_P(const char* str, PGM_P v, void(*fpt[])(void) ){ } } +#endif + +#else /* CLI_OLD */ + +cli_rx_fpt cli_rx = NULL; +cli_tx_fpt cli_tx = NULL; +uint8_t cli_echo=1; + +void cli_putstr(char* s){ + if(!cli_tx) + return; + while(*s) + cli_tx(*s++); +} + +void cli_putstr_P(PGM_P s){ + char c; + if(!cli_tx) + return; + for(;;){ + c = pgm_read_byte(s++); + if(!c) + return; + cli_tx(c); + } +} + +void cli_hexdump(void* data, uint16_t length){ + char hex_tab[] = {'0', '1', '2', '3', + '4', '5', '6', '7', + '8', '9', 'A', 'B', + 'C', 'D', 'E', 'F'}; + if(!cli_tx) + return; + while(length--){ + cli_tx(hex_tab[(*((uint8_t*)data))>>4]); + cli_tx(hex_tab[(*((uint8_t*)data))&0xf]); + data = (uint8_t*)data +1; + } +} + +void cli_auto_help(uint16_t maxcmdlength, PGM_VOID_P cmdlist){ + cmdlist_entry_t item; + uint16_t i; + if(!cli_tx) + return; + + cli_putstr_P(PSTR("\r\n[auto help] available commands:\r\n" + " - -
\r\n")); + for(;;){ + item.cmd_name = (void*)pgm_read_word(cmdlist+0); + item.cmd_param_str = (void*)pgm_read_word(cmdlist+2); + item.cmd_function = (void_fpt)pgm_read_word(cmdlist+4); + cmdlist = (uint8_t*)cmdlist+6; + if(item.cmd_name==NULL){ + return; + } + cli_tx(' '); + cli_putstr_P(item.cmd_name); + i=maxcmdlength-strlen_P(item.cmd_name); + while(i--) + cli_tx(' '); + cli_putstr_P(PSTR(" - ")); + if(item.cmd_param_str==NULL){ + cli_putstr_P(PSTR("none \t- 0x")); + } else { + if(item.cmd_param_str==(void*)1){ + cli_putstr_P(PSTR("yes \t- 0x")); + } else { + cli_putstr_P(item.cmd_param_str); + cli_putstr_P(PSTR(" \t- 0x")); + } + } + cli_hexdump(&item.cmd_function, 2); + cli_putstr_P(PSTR("\r\n")); + } +} + +uint16_t firstword_length(char* s){ + uint16_t ret=0; + while(isalnum(*s++)) + ret++; + return ret; +} + +void echo_ctrl(char* s){ + if(s==NULL || *s=='\0'){ + cli_putstr_P(PSTR("\r\necho is ")); + cli_putstr_P(cli_echo?PSTR("on"):PSTR("off")); + cli_putstr_P(PSTR("\r\n")); + } + strlwr(s); + if(!strcmp_P(s, PSTR("true")) || !strcmp_P(s, PSTR("on")) || *s=='1'){ + cli_echo=1; + } + if(!strcmp_P(s, PSTR("false")) || !strcmp_P(s, PSTR("off")) || *s=='0'){ + cli_echo=0; + } +} + +typedef void(*str_fpt)(char*); +#define CLI_ENTER 13 +#define CLI_BACKSPACE 8 +#define CLI_TABULATOR 9 + +int8_t search_and_call(char* cmd, uint16_t maxcmdlength, PGM_VOID_P cmdlist){ + PGM_VOID_P cmdlist_orig = cmdlist; + if(*cmd=='\0' || *cmd=='#') + return 1; + if(!strcmp_P(cmd, PSTR("exit"))) + return 0; + if((!strcmp_P(cmd, PSTR("help"))) || (!strcmp_P(cmd, PSTR("?")))){ + cli_auto_help(maxcmdlength, cmdlist); + return 1; + } + uint16_t fwlength=firstword_length(cmd); + char fw[fwlength+1]; + memcpy(fw, cmd, fwlength); + fw[fwlength] = '\0'; + cmdlist_entry_t item; + do{ + item.cmd_name = (void*)pgm_read_word(cmdlist+0); + item.cmd_param_str = (void*)pgm_read_word(cmdlist+2); + item.cmd_function = (void_fpt)pgm_read_word(cmdlist+4); + cmdlist = (uint8_t*)cmdlist+6; + }while(item.cmd_name!=NULL && strcmp_P(fw, item.cmd_name)); + if(item.cmd_name==NULL){ + cli_auto_help(maxcmdlength, cmdlist_orig); + } else { + if(item.cmd_function==NULL) + return 2; + switch((uint16_t)item.cmd_param_str){ + case 0: + item.cmd_function(); + break; + case 1: + if(cmd[fwlength]=='\0'){ + ((str_fpt)item.cmd_function)(cmd+fwlength); + } else { + ((str_fpt)item.cmd_function)(cmd+fwlength+1); + } + break; + default: + cli_putstr_P(PSTR("\r\nparam parsing currently not implemented!\r\n")); + break; + } + + } + return 1; +} + +uint16_t max_cmd_length(PGM_VOID_P cmdlist){ + uint16_t t,ret=0; + char* str; + for(;;){ + str = (char*)pgm_read_word(cmdlist); + cmdlist = (uint8_t*)cmdlist + 6; + if(str==NULL) + return ret; + t = strlen_P(str); + if(t>ret) + ret=t; + } +} + +uint16_t stridentcnt_P(char* a, PGM_P b){ + uint16_t i=0; + char c; + for(;;){ + c = pgm_read_byte(b++); + if(*a != c || c=='\0') + return i; + i++; + a++; + } +} + +uint8_t cli_completion(char* buffer, uint16_t maxcmdlength, PGM_VOID_P cmdlist){ + uint8_t i=0; + char ref[maxcmdlength+1]; + char* itemstr; + ref[0]='\0'; + /* check if we are behind the first word */ + while(buffer[i]){ + if(!isalnum(buffer[i++])) + return 0; + } + for(;;){ + itemstr = (char*)pgm_read_word(cmdlist); + if(itemstr==NULL) + break; + cmdlist = (uint8_t*)cmdlist +6; + if(!strncmp_P(buffer, itemstr, i)){ + if(!ref[0]){ + strcpy_P(ref, itemstr); + }else{ + ref[stridentcnt_P(ref, itemstr)]='\0'; + } + } + } + i = strcmp(buffer, ref); + if(i) + strcpy(buffer, ref); + return ~i; +} + +void cli_option_listing(char* buffer, PGM_VOID_P cmdlist){ + char* itemstr; + uint16_t len=strlen(buffer); + for(;;){ + itemstr = (char*)pgm_read_word(cmdlist); + if(itemstr==NULL){ + cli_putstr_P(PSTR("\r\n>")); + cli_putstr(buffer); + return; + } + cmdlist = (uint8_t*)cmdlist +6; + if(!strncmp_P(buffer, itemstr, len)){ + cli_putstr_P(PSTR("\r\n ")); + cli_putstr_P(itemstr); + } + } +} + +int8_t cmd_interface(PGM_VOID_P cmd_desc){ + uint16_t cli_buffer_size; + uint16_t cli_buffer_index; + int8_t exit_code; + uint8_t completion_failed=0; + char* cli_buffer; + char c; + uint16_t maxcmdlength = max_cmd_length(cmd_desc); + cli_buffer = calloc(1,cli_buffer_size=maxcmdlength+2); + cli_buffer_index=0; + if(!cli_rx) + return -1; + if(cli_tx) + cli_tx('>'); + for(;;){ + c = cli_rx(); + switch (c){ + case CLI_ENTER: + if((exit_code=search_and_call(cli_buffer, maxcmdlength, cmd_desc))<=0){ + free(cli_buffer); + return exit_code; + } + memset(cli_buffer, 0, cli_buffer_size); + cli_buffer_index=0; + cli_putstr_P(PSTR("\r\n>")); + completion_failed=0; + break; + case CLI_BACKSPACE: + completion_failed=0; + if(cli_buffer_index==0) + break; + cli_buffer_index--; + cli_buffer[cli_buffer_index] = '\0'; + if(cli_echo && cli_tx){ + cli_tx(c); + } + break; + case CLI_TABULATOR: + if(completion_failed || cli_buffer_index==0){ + if(cli_tx) + cli_option_listing(cli_buffer, cmd_desc); + } else { + uint16_t old_idx = cli_buffer_index; + completion_failed = + ~cli_completion(cli_buffer, maxcmdlength, cmd_desc); + cli_buffer_index = strlen(cli_buffer); + if(cli_echo && cli_tx){ + while(old_idx #include +#include "cli.h" -char* cipher_name = "A5_1"; +char* algo_name = "A5_1"; /***************************************************************************** * additional validation-functions * @@ -47,7 +48,7 @@ void testrun_nessie_a51(void){ nessie_stream_ctx.outsize_b = 8; /* actually unused */ nessie_stream_ctx.keysize_b = 64; nessie_stream_ctx.ivsize_b = 64; - nessie_stream_ctx.name = cipher_name; + nessie_stream_ctx.name = algo_name; nessie_stream_ctx.ctx_size_B = sizeof(a5_1_ctx_t); nessie_stream_ctx.cipher_genctx = (nessie_stream_genctx_fpt)a51_genctx_dummy; nessie_stream_ctx.cipher_enc = (nessie_stream_genenc_fpt)a5_1_gen; @@ -61,26 +62,31 @@ void testrun_nessie_a51(void){ * main * *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char testkey_str[] PROGMEM = "testkey"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_a51 }, +/* { performance_str, NULL, testrun_performance_a51}, */ + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + int main (void){ - char str[20]; DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - -restart: - while(1){ - if (!getnextwordn(str,20)) {DEBUG_S("DBG: W1\r\n"); goto error;} - if (strcmp(str, "nessie")) {DEBUG_S("DBG: 1b\r\n"); goto error;} - testrun_nessie_a51(); - goto restart; - continue; - error: - uart_putstr("ERROR\r\n"); - } + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); + } } diff --git a/test_src/main-aes-test.c b/test_src/main-aes-test.c index ecb9ad2..47ed459 100644 --- a/test_src/main-aes-test.c +++ b/test_src/main-aes-test.c @@ -1,6 +1,6 @@ /* main-aes-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -42,8 +42,9 @@ #include #include #include +#include -char* cipher_name = "AES"; +char* algo_name = "AES"; /***************************************************************************** * additional validation-functions * @@ -52,7 +53,7 @@ char* cipher_name = "AES"; void testrun_nessie_aes(void){ nessie_bc_ctx.blocksize_B = 16; nessie_bc_ctx.keysize_b = 128; - nessie_bc_ctx.name = cipher_name; + nessie_bc_ctx.name = algo_name; nessie_bc_ctx.ctx_size_B = sizeof(aes128_ctx_t); nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)aes128_enc; nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)aes128_dec; @@ -299,30 +300,32 @@ void testrun_performance_aes(void){ * main * *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char testkey_str[] PROGMEM = "testkey"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_aes }, + { test_str, NULL, testrun_test_aes}, + { testkey_str, NULL, testrun_testkey_aes}, + { performance_str, NULL, testrun_performance_aes}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + + int main (void){ - char str[20]; DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0testkey\0performance\0"); - void_fpt v[] = {testrun_nessie_aes, - testrun_test_aes, - testrun_testkey_aes, - testrun_performance_aes}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } - } diff --git a/test_src/main-arcfour-test.c b/test_src/main-arcfour-test.c index 84fb954..f16c2db 100644 --- a/test_src/main-arcfour-test.c +++ b/test_src/main-arcfour-test.c @@ -1,6 +1,6 @@ /* main-arcfour-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -35,7 +35,7 @@ #include #include -char* cipher_name = "Arcfour"; +char* algo_name = "Arcfour"; /***************************************************************************** * additional validation-functions * @@ -50,7 +50,7 @@ void testrun_nessie_arcfour(void){ nessie_stream_ctx.outsize_b = 8; /* actually unused */ nessie_stream_ctx.keysize_b = 128; /* this is theone we have refrence vectors for */ nessie_stream_ctx.ivsize_b = (uint16_t)-1; - nessie_stream_ctx.name = cipher_name; + nessie_stream_ctx.name = algo_name; nessie_stream_ctx.ctx_size_B = sizeof(arcfour_ctx_t); nessie_stream_ctx.cipher_genctx = (nessie_stream_genctx_fpt)arcfour_genctx_dummy; nessie_stream_ctx.cipher_enc = (nessie_stream_genenc_fpt)arcfour_gen; @@ -91,29 +91,29 @@ void testrun_performance_arcfour(void){ * main * *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_arcfour }, + { test_str, NULL, testrun_nessie_arcfour}, + { performance_str, NULL, testrun_performance_arcfour}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + int main (void){ - char str[20]; DEBUG_INIT(); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_arcfour, - testrun_nessie_arcfour, - testrun_performance_arcfour}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + uart_putstr("\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } - - } diff --git a/test_src/main-camellia-test.c b/test_src/main-camellia-test.c index b52cb09..07191e4 100644 --- a/test_src/main-camellia-test.c +++ b/test_src/main-camellia-test.c @@ -1,6 +1,6 @@ /* main-camellia-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -31,7 +31,7 @@ #include "performance_test.h" #include "cli.h" -char* cipher_name = "Camellia"; +char* algo_name = "Camellia"; #include @@ -50,7 +50,7 @@ void camellia128_init_dummy(void* key, uint16_t keysize_b, void* ctx){ void testrun_nessie_camellia(void){ nessie_bc_ctx.blocksize_B = 16; nessie_bc_ctx.keysize_b = 128; - nessie_bc_ctx.name = cipher_name; + nessie_bc_ctx.name = algo_name; nessie_bc_ctx.ctx_size_B = sizeof(camellia128_ctx_t); nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)camellia128_enc; nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)camellia128_dec; @@ -142,28 +142,29 @@ void testrun_camellia(void){ * main * *****************************************************************************/ -int main (void){ - char str[20]; +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; - +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_camellia }, + { test_str, NULL, testrun_camellia}, + { performance_str, NULL, test_performance_camellia}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + +int main (void){ DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_camellia, testrun_camellia, test_performance_camellia}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } } diff --git a/test_src/main-cast5-test.c b/test_src/main-cast5-test.c index 3cdb703..2dcc2ae 100644 --- a/test_src/main-cast5-test.c +++ b/test_src/main-cast5-test.c @@ -1,6 +1,6 @@ /* main-cast5-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -35,7 +35,7 @@ #include #include -char* cipher_name = "cast-128 (cast5)"; +char* algo_name = "cast-128 (cast5)"; /***************************************************************************** * additional validation-functions * @@ -44,7 +44,7 @@ char* cipher_name = "cast-128 (cast5)"; void testrun_nessie_cast5(void){ nessie_bc_ctx.blocksize_B = 8; nessie_bc_ctx.keysize_b = 128; - nessie_bc_ctx.name = cipher_name; + nessie_bc_ctx.name = algo_name; nessie_bc_ctx.ctx_size_B = sizeof(cast5_ctx_t); nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)cast5_enc; nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)cast5_dec; @@ -193,28 +193,28 @@ void testrun_performance_cast5(void){ * main * *****************************************************************************/ -int main (void){ - char str[20]; +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; - +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_cast5}, + { test_str, NULL, testrun_cast5}, + { performance_str, NULL, testrun_performance_cast5}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + +int main (void){ DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_cast5, testrun_cast5, testrun_performance_cast5}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } } - diff --git a/test_src/main-des-test.c b/test_src/main-des-test.c index b421d35..349c290 100644 --- a/test_src/main-des-test.c +++ b/test_src/main-des-test.c @@ -1,6 +1,6 @@ /* main-des-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -35,7 +35,7 @@ #include #include -char* cipher_name = "DES"; +char* algo_name = "DES"; /***************************************************************************** * additional validation-functions * @@ -56,7 +56,7 @@ void testrun_nessie_des(void){ nessie_bc_init(); nessie_bc_ctx.blocksize_B = 8; nessie_bc_ctx.keysize_b = 64; - nessie_bc_ctx.name = cipher_name; + nessie_bc_ctx.name = algo_name; nessie_bc_ctx.ctx_size_B = 8; nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)des_enc_dummy; nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)des_dec_dummy; @@ -97,27 +97,28 @@ void testrun_performance_des(void){ * main *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_des }, + { test_str, NULL, testrun_nessie_des }, + { performance_str, NULL, testrun_performance_des}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + int main (void){ - char str[20]; DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_des, testrun_nessie_des, testrun_performance_des}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } - } - diff --git a/test_src/main-entropium-test.c b/test_src/main-entropium-test.c index df0bc74..3f62fb9 100644 --- a/test_src/main-entropium-test.c +++ b/test_src/main-entropium-test.c @@ -1,6 +1,6 @@ /* main-entropium-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -35,7 +35,7 @@ #include #include -char* cipher_name = "Entropium"; +char* algo_name = "Entropium"; /***************************************************************************** * additional validation-functions * @@ -90,27 +90,29 @@ void testrun_performance_entropium(void){ * main * *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_entropium}, + { test_str, NULL, testrun_entropium}, + { performance_str, NULL, testrun_performance_entropium}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + + int main (void){ - char str[20]; DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_entropium, testrun_entropium, testrun_performance_entropium}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } - } - diff --git a/test_src/main-grain-test.c b/test_src/main-grain-test.c index d09e002..036faad 100644 --- a/test_src/main-grain-test.c +++ b/test_src/main-grain-test.c @@ -1,6 +1,6 @@ /* main-grain-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -35,7 +35,7 @@ #include #include -char* cipher_name = "Grain"; +char* algo_name = "Grain"; /***************************************************************************** * additional validation-functions * @@ -67,7 +67,7 @@ void testrun_nessie_grain(void){ nessie_stream_ctx.outsize_b = 8; /* actually unused */ nessie_stream_ctx.keysize_b = 80; /* this is the one we have refrence vectors for */ nessie_stream_ctx.ivsize_b = 64; - nessie_stream_ctx.name = cipher_name; + nessie_stream_ctx.name = algo_name; nessie_stream_ctx.ctx_size_B = sizeof(grain_ctx_t); nessie_stream_ctx.cipher_genctx = (nessie_stream_genctx_fpt)grain_genctx_dummy; nessie_stream_ctx.cipher_enc = (nessie_stream_genenc_fpt)grain_getbyte_dummy_rev; @@ -153,28 +153,28 @@ void testrun_performance_grain(void){ * main * *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_grain }, + { test_str, NULL, testrun_std_grain}, + { performance_str, NULL, testrun_performance_grain}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + int main (void){ - char str[20]; DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_grain, testrun_std_grain, testrun_performance_grain}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); - } + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); + } } - - - diff --git a/test_src/main-hmac-sha1-test.c b/test_src/main-hmac-sha1-test.c index 4e24855..74d331e 100644 --- a/test_src/main-hmac-sha1-test.c +++ b/test_src/main-hmac-sha1-test.c @@ -1,6 +1,6 @@ /* main-hmac-sha1-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -73,28 +73,28 @@ void testrun_nessie_hmacsha1(void){ * main * *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +/* const char performance_str[] PROGMEM = "performance"; */ +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_hmacsha1}, + { test_str, NULL, testrun_nessie_hmacsha1}, +/* { performance_str, NULL, testrun_performance_hmacsha1}, */ + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + int main (void){ - char str[20]; DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(algo_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0"); - void_fpt v[] = {testrun_nessie_hmacsha1, testrun_nessie_hmacsha1}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } - - } - diff --git a/test_src/main-hmac-sha256-test.c b/test_src/main-hmac-sha256-test.c index 5d68ff5..6d80d54 100644 --- a/test_src/main-hmac-sha256-test.c +++ b/test_src/main-hmac-sha256-test.c @@ -1,6 +1,6 @@ /* main-hmac-sha256-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -73,27 +73,28 @@ void testrun_nessie_hmacsha256(void){ * main * *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +/* const char performance_str[] PROGMEM = "performance"; */ +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_hmacsha256}, + { test_str, NULL, testrun_nessie_hmacsha256}, +/* { performance_str, NULL, testrun_performance_hmacsha256}, */ + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + int main (void){ - char str[20]; DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(algo_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0"); - void_fpt v[] = {testrun_nessie_hmacsha256, testrun_nessie_hmacsha256}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } - } - diff --git a/test_src/main-md5-test.c b/test_src/main-md5-test.c index c38414b..1ede353 100644 --- a/test_src/main-md5-test.c +++ b/test_src/main-md5-test.c @@ -1,6 +1,6 @@ /* main-md5-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -148,25 +148,28 @@ void testrun_performance_md5(void){ * main * *****************************************************************************/ -int main (void){ - char str[20]; +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; - +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_md5}, + { test_str, NULL, testrun_md5}, + { performance_str, NULL, testrun_performance_md5}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + +int main (void){ DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr("\r\n\r\nCrypto-VS (MD5)\r\nloaded and running\r\n"); - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_md5, testrun_md5, testrun_performance_md5}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } } - diff --git a/test_src/main-noekeon-test.c b/test_src/main-noekeon-test.c index ebe42f7..1907c5e 100644 --- a/test_src/main-noekeon-test.c +++ b/test_src/main-noekeon-test.c @@ -1,6 +1,6 @@ /* main-noekeon-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -35,7 +35,7 @@ #include #include -char* cipher_name = "Noekeon"; +char* algo_name = "Noekeon"; /***************************************************************************** * additional validation-functions * @@ -45,8 +45,8 @@ void noekeon_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){ } void testrun_nessie_noekeon_indirect(void){ - char str[strlen(cipher_name)+10]; - strcpy(str, cipher_name); + char str[strlen(algo_name)+10]; + strcpy(str, algo_name); strcat(str, "-indirect"); nessie_bc_ctx.blocksize_B = 16; @@ -65,8 +65,8 @@ void noekeon_genctx_dummy_direct(uint8_t* key, uint16_t keysize, void* ctx){ } void testrun_nessie_noekeon_direct(void){ - char str[strlen(cipher_name)+10]; - strcpy(str, cipher_name); + char str[strlen(algo_name)+10]; + strcpy(str, algo_name); strcat(str, "-Direct"); nessie_bc_ctx.blocksize_B = 16; @@ -211,31 +211,32 @@ void testrun_performance_noekeon(void){ * main * *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char direct_str[] PROGMEM = "direct"; +const char indirect_str[] PROGMEM = "indirect"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_noekeon}, + { test_str, NULL, testrun_stdtest_noekeon}, + { direct_str, NULL, testrun_nessie_noekeon_direct}, + { indirect_str, NULL, testrun_nessie_noekeon_indirect}, + { performance_str, NULL, testrun_performance_noekeon}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + int main (void){ - char str[20]; DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0direct\0indirect\0performance\0"); - void_fpt v[] = {testrun_nessie_noekeon, - testrun_stdtest_noekeon, - testrun_nessie_noekeon_direct, - testrun_nessie_noekeon_indirect, - testrun_performance_noekeon}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } - } - diff --git a/test_src/main-omac-noekeon-test.c b/test_src/main-omac-noekeon-test.c index c05d238..fc5b731 100644 --- a/test_src/main-omac-noekeon-test.c +++ b/test_src/main-omac-noekeon-test.c @@ -1,6 +1,6 @@ /* main-omac-noekeon-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -152,29 +152,28 @@ void testrun_performance_omac_noekeon(void){ * main * *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_omac_noekeon }, + { test_str, NULL, testrun_test_omac_noekeon}, + { performance_str, NULL, testrun_performance_omac_noekeon}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + int main (void){ - char str[20]; DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(algo_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_omac_noekeon, - testrun_test_omac_noekeon, - testrun_performance_omac_noekeon}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } - } - diff --git a/test_src/main-present-test.c b/test_src/main-present-test.c index 03d4565..7f20922 100644 --- a/test_src/main-present-test.c +++ b/test_src/main-present-test.c @@ -1,6 +1,6 @@ /* main-present-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -35,7 +35,7 @@ #include #include -char* cipher_name = "Present"; +char* algo_name = "Present"; /***************************************************************************** * additional validation-functions * @@ -47,7 +47,7 @@ void present_genctx_dummy(uint8_t* key, uint16_t keysize_b, present_ctx_t* ctx){ void testrun_nessie_present(void){ nessie_bc_ctx.blocksize_B = 8; nessie_bc_ctx.keysize_b = 80; - nessie_bc_ctx.name = cipher_name; + nessie_bc_ctx.name = algo_name; nessie_bc_ctx.ctx_size_B = sizeof(present_ctx_t); nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)present_enc; nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)present_dec; @@ -127,26 +127,28 @@ void testrun_performance_present(void){ * main * *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_present}, + { test_str, NULL, testrun_self_present}, + { performance_str, NULL, testrun_performance_present}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + int main (void){ - char str[20]; DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_present, testrun_self_present, testrun_performance_present}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } - } diff --git a/test_src/main-rc5-test.c b/test_src/main-rc5-test.c index 7a4c770..a81158a 100644 --- a/test_src/main-rc5-test.c +++ b/test_src/main-rc5-test.c @@ -1,6 +1,6 @@ /* main-rc5-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -36,7 +36,7 @@ #include #define RC5_ROUNDS 12 -char* cipher_name = "RC5-32/12/16"; +char* algo_name = "RC5-32/12/16"; /***************************************************************************** * additional validation-functions * @@ -49,7 +49,7 @@ void testrun_nessie_rc5(void){ nessie_bc_init(); nessie_bc_ctx.blocksize_B = 8; nessie_bc_ctx.keysize_b = 128; - nessie_bc_ctx.name = cipher_name; + nessie_bc_ctx.name = algo_name; nessie_bc_ctx.ctx_size_B = sizeof(rc5_ctx_t); nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)rc5_enc; nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)rc5_dec; @@ -105,27 +105,28 @@ void testrun_performance_rc5(void){ * main * *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_rc5 }, + { test_str, NULL, testrun_nessie_rc5}, + { performance_str, NULL, testrun_performance_rc5}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + int main (void){ - char str[20]; DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_rc5, testrun_nessie_rc5, testrun_performance_rc5}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } - } - diff --git a/test_src/main-rc6-test.c b/test_src/main-rc6-test.c index 5e3dfef..0b1dc7b 100644 --- a/test_src/main-rc6-test.c +++ b/test_src/main-rc6-test.c @@ -1,6 +1,6 @@ /* main-rc6-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -17,7 +17,7 @@ along with this program. If not, see . */ /* - * rc5 test-suit + * rc6 test-suit * */ @@ -36,7 +36,7 @@ #include #define RC6_ROUNDS 20 -char* cipher_name = "RC6-32/20/16"; +char* algo_name = "RC6-32/20/16"; /***************************************************************************** * additional validation-functions * @@ -49,7 +49,7 @@ void testrun_nessie_rc6(void){ nessie_bc_init(); nessie_bc_ctx.blocksize_B = 16; nessie_bc_ctx.keysize_b = 128; - nessie_bc_ctx.name = cipher_name; + nessie_bc_ctx.name = algo_name; nessie_bc_ctx.ctx_size_B = sizeof(rc6_ctx_t); nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)rc6_enc; nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)rc6_dec; @@ -112,27 +112,28 @@ void testrun_performance_rc6(void){ * main * *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_rc6}, + { test_str, NULL, testrun_nessie_rc6}, + { performance_str, NULL, testrun_performance_rc6}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + int main (void){ - char str[20]; DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_rc6, testrun_nessie_rc6, testrun_performance_rc6}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } - } - diff --git a/test_src/main-seed-test.c b/test_src/main-seed-test.c index 78b64fe..8d264dc 100644 --- a/test_src/main-seed-test.c +++ b/test_src/main-seed-test.c @@ -1,6 +1,6 @@ /* main-seed-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -40,7 +40,7 @@ #include #include -char* cipher_name = "Seed"; +char* algo_name = "Seed"; /***************************************************************************** * additional validation-functions * @@ -52,7 +52,7 @@ void seed_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){ void testrun_nessie_seed(void){ nessie_bc_ctx.blocksize_B = 16; nessie_bc_ctx.keysize_b = 128; - nessie_bc_ctx.name = cipher_name; + nessie_bc_ctx.name = algo_name; nessie_bc_ctx.ctx_size_B = sizeof(seed_ctx_t); nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)seed_enc; nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)seed_dec; @@ -163,27 +163,28 @@ void testrun_seed(void){ * main * *****************************************************************************/ -int main (void){ - char str[20]; +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; - DEBUG_INIT(); +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_seed}, + { test_str, NULL, testrun_seed}, + { performance_str, NULL, testrun_performance_seed}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_seed, testrun_seed, testrun_performance_seed}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); +int main (void){ + DEBUG_INIT(); + uart_putstr("\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } - } - diff --git a/test_src/main-serpent-test.c b/test_src/main-serpent-test.c index ea48b74..ae8ad16 100644 --- a/test_src/main-serpent-test.c +++ b/test_src/main-serpent-test.c @@ -1,6 +1,6 @@ /* main-serpent-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -35,7 +35,7 @@ #include #include -char* cipher_name = "Serpent"; +char* algo_name = "Serpent"; /***************************************************************************** * additional validation-functions * @@ -47,7 +47,7 @@ void serpent_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){ void testrun_nessie_serpent(void){ nessie_bc_ctx.blocksize_B = 16; nessie_bc_ctx.keysize_b = 128; - nessie_bc_ctx.name = cipher_name; + nessie_bc_ctx.name = algo_name; nessie_bc_ctx.ctx_size_B = sizeof(serpent_ctx_t); nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)serpent_enc; nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)serpent_dec; @@ -117,27 +117,28 @@ void testrun_performance_serpent(void){ * main * *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_serpent}, + { test_str, NULL, testrun_test_serpent}, + { performance_str, NULL, testrun_performance_serpent}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + int main (void){ - char str[20]; DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_serpent, testrun_test_serpent, testrun_performance_serpent}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } - } - diff --git a/test_src/main-sha1-test.c b/test_src/main-sha1-test.c index e1c3139..1ba4bf0 100644 --- a/test_src/main-sha1-test.c +++ b/test_src/main-sha1-test.c @@ -1,6 +1,6 @@ /* main-sha1-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -146,26 +146,28 @@ void testrun_performance_sha1(void){ * main * *****************************************************************************/ -int main (void){ - char str[20]; +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_sha1}, + { test_str, NULL, testrun_sha1}, + { performance_str, NULL, testrun_performance_sha1}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; +int main (void){ DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr("\r\n\r\nCrypto-VS (SHA-1)\r\nloaded and running\r\n"); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_sha1, testrun_sha1, testrun_performance_sha1}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } } - - diff --git a/test_src/main-sha256-test.c b/test_src/main-sha256-test.c index 3fcacb6..a4ba9f9 100644 --- a/test_src/main-sha256-test.c +++ b/test_src/main-sha256-test.c @@ -1,6 +1,6 @@ /* main-sha256-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -102,26 +102,28 @@ void testrun_performance_sha256(void){ * main * *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_sha256}, + { test_str, NULL, testrun_nessie_sha256}, + { performance_str, NULL, testrun_performance_sha256}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + int main (void){ - char str[20]; DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(algo_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_sha256, testrun_nessie_sha256, testrun_performance_sha256}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } } - diff --git a/test_src/main-shabea-test.c b/test_src/main-shabea-test.c index e7f0066..ba78a78 100644 --- a/test_src/main-shabea-test.c +++ b/test_src/main-shabea-test.c @@ -1,6 +1,6 @@ /* main-shabea-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -39,7 +39,7 @@ #include #include -char* cipher_name = "Shabea"; +char* algo_name = "Shabea"; /***************************************************************************** * additional validation-functions * @@ -60,7 +60,7 @@ void shabea_dec_dummy(void* buffer, void* ctx){ void testrun_nessie_shabea(void){ nessie_bc_ctx.blocksize_B = 32; nessie_bc_ctx.keysize_b = 256; - nessie_bc_ctx.name = cipher_name; + nessie_bc_ctx.name = algo_name; nessie_bc_ctx.ctx_size_B = 32; nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)shabea_enc_dummy; nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)shabea_dec_dummy; @@ -166,28 +166,28 @@ void testrun_shabea(void){ * main * *****************************************************************************/ -int main (void){ - char str[20]; +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_shabea}, + { test_str, NULL, testrun_shabea}, + { performance_str, NULL, testrun_performance_shabea}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; +int main (void){ DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_shabea, testrun_shabea, testrun_performance_shabea}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } - } - diff --git a/test_src/main-shacal1_enc-test.c b/test_src/main-shacal1_enc-test.c index 6998d04..b36ef86 100644 --- a/test_src/main-shacal1_enc-test.c +++ b/test_src/main-shacal1_enc-test.c @@ -1,6 +1,6 @@ /* main-shacal1_enc-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -35,7 +35,7 @@ #include #include -char* cipher_name = "Shacal1 encryption only"; +char* algo_name = "Shacal1 encryption only"; /***************************************************************************** * additional validation-functions * @@ -51,7 +51,7 @@ void shacal1_enc_dummy(void* buffer, void* ctx){ void testrun_nessie_shacal1enc(void){ nessie_bc_ctx.blocksize_B = SHACAL1_BLOCKSIZE_B; nessie_bc_ctx.keysize_b = SHACAL1_KEYSIZE; - nessie_bc_ctx.name = cipher_name; + nessie_bc_ctx.name = algo_name; nessie_bc_ctx.ctx_size_B = SHACAL1_KEYSIZE_B; nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)shacal1_enc_dummy; nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)NULL; @@ -83,28 +83,28 @@ void testrun_performance_shacal1enc(void){ * main * *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_shacal1enc}, + { test_str, NULL, testrun_nessie_shacal1enc}, + { performance_str, NULL, testrun_performance_shacal1enc}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + int main (void){ - char str[20]; DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_shacal1enc, - testrun_nessie_shacal1enc, - testrun_performance_shacal1enc}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } - } diff --git a/test_src/main-shacal2_enc-test.c b/test_src/main-shacal2_enc-test.c index 2925e71..53fcc8e 100644 --- a/test_src/main-shacal2_enc-test.c +++ b/test_src/main-shacal2_enc-test.c @@ -1,6 +1,6 @@ /* main-shacal2_enc-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -35,7 +35,7 @@ #include #include -char* cipher_name = "Shacal2 encryption only"; +char* algo_name = "Shacal2 encryption only"; /***************************************************************************** * additional validation-functions * @@ -51,7 +51,7 @@ void shacal2_enc_dummy(void* buffer, void* ctx){ void testrun_nessie_shacal2enc(void){ nessie_bc_ctx.blocksize_B = SHACAL2_BLOCKSIZE_B; nessie_bc_ctx.keysize_b = SHACAL2_KEYSIZE; - nessie_bc_ctx.name = cipher_name; + nessie_bc_ctx.name = algo_name; nessie_bc_ctx.ctx_size_B = SHACAL2_KEYSIZE_B; nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)shacal2_enc_dummy; nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)NULL; @@ -83,28 +83,28 @@ void testrun_performance_shacal2enc(void){ * main * *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_shacal2enc}, + { test_str, NULL, testrun_nessie_shacal2enc}, + { performance_str, NULL, testrun_performance_shacal2enc}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + int main (void){ - char str[20]; DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_shacal2enc, - testrun_nessie_shacal2enc, - testrun_performance_shacal2enc}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } - } diff --git a/test_src/main-skipjack-test.c b/test_src/main-skipjack-test.c index bb08986..5a648b3 100644 --- a/test_src/main-skipjack-test.c +++ b/test_src/main-skipjack-test.c @@ -1,6 +1,6 @@ /* main-skipjack-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -36,7 +36,7 @@ #include -char* cipher_name = "Skipjack"; +char* algo_name = "Skipjack"; /***************************************************************************** * additional validation-functions * @@ -48,7 +48,7 @@ void skipjack_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){ void testrun_nessie_skipjack(void){ nessie_bc_ctx.blocksize_B = 8; nessie_bc_ctx.keysize_b = 80; - nessie_bc_ctx.name = cipher_name; + nessie_bc_ctx.name = algo_name; nessie_bc_ctx.ctx_size_B = 10; nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)skipjack_enc; nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)skipjack_dec; @@ -137,26 +137,28 @@ void testrun_skipjack(void){ * main * *****************************************************************************/ -int main (void){ - char str[20]; +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_skipjack}, + { test_str, NULL, testrun_skipjack}, + { performance_str, NULL, testrun_performance_skipjack}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; +int main (void){ DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr("\r\n\r\nCrypto-VS (skipjack)\r\nloaded and running\r\n"); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_skipjack, testrun_skipjack, testrun_performance_skipjack}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } - } - diff --git a/test_src/main-tdes-test.c b/test_src/main-tdes-test.c index fbe7e00..f32c972 100644 --- a/test_src/main-tdes-test.c +++ b/test_src/main-tdes-test.c @@ -1,6 +1,6 @@ /* main-tdes-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -35,7 +35,7 @@ #include #include -char* cipher_name = "TDES"; +char* algo_name = "TDES"; /***************************************************************************** * additional validation-functions * @@ -56,7 +56,7 @@ void testrun_nessie_tdes(void){ nessie_bc_init(); nessie_bc_ctx.blocksize_B = 8; nessie_bc_ctx.keysize_b = 192; - nessie_bc_ctx.name = cipher_name; + nessie_bc_ctx.name = algo_name; nessie_bc_ctx.ctx_size_B = sizeof(8*3); nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)tdes_enc_dummy; nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)tdes_dec_dummy; @@ -97,27 +97,28 @@ void testrun_performance_tdes(void){ * main * *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_tdes}, + { test_str, NULL, testrun_nessie_tdes}, + { performance_str, NULL, testrun_performance_tdes}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + int main (void){ - char str[20]; DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_tdes, testrun_nessie_tdes, testrun_performance_tdes}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } - } - diff --git a/test_src/main-trivium-test.c b/test_src/main-trivium-test.c index ad0f385..13d00d7 100644 --- a/test_src/main-trivium-test.c +++ b/test_src/main-trivium-test.c @@ -1,6 +1,6 @@ /* main-trivium-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -35,7 +35,7 @@ #include #include -char* cipher_name = "Trivium"; +char* algo_name = "Trivium"; /***************************************************************************** * additional validation-functions * @@ -58,7 +58,7 @@ void testrun_nessie_trivium(void){ nessie_stream_ctx.outsize_b = 8; /* actually unused */ nessie_stream_ctx.keysize_b = 80; /* this is the one we have refrence vectors for */ nessie_stream_ctx.ivsize_b = 32; - nessie_stream_ctx.name = cipher_name; + nessie_stream_ctx.name = algo_name; nessie_stream_ctx.ctx_size_B = sizeof(trivium_ctx_t); nessie_stream_ctx.cipher_genctx = (nessie_stream_genctx_fpt)trivium_genctx_dummy; nessie_stream_ctx.cipher_enc = (nessie_stream_genenc_fpt)trivium_getbyte_dummy; @@ -99,25 +99,28 @@ void testrun_performance_trivium(void){ * main * *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_trivium}, + { test_str, NULL, testrun_nessie_trivium}, + { performance_str, NULL, testrun_performance_trivium}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + int main (void){ - char str[20]; DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_trivium, testrun_nessie_trivium, testrun_performance_trivium}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); - } + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); + } } diff --git a/test_src/main-twister224-test.c b/test_src/main-twister224-test.c index dbc5883..d2e0a14 100644 --- a/test_src/main-twister224-test.c +++ b/test_src/main-twister224-test.c @@ -1,6 +1,6 @@ /* main-twister224-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -188,29 +188,28 @@ void testrun_performance_twister224(void){ * main * *****************************************************************************/ -int main (void){ - char str[20]; +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; - - DEBUG_INIT(); - uart_putstr_P(PSTR("\r\n")); +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_twister224}, + { test_str, NULL, testrun_twister224}, + { performance_str, NULL, testrun_performance_twister224}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(algo_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = { testrun_nessie_twister224, - testrun_twister224, - testrun_performance_twister224 }; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); +int main (void){ + DEBUG_INIT(); + uart_putstr("\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } } - diff --git a/test_src/main-twister256-test.c b/test_src/main-twister256-test.c index 25ae089..2a54084 100644 --- a/test_src/main-twister256-test.c +++ b/test_src/main-twister256-test.c @@ -1,6 +1,6 @@ /* main-twister256-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -178,29 +178,28 @@ void testrun_performance_twister256(void){ * main * *****************************************************************************/ -int main (void){ - char str[20]; +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; - - DEBUG_INIT(); - uart_putstr_P(PSTR("\r\n")); +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_twister256}, + { test_str, NULL, testrun_twister256}, + { performance_str, NULL, testrun_performance_twister256}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(algo_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = { testrun_nessie_twister256, - testrun_twister256, - testrun_performance_twister256 }; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); +int main (void){ + DEBUG_INIT(); + uart_putstr("\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } } - diff --git a/test_src/main-twister384-test.c b/test_src/main-twister384-test.c index dcd0195..b913fa5 100644 --- a/test_src/main-twister384-test.c +++ b/test_src/main-twister384-test.c @@ -1,6 +1,6 @@ /* main-twister384-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -182,29 +182,28 @@ void testrun_performance_twister384(void){ * *****************************************************************************/ -int main (void){ - char str[20]; +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; - - DEBUG_INIT(); - uart_putstr_P(PSTR("\r\n")); +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_twister384}, + { test_str, NULL, testrun_twister384}, + { performance_str, NULL, testrun_performance_twister384}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(algo_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = { testrun_nessie_twister384, - testrun_twister384, - testrun_performance_twister384 }; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); +int main (void){ + DEBUG_INIT(); + uart_putstr("\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } } - diff --git a/test_src/main-twister512-test.c b/test_src/main-twister512-test.c index 8ec706c..149abef 100644 --- a/test_src/main-twister512-test.c +++ b/test_src/main-twister512-test.c @@ -1,6 +1,6 @@ /* main-twister512-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -182,29 +182,28 @@ void testrun_performance_twister512(void){ * *****************************************************************************/ -int main (void){ - char str[20]; +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; - - DEBUG_INIT(); - uart_putstr_P(PSTR("\r\n")); +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_twister512}, + { test_str, NULL, testrun_twister512}, + { performance_str, NULL, testrun_performance_twister512}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(algo_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = { testrun_nessie_twister512, - testrun_twister512, - testrun_performance_twister512 }; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); +int main (void){ + DEBUG_INIT(); + uart_putstr("\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } } - diff --git a/test_src/main-xtea-test.c b/test_src/main-xtea-test.c index 94a2475..a1dfd02 100644 --- a/test_src/main-xtea-test.c +++ b/test_src/main-xtea-test.c @@ -1,6 +1,6 @@ /* main-xtea-test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -34,7 +34,7 @@ #include #include -char* cipher_name = "XTEA"; +char* algo_name = "XTEA"; void xtea_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){ memcpy(ctx, key, (keysize+7)/8); @@ -51,7 +51,7 @@ void xtea_dec_dummy(uint8_t* buffer, void* ctx){ void testrun_nessie_xtea(void){ nessie_bc_ctx.blocksize_B = 8; nessie_bc_ctx.keysize_b = 128; - nessie_bc_ctx.name = cipher_name; + nessie_bc_ctx.name = algo_name; nessie_bc_ctx.ctx_size_B = 128/8; nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)xtea_enc_dummy; nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)xtea_dec_dummy; @@ -87,25 +87,28 @@ void testrun_performance_xtea(void){ * main * *****************************************************************************/ +const char nessie_str[] PROGMEM = "nessie"; +const char test_str[] PROGMEM = "test"; +const char performance_str[] PROGMEM = "performance"; +const char echo_str[] PROGMEM = "echo"; + +cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_xtea}, + { test_str, NULL, testrun_nessie_xtea}, + { performance_str, NULL, testrun_performance_xtea}, + { echo_str, (void*)1, (void_fpt)echo_ctrl}, + { NULL, NULL, NULL} +}; + int main (void){ - char str[20]; DEBUG_INIT(); uart_putstr("\r\n"); - - uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - uart_putstr(cipher_name); - uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); - - PGM_P u = PSTR("nessie\0test\0performance\0"); - void_fpt v[] = {testrun_nessie_xtea, testrun_nessie_xtea, testrun_performance_xtea}; - - while(1){ - if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;} - if(execcommand_d0_P(str, u, v)<0){ - uart_putstr_P(PSTR("\r\nunknown command\r\n")); - } - continue; - error: - uart_putstr("ERROR\r\n"); + cli_rx = uart_getc; + cli_tx = uart_putc; + for(;;){ + uart_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); + uart_putstr(algo_name); + uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); + cmd_interface(cmdlist); } } diff --git a/test_src/nessie_bc_test.c b/test_src/nessie_bc_test.c index 70cd883..3d96c62 100644 --- a/test_src/nessie_bc_test.c +++ b/test_src/nessie_bc_test.c @@ -1,6 +1,6 @@ /* nessie_bc_test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify diff --git a/test_src/nessie_bc_test.h b/test_src/nessie_bc_test.h index 07e3954..a641f5a 100644 --- a/test_src/nessie_bc_test.h +++ b/test_src/nessie_bc_test.h @@ -1,6 +1,6 @@ /* nessie_bc_test.h */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify diff --git a/test_src/nessie_common.c b/test_src/nessie_common.c index 96967af..4a57465 100644 --- a/test_src/nessie_common.c +++ b/test_src/nessie_common.c @@ -1,6 +1,6 @@ /* nessie_common.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify diff --git a/test_src/nessie_common.h b/test_src/nessie_common.h index dcae12e..0d1754b 100644 --- a/test_src/nessie_common.h +++ b/test_src/nessie_common.h @@ -1,6 +1,6 @@ /* nessie_common.h */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify diff --git a/test_src/nessie_hash_test.c b/test_src/nessie_hash_test.c index dbb98a0..fccc176 100644 --- a/test_src/nessie_hash_test.c +++ b/test_src/nessie_hash_test.c @@ -1,6 +1,6 @@ /* nessie_hash_test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify diff --git a/test_src/nessie_hash_test.h b/test_src/nessie_hash_test.h index b18a1ab..eb9293d 100644 --- a/test_src/nessie_hash_test.h +++ b/test_src/nessie_hash_test.h @@ -1,6 +1,6 @@ /* nessie_hash_test.h */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify diff --git a/test_src/nessie_mac_test.c b/test_src/nessie_mac_test.c index e511e6f..ef4c0d8 100644 --- a/test_src/nessie_mac_test.c +++ b/test_src/nessie_mac_test.c @@ -1,6 +1,6 @@ /* nessie_mac_test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify diff --git a/test_src/nessie_mac_test.h b/test_src/nessie_mac_test.h index 571c032..94e6049 100644 --- a/test_src/nessie_mac_test.h +++ b/test_src/nessie_mac_test.h @@ -1,6 +1,6 @@ /* nessie_mac_test.h */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify diff --git a/test_src/nessie_stream_test.c b/test_src/nessie_stream_test.c index 9aecdbe..461f5cb 100644 --- a/test_src/nessie_stream_test.c +++ b/test_src/nessie_stream_test.c @@ -1,6 +1,6 @@ /* nessie_stream_test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify diff --git a/test_src/nessie_stream_test.h b/test_src/nessie_stream_test.h index a1065d4..116d11c 100644 --- a/test_src/nessie_stream_test.h +++ b/test_src/nessie_stream_test.h @@ -1,6 +1,6 @@ /* nessie_stream_test.h */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify diff --git a/test_src/performance_test.c b/test_src/performance_test.c index 9794e5b..e371a5f 100644 --- a/test_src/performance_test.c +++ b/test_src/performance_test.c @@ -1,6 +1,6 @@ /* performance_test.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify diff --git a/test_src/performance_test.h b/test_src/performance_test.h index 6c0d13c..5283b02 100644 --- a/test_src/performance_test.h +++ b/test_src/performance_test.h @@ -1,6 +1,6 @@ /* performance_test.h */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify diff --git a/test_src/serial-tools.c b/test_src/serial-tools.c index cb30433..7bfd25d 100644 --- a/test_src/serial-tools.c +++ b/test_src/serial-tools.c @@ -1,6 +1,6 @@ /* serial-tools.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify diff --git a/test_src/serial-tools.h b/test_src/serial-tools.h index 4de6f83..9dcf028 100644 --- a/test_src/serial-tools.h +++ b/test_src/serial-tools.h @@ -1,6 +1,6 @@ /* serial-tools.h */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify diff --git a/test_src/uart.c b/test_src/uart.c index 68ac4a6..8254211 100644 --- a/test_src/uart.c +++ b/test_src/uart.c @@ -1,6 +1,6 @@ /* uart.c */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify -- 2.39.5