]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - test_src/main-twister256-test.c
new cli system
[avr-crypto-lib.git] / test_src / main-twister256-test.c
index e6bb300a258b4a7c9c72446efb7e6feb626a802a..2a54084b1d4333e404aabd7066f9609ff4ea35b9 100644 (file)
@@ -1,6 +1,6 @@
 /* main-twister256-test.c */
 /*
-    This file is part of the Crypto-avr-lib/microcrypt-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
@@ -71,9 +71,14 @@ void testrun_nessie_twister256(void){
 }
 
 /*****************************************************************************
- *  self tests                                                                                                                          *
+ * selftests
+ *
  *****************************************************************************/
 
+void print_hash(void* hash){
+       uart_hexdump(hash, 256/8);
+}
+
 void testrun_twister256(void){
        twister256_hash_t hash;
        char* testv[]={
@@ -92,7 +97,7 @@ void testrun_twister256(void){
                uart_putstr(testv[i]);
                uart_putstr_P(PSTR("\") = \r\n\t"));
                twister256(&hash, testv[i], strlen(testv[i])*8);
-               uart_hexdump(hash, 256/8);
+               print_hash(hash);
        }
        
        uart_putstr_P(PSTR("\r\n\r\n=== TWISTER-256 test suit (short test values) ==="));
@@ -103,9 +108,10 @@ void testrun_twister256(void){
                uart_hexdump(&(stestv[i]), 1);
                uart_putstr_P(PSTR("\") = \r\n\t"));
                twister256(&hash, &(stestv[i]), stestl[i]);
-               uart_hexdump(hash, 256/8);
+               print_hash(hash);
        }
-
+       
+#ifdef TWISTER_LONGTEST
        uart_putstr_P(PSTR("\r\n\r\n=== TWISTER-256 test suit (long test) ==="));
        char* ltest= "abcdefghbcdefghicdefghijdefghijk"
                            "efghijklfghijklmghijklmnhijklmno"; 
@@ -118,7 +124,8 @@ void testrun_twister256(void){
                twister224_nextBlock(&ctx, ltest);
        }
        twister256_ctx2hash(hash, &ctx);
-       uart_hexdump(hash, 256/8);
+       print_hash(hash);
+#endif
 }
 
 
@@ -171,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);
        }
 }
-