]> git.cryptolib.org Git - avr-crypto-lib.git/commitdiff
fixing bug in skein (asm); + new tools for hfal
authorbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Mon, 11 May 2009 11:57:10 +0000 (11:57 +0000)
committerbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Mon, 11 May 2009 11:57:10 +0000 (11:57 +0000)
15 files changed:
hfal-nessie.c [new file with mode: 0644]
hfal-nessie.h [new file with mode: 0644]
hfal-performance.c [new file with mode: 0644]
hfal-performance.h [new file with mode: 0644]
hfal-test.c [new file with mode: 0644]
hfal-test.h [new file with mode: 0644]
mkfiles/blake_c.mk
mkfiles/skein.mk
skein1024_asm.S
skein256_asm.S
skein512_asm.S
test_src/main-blake-test.c
test_src/main-skein-test.c
test_src/nessie_hash_test.c
test_src/nessie_hash_test.h

diff --git a/hfal-nessie.c b/hfal-nessie.c
new file mode 100644 (file)
index 0000000..7188d0e
--- /dev/null
@@ -0,0 +1,61 @@
+/* hfal-nessie.c */
+/*
+    This file is part of the AVR-Crypto-Lib.
+    Copyright (C) 2009  Daniel Otte (daniel.otte@rub.de)
+
+    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
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ * \file    hfal-nessie.c
+ * \author  Daniel Otte
+ * \email   daniel.otte@rub.de
+ * \date    2009-05-10
+ * \license GPLv3 or later
+ * 
+ */
+
+#include "nessie_hash_test.h"
+#include "hashfunction_descriptor.h"
+#include <stdint.h>
+#include <avr/pgmspace.h>
+
+void hfal_nessie(const hfdesc_t* hd){
+       if(pgm_read_byte(&(hd->type))!=HFDESC_TYPE_HASHFUNCTION)
+               return;
+       char name[1+strlen_P((void*)pgm_read_word(&(hd->name)))];
+       strcpy_P(name, (void*)pgm_read_word(&(hd->name)));
+       
+       nessie_hash_ctx.hashsize_b  = pgm_read_word(&(hd->hashsize_b));
+       nessie_hash_ctx.name = name;
+       nessie_hash_ctx.blocksize_B = pgm_read_word(&(hd->blocksize_b))/8;
+       nessie_hash_ctx.ctx_size_B  = pgm_read_word(&(hd->ctxsize_B));
+       nessie_hash_ctx.hash_init = (nessie_hash_init_fpt)pgm_read_word(&(hd->init));
+       nessie_hash_ctx.hash_next = (nessie_hash_next_fpt)pgm_read_word(&(hd->nextBlock));
+       nessie_hash_ctx.hash_last = (nessie_hash_last_fpt)pgm_read_word(&(hd->lastBlock));
+       nessie_hash_ctx.hash_conv = (nessie_hash_conv_fpt)pgm_read_word(&(hd->ctx2hash));
+       
+       nessie_hash_run();
+}
+
+void hfal_nessie_multiple(const hfdesc_t** hd_list){
+       const hfdesc_t* hd;
+       for(;;){
+               hd = (void*)pgm_read_word(hd_list);
+               if(!hd)
+                       return;
+               hfal_nessie(hd);
+               hd_list = (void*)((uint8_t*)hd_list + 2);
+       }
+}
+
diff --git a/hfal-nessie.h b/hfal-nessie.h
new file mode 100644 (file)
index 0000000..e9be131
--- /dev/null
@@ -0,0 +1,36 @@
+/* hfal-nessie.h */
+/*
+    This file is part of the AVR-Crypto-Lib.
+    Copyright (C) 2009  Daniel Otte (daniel.otte@rub.de)
+
+    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
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ * \file    hfal-nessie.h
+ * \author  Daniel Otte
+ * \email   daniel.otte@rub.de
+ * \date    2009-05-10
+ * \license GPLv3 or later
+ * 
+ */
+
+#ifndef HFAL_NESSIE_H_
+#define HFAL_NESSIE_H_
+
+#include "hashfunction_descriptor.h"
+
+void hfal_nessie(const hfdesc_t* hd);
+void hfal_nessie_multiple(const hfdesc_t** hd_list);
+
+#endif /* HFAL_NESSIE_H_ */
diff --git a/hfal-performance.c b/hfal-performance.c
new file mode 100644 (file)
index 0000000..391fac8
--- /dev/null
@@ -0,0 +1,108 @@
+/* hfal-performance.c */
+/*
+    This file is part of the AVR-Crypto-Lib.
+    Copyright (C) 2009  Daniel Otte (daniel.otte@rub.de)
+
+    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
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ * \file    hfal-performance.c
+ * \author  Daniel Otte
+ * \email   daniel.otte@rub.de
+ * \date    2009-05-10
+ * \license GPLv3 or later
+ * 
+ */
+
+#include "hfal-performance.h"
+#include "hashfunction_descriptor.h"
+#include "cli.h"
+#include "performance_test.h"
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <avr/pgmspace.h>
+
+
+static
+void printvalue(unsigned int v){
+       char str[20];
+       int i;
+       ultoa(v, str, 10);
+       for(i=0; i<10-strlen(str); ++i){
+               cli_putc(' ');
+       }
+       cli_putstr(str);
+}
+
+void hfal_performance(const hfdesc_t* hd){
+       hfdesc_t hf;
+       memcpy_P(&hf, hd, sizeof(hfdesc_t));
+       uint8_t ctx[hf.ctxsize_B];
+       uint8_t data[(hf.blocksize_b+7)/8];
+       uint8_t digest[(hf.hashsize_b+7)/8];
+       uint64_t t;
+       
+       if(hf.type!=HFDESC_TYPE_HASHFUNCTION)
+               return;
+       calibrateTimer();
+       cli_putstr_P(PSTR("\r\n\r\n === "));
+       cli_putstr_P(hf.name);
+       cli_putstr_P(PSTR(" performance === "
+                         "\r\n    hashsize (bits):    "));
+       printvalue(hf.hashsize_b);
+       
+       cli_putstr_P(PSTR("\r\n    ctxsize (bytes):    "));
+       printvalue(hf.ctxsize_B);
+       
+       cli_putstr_P(PSTR("\r\n    blocksize (bits):   "));
+       printvalue(hf.blocksize_b);
+       
+       startTimer(1);
+       hf.init(&ctx);
+       t = stopTimer();
+       cli_putstr_P(PSTR("\r\n    init (cycles):      "));
+       printvalue(t);
+       
+       startTimer(1);
+       hf.nextBlock(&ctx, data);
+       t = stopTimer();
+       cli_putstr_P(PSTR("\r\n    nextBlock (cycles): "));
+       printvalue(t);
+       
+       startTimer(1);
+       hf.lastBlock(&ctx, data, 0);
+       t = stopTimer();
+       cli_putstr_P(PSTR("\r\n    lastBlock (cycles): "));
+       printvalue(t);
+       
+       startTimer(1);
+       hf.ctx2hash(digest, &ctx);
+       t = stopTimer();
+       cli_putstr_P(PSTR("\r\n    ctx2hash (cycles):  "));
+       printvalue(t);
+}
+
+
+void hfal_performance_multiple(const hfdesc_t** hd_list){
+       const hfdesc_t* hd;
+       for(;;){
+               hd = (void*)pgm_read_word(hd_list);
+               if(!hd)
+                       return;
+               hfal_performance(hd);
+               hd_list = (void*)((uint8_t*)hd_list + 2);
+       }
+}
+
diff --git a/hfal-performance.h b/hfal-performance.h
new file mode 100644 (file)
index 0000000..65b0473
--- /dev/null
@@ -0,0 +1,35 @@
+/* hfal-performance.h */
+/*
+    This file is part of the AVR-Crypto-Lib.
+    Copyright (C) 2009  Daniel Otte (daniel.otte@rub.de)
+
+    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
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ * \file    hfal-performance.h
+ * \author  Daniel Otte
+ * \email   daniel.otte@rub.de
+ * \date    2009-05-10
+ * \license GPLv3 or later
+ * 
+ */
+
+#ifndef HFAL_PERFORMANCE_H_
+#define HFAL_PERFORMANCE_H_
+
+#include "hashfunction_descriptor.h"
+
+void hfal_performance(const hfdesc_t* hd);
+void hfal_performance_multiple(const hfdesc_t** hd_list);
+#endif /* HFAL_PERFORMANCE_H_ */
diff --git a/hfal-test.c b/hfal-test.c
new file mode 100644 (file)
index 0000000..2879331
--- /dev/null
@@ -0,0 +1,50 @@
+/* hfal-test.c */
+/*
+    This file is part of the AVR-Crypto-Lib.
+    Copyright (C) 2009  Daniel Otte (daniel.otte@rub.de)
+
+    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
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ * \file    hfal-test.c
+ * \author  Daniel Otte
+ * \email   daniel.otte@rub.de
+ * \date    2009-05-10
+ * \license GPLv3 or later
+ * 
+ */
+
+#include "nessie_hash_test.h"
+#include "hfal-basic.h"
+#include "hashfunction_descriptor.h"
+#include "cli.h"
+#include <stdint.h>
+#include <avr/pgmspace.h>
+
+void hfal_test(const hfdesc_t* hd, void* msg, uint32_t length_b){
+       if(pgm_read_byte(&(hd->type))!=HFDESC_TYPE_HASHFUNCTION)
+               return;
+       uint16_t dlen = (pgm_read_word(&(hd->hashsize_b))+7)/8;
+       uint8_t digest[dlen];
+       cli_putstr_P(PSTR("\r\n=== "));
+       cli_putstr_P((void*)pgm_read_word(&(hd->name)));
+       cli_putstr_P(PSTR(" ===\r\n message:"));
+       cli_hexdump_block(msg, (length_b+7)/8, 4, 16);
+       hfal_hash_mem(hd, digest, msg, length_b);
+       cli_putstr_P(PSTR(" \r\n digest:"));
+       cli_hexdump_block(digest, dlen, 4, 16);
+       cli_putstr_P(PSTR("\r\n"));
+}
+
+
diff --git a/hfal-test.h b/hfal-test.h
new file mode 100644 (file)
index 0000000..ac43338
--- /dev/null
@@ -0,0 +1,36 @@
+/* hfal-test.h */
+/*
+    This file is part of the AVR-Crypto-Lib.
+    Copyright (C) 2009  Daniel Otte (daniel.otte@rub.de)
+
+    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
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ * \file    hfal-test.h
+ * \author  Daniel Otte
+ * \email   daniel.otte@rub.de
+ * \date    2009-05-10
+ * \license GPLv3 or later
+ * 
+ */
+
+#ifndef HFAL_TEST_H_
+#define HFAL_TEST_H_
+
+#include "hashfunction_descriptor.h"
+#include <stdint.h>
+
+void hfal_test(const hfdesc_t* hd, void* msg, uint32_t length_b);
+
+#endif /* HFAL_TEST_H_ */
index f08fedfe3a089f0cfc44e22364f73e7a0e138257..4dc8349db9747396ea258f013ab8695913a2449f 100644 (file)
@@ -8,7 +8,8 @@ HASHES += $(ALGO_NAME)
 $(ALGO_NAME)_OBJ      := blake_small.o blake_large.o blake_common.o memxor.o
 $(ALGO_NAME)_TEST_BIN := main-blake-test.o debug.o uart.o hexdigit_tab.o  \
                          dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o \
-                        nessie_hash_test.o hfal-basic.o hfal_blake_small.o hfal_blake_large.o shavs.o
+                        nessie_hash_test.o hfal-basic.o hfal_blake_small.o hfal_blake_large.o \
+                        shavs.o hfal-nessie.o hfal-test.o hfal-performance.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
 $(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index 5b70c0ae5d2601f02b3a63abcb06fc077b94ce37..2e8851e4a91c69297999853a493bfb277c2eabaa 100644 (file)
@@ -11,7 +11,8 @@ $(ALGO_NAME)_OBJ      := threefish_mix.o \
                         threefish1024_enc_asm.o ubi1024_asm.o skein1024_asm.o
 $(ALGO_NAME)_TEST_BIN := main-skein-test.o debug.o uart.o hexdigit_tab.o  \
                          dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o \
-                         hfal-basic.o hfal_skein256.o hfal_skein512.o hfal_skein1024.o shavs.o
+                         hfal-basic.o hfal_skein256.o hfal_skein512.o hfal_skein1024.o shavs.o \
+                        hfal-performance.o hfal-nessie.o nessie_hash_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
 $(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index b78240035a4d1db257c1930609076c6e66034503..8983f6a2e539381b61bceeb93cce23cd499837e5 100644 (file)
@@ -237,7 +237,7 @@ skein1024_ctx2hash:
        dec r24
        brne 6b
        /* store new dest */
-       movw DEST0, r26
+       movw DEST0, r30
        /* adjust counter and outsize_b*/
        subi OUTSIZE_B1, 2
        movw r30, UCTX0
index b34540137819d0c1efaade4c11f35251f0152db4..97ef47226d1ba64e0291eb903830de062ea2350a 100644 (file)
@@ -228,7 +228,7 @@ skein256_ctx2hash:
        dec r24
        brne 6b
        /* store new dest */
-       movw DEST0, r26
+       movw DEST0, r30 ;XXX r26
        /* adjust counter and outsize_b*/
        dec OUTSIZE_B1
        movw r30, UCTX0
index 834e684e54b0a6d2ee7a22dc5df779d6de56250c..8f6229d9796a8344d752bea4e465158f47e8335a 100644 (file)
@@ -233,7 +233,7 @@ skein512_ctx2hash:
        dec r24
        brne 6b
        /* store new dest */
-       movw DEST0, r26
+       movw DEST0, r30
        /* adjust counter and outsize_b*/
        subi OUTSIZE_B1, 2
        movw r30, UCTX0
index 6fd492a6213699139273d94a6e882a7f4c3dc7cd..54f1902ac1a56a4455b114546f0b677bc7de7465 100644 (file)
@@ -30,6 +30,9 @@
 #include "blake_large.h"
 #include "hfal_blake_small.h"
 #include "hfal_blake_large.h"
+#include "hfal-nessie.h"
+#include "hfal-test.h"
+#include "hfal-performance.h"
 #include "shavs.h"
 #include "cli.h"
 #include "nessie_hash_test.h"
 
 char* algo_name = "Blake";
 
+
+const hfdesc_t* algolist[] PROGMEM = {
+       (hfdesc_t*)&blake28_desc,
+       (hfdesc_t*)&blake32_desc,
+       (hfdesc_t*)&blake48_desc,
+       (hfdesc_t*)&blake64_desc,
+       NULL
+};
+
 /*****************************************************************************
  *  additional validation-functions                                                                                     *
  *****************************************************************************/
 
 void testrun_nessie_blake(void){
-       nessie_hash_ctx.hashsize_b  = 224;
-       nessie_hash_ctx.name = "Blake28";
-       nessie_hash_ctx.blocksize_B = 512/8;
-       nessie_hash_ctx.ctx_size_B  = sizeof(blake28_ctx_t);
-       nessie_hash_ctx.hash_init = (nessie_hash_init_fpt)blake28_init;
-       nessie_hash_ctx.hash_next = (nessie_hash_next_fpt)blake28_nextBlock;
-       nessie_hash_ctx.hash_last = (nessie_hash_last_fpt)blake28_lastBlock;
-       nessie_hash_ctx.hash_conv = (nessie_hash_conv_fpt)blake28_ctx2hash;
-       
-       nessie_hash_run();
-       
-       nessie_hash_ctx.hashsize_b  = 256;
-       nessie_hash_ctx.name = "Blake32";
-       nessie_hash_ctx.blocksize_B = 512/8;
-       nessie_hash_ctx.ctx_size_B  = sizeof(blake32_ctx_t);
-       nessie_hash_ctx.hash_init = (nessie_hash_init_fpt)blake32_init;
-       nessie_hash_ctx.hash_next = (nessie_hash_next_fpt)blake32_nextBlock;
-       nessie_hash_ctx.hash_last = (nessie_hash_last_fpt)blake32_lastBlock;
-       nessie_hash_ctx.hash_conv = (nessie_hash_conv_fpt)blake32_ctx2hash;
-       
-       nessie_hash_run();
+       hfal_nessie_multiple(algolist);
 }
 void blake28_test(void* msg, uint32_t length_b){
-       uint8_t diggest[224/8];
-       cli_putstr_P(PSTR("\r\n=== Blake28 test ===\r\n message:\r\n"));
-       cli_hexdump_block(msg, (length_b+7)/8, 4, 16);
-       blake28(diggest, msg, length_b);
-       cli_putstr_P(PSTR("\r\n diggest:\r\n"));
-       cli_hexdump_block(diggest, 224/8, 4, 16);
+       hfal_test(&blake28_desc, msg, length_b);
 }
 
 void blake32_test(void* msg, uint32_t length_b){
-       uint8_t diggest[256/8];
-       cli_putstr_P(PSTR("\r\n=== Blake32 test ===\r\n message:\r\n"));
-       cli_hexdump_block(msg, (length_b+7)/8, 4, 16);
-       blake32(diggest, msg, length_b);
-       cli_putstr_P(PSTR("\r\n diggest:\r\n"));
-       cli_hexdump_block(diggest, 256/8, 4, 16);
+       hfal_test(&blake32_desc, msg, length_b);
 }
 
 void blake48_test(void* msg, uint32_t length_b){
-       uint8_t diggest[384/8];
-       cli_putstr_P(PSTR("\r\n=== Blake48 test ===\r\n message:\r\n"));
-       cli_hexdump_block(msg, (length_b+7)/8, 4, 16);
-       blake48(diggest, msg, length_b);
-       cli_putstr_P(PSTR("\r\n diggest:\r\n"));
-       cli_hexdump_block(diggest, 384/8, 4, 16);
+       hfal_test(&blake48_desc, msg, length_b);
 }
 
 void blake64_test(void* msg, uint32_t length_b){
-       uint8_t diggest[512/8];
-       cli_putstr_P(PSTR("\r\n=== Blake48 test ===\r\n message:\r\n"));
-       cli_hexdump_block(msg, (length_b+7)/8, 4, 16);
-       blake64(diggest, msg, length_b);
-       cli_putstr_P(PSTR("\r\n diggest:\r\n"));
-       cli_hexdump_block(diggest, 512/8, 4, 16);
+       hfal_test(&blake64_desc, msg, length_b);
 }
 void testrun_stdtest_blake(void){
        uint8_t msg1[144]; 
@@ -226,27 +198,25 @@ void performance_blake(void){
 
 }
 
+void autoperformance_blake(void){
+       hfal_performance_multiple(algolist);
+}
+
 /*****************************************************************************
  *  main                                                                                                                                        *
  *****************************************************************************/
 
-const hfdesc_t* algolist[] PROGMEM = {
-       (hfdesc_t*)&blake28_desc,
-       (hfdesc_t*)&blake32_desc,
-       (hfdesc_t*)&blake48_desc,
-       (hfdesc_t*)&blake64_desc,
-       NULL
-};
 
-const char nessie_str[]      PROGMEM = "nessie";
-const char test_str[]        PROGMEM = "test";
-const char testshort_str[]   PROGMEM = "short";
-const char testlshort_str[]  PROGMEM = "lshort";
-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 shavs_test1_str[] PROGMEM = "shavs_test1";
+const char nessie_str[]       PROGMEM = "nessie";
+const char test_str[]         PROGMEM = "test";
+const char testshort_str[]    PROGMEM = "short";
+const char testlshort_str[]   PROGMEM = "lshort";
+const char performance_str[]  PROGMEM = "performance";
+const char aperformance_str[] PROGMEM = "autoperformance";
+const char echo_str[]         PROGMEM = "echo";
+const char shavs_list_str[]   PROGMEM = "shavs_list";
+const char shavs_set_str[]    PROGMEM = "shavs_set";
+const char shavs_test1_str[]  PROGMEM = "shavs_test1";
 
 cmdlist_entry_t cmdlist[] PROGMEM = {
        { nessie_str,          NULL, testrun_nessie_blake},
@@ -254,6 +224,7 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
        { testshort_str,       NULL, testshort},
        { testlshort_str,      NULL, testlshort},
        { performance_str,     NULL, performance_blake},
+       { aperformance_str,    NULL, autoperformance_blake},
        { shavs_list_str,      NULL, shavs_listalgos},
        { shavs_set_str,   (void*)1, (void_fpt)shavs_setalgo},
        { shavs_test1_str,     NULL, shavs_test1},
index 4392314fd3fbfdca6067f5caa6e9561d82b24b90..0a44e34e7ff4f9c8efc6f92a40bde6e04f72f225 100644 (file)
 #include "hfal_skein1024.h"
 #include "cli.h"
 #include "shavs.h"
+#include "nessie_hash_test.h"
 #include "performance_test.h"
+#include "hfal-performance.h"
+#include "hfal-nessie.h"
+
 
 #include <stdint.h>
 #include <string.h>
 
 char* algo_name = "Skein";
 
+const hfdesc_t* algolist[] PROGMEM = {
+       (hfdesc_t*)&skein256_128_desc,
+       (hfdesc_t*)&skein256_160_desc,
+       (hfdesc_t*)&skein256_224_desc,
+       (hfdesc_t*)&skein256_256_desc,
+       (hfdesc_t*)&skein256_384_desc,
+       (hfdesc_t*)&skein256_512_desc,
+       
+       (hfdesc_t*)&skein512_128_desc,
+       (hfdesc_t*)&skein512_160_desc,
+       (hfdesc_t*)&skein512_224_desc,
+       (hfdesc_t*)&skein512_256_desc,
+       (hfdesc_t*)&skein512_384_desc,
+       (hfdesc_t*)&skein512_512_desc,
+       (hfdesc_t*)&skein512_1024_desc,
+       
+       (hfdesc_t*)&skein1024_128_desc,
+       (hfdesc_t*)&skein1024_160_desc,
+       (hfdesc_t*)&skein1024_224_desc,
+       (hfdesc_t*)&skein1024_256_desc,
+       (hfdesc_t*)&skein1024_384_desc,
+       (hfdesc_t*)&skein1024_512_desc,
+       (hfdesc_t*)&skein1024_1024_desc,
+       NULL
+};
+
 /*****************************************************************************
  *  additional validation-functions                                                                                     *
  *****************************************************************************/
@@ -175,6 +205,12 @@ void zeromsg_test_common(char* p){
 }
 
 void performance_skein(void){
+       hfal_performance_multiple(algolist);
+}
+
+void testrun_nessie_skein(void){
+       nessie_hash_quick = 1;
+       hfal_nessie_multiple(algolist);
 }
 
 
@@ -182,31 +218,6 @@ void performance_skein(void){
  *  main                                                                                                                                        *
  *****************************************************************************/
 
-const hfdesc_t* algolist[] PROGMEM = {
-       (hfdesc_t*)&skein256_128_desc,
-       (hfdesc_t*)&skein256_160_desc,
-       (hfdesc_t*)&skein256_224_desc,
-       (hfdesc_t*)&skein256_256_desc,
-       (hfdesc_t*)&skein256_384_desc,
-       (hfdesc_t*)&skein256_512_desc,
-       
-       (hfdesc_t*)&skein512_128_desc,
-       (hfdesc_t*)&skein512_160_desc,
-       (hfdesc_t*)&skein512_224_desc,
-       (hfdesc_t*)&skein512_256_desc,
-       (hfdesc_t*)&skein512_384_desc,
-       (hfdesc_t*)&skein512_512_desc,
-       (hfdesc_t*)&skein512_1024_desc,
-       
-       (hfdesc_t*)&skein1024_128_desc,
-       (hfdesc_t*)&skein1024_160_desc,
-       (hfdesc_t*)&skein1024_224_desc,
-       (hfdesc_t*)&skein1024_256_desc,
-       (hfdesc_t*)&skein1024_384_desc,
-       (hfdesc_t*)&skein1024_512_desc,
-       (hfdesc_t*)&skein1024_1024_desc,
-       NULL
-};
 
 const char nessie_str[]      PROGMEM = "nessie";
 const char test_str[]        PROGMEM = "test";
@@ -218,7 +229,7 @@ const char shavs_set_str[]   PROGMEM = "shavs_set";
 const char shavs_test1_str[] PROGMEM = "shavs_test1";
 
 cmdlist_entry_t cmdlist[] PROGMEM = {
-//     { nessie_str,          NULL, testrun_nessie_skein},
+       { nessie_str,          NULL, testrun_nessie_skein},
        { performance_str,     NULL, performance_skein},
        { test_str,            NULL, testrun_stdtest_skein},
        { ztest_str,       (void*)1, (void_fpt)zeromsg_test_common},
index 27df4c1d9cf5044bd99199d0b7016d74d594b1c7..04895b0c89e6f36683a40e2adcda97dde093fac2 100644 (file)
@@ -32,6 +32,7 @@
 #include "dbz_strings.h"
 
 nessie_hash_ctx_t nessie_hash_ctx;
+uint8_t           nessie_hash_quick=0;
 
 #define HASHSIZE_B ((nessie_hash_ctx.hashsize_b+7)/8)
 #define BLOCKSIZE_B (nessie_hash_ctx.blocksize_B)
@@ -185,6 +186,8 @@ void tv4_hash(void){
        nessie_hash_ctx.hash_last(ctx, block, n);
        nessie_hash_ctx.hash_conv(hash, ctx);
        nessie_print_item("hash", hash, (nessie_hash_ctx.hashsize_b+7)/8);
+       if(nessie_hash_quick)
+               return;
        for(i=1; i<100000L; ++i){ /* this assumes BLOCKSIZE >= HASHSIZE */
                nessie_hash_ctx.hash_init(ctx);
                nessie_hash_ctx.hash_last(ctx, hash, nessie_hash_ctx.hashsize_b);
@@ -242,7 +245,8 @@ void nessie_hash_run(void){
                ascii_hash_P(challange[2*i], challange[2*i+1]);
        }
        nessie_print_set_vector(set, i);
-       amillion_hash();
+       if(!nessie_hash_quick)
+               amillion_hash();
        /* test set 2 */
        set=2;
        nessie_print_setheader(set);
index a0cce84d18871f3a1f0099d134a54f0971944a18..c3bf13146c1e58f315ffad459b2cf7abeb00ffbf 100644 (file)
@@ -40,7 +40,7 @@ typedef struct nessie_hash_ctx_st{
 
 
 extern nessie_hash_ctx_t nessie_hash_ctx;
-
+extern uint8_t nessie_hash_quick;
 void nessie_hash_run(void);
 
 #endif /*NESSIE_HASH_TEST_H_*/