]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - test_src/nessie_hash_test.c
a lot of fixes
[avr-crypto-lib.git] / test_src / nessie_hash_test.c
index 27df4c1d9cf5044bd99199d0b7016d74d594b1c7..5dc117e31dc373e31f91ade30abb8bd1666f859d 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)
@@ -175,7 +176,7 @@ void tv4_hash(void){
        NESSIE_PUTC('0' + nessie_hash_ctx.hashsize_b%10);
 
        NESSIE_PUTSTR_P(PSTR(" zero bits"));
-       memset(block, 0, 256/8);
+       memset(block, 0, nessie_hash_ctx.hashsize_b/8);
        
        nessie_hash_ctx.hash_init(ctx);
        while(n>=nessie_hash_ctx.blocksize_B*8){
@@ -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);
@@ -212,7 +215,7 @@ void nessie_hash_run(void){
        
        nessie_print_header(nessie_hash_ctx.name, 0, 0, nessie_hash_ctx.hashsize_b, 0, 0);
        /* test set 1 */
-       char* challange_dbz= PSTR(
+       const char* challange_dbz= PSTR(
                  "\0"
                "\"\" (empty string)\0"
                  "a\0"
@@ -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);