]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - test_src/main-echo-test.c
fixing E-Mail-Address & Copyright
[avr-crypto-lib.git] / test_src / main-echo-test.c
index 8be0b7161cc6b7ab63aa3ba24c3dbfe34bf95394..49efba890d2bec24ef6b636a062b95a2a1c15a05 100644 (file)
@@ -1,7 +1,7 @@
 /* main-echo-test.c */
 /*
     This file is part of the AVR-Crypto-Lib.
-    Copyright (C) 2008  Daniel Otte (daniel.otte@rub.de)
+    Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org)
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
  *
 */
 
-#include "config.h"
-#include "uart_i.h"
-#include "debug.h"
+#include "main-test-common.h"
 
 #include "echo.h"
-#include "cli.h"
 #include "hfal_echo.h"
 #include "shavs.h"
 #include "nessie_hash_test.h"
 #include "hfal-performance.h"
 #include "hfal-test.h"
 
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
+char *algo_name = "Echo";
 
-char* algo_name = "CubeHash";
 
-
-const hfdesc_t* algolist[] PROGMEM = {
+const hfdesc_t *const algolist[] PROGMEM = {
        (hfdesc_t*)&echo224_desc,
        (hfdesc_t*)&echo256_desc,
+       (hfdesc_t*)&echo384_desc,
+       (hfdesc_t*)&echo512_desc,
        NULL
 };
 
@@ -52,7 +47,7 @@ const hfdesc_t* algolist[] PROGMEM = {
  *  additional validation-functions                                                                                     *
  *****************************************************************************/
 /* IntermediateKAT1_256.txt */
-uint8_t intermediate_data[] PROGMEM = {
+const uint8_t intermediate_data[] PROGMEM = {
        0xDB, 0x11, 0xF6, 0x09, 0xBA, 0xBA, 0x7B, 0x0C,
        0xA6, 0x34, 0x92, 0x6B, 0x1D, 0xD5, 0x39, 0xC8,
        0xCB, 0xAD, 0xA2, 0x49, 0x67, 0xD7, 0xAD, 0xD4,
@@ -77,6 +72,23 @@ uint8_t intermediate_data[] PROGMEM = {
        0xFD, 0x29, 0xD1, 0x04, 0xCE
        };
 
+const uint8_t intermediate_data2[] PROGMEM = {
+       0x75, 0x8E, 0xA3, 0xFE, 0xA7, 0x38, 0x97, 0x3D,
+       0xB0, 0xB8, 0xBE, 0x7E, 0x59, 0x9B, 0xBE, 0xF4,
+       0x51, 0x93, 0x73, 0xD6, 0xE6, 0xDC, 0xD7, 0x19,
+       0x5E, 0xA8, 0x85, 0xFC, 0x99, 0x1D, 0x89, 0x67,
+       0x62, 0x99, 0x27, 0x59, 0xC2, 0xA0, 0x90, 0x02,
+       0x91, 0x2F, 0xB0, 0x8E, 0x0C, 0xB5, 0xB7, 0x6F,
+       0x49, 0x16, 0x2A, 0xEB, 0x8C, 0xF8, 0x7B, 0x17,
+       0x2C, 0xF3, 0xAD, 0x19, 0x02, 0x53, 0xDF, 0x61,
+       0x2F, 0x77, 0xB1, 0xF0, 0xC5, 0x32, 0xE3, 0xB5,
+       0xFC, 0x99, 0xC2, 0xD3, 0x1F, 0x8F, 0x65, 0x01,
+       0x16, 0x95, 0xA0, 0x87, 0xA3, 0x5E, 0xE4, 0xEE,
+       0xE5, 0xE3, 0x34, 0xC3, 0x69, 0xD8, 0xEE, 0x5D,
+       0x29, 0xF6, 0x95, 0x81, 0x5D, 0x86, 0x6D, 0xA9,
+       0x9D, 0xF3, 0xF7, 0x94, 0x03
+};
+
 void echo256_interm(void){
        echo_small_ctx_t ctx;
        uint8_t data[1384/8];
@@ -91,6 +103,20 @@ void echo256_interm(void){
        cli_hexdump(hash, 32);
 }
 
+void echo512_interm(void){
+       echo_large_ctx_t ctx;
+       uint8_t data[872/8];
+       uint8_t hash[64];
+       echo512_init(&ctx);
+       memcpy_P(data, intermediate_data2, 872/8);
+       cli_putstr_P(PSTR("\r\ninit done "));
+       echo_large_lastBlock(&ctx, data, 872);
+       cli_putstr_P(PSTR("\r\nlastblock done "));
+       echo512_ctx2hash(hash, &ctx);
+       cli_putstr_P(PSTR("\r\nhash = "));
+       cli_hexdump(hash, 64);
+}
+
 void echo256_test0(void){
        echo_small_ctx_t ctx;
        uint8_t hash[32];
@@ -117,6 +143,7 @@ void testrun_nessie_echo(void){
 const char nessie_str[]      PROGMEM = "nessie";
 const char test256_str[]     PROGMEM = "test256";
 const char interm_str[]      PROGMEM = "interm";
+const char interm2_str[]     PROGMEM = "interm2";
 const char performance_str[] PROGMEM = "performance";
 const char echo_str[]        PROGMEM = "echo";
 const char shavs_list_str[]  PROGMEM = "shavs_list";
@@ -124,9 +151,10 @@ const char shavs_set_str[]   PROGMEM = "shavs_set";
 const char shavs_test1_str[] PROGMEM = "shavs_test1";
 const char shavs_test3_str[] PROGMEM = "shavs_test3";
 
-cmdlist_entry_t cmdlist[] PROGMEM = {
+const cmdlist_entry_t cmdlist[] PROGMEM = {
        { nessie_str,                NULL, testrun_nessie_echo         },
        { interm_str,                NULL, echo256_interm              },
+       { interm2_str,               NULL, echo512_interm              },
        { test256_str,               NULL, echo256_test0               },
        { performance_str,           NULL, performance_echo            },
        { shavs_list_str,            NULL, shavs_listalgos             },
@@ -138,20 +166,12 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 };
 
 int main (void){
-       DEBUG_INIT();
+    main_setup();
 
-       cli_rx = (cli_rx_fpt)uart0_getc;
-       cli_tx = (cli_tx_fpt)uart0_putc;
-       shavs_algolist=(hfdesc_t**)algolist;
+    shavs_algolist=(hfdesc_t**)algolist;
        shavs_algo=(hfdesc_t*)&echo256_desc;
        for(;;){
-               cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
-               cli_putstr(algo_name);
-               cli_putstr_P(PSTR("; "));
-               cli_putstr(__DATE__);
-               cli_putstr_P(PSTR(" "));
-               cli_putstr(__TIME__);
-               cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+           welcome_msg(algo_name);
 
                cmd_interface(cmdlist);
        }