]> git.cryptolib.org Git - avr-crypto-lib.git/commitdiff
fixing some warnings (AES); simplifyning AES headers (now simply include "aes.h"...
authorbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Sat, 28 Nov 2009 18:52:23 +0000 (18:52 +0000)
committerbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Sat, 28 Nov 2009 18:52:23 +0000 (18:52 +0000)
29 files changed:
aes/aes.h
aes/aes128_dec.h
aes/aes128_enc.h
aes/aes192_dec.h
aes/aes192_enc.h
aes/aes256_dec.h
aes/aes256_enc.h
aes/aes_dec.h
aes/aes_enc.h
aes/aes_keyschedule.c
aes/aes_keyschedule.h
aes/aes_types.h [new file with mode: 0644]
bmw/bmw_small.c
bmw/f0-opt-table.txt
config.h
debug.h
groestl/groestl_small.c
hfal-performance.c
host/shavs_test2.rb
test_src/config.h
test_src/debug.c
test_src/main-aes-test.c
test_src/main-aes128-test.c
test_src/main-aes192-test.c
test_src/main-aes256-test.c
test_src/main-groestl-test.c
test_src/performance_test.c
test_src/serial-tools.h [deleted file]
testport.conf

index 9d5b77087efed4dad22018ed795eceec26b9ca97..8e651f496d9d772864ba03cf47964232449c2692 100644 (file)
--- a/aes/aes.h
+++ b/aes/aes.h
 /**
  * \file     aes.h
  * \email    daniel.otte@rub.de
- * \author   Daniel Otte 
+ * \author   Daniel Otte
  * \date     2008-12-30
  * \license  GPLv3 or later
- * 
+ *
  */
 #ifndef AES_H_
 #define AES_H_
 
 #include <stdint.h>
 
-typedef struct{
-       uint8_t ks[16];
-} aes_roundkey_t;
-
-typedef struct{
-       aes_roundkey_t key[10+1];
-} aes128_ctx_t;
-
-typedef struct{
-       aes_roundkey_t key[12+1];
-} aes192_ctx_t;
-
-typedef struct{
-       aes_roundkey_t key[14+1];
-} aes256_ctx_t;
-
-typedef struct{
-       aes_roundkey_t key[1]; /* just to avoid the warning */
-} aes_genctx_t;
-
-typedef struct{
-       uint8_t s[16];
-} aes_cipher_state_t;
+#include "aes_types.h"
+#include "aes128_enc.h"
+#include "aes192_enc.h"
+#include "aes256_enc.h"
+#include "aes128_dec.h"
+#include "aes192_dec.h"
+#include "aes256_dec.h"
+#include "aes_enc.h"
+#include "aes_dec.h"
+#include "aes_keyschedule.h"
 
 #endif
index f6015d8cc05e7a5062900cc26877a3892677f9d3..b5df9df702ae3c5f3ed8d17d7f8a4c0a9e8fe697 100644 (file)
@@ -19,7 +19,7 @@
 /**
  * \file     aes128_dec.h
  * \email    daniel.otte@rub.de
- * \author   Daniel Otte 
+ * \author   Daniel Otte
  * \date     2008-12-30
  * \license  GPLv3 or later
  * \ingroup  AES
 #ifndef AES128_DEC_H_
 #define AES128_DEC_H_
 
-#include "aes.h"
+#include "aes_types.h"
 #include "aes_dec.h"
 
-/** \fn void aes128_dec(void* buffer, aes128_ctx_t* ctx)
+/**
  * \brief decrypt with 128 bit key.
- * 
+ *
  * This function decrypts one block with the AES algorithm under control of
  * a keyschedule produced from a 128 bit key.
  * \param buffer pointer to the block to decrypt
- * \param ctx    pointer to the key schedule 
+ * \param ctx    pointer to the key schedule
  */
 void aes128_dec(void* buffer, aes128_ctx_t* ctx);
 
index 5cb49539ea6121998832111001c21569d9a71329..98a8cc21c8f1e08ad616617a9f36d20822601a2b 100644 (file)
@@ -19,7 +19,7 @@
 /**
  * \file     aes128_enc.h
  * \email    daniel.otte@rub.de
- * \author   Daniel Otte 
+ * \author   Daniel Otte
  * \date     2008-12-30
  * \license  GPLv3 or later
  * \ingroup  AES
 #ifndef AES128_ENC_H_
 #define AES128_ENC_H_
 
-#include "aes.h"
+#include "aes_types.h"
 #include "aes_enc.h"
 
 
-/** \fn void aes128_enc(void* buffer, aes128_ctx_t* ctx)
+/**
  * \brief encrypt with 128 bit key.
- * 
+ *
  * This function encrypts one block with the AES algorithm under control of
  * a keyschedule produced from a 128 bit key.
  * \param buffer pointer to the block to encrypt
- * \param ctx    pointer to the key schedule 
+ * \param ctx    pointer to the key schedule
  */
 void aes128_enc(void* buffer, aes128_ctx_t* ctx);
 
index 299edf9f75ebda8234aeadf3f69127687e30731b..577ab44fa97ad3c7d5bca0834e82fac37604811b 100644 (file)
@@ -19,7 +19,7 @@
 /**
  * \file     aes192_dec.h
  * \email    daniel.otte@rub.de
- * \author   Daniel Otte 
+ * \author   Daniel Otte
  * \date     2008-12-31
  * \license  GPLv3 or later
  * \ingroup  AES
 #ifndef AES192_DEC_H_
 #define AES192_DEC_H_
 
-#include "aes.h"
+#include "aes_types.h"
 #include "aes_dec.h"
 
-/** \fn void aes192_dec(void* buffer, aes192_ctx_t* ctx)
+/**
  * \brief decrypt with 192 bit key.
- * 
+ *
  * This function decrypts one block with the AES algorithm under control of
  * a keyschedule produced from a 192 bit key.
  * \param buffer pointer to the block to decrypt
- * \param ctx    pointer to the key schedule 
+ * \param ctx    pointer to the key schedule
  */
 void aes192_dec(void* buffer, aes192_ctx_t* ctx);
 
index 30b79ece34d6855094dc0fadabb77eed3d9b4d58..1c39aa02cdbe77f4ea03c10e3bf0191e826a7c25 100644 (file)
@@ -19,7 +19,7 @@
 /**
  * \file     aes192_enc.h
  * \email    daniel.otte@rub.de
- * \author   Daniel Otte 
+ * \author   Daniel Otte
  * \date     2008-12-31
  * \license  GPLv3 or later
  * \ingroup  AES
 #ifndef AES192_ENC_H_
 #define AES192_ENC_H_
 
-#include "aes.h"
+#include "aes_types.h"
 #include "aes_enc.h"
 
 
-/** \fn void aes192_enc(void* buffer, aes192_ctx_t* ctx)
+/**
  * \brief encrypt with 192 bit key.
- * 
+ *
  * This function encrypts one block with the AES algorithm under control of
  * a keyschedule produced from a 192 bit key.
  * \param buffer pointer to the block to encrypt
- * \param ctx    pointer to the key schedule 
+ * \param ctx    pointer to the key schedule
  */
 void aes192_enc(void* buffer, aes192_ctx_t* ctx);
 
index 3c77c7b5e1dc72448df624cd710044138450bf64..14b8a0a22aaf64c12a1b0c423ebfa469587973f5 100644 (file)
@@ -19,7 +19,7 @@
 /**
  * \file     aes256_dec.h
  * \email    daniel.otte@rub.de
- * \author   Daniel Otte 
+ * \author   Daniel Otte
  * \date     2008-12-31
  * \license  GPLv3 or later
  * \ingroup  AES
 #ifndef AES256_DEC_H_
 #define AES256_DEC_H_
 
-#include "aes.h"
+#include "aes_types.h"
 #include "aes_dec.h"
 
-/** \fn void aes256_dec(void* buffer, aes256_ctx_t* ctx)
+/**
  * \brief decrypt with 256 bit key.
- * 
+ *
  * This function decrypts one block with the AES algorithm under control of
  * a keyschedule produced from a 256 bit key.
  * \param buffer pointer to the block to decrypt
- * \param ctx    pointer to the key schedule 
+ * \param ctx    pointer to the key schedule
  */
 void aes256_dec(void* buffer, aes256_ctx_t* ctx);
 
index b42b0f3e23af3564661dc562a770a4847d0f591a..a890cd3e9ac191cb79cd0c73591b96ed2176cc2a 100644 (file)
@@ -19,7 +19,7 @@
 /**
  * \file     aes256_enc.h
  * \email    daniel.otte@rub.de
- * \author   Daniel Otte 
+ * \author   Daniel Otte
  * \date     2008-12-31
  * \license  GPLv3 or later
  * \ingroup  AES
 #ifndef AES256_ENC_H_
 #define AES256_ENC_H_
 
-#include "aes.h"
+#include "aes_types.h"
 #include "aes_enc.h"
 
 
-/** \fn void aes256_enc(void* buffer, aes256_ctx_t* ctx)
+/**
  * \brief encrypt with 256 bit key.
- * 
+ *
  * This function encrypts one block with the AES algorithm under control of
  * a keyschedule produced from a 256 bit key.
  * \param buffer pointer to the block to encrypt
- * \param ctx    pointer to the key schedule 
+ * \param ctx    pointer to the key schedule
  */
 void aes256_enc(void* buffer, aes256_ctx_t* ctx);
 
index 631d95377b7f3e933551564facf37c7de50f8865..0517bd910a2bf4909c246a17816753762885866e 100644 (file)
 /**
  * \file     aes_dec.h
  * \email    daniel.otte@rub.de
- * \author   Daniel Otte 
+ * \author   Daniel Otte
  * \date     2008-12-30
  * \license  GPLv3 or later
- * 
+ *
  */
 #ifndef AES_DEC_H_
 #define AES_DEC_H_
-#include "aes.h"
+#include "aes_types.h"
 #include <stdint.h>
 
 
index f3c4dfab1da005beddded25f99e92db4b350999b..fb25764a181a1e8e7552b381a82f9a6c807c579b 100644 (file)
 /**
  * \file     aes_enc.h
  * \email    daniel.otte@rub.de
- * \author   Daniel Otte 
+ * \author   Daniel Otte
  * \date     2008-12-30
  * \license  GPLv3 or later
- * 
+ *
  */
 #ifndef AES_ENC_H_
 #define AES_ENC_H_
-#include "aes.h"
+#include "aes_types.h"
 #include <stdint.h>
 
 
index 9e58eb578320de6ae738aa34cad0b521d487fb3a..9225323a6082aa687321cddc8f8dd89379634e05 100644 (file)
 /**
  * \file     aes_keyschedule.c
  * \email    daniel.otte@rub.de
- * \author   Daniel Otte 
+ * \author   Daniel Otte
  * \date     2008-12-30
  * \license  GPLv3 or later
- * 
+ *
  */
 
 #include <stdint.h>
@@ -49,32 +49,35 @@ uint8_t rc_tab[] PROGMEM = { 0x01, 0x02, 0x04, 0x08,
 void aes_init(const void* key, uint16_t keysize_b, aes_genctx_t* ctx){
        uint8_t hi,i,nk, next_nk;
        uint8_t rc=0;
-       uint8_t tmp[4];
+       union {
+               uint32_t v32;
+               uint8_t  v8[4];
+       } tmp;
        nk=keysize_b>>5; /* 4, 6, 8 */
        hi=4*(nk+6+1);
        memcpy(ctx, key, keysize_b/8);
        next_nk = nk;
        for(i=nk;i<hi;++i){
-               *((uint32_t*)tmp) = ((uint32_t*)(ctx->key[0].ks))[i-1];
+               tmp.v32 = ((uint32_t*)(ctx->key[0].ks))[i-1];
                if(i!=next_nk){
                        if(nk==8 && i%8==4){
-                               tmp[0] = pgm_read_byte(aes_sbox+tmp[0]);
-                               tmp[1] = pgm_read_byte(aes_sbox+tmp[1]);
-                               tmp[2] = pgm_read_byte(aes_sbox+tmp[2]);
-                               tmp[3] = pgm_read_byte(aes_sbox+tmp[3]);
+                               tmp.v8[0] = pgm_read_byte(aes_sbox+tmp.v8[0]);
+                               tmp.v8[1] = pgm_read_byte(aes_sbox+tmp.v8[1]);
+                               tmp.v8[2] = pgm_read_byte(aes_sbox+tmp.v8[2]);
+                               tmp.v8[3] = pgm_read_byte(aes_sbox+tmp.v8[3]);
                        }
                } else {
                        next_nk += nk;
-                       aes_rotword(tmp);
-                       tmp[0] = pgm_read_byte(aes_sbox+tmp[0]);
-                       tmp[1] = pgm_read_byte(aes_sbox+tmp[1]);
-                       tmp[2] = pgm_read_byte(aes_sbox+tmp[2]);
-                       tmp[3] = pgm_read_byte(aes_sbox+tmp[3]);
-                       tmp[0] ^= pgm_read_byte(rc_tab+rc);
+                       aes_rotword(&(tmp.v32));
+                       tmp.v8[0] = pgm_read_byte(aes_sbox+tmp.v8[0]);
+                       tmp.v8[1] = pgm_read_byte(aes_sbox+tmp.v8[1]);
+                       tmp.v8[2] = pgm_read_byte(aes_sbox+tmp.v8[2]);
+                       tmp.v8[3] = pgm_read_byte(aes_sbox+tmp.v8[3]);
+                       tmp.v8[0] ^= pgm_read_byte(rc_tab+rc);
                        rc++;
                }
                ((uint32_t*)(ctx->key[0].ks))[i] = ((uint32_t*)(ctx->key[0].ks))[i-nk]
-                                                  ^ *((uint32_t*)tmp);
+                                                  ^ tmp.v32;
        }
 }
 
index b013971df759b2b74f26d5c40c6e6bedeed94f5b..ab5786ab602bb1d706df99109b7078a513e8d8a3 100644 (file)
@@ -19,7 +19,7 @@
 /**
  * \file     aes_keyschedule.h
  * \email    daniel.otte@rub.de
- * \author   Daniel Otte 
+ * \author   Daniel Otte
  * \date     2008-12-30
  * \license  GPLv3 or later
  * \ingroup  AES
 #ifndef AES_KEYSCHEDULE_H_
 #define AES_KEYSCHEDULE_H_
 
-#include "aes.h"
-/** \fn void aes_init(const void* key, uint16_t keysize_b, aes_genctx_t* ctx)
+#include "aes_types.h"
+/**
  * \brief initialize the keyschedule
- * 
+ *
  * This function computes the keyschedule from a given key with a given length
  * and stores it in the context variable
  * \param key       pointer to the key material
@@ -41,9 +41,9 @@
  */
 void aes_init(const void* key, uint16_t keysize_b, aes_genctx_t* ctx);
 
-/** \fn void aes128_init(const void* key, aes128_ctx_t* ctx)
+/**
  * \brief initialize the keyschedule for 128 bit key
- * 
+ *
  * This function computes the keyschedule from a given 128 bit key
  * and stores it in the context variable
  * \param key       pointer to the key material
@@ -51,9 +51,9 @@ void aes_init(const void* key, uint16_t keysize_b, aes_genctx_t* ctx);
  */
 void aes128_init(const void* key, aes128_ctx_t* ctx);
 
-/** \fn void aes192_init(const void* key, aes192_ctx_t* ctx)
+/**
  * \brief initialize the keyschedule for 192 bit key
- * 
+ *
  * This function computes the keyschedule from a given 192 bit key
  * and stores it in the context variable
  * \param key       pointer to the key material
@@ -61,9 +61,9 @@ void aes128_init(const void* key, aes128_ctx_t* ctx);
  */
 void aes192_init(const void* key, aes192_ctx_t* ctx);
 
-/** \fn void aes256_init(const void* key, aes256_ctx_t* ctx)
+/**
  * \brief initialize the keyschedule for 256 bit key
- * 
+ *
  * This function computes the keyschedule from a given 256 bit key
  * and stores it in the context variable
  * \param key       pointer to the key material
@@ -72,4 +72,4 @@ void aes192_init(const void* key, aes192_ctx_t* ctx);
 void aes256_init(const void* key, aes256_ctx_t* ctx);
 
 #endif /* AES_KEYSCHEDULE_H_ */
-       
+
diff --git a/aes/aes_types.h b/aes/aes_types.h
new file mode 100644 (file)
index 0000000..d69dd9f
--- /dev/null
@@ -0,0 +1,56 @@
+/* aes.h */
+/*
+    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
+    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     aes_types.h
+ * \email    daniel.otte@rub.de
+ * \author   Daniel Otte
+ * \date     2008-12-30
+ * \license  GPLv3 or later
+ *
+ */
+#ifndef AES_TYPES_H_
+#define AES_TYPES_H_
+
+#include <stdint.h>
+
+typedef struct{
+       uint8_t ks[16];
+} aes_roundkey_t;
+
+typedef struct{
+       aes_roundkey_t key[10+1];
+} aes128_ctx_t;
+
+typedef struct{
+       aes_roundkey_t key[12+1];
+} aes192_ctx_t;
+
+typedef struct{
+       aes_roundkey_t key[14+1];
+} aes256_ctx_t;
+
+typedef struct{
+       aes_roundkey_t key[1]; /* just to avoid the warning */
+} aes_genctx_t;
+
+typedef struct{
+       uint8_t s[16];
+} aes_cipher_state_t;
+
+#endif
index c9a011c8e7962d0d3cb2ab3766a32768c96bd6be..9f9393562e42fd5a3ef789f866b70ed4e4c123d6 100644 (file)
@@ -213,24 +213,25 @@ uint32_t k_lut[] PROGMEM = {
 static
 uint32_t bmw_small_expand1(uint8_t j, const uint32_t* q, const void* m, const void* h){
        uint32_t(*s[])(uint32_t) = {bmw_small_s1, bmw_small_s2, bmw_small_s3, bmw_small_s0};
-       uint32_t r=0;
+       uint32_t r;
        uint8_t i;
        /* r = 0x05555555*(j+16); */
-       for(i=0; i<16; ++i){
-               r += s[i%4](q[j+i]);
-       }
+
 #if TWEAK
-       r += (   ROTL32(((uint32_t*)m)[j&0xf],      ((j+0)&0xf)+1  )
+       r = (   ROTL32(((uint32_t*)m)[j&0xf],      ((j+0)&0xf)+1  )
               + ROTL32(((uint32_t*)m)[(j+3)&0xf],  ((j+3)&0xf)+1  )
               - ROTL32(((uint32_t*)m)[(j+10)&0xf], ((j+10)&0xf)+1 )
               + pgm_read_dword(k_lut+j)
             ) ^ ((uint32_t*)h)[(j+7)&0xf];
 #else
-       r += pgm_read_dword(k_lut+j);
+       r = pgm_read_dword(k_lut+j);
        r += ((uint32_t*)m)[j&0xf];
        r += ((uint32_t*)m)[(j+3)&0xf];
        r -= ((uint32_t*)m)[(j+10)&0xf];
 #endif
+       for(i=0; i<16; ++i){
+               r += s[i%4](q[j+i]);
+       }
        return r;
 }
 
index a9756443b484c858b3e66d77766aba3154eb5a76..a35e6adf8a440f552001f60ce678627208b7c50f 100644 (file)
@@ -1,3 +1,5 @@
+
+
        q[ 0] = (+ h[ 5] - h[ 7] + h[10] + h[13] + h[14]);
        q[ 1] = (+ h[ 6] - h[ 8] + h[11] + h[14] - h[15]);
        q[ 2] = (+ h[ 7] + h[ 9] - h[12] + h[15] + h[ 0]);
index 76debe5b46192c0a62abc180db96ae4cb0c2c5b2..04c8cd2531b580a084dee1679d91ba1846ea40b8 100644 (file)
--- a/config.h
+++ b/config.h
 #define __CONFIG_H__
 #include <avr/io.h>
 // #define F_CPU 20000000
- #define F_CPU 16000000         /* Oszillator-Frequenz in Hz */
+// #define F_CPU 16000000         /* oscillator-frequency in Hz */
 // #define F_CPU 14745600
+#define F_CPU 20000000 /* this is out of spec but lets try it */
 
+#define DEBUG_METHOD uart
 
 #include "uart_defs.h"
 
-#define DEBUG uart
-
-#undef UART_LEDS
-
 #define UART0_I 1
 #define UART0_BAUD_RATE  38400
 #define UART0_PARATY     UART_PARATY_NONE
diff --git a/debug.h b/debug.h
index acc0a09f37d313ff17c419b708cddd36632d3e6f..76ef0ce4094264c6f32d22d3998faba903b93c8c 100644 (file)
--- a/debug.h
+++ b/debug.h
@@ -19,7 +19,7 @@
 #ifndef DEBUG_H_
 #define DEBUG_H_
 
-#ifdef DEBUG
+#ifdef DEBUG_METHOD
        #define DEBUG_INIT() debug_init()
        #define DEBUG_C(_c) debug_char(_c)
        #define DEBUG_S(_s) debug_str(_s)
index e5a3d9422393761add7bd59f0f6ac2b5b658d449..44ab7eec8447de2cf5edd701ff8ec71ac86ec82a 100644 (file)
@@ -22,7 +22,7 @@
  * \email   daniel.otte@rub.de
  * \date    2009-05-19
  * \license GPLv3 or later
- * 
+ *
  */
 
 #include "groestl_small.h"
@@ -74,7 +74,7 @@ void groestl_small_rounds(uint8_t *m, uint8_t q){
                }else{
                        m[0] ^= r;
                }
-#if DEBUG              
+#if DEBUG
                if(r<2){
                        cli_putstr_P(PSTR("\r\npost add-const"));
                        dump_m(m);
@@ -90,12 +90,12 @@ void groestl_small_rounds(uint8_t *m, uint8_t q){
                                m[i+((j-i+8)%8)*8] = tmp[j];
                        }
                }
-#if DEBUG              
+#if DEBUG
                if(r<2){
                        cli_putstr_P(PSTR("\r\npost shift-bytes"));
                        dump_m(m);
                }
-#endif                 
+#endif
                for(i=0; i<8; ++i){
                        memcpy(tmp, m+8*i, 8);
                        for(j=0; j<8; ++j){
@@ -114,20 +114,20 @@ void groestl_small_rounds(uint8_t *m, uint8_t q){
                        cli_putstr_P(PSTR("\r\npost mix-bytes"));
                        dump_m(m);
                }
-#endif         
+#endif
        }
 }
 
 void groestl224_init(groestl224_ctx_t* ctx){
        memset(ctx->h, 0, 8*8);
        ctx->h[8*8-1] = 224;
-       ctx->counter = 0;
+       ctx->counter = 1;
 }
 
 void groestl256_init(groestl256_ctx_t* ctx){
        memset(ctx->h, 0, 8*8);
        ctx->h[8*8-2] = 1;
-       ctx->counter = 0;
+       ctx->counter = 1;
 }
 
 void groestl_small_nextBlock(groestl_small_ctx_t* ctx, const void* block){
@@ -137,7 +137,7 @@ void groestl_small_nextBlock(groestl_small_ctx_t* ctx, const void* block){
                        tmp1[j*8+i] = ((uint8_t*)block)[i*8+j];
                }
        }
-*/ 
+*/
        memcpy(tmp1, block, 64);
        memcpy(tmp2, tmp1, 64);
        memxor(tmp1, ctx->h, 64);
@@ -157,12 +157,12 @@ void groestl_small_lastBlock(groestl_small_ctx_t* ctx, const void* block, uint16
        }
        memset(buffer, 0, 64);
        memcpy(buffer, block, (length_b+7)/8);
-       buffer[length_b/8] |= 0x80>>(length_b%8);
+       buffer[length_b/8] |= 0x80>>(length_b&0x7);
        if(length_b>512-65){
                groestl_small_nextBlock(ctx, buffer);
                memset(buffer, 0, 64-4);
        }
-       ctx->counter++;
+//     ctx->counter++;
        buffer[64-1]  = (uint8_t)(ctx->counter);
        buffer[64-2]  = (uint8_t)((ctx->counter)>>8);
        buffer[64-3]  = (uint8_t)((ctx->counter)>>16);
@@ -178,7 +178,7 @@ void groestl_small_ctx2hash(void* dest, const groestl_small_ctx_t* ctx, uint16_t
 #if DEBUG
        cli_putstr_P(PSTR("\r\npost finalisation"));
        dump_m(tmp);
-#endif         
+#endif
        memcpy(dest, tmp+64-outlength_b/8, outlength_b/8);
 }
 
index e9ec7707a427141ea1d78ec33e840b2183918964..70f2ef15eb37ed2736669bcef2c5f69b37370db2 100644 (file)
@@ -22,7 +22,7 @@
  * \email   daniel.otte@rub.de
  * \date    2009-05-10
  * \license GPLv3 or later
- * 
+ *
  */
 
 #include "hfal-performance.h"
@@ -53,23 +53,24 @@ void hfal_performance(const hfdesc_t* hd){
        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();
+       print_overhead();
        cli_putstr_P(PSTR("\r\n\r\n === "));
        cli_putstr_P(hf.name);
        cli_putstr_P(PSTR(" performance === "
                          "\r\n    type:             hashfunction"
                          "\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(0);
        START_TIMER;
        hf.init(&ctx);
@@ -77,7 +78,7 @@ void hfal_performance(const hfdesc_t* hd){
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n    init (cycles):      "));
        printvalue(t);
-       
+
        startTimer(0);
        START_TIMER;
        hf.nextBlock(&ctx, data);
@@ -85,7 +86,7 @@ void hfal_performance(const hfdesc_t* hd){
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n    nextBlock (cycles): "));
        printvalue(t);
-       
+
        startTimer(0);
        START_TIMER;
        hf.lastBlock(&ctx, data, 0);
@@ -93,7 +94,7 @@ void hfal_performance(const hfdesc_t* hd){
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n    lastBlock (cycles): "));
        printvalue(t);
-       
+
        startTimer(0);
        START_TIMER;
        hf.ctx2hash(digest, &ctx);
index ad242f4445b81a671b190666e573a89c51248085..863fb845ca164829f15fe6ed227379aac5927581 100644 (file)
@@ -25,8 +25,12 @@ require 'serialport'
 require 'getopt/std'
 
 $buffer_size = 0
+$conffile_check = Hash.new
+$conffile_check.default = 0
 
 def readconfigfile(fname, conf)
+  return conf if $conffile_check[fname]==1
+  $conffile_check[fname]=1
   section = "default"
   if not File.exists?(fname)
     return conf
@@ -42,7 +46,11 @@ def readconfigfile(fname, conf)
        end
        next if not /=/.match(line)
        m=/[\s]*([^\s]*)[\s]*=[\s]*([^\s]*)/.match(line)
-       conf[section][m[1]] = m[2]
+       if m[1]=="include"
+         Dir.glob(m[2]){ |fn| conf = readconfigfile(fn, conf) }
+       else
+         conf[section][m[1]] = m[2]
+       end
   end
   file.close()
   return conf
@@ -96,6 +104,7 @@ def send_md(md_string)
   for i in 0..md_string.length-1
     $sp.print(md_string[i].chr)
 #      print("DBG s: "+ md_string[i].chr) if $debug
+    sleep(0.01)
        if((i%($buffer_size*2)==0)&&(i!=0))
          begin
                line=$sp.gets()
@@ -148,7 +157,8 @@ def run_test(filename, skip=0)
          putc('*')
        else
          putc('!')
-         printf("<%d>",len)
+       #  printf("<%d>",len)
+         printf("\nError @%05d: %s \n           != %s - ",len, a, b)
          nerrors += 1
        end
        pos += 1
@@ -156,10 +166,14 @@ def run_test(filename, skip=0)
   return nerrors.to_i
 end
 
+opts = Getopt::Std.getopts("s:f:i:hdca")
+
 conf = Hash.new
 conf = readconfigfile("/etc/testport.conf", conf)
 conf = readconfigfile("~/.testport.conf", conf)
 conf = readconfigfile("testport.conf", conf)
+conf = readconfigfile(opts["f"], conf) if opts["f"]
+
 #puts conf.inspect
 
 puts("serial port interface version: " + SerialPort::VERSION);
@@ -190,7 +204,19 @@ reset_system()
 algos=scan_system()
 #puts algos.inspect
 
-algos.sort.each do |algoa|
+if opts["s"]
+  algos_rev = algos.invert
+  algo_tasks = Array.new
+  opts["s"].each_byte{ |x|
+    if algos_rev[x.chr]
+      algo_tasks << [algos_rev[x.chr],x.chr]
+    end
+  }
+else
+  algo_tasks=algos.sort
+end
+
+algo_tasks.each do |algoa|
   algo = algoa[0]
   if conf[algo]==nil
     puts("No test-set defined for #{algo} \r\n")
@@ -202,7 +228,9 @@ algos.sort.each do |algoa|
          puts("Testing #{algo} with #{conf[algo]["file_#{i}"]}")
          reset_system()
          init_system(algoa[1])
-         nerrors=run_test(conf[algo]["file_#{i}"], 0)
+         skip=0
+         skip=opts["i"].to_i if opts["i"]
+         nerrors=run_test(conf[algo]["file_#{i}"], skip)
       if nerrors == 0
         puts("\n[ok]")
         logfile.puts("[ok] "+conf[algo]["file_#{i}"]+ " ("+Time.now.to_s()+")")
index 76debe5b46192c0a62abc180db96ae4cb0c2c5b2..04c8cd2531b580a084dee1679d91ba1846ea40b8 100644 (file)
 #define __CONFIG_H__
 #include <avr/io.h>
 // #define F_CPU 20000000
- #define F_CPU 16000000         /* Oszillator-Frequenz in Hz */
+// #define F_CPU 16000000         /* oscillator-frequency in Hz */
 // #define F_CPU 14745600
+#define F_CPU 20000000 /* this is out of spec but lets try it */
 
+#define DEBUG_METHOD uart
 
 #include "uart_defs.h"
 
-#define DEBUG uart
-
-#undef UART_LEDS
-
 #define UART0_I 1
 #define UART0_BAUD_RATE  38400
 #define UART0_PARATY     UART_PARATY_NONE
index 128b4bcb2278aa9cc921562ca53fe7ed681d0ac6..65264795c00526edfa9f467fcafe525e4a7ba318 100644 (file)
 ****************************/
 #include "config.h"
 
-#if DEBUG == uart
+#if DEBUG_METHOD == uart
  #include "uart_i.h"
 #else
   #error "Your DEBUG methode is not suported!"
 #endif
 
-#ifdef DEBUG
+#ifdef DEBUG_METHOD
  void debug_init(void){
- #if DBUG==uart
+ #if DEBUG_METHOD==uart
   uart0_init();
  #else
   #error "Your DEBUG methode is not suported!"
  #endif
  }
+
  void debug_char(char c){
        static char initialised = 0;
        if (!initialised){
                uart0_init();
                initialised=1;
-       }       
+       }
        uart0_putc(c);
  }
+
  void debug_str(char* s){
        while (*s)
                debug_char(*s++);
  }
+
 
 
  void debug_byte(char b){
index e2d3685d6e0ec813dcac488e06053143b71a435f..71b6600a6dcee9f607c84d6649bd58df7f675226 100644 (file)
@@ -18,7 +18,7 @@
 */
 /*
  * AES test-suit
- * 
+ *
 */
 
 #include "config.h"
 #include "debug.h"
 
 #include "aes/aes.h"
-#include "aes/aes128_enc.h"
-#include "aes/aes128_dec.h"
-#include "aes/aes192_enc.h"
-#include "aes/aes192_dec.h"
-#include "aes/aes256_enc.h"
-#include "aes/aes256_dec.h"
-#include "aes/aes_keyschedule.h"
 
 #include "nessie_bc_test.h"
 #include "cli.h"
@@ -59,28 +52,28 @@ void testrun_nessie_aes(void){
        nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)aes128_dec;
        nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)aes_init;
        nessie_bc_run();
-       
+
        nessie_bc_ctx.keysize_b   = 192;
        nessie_bc_ctx.ctx_size_B  = sizeof(aes192_ctx_t);
        nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)aes192_enc;
        nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)aes192_dec;
        nessie_bc_run();
-       
+
        nessie_bc_ctx.keysize_b   = 256;
        nessie_bc_ctx.ctx_size_B  = sizeof(aes256_ctx_t);
        nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)aes256_enc;
        nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)aes256_dec;
-       nessie_bc_run(); 
+       nessie_bc_run();
 }
 
 void testrun_test_aes(void){
-       uint8_t key[16] = { 0x2b, 0x7e, 0x15, 0x16, 
+       uint8_t key[16] = { 0x2b, 0x7e, 0x15, 0x16,
                            0x28, 0xae, 0xd2, 0xa6,
                            0xab, 0xf7, 0x15, 0x88,
                            0x09, 0xcf, 0x4f, 0x3c };
        uint8_t data[16] = { 0x32, 0x43, 0xf6, 0xa8,
-                            0x88, 0x5a, 0x30, 0x8d, 
-                            0x31, 0x31, 0x98, 0xa2, 
+                            0x88, 0x5a, 0x30, 0x8d,
+                            0x31, 0x31, 0x98, 0xa2,
                             0xe0, 0x37, 0x07, 0x34 };
        aes128_ctx_t ctx;
        aes128_init(key, &ctx);
@@ -94,12 +87,12 @@ void testrun_test_aes(void){
        aes128_dec(data, &ctx);
        cli_putstr_P(PSTR("\r\n plaintext:  "));
        cli_hexdump(data, 16);
-       
-       
+
+
 }
 
 void testrun_testkey_aes128(void){
-       uint8_t key[16] = { 0x2b, 0x7e, 0x15, 0x16, 
+       uint8_t key[16] = { 0x2b, 0x7e, 0x15, 0x16,
                            0x28, 0xae, 0xd2, 0xa6,
                            0xab, 0xf7, 0x15, 0x88,
                            0x09, 0xcf, 0x4f, 0x3c};
@@ -118,11 +111,11 @@ void testrun_testkey_aes128(void){
 }
 
 void testrun_testkey_aes192(void){
-       uint8_t key[24] = { 0x8e, 0x73, 0xb0, 0xf7, 
+       uint8_t key[24] = { 0x8e, 0x73, 0xb0, 0xf7,
                            0xda, 0x0e, 0x64, 0x52,
-                           0xc8, 0x10, 0xf3, 0x2b, 
-                           0x80, 0x90, 0x79, 0xe5, 
-                           0x62, 0xf8, 0xea, 0xd2, 
+                           0xc8, 0x10, 0xf3, 0x2b,
+                           0x80, 0x90, 0x79, 0xe5,
+                           0x62, 0xf8, 0xea, 0xd2,
                            0x52, 0x2c, 0x6b, 0x7b};
        aes192_ctx_t ctx;
        uint8_t i;
@@ -141,13 +134,13 @@ void testrun_testkey_aes192(void){
 
 
 void testrun_testkey_aes256(void){
-       uint8_t key[32] = { 0x60, 0x3d, 0xeb, 0x10, 
-                           0x15, 0xca, 0x71, 0xbe, 
-                           0x2b, 0x73, 0xae, 0xf0, 
-                           0x85, 0x7d, 0x77, 0x81, 
-                           0x1f, 0x35, 0x2c, 0x07, 
-                           0x3b, 0x61, 0x08, 0xd7, 
-                           0x2d, 0x98, 0x10, 0xa3, 
+       uint8_t key[32] = { 0x60, 0x3d, 0xeb, 0x10,
+                           0x15, 0xca, 0x71, 0xbe,
+                           0x2b, 0x73, 0xae, 0xf0,
+                           0x85, 0x7d, 0x77, 0x81,
+                           0x1f, 0x35, 0x2c, 0x07,
+                           0x3b, 0x61, 0x08, 0xd7,
+                           0x2d, 0x98, 0x10, 0xa3,
                            0x09, 0x14, 0xdf, 0xf4};
        aes256_ctx_t ctx;
        uint8_t i;
@@ -176,36 +169,36 @@ void testrun_performance_aes128(void){
        char str[16];
        uint8_t key[32], data[16];
        aes128_ctx_t ctx;
-       
+
        calibrateTimer();
        print_overhead();
-       
+
        memset(key,  0, 32);
        memset(data, 0, 16);
-       
+
        startTimer(1);
        aes128_init(key, &ctx);
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
        ultoa((unsigned long)t, str, 10);
        cli_putstr(str);
-       
-       
+
+
        startTimer(1);
        aes128_enc(data, &ctx);
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n\tencrypt time: "));
        ultoa((unsigned long)t, str, 10);
        cli_putstr(str);
-       
-       
+
+
        startTimer(1);
        aes128_dec(data, &ctx);
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
        ultoa((unsigned long)t, str, 10);
        cli_putstr(str);
-       
+
        cli_putstr_P(PSTR("\r\n"));
 }
 
@@ -215,36 +208,36 @@ void testrun_performance_aes192(void){
        char str[16];
        uint8_t key[32], data[16];
        aes192_ctx_t ctx;
-       
+
        calibrateTimer();
        print_overhead();
-       
+
        memset(key,  0, 32);
        memset(data, 0, 16);
-       
+
        startTimer(1);
        aes192_init(key, &ctx);
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
        ultoa((unsigned long)t, str, 10);
        cli_putstr(str);
-       
-       
+
+
        startTimer(1);
        aes192_enc(data, &ctx);
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n\tencrypt time: "));
        ultoa((unsigned long)t, str, 10);
        cli_putstr(str);
-       
-       
+
+
        startTimer(1);
        aes192_dec(data, &ctx);
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
        ultoa((unsigned long)t, str, 10);
        cli_putstr(str);
-       
+
        cli_putstr_P(PSTR("\r\n"));
 }
 
@@ -254,36 +247,36 @@ void testrun_performance_aes256(void){
        char str[16];
        uint8_t key[32], data[16];
        aes256_ctx_t ctx;
-       
+
        calibrateTimer();
        print_overhead();
-       
+
        memset(key,  0, 32);
        memset(data, 0, 16);
-       
+
        startTimer(1);
        aes256_init(key, &ctx);
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
        ultoa((unsigned long)t, str, 10);
        cli_putstr(str);
-       
-       
+
+
        startTimer(1);
        aes256_enc(data, &ctx);
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n\tencrypt time: "));
        ultoa((unsigned long)t, str, 10);
        cli_putstr(str);
-       
-       
+
+
        startTimer(1);
        aes256_dec(data, &ctx);
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
        ultoa((unsigned long)t, str, 10);
        cli_putstr(str);
-       
+
        cli_putstr_P(PSTR("\r\n"));
 }
 
@@ -314,13 +307,13 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
        { echo_str,    (void*)1, (void_fpt)echo_ctrl},
        { NULL,            NULL, NULL}
 };
+
 
 int main (void){
        DEBUG_INIT();
-       
+
        cli_rx = (cli_rx_fpt)uart0_getc;
-       cli_tx = (cli_tx_fpt)uart0_putc;                
+       cli_tx = (cli_tx_fpt)uart0_putc;
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index ce9468f1c4d65c1ec70904e67b3c32c7b744e96e..01cf583557440443c00e1716b5d782d7e0edc01f 100644 (file)
@@ -18,7 +18,7 @@
 */
 /*
  * AES-128 test-suit
- * 
+ *
 */
 
 #include "config.h"
 #include "debug.h"
 
 #include "aes/aes.h"
-#include "aes/aes128_enc.h"
-#include "aes/aes128_dec.h"
-#include "aes/aes_keyschedule.h"
-
 #include "nessie_bc_test.h"
 #include "cli.h"
 #include "performance_test.h"
@@ -57,13 +53,13 @@ void testrun_nessie_aes(void){
 }
 
 void testrun_test_aes(void){
-       uint8_t key[16] = { 0x2b, 0x7e, 0x15, 0x16, 
+       uint8_t key[16] = { 0x2b, 0x7e, 0x15, 0x16,
                            0x28, 0xae, 0xd2, 0xa6,
                            0xab, 0xf7, 0x15, 0x88,
                            0x09, 0xcf, 0x4f, 0x3c };
        uint8_t data[16] = { 0x32, 0x43, 0xf6, 0xa8,
-                            0x88, 0x5a, 0x30, 0x8d, 
-                            0x31, 0x31, 0x98, 0xa2, 
+                            0x88, 0x5a, 0x30, 0x8d,
+                            0x31, 0x31, 0x98, 0xa2,
                             0xe0, 0x37, 0x07, 0x34 };
        aes128_ctx_t ctx;
        aes128_init(key, &ctx);
@@ -77,12 +73,12 @@ void testrun_test_aes(void){
        aes128_dec(data, &ctx);
        cli_putstr_P(PSTR("\r\n plaintext:  "));
        cli_hexdump(data, 16);
-       
-       
+
+
 }
 
 void testrun_testkey_aes128(void){
-       uint8_t key[16] = { 0x2b, 0x7e, 0x15, 0x16, 
+       uint8_t key[16] = { 0x2b, 0x7e, 0x15, 0x16,
                            0x28, 0xae, 0xd2, 0xa6,
                            0xab, 0xf7, 0x15, 0x88,
                            0x09, 0xcf, 0x4f, 0x3c};
@@ -110,36 +106,36 @@ void testrun_performance_aes128(void){
        char str[16];
        uint8_t key[32], data[16];
        aes128_ctx_t ctx;
-       
+
        calibrateTimer();
        print_overhead();
-       
+
        memset(key,  0, 32);
        memset(data, 0, 16);
-       
+
        startTimer(1);
        aes128_init(key, &ctx);
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
        ultoa((unsigned long)t, str, 10);
        cli_putstr(str);
-       
-       
+
+
        startTimer(1);
        aes128_enc(data, &ctx);
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n\tencrypt time: "));
        ultoa((unsigned long)t, str, 10);
        cli_putstr(str);
-       
-       
+
+
        startTimer(1);
        aes128_dec(data, &ctx);
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
        ultoa((unsigned long)t, str, 10);
        cli_putstr(str);
-       
+
        cli_putstr_P(PSTR("\r\n"));
 }
 
@@ -166,12 +162,12 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
        { echo_str,    (void*)1, (void_fpt)echo_ctrl},
        { NULL,            NULL, NULL}
 };
+
 int main (void){
        DEBUG_INIT();
-       
+
        cli_rx = (cli_rx_fpt)uart0_getc;
-       cli_tx = (cli_tx_fpt)uart0_putc;                
+       cli_tx = (cli_tx_fpt)uart0_putc;
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 850d773956e0311d7d4aed76b6c8f7ec2f207434..2324705fa5c66bb456e38f3c5a5d68a0272b51d0 100644 (file)
@@ -18,7 +18,7 @@
 */
 /*
  * AES-192 test-suit
- * 
+ *
 */
 
 #include "config.h"
@@ -27,9 +27,6 @@
 #include "debug.h"
 
 #include "aes/aes.h"
-#include "aes/aes192_enc.h"
-#include "aes/aes192_dec.h"
-#include "aes/aes_keyschedule.h"
 
 #include "nessie_bc_test.h"
 #include "cli.h"
@@ -57,11 +54,11 @@ void testrun_nessie_aes(void){
 }
 
 void testrun_testkey_aes192(void){
-       uint8_t key[24] = { 0x8e, 0x73, 0xb0, 0xf7, 
+       uint8_t key[24] = { 0x8e, 0x73, 0xb0, 0xf7,
                            0xda, 0x0e, 0x64, 0x52,
-                           0xc8, 0x10, 0xf3, 0x2b, 
-                           0x80, 0x90, 0x79, 0xe5, 
-                           0x62, 0xf8, 0xea, 0xd2, 
+                           0xc8, 0x10, 0xf3, 0x2b,
+                           0x80, 0x90, 0x79, 0xe5,
+                           0x62, 0xf8, 0xea, 0xd2,
                            0x52, 0x2c, 0x6b, 0x7b};
        aes192_ctx_t ctx;
        uint8_t i;
@@ -88,36 +85,36 @@ void testrun_performance_aes192(void){
        char str[16];
        uint8_t key[32], data[16];
        aes192_ctx_t ctx;
-       
+
        calibrateTimer();
        print_overhead();
-       
+
        memset(key,  0, 32);
        memset(data, 0, 16);
-       
+
        startTimer(1);
        aes192_init(key, &ctx);
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
        ultoa((unsigned long)t, str, 10);
        cli_putstr(str);
-       
-       
+
+
        startTimer(1);
        aes192_enc(data, &ctx);
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n\tencrypt time: "));
        ultoa((unsigned long)t, str, 10);
        cli_putstr(str);
-       
-       
+
+
        startTimer(1);
        aes192_dec(data, &ctx);
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
        ultoa((unsigned long)t, str, 10);
        cli_putstr(str);
-       
+
        cli_putstr_P(PSTR("\r\n"));
 }
 
@@ -148,9 +145,9 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 
 int main (void){
        DEBUG_INIT();
-       
+
        cli_rx = (cli_rx_fpt)uart0_getc;
-       cli_tx = (cli_tx_fpt)uart0_putc;                
+       cli_tx = (cli_tx_fpt)uart0_putc;
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 53c4fe60448f4dd1db7ca2c60c620e668893f064..d75fc526bcde4bf4126b1cc09f1cd0c091a760a1 100644 (file)
@@ -18,7 +18,7 @@
 */
 /*
  * AES-256 test-suit
- * 
+ *
 */
 
 #include "config.h"
@@ -27,9 +27,6 @@
 #include "debug.h"
 
 #include "aes/aes.h"
-#include "aes/aes256_enc.h"
-#include "aes/aes256_dec.h"
-#include "aes/aes_keyschedule.h"
 
 #include "nessie_bc_test.h"
 #include "cli.h"
@@ -57,13 +54,13 @@ void testrun_nessie_aes(void){
 }
 
 void testrun_testkey_aes256(void){
-       uint8_t key[32] = { 0x60, 0x3d, 0xeb, 0x10, 
-                           0x15, 0xca, 0x71, 0xbe, 
-                           0x2b, 0x73, 0xae, 0xf0, 
-                           0x85, 0x7d, 0x77, 0x81, 
-                           0x1f, 0x35, 0x2c, 0x07, 
-                           0x3b, 0x61, 0x08, 0xd7, 
-                           0x2d, 0x98, 0x10, 0xa3, 
+       uint8_t key[32] = { 0x60, 0x3d, 0xeb, 0x10,
+                           0x15, 0xca, 0x71, 0xbe,
+                           0x2b, 0x73, 0xae, 0xf0,
+                           0x85, 0x7d, 0x77, 0x81,
+                           0x1f, 0x35, 0x2c, 0x07,
+                           0x3b, 0x61, 0x08, 0xd7,
+                           0x2d, 0x98, 0x10, 0xa3,
                            0x09, 0x14, 0xdf, 0xf4};
        aes256_ctx_t ctx;
        uint8_t i;
@@ -90,36 +87,36 @@ void testrun_performance_aes256(void){
        char str[16];
        uint8_t key[32], data[16];
        aes256_ctx_t ctx;
-       
+
        calibrateTimer();
        print_overhead();
-       
+
        memset(key,  0, 32);
        memset(data, 0, 16);
-       
+
        startTimer(1);
        aes256_init(key, &ctx);
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
        ultoa((unsigned long)t, str, 10);
        cli_putstr(str);
-       
-       
+
+
        startTimer(1);
        aes256_enc(data, &ctx);
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n\tencrypt time: "));
        ultoa((unsigned long)t, str, 10);
        cli_putstr(str);
-       
-       
+
+
        startTimer(1);
        aes256_dec(data, &ctx);
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
        ultoa((unsigned long)t, str, 10);
        cli_putstr(str);
-       
+
        cli_putstr_P(PSTR("\r\n"));
 }
 
@@ -150,9 +147,9 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 
 int main (void){
        DEBUG_INIT();
-       
+
        cli_rx = (cli_rx_fpt)uart0_getc;
-       cli_tx = (cli_tx_fpt)uart0_putc;                
+       cli_tx = (cli_tx_fpt)uart0_putc;
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index a2e9714763121d187a3090ea3f4ba87b67ad254a..5b46497619c5af35012f94e807d6cd165ca40eb4 100644 (file)
@@ -18,7 +18,7 @@
 */
 /*
  * groestl test-suit
- * 
+ *
 */
 
 #include "config.h"
@@ -78,7 +78,7 @@ void groestl512_test(void* msg, uint32_t length_b){
 
 
 void testrun_stdtest_groestl(void){
-       uint8_t msg1[144]; 
+       uint8_t msg1[144];
        memset(msg1, 0, 144);
        groestl224_test("", 8);
        groestl224_test(msg1, 576);
@@ -98,6 +98,19 @@ void testlshort(void){
        groestl512_test("abc", 24);
 }
 
+void test505(void){
+       uint8_t data[] = {
+               0x84, 0x73, 0xDC, 0x53, 0x82, 0xDE, 0x32, 0x95,
+               0x7E, 0x3A, 0x15, 0xCA, 0x3D, 0x79, 0x1C, 0x67,
+               0xD2, 0x0C, 0xF9, 0xEF, 0xBE, 0x3E, 0x46, 0x40,
+               0x7D, 0xCA, 0x5D, 0x02, 0x63, 0x5A, 0xC8, 0x6D,
+               0x2E, 0x0B, 0x22, 0xC7, 0x6D, 0x7D, 0x08, 0x0D,
+               0x36, 0x2E, 0x82, 0x75, 0x89, 0x14, 0xCC, 0x0A,
+               0xE2, 0xB8, 0x9B, 0xD3, 0x5F, 0x71, 0xD8, 0x44,
+               0x92, 0xD9, 0x43, 0x07, 0x42, 0x78, 0x9C, 0x80 };
+       groestl224_test(data, 505);
+}
+
 
 void performance_groestl(void){
        hfal_performance_multiple(algolist);
@@ -112,6 +125,7 @@ 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 test505_str[]      PROGMEM = "test505";
 const char performance_str[]  PROGMEM = "performance";
 const char echo_str[]         PROGMEM = "echo";
 const char shavs_list_str[]   PROGMEM = "shavs_list";
@@ -123,6 +137,7 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
        { test_str,            NULL, testrun_stdtest_groestl},
        { testshort_str,       NULL, testshort},
        { testlshort_str,      NULL, testlshort},
+       { test505_str,         NULL, test505},
        { performance_str,     NULL, performance_groestl},
        { shavs_list_str,      NULL, shavs_listalgos},
        { shavs_set_str,   (void*)1, (void_fpt)shavs_setalgo},
@@ -133,9 +148,9 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 
 int main (void){
        DEBUG_INIT();
-       
+
        cli_rx = (cli_rx_fpt)uart0_getc;
-       cli_tx = (cli_tx_fpt)uart0_putc;                
+       cli_tx = (cli_tx_fpt)uart0_putc;
        shavs_algolist=(hfdesc_t**)algolist;
        shavs_algo=(hfdesc_t*)&groestl256_desc;
        for(;;){
@@ -146,7 +161,7 @@ int main (void){
                cli_putstr_P(PSTR(" "));
                cli_putstr(__TIME__);
                cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-               
+
                cmd_interface(cmdlist);
        }
-}      
+}
index ad745fc4c96a0b6480bb25fb563500f911040689..6ba564512985fc1ef0ebfb410be65c7f39d8b3dc 100644 (file)
@@ -51,7 +51,7 @@ ISR(TIMER1_OVF_vect){
 }
 
 void calibrateTimer(void){
-       volatile uint8_t i;
+       volatile uint8_t i=0;
        startTimer(1);
        stopTimer();
        const_overhead = TCNT1;
diff --git a/test_src/serial-tools.h b/test_src/serial-tools.h
deleted file mode 100644 (file)
index 9dcf028..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/* serial-tools.h */
-/*
-    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
-    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/>.
-*/
-#ifndef SERIALTOOLS_H_
-#define SERIALTOOLS_H_
-
-
-int getnextwordn(char *s, int n); /* words are seperated by spaces */
-void readhex2buffer(void* buffer, int n);
-void uart_putptr(void* p);
-
-#endif /*SERIALTOOLS_H_*/
index 213533d10b47ba01975bd9923034caa8f38beb12..92c450e112d946c6929abb7b9dea0aacf9759927 100644 (file)
@@ -6,60 +6,9 @@ baud = 38400
 databits = 8
 stopbits = 1
 paraty = none
-testlogbase = testlog_
+testlogbase = testlog/testlog_
 
-###############################################################################
-
-[BlueMidnightWish-224]
-algo=a
-file_0=testvectors/shavs/BlueMidnightWish/ShortMsgKAT_224.txt
-file_1=testvectors/shavs/BlueMidnightWish/LongMsgKAT_224.txt
-
-[BlueMidnightWish-256]
-algo=b
-file_0=testvectors/shavs/BlueMidnightWish/ShortMsgKAT_256.txt
-file_1=testvectors/shavs/BlueMidnightWish/LongMsgKAT_256.txt
-
-[BlueMidnightWish-384]
-algo=c
-file_0=testvectors/shavs/BlueMidnightWish/ShortMsgKAT_384.txt
-file_1=testvectors/shavs/BlueMidnightWish/LongMsgKAT_384.txt
-
-[BlueMidnightWish-512]
-algo=d
-file_0=testvectors/shavs/BlueMidnightWish/ShortMsgKAT_512.txt
-file_1=testvectors/shavs/BlueMidnightWish/LongMsgKAT_512.txt
-
-[BlueMidnightWish]
-meta=1
-test_0=BlueMidnightWish-256
-test_1=BlueMidnightWish-512
-test_2=BlueMidnightWish-224
-test_3=BlueMidnightWish-384
-
-###############################################################################
-
-[Blake-28]
-algo=a
-file_0=testvectors/shavs/Blake/ShortMsgKAT_224.txt
-file_1=testvectors/shavs/Blake/LongMsgKAT_224.txt
-
-[Blake-32]
-algo=b
-file_0=testvectors/shavs/Blake/ShortMsgKAT_256.txt
-file_1=testvectors/shavs/Blake/LongMsgKAT_256.txt
-
-[Blake-48]
-algo=c
-file_0=testvectors/shavs/Blake/ShortMsgKAT_384.txt
-file_1=testvectors/shavs/Blake/LongMsgKAT_384.txt
-
-[Blake-64]
-algo=d
-file_0=testvectors/shavs/Blake/ShortMsgKAT_512.txt
-file_1=testvectors/shavs/Blake/LongMsgKAT_512.txt
-
-###############################################################################
+include=testconf/*.conf
 
 
 # END OF CONFIGFILE