]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - test_src/main-sha256-test.c
new hash function abstraction layer + shavs + dump util + ...
[avr-crypto-lib.git] / test_src / main-sha256-test.c
index 3fcacb6a7ee8ec4167dd39654c7917b6be031a36..6adb2ff520563a91382b1d02dc1bfe6478bb4f97 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
@@ -34,6 +34,9 @@
 #include <string.h>
 #include <stdlib.h>
 #include "cli.h"
+#include "shavs.h"
+#include "hfal_sha256.h"
+#include "dump.h"
 
 char* algo_name = "SHA-256";
 
@@ -102,26 +105,40 @@ 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";
+const char shavs_list_str[]  PROGMEM = "shavs_list";
+const char shavs_set_str[]   PROGMEM = "shavs_set";
+const char dump_str[]        PROGMEM = "dump";
+
+const hfdesc_t* algo_list[] PROGMEM = {
+       (hfdesc_t*)&sha256_desc,
+       NULL
+};
+
+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},
+       { shavs_list_str,      NULL, shavs_listalgos},
+       { shavs_set_str,   (void*)1, (void_fpt)shavs_setalgo},
+       { dump_str,        (void*)1, (void_fpt)dump},
+       { 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;             
+       algolist=algo_list;
+       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);
        }
 }
-