]> git.cryptolib.org Git - avr-crypto-lib.git/commitdiff
new cli system
authorbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Fri, 30 Jan 2009 23:00:04 +0000 (23:00 +0000)
committerbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Fri, 30 Jan 2009 23:00:04 +0000 (23:00 +0000)
54 files changed:
config.h
host/gf256_table_gen.c
host/gf256mul.c
host/gf256mul.h
mkfiles/a5_1.mk
test_src/cli.c
test_src/cli.h
test_src/debug.c
test_src/main-a5_1-test.c
test_src/main-aes-test.c
test_src/main-arcfour-test.c
test_src/main-camellia-test.c
test_src/main-cast5-test.c
test_src/main-des-test.c
test_src/main-entropium-test.c
test_src/main-grain-test.c
test_src/main-hmac-sha1-test.c
test_src/main-hmac-sha256-test.c
test_src/main-md5-test.c
test_src/main-noekeon-test.c
test_src/main-omac-noekeon-test.c
test_src/main-present-test.c
test_src/main-rc5-test.c
test_src/main-rc6-test.c
test_src/main-seed-test.c
test_src/main-serpent-test.c
test_src/main-sha1-test.c
test_src/main-sha256-test.c
test_src/main-shabea-test.c
test_src/main-shacal1_enc-test.c
test_src/main-shacal2_enc-test.c
test_src/main-skipjack-test.c
test_src/main-tdes-test.c
test_src/main-trivium-test.c
test_src/main-twister224-test.c
test_src/main-twister256-test.c
test_src/main-twister384-test.c
test_src/main-twister512-test.c
test_src/main-xtea-test.c
test_src/nessie_bc_test.c
test_src/nessie_bc_test.h
test_src/nessie_common.c
test_src/nessie_common.h
test_src/nessie_hash_test.c
test_src/nessie_hash_test.h
test_src/nessie_mac_test.c
test_src/nessie_mac_test.h
test_src/nessie_stream_test.c
test_src/nessie_stream_test.h
test_src/performance_test.c
test_src/performance_test.h
test_src/serial-tools.c
test_src/serial-tools.h
test_src/uart.c

index 3997f59d792084fa5a41a9c3b0d582452cb1eaea..a813f10f71d048534167aa1aba631db596065963 100644 (file)
--- a/config.h
+++ b/config.h
@@ -20,7 +20,6 @@
 #define __CONFIG_H__
 #include <avr/io.h>
 
-
 #define F_CPU 16000000         /* Oszillator-Frequenz in Hz */
 // #define F_CPU    14745600
 
index a7512e7dd478c6917b53e8f4117729b957eddf2c..b3594116d95b78fb2260d19eb901fcf0ef3d452d 100644 (file)
@@ -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
index 46e7d24a7efc13574de418eac963d767fca8111b..b3dd4605a44b1bd7adcffe983b8b12556077ccf2 100644 (file)
@@ -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
index 50ede5efc90664d9d4e3dfb526da227a40f81846..8cfea1541021cc20f591ab8b13a9304ec0cb9895 100644 (file)
@@ -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
index 4305d0e9b6c889149e60ad067cf9fdb34e54127a..76692f0a563db79f9f395ba1f68d50846541ea84 100644 (file)
@@ -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"
 
index d702699f1f9b9e05cbd0e26bf39e2cd9c6265b91..47bd6adca27dd460cf01e22e237eb87cfbccdc4a 100644 (file)
@@ -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
  * 
  **/
  
+#include <stdlib.h> 
 #include <stdint.h>
+#include <ctype.h>
 #include <string.h>
 #include <avr/pgmspace.h>
+#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"
+                         " <command> - <params> - <address>\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<cli_buffer_index){
+                                               cli_tx(cli_buffer[old_idx++]);
+                                       }
+                               }
+                       }
+                       break;
+               default:
+                       completion_failed=0;
+                       if(cli_echo && cli_tx){
+                               cli_tx(c);
+                       }
+                       if(cli_buffer_index+1==cli_buffer_size){
+                               cli_buffer = realloc(cli_buffer, cli_buffer_size+=CLI_BUFFER_BS);
+                               if(!cli_buffer){
+                                       return -2;
+                               }
+                               memset(cli_buffer+cli_buffer_index+1, 0, CLI_BUFFER_BS);
+                       }
+                       cli_buffer[cli_buffer_index++] = c;
+               }
+       }
+}
+
+#endif
 
index bf92b186ce3aef37b75e38d763840e482bd570bd..182611d4e5170c823b0b60f73c343f9418df36ee 100644 (file)
@@ -1,6 +1,6 @@
 /* cli.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
 
 typedef void(*void_fpt)(void);
 
+#ifdef CLI_OLD
+
 int16_t findstring_d0(const char* str, const char* v);
 int16_t findstring_d0_P(const char* str, PGM_P v);
 
 int16_t execcommand_d0_P(const char* str, PGM_P v, void(*fpt[])(void) );
+
+#else
+
+typedef char (*cli_rx_fpt)(void);
+typedef void (*cli_tx_fpt)(char);
+
+#define CLI_BUFFER_BS 20
+
+typedef struct {
+       PGM_P      cmd_name;      /* string containing the function name */
+       PGM_P      cmd_param_str; /* param descriptor string */
+       void_fpt   cmd_function;  /* function pointer */
+} cmdlist_entry_t;
+
+extern cli_rx_fpt cli_rx;
+extern cli_tx_fpt cli_tx;
+extern uint8_t cli_echo;
+
+void echo_ctrl(char* s);
+int8_t cmd_interface(PGM_VOID_P cmd_desc);
+
+#endif
+
+
+
 #endif /*CLI_H_*/
index a9a52921792dda36ac11aec1176a7d9c5897c883..1e07451b8e3bb14b65d41f5f0eb6f3bf76142b43 100644 (file)
@@ -1,6 +1,6 @@
 /* debug.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
index 8b73b40279e51f4045029e822b50ad461b56006e..7afb223f81ae527b47367e82f077db415b304f95 100644 (file)
@@ -1,6 +1,6 @@
 /* main-a5_1-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,8 +31,9 @@
 
 #include <stdint.h>
 #include <string.h>
+#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);
+       }
        
 }
 
index ecb9ad2f45a11b5750a1d5ef281131a207f1985b..47ed45972a6d646f8d147156aec7c5a83a5805cf 100644 (file)
@@ -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 <stdint.h>
 #include <string.h>
 #include <stdlib.h>
+#include <avr/pgmspace.h>
 
-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);
        }
-       
 }
 
index 84fb9543e0bc61472bcc1678cadcb19de4139b85..f16c2db42344d66198e4c43a4b94841a51176d60 100644 (file)
@@ -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 <stdint.h>
 #include <string.h>
 
-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);
        }
-       
-       
 }
 
index b52cb09fae89d33e9e70c231e8841493b4ab3c5e..07191e4152bf2dc02eae565c17aba2bdf768fb6a 100644 (file)
@@ -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 <stdint.h>
@@ -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);
        }
 }
 
index 3cdb70355ac5665f59679c4f05cf7e8f2a9ae178..2dcc2aef7e63e327ceafe91394e0ed94b5360773 100644 (file)
@@ -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 <string.h>
 #include <stdlib.h>
 
-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);
        }
 }
-
index b421d352cb247df21aab1bd2d3a978e14e9feff4..349c2903d7152cf8090b2c1eb9844c9b363a8cd2 100644 (file)
@@ -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 <string.h>
 #include <stdlib.h>
 
-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);
        }
-       
 }
-
index df0bc744e9c9bf01d5cf1a16b05d8bd62d3a9938..3f62fb9e39252dce41f3adaf21e84a189377354e 100644 (file)
@@ -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 <string.h>
 #include <stdlib.h>
 
-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);
        }
-       
 }
-
index d09e0024d53a57d32a37cba70bbcb4628e1ec08e..036faad94490a06930f813491e2da0f7a57eaaf1 100644 (file)
@@ -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 <stdint.h>
 #include <string.h>
 
-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);
+       }
 }
-
-
-
index 4e248558de09784c49fbf82c1b84ad54e52ea441..74d331e4b6be8a970142709c2a888433319fd729 100644 (file)
@@ -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);
        }
-       
-       
 }
-
index 5d68ff5af4b11b3f7adfff3b49086e3756ea2f17..6d80d54022bab645070027bb7fde60d37c1cf1f9 100644 (file)
@@ -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);
        }
-       
 }
-
index c38414b28f387fdd6663e55a2b786422744cca0d..1ede35338319125983d2082df984b882abbb67ca 100644 (file)
@@ -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);
        }
 }
-
index ebe42f7324c2e4f90060288dfdd4f0c5a5f3efe9..1907c5e800f65706a6af7c41394343d6c5f7ab4b 100644 (file)
@@ -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 <string.h>
 #include <stdlib.h>
 
-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);
        }
-       
 }
-
index c05d23827fd14992d3c76374dadee6b30be0901b..fc5b731ce5d0dc37061bc3866c0011c58121745a 100644 (file)
@@ -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);
        }
-       
 }
-
index 03d456525fb4e073dac3a5981460a8f2d3395210..7f20922e6196e7b896ab2d17254c2886036921cb 100644 (file)
@@ -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 <stdint.h>
 #include <string.h>
 
-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);
        }
-       
 }
index 7a4c770c5a91872b48f9e2262a473d28bcc10bda..a81158a91503a554837635f861bc73757081a736 100644 (file)
@@ -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 <stdlib.h>
 
 #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);
        }
-       
 }
-
index 5e3dfef9d120aa7ecd7673c9a79415040fdfa942..0b1dc7bcf96a9ab866c5e083cfc2992d9d9f06b5 100644 (file)
@@ -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 <http://www.gnu.org/licenses/>.
 */
 /*
- * rc5 test-suit
+ * rc6 test-suit
  * 
 */
 
@@ -36,7 +36,7 @@
 #include <stdlib.h>
 
 #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);
        }
-       
 }
-
index 78b64fea8ecaac9eca9dab52134de1c6bf6761fe..8d264dccfef79d8ab5fdbb87ed2036ac7c16753b 100644 (file)
@@ -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 <string.h>
 #include <stdlib.h>
 
-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);
        }
-       
 }
-
index ea48b749cf62ec5ebd08a9fb3494122a7fcd84b5..ae8ad161ce049a1492d72199a569e0d4dfecf815 100644 (file)
@@ -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 <string.h>
 #include <stdlib.h>
 
-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);
        }
-       
 }
-
index e1c3139ef05d0d36fce65dd818fabd22f3eff34c..1ba4bf04bf311c8bcd9f6e9d715f7a61dd21ae1a 100644 (file)
@@ -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);
        }
 }
-
-
index 3fcacb6a7ee8ec4167dd39654c7917b6be031a36..a4ba9f9cdca777ed0c80108f07708d2cad19ca0c 100644 (file)
@@ -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);
        }
 }
-
index e7f006675ab4bdfdf254cf1d3bb2e2c8e237cbbd..ba78a7861bf7a04ea7dce1a8b7d92860a2c26021 100644 (file)
@@ -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 <string.h>
 #include <stdlib.h>
 
-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);
        }
-       
 }
-
index 6998d041b76a2a91ad2870b9763c6d21d7ed658a..b36ef867aceb882776598f5b7b86406db704f506 100644 (file)
@@ -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 <stdint.h>
 #include <string.h>
 
-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);
        }
-       
 }
index 2925e71843d270d7ef0e1874b44a33dabaec7d15..53fcc8ee243bdc0df42ddd1f65a93b41a1dc94a1 100644 (file)
@@ -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 <stdint.h>
 #include <string.h>
 
-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);
        }
-       
 }
index bb08986d8240c891527a4a07f825bbc04adae652..5a648b32bbd18c4e3752ff05491ceb61f85200e3 100644 (file)
@@ -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 <stdlib.h>
 
 
-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);
        }
-       
 }
-
index fbe7e004ba52fe4eb4d357817c3aa07a79495762..f32c972a58f24d637a1e9ad8a453c60bc8589723 100644 (file)
@@ -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 <string.h>
 #include <stdlib.h>
 
-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);
        }
-       
 }
-
index ad0f3856db625df28163926bc0ba99e87e35bc2c..13d00d7e872f9ab95ae0fe76bc9fbebe00085413 100644 (file)
@@ -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 <stdint.h>
 #include <string.h>
 
-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);
+       }
 }
index dbc58832d5da83bfc8bdf5032f47219909002551..d2e0a141b49925f128f427e7b9ec338aaf6900e1 100644 (file)
@@ -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);
        }
 }
-
index 25ae0896f8bc134b549d5fbe4d87c917be3c9804..2a54084b1d4333e404aabd7066f9609ff4ea35b9 100644 (file)
@@ -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);
        }
 }
-
index dcd0195c2745640d08ec2912407a24b0c72730c5..b913fa5fa4b89e9109f8e75942bf442c61f70406 100644 (file)
@@ -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);
        }
 }
-
index 8ec706cfc0842f955ba19359565155b034b34547..149abef17de2b2905ac1fab0613a0ae68e08a30a 100644 (file)
@@ -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);
        }
 }
-
index 94a2475683b563f08be374086aeb40e5fb9898fb..a1dfd029bf37caf0c542f7588b5499df0d724100 100644 (file)
@@ -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 <stdint.h>
 #include <string.h>
 
-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);
        }
 }
index 70cd883a65fa32df41ec2e1748f84c56d677653f..3d96c62f28fbd4738056cb2e94a55b67202ae517 100644 (file)
@@ -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
index 07e39541618c51c435c3267b9130350c1683f509..a641f5a5beb3b9babaa3f1b19f2e04d0e47f8d34 100644 (file)
@@ -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
index 96967afc1cc28a366da8c1fff518e80ded3edfbb..4a5746509a3c8b7aba43dfb5890804d0ff2e399b 100644 (file)
@@ -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
index dcae12eb07894715d10e0834ea245ff3d1d781f3..0d1754b96c9ce36d0d6592c3d85564a8022b91e5 100644 (file)
@@ -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
index dbb98a0781ad10df79680c646574a4f341838018..fccc1764fc3244b2f469955fb1b4a321fa5a6ddc 100644 (file)
@@ -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
index b18a1ab0d9e66cc1a277fedc559765783d9f680c..eb9293db6fde03f150829377af390641e7cafc21 100644 (file)
@@ -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
index e511e6febc9afe889f588aefc00255e5e60d4913..ef4c0d82c383aae3daa74b8e191e593a0b42ab47 100644 (file)
@@ -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
index 571c0325d4f00542b932fb37479f4546b8585020..94e6049c25148dce6f6b464dab3c947826a553f0 100644 (file)
@@ -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
index 9aecdbee3ba97ca29e968ed7467c0acc9485c3bd..461f5cbbc2e334778aba725f13823944470f3515 100644 (file)
@@ -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
index a1065d4db8f7dce965e6905a110e5cd42016085c..116d11cdaa0a273e5e3f37989a84934f179df72a 100644 (file)
@@ -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
index 9794e5bf46cf49205722cfdd154e7809da75f590..e371a5fc1c7951c0988a1bb5b211e5b48ae983d5 100644 (file)
@@ -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
index 6c0d13cc55df6c033a736945acc36409ab5ccd35..5283b02e6bc8e95926a994f19cced0b89f3a4faa 100644 (file)
@@ -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
index cb30433710ce5b9b596c7d427f360db5101645c0..7bfd25d747e4cea3c121368a7e9ece1db9bb0bdd 100644 (file)
@@ -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
index 4de6f8343141b3c70d7a1242dcd74111833bdbbf..9dcf0283fa072b4e39f162140eedfecc176a4621 100644 (file)
@@ -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
index 68ac4a646cfc3c24720209833ece132e5fc93e20..82542112260d897bc5b408bc83f57c62da788093 100644 (file)
@@ -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