]> git.cryptolib.org Git - avr-crypto-lib.git/commitdiff
modification to the build system
authorbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Sat, 2 Aug 2008 10:37:02 +0000 (10:37 +0000)
committerbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Sat, 2 Aug 2008 10:37:02 +0000 (10:37 +0000)
120 files changed:
Makefile
avr-makefile.inc
cli.c [deleted file]
cli.h [deleted file]
debug.c [deleted file]
deps/test_src [new symlink]
main-arcfour-test.c [deleted file]
main-camellia-test.c [deleted file]
main-cast5-test.c [deleted file]
main-des-test.c [deleted file]
main-entropium-test.c [deleted file]
main-grain-test.c [deleted file]
main-hmac-sha1-test.c [deleted file]
main-hmac-sha256-test.c [deleted file]
main-md5-test.c [deleted file]
main-noekeon-test.c [deleted file]
main-present-test.c [deleted file]
main-rc5-test.c [deleted file]
main-rc6-test.c [deleted file]
main-seed-test.c [deleted file]
main-serpent-test.c [deleted file]
main-sha1-test.c [deleted file]
main-sha256-test.c [deleted file]
main-shabea-test.c [deleted file]
main-shacal1_enc-test.c [deleted file]
main-shacal2_enc-test.c [deleted file]
main-skipjack-test.c [deleted file]
main-tdes-test.c [deleted file]
main-trivium-test.c [deleted file]
main-xtea-test.c [deleted file]
mkfiles/a5_1.mk
mkfiles/arcfour.mk
mkfiles/arcfour_c.mk
mkfiles/camellia.mk
mkfiles/cast5.mk
mkfiles/des.mk
mkfiles/entropium.mk
mkfiles/grain.mk
mkfiles/hmac-sha1.mk
mkfiles/hmac-sha256.mk
mkfiles/md5.mk
mkfiles/noekeon.mk
mkfiles/noekeon_c.mk
mkfiles/present.mk
mkfiles/rc5.mk
mkfiles/rc6.mk
mkfiles/seed.mk
mkfiles/serpent-bitslice.mk
mkfiles/serpent.mk
mkfiles/sha1.mk
mkfiles/sha1_c.mk
mkfiles/sha256.mk
mkfiles/sha256_c.mk
mkfiles/shabea.mk
mkfiles/shacal1enc.mk
mkfiles/shacal2enc.mk
mkfiles/skipjack.mk
mkfiles/tdes.mk
mkfiles/trivium.mk
mkfiles/xtea.mk
mkfiles/xtea_c.mk
nessie_bc_test.c [deleted file]
nessie_bc_test.h [deleted file]
nessie_common.c [deleted file]
nessie_common.h [deleted file]
nessie_hash_test.c [deleted file]
nessie_hash_test.h [deleted file]
nessie_mac_test.c [deleted file]
nessie_mac_test.h [deleted file]
nessie_stream_test.c [deleted file]
nessie_stream_test.h [deleted file]
performance_test.c [deleted file]
performance_test.h [deleted file]
serial-tools.c [deleted file]
serial-tools.h [deleted file]
serpent.c
serpent.h
test_src/cli.c [new file with mode: 0644]
test_src/cli.h [new file with mode: 0644]
test_src/debug.c [new file with mode: 0644]
test_src/main-arcfour-test.c [new file with mode: 0644]
test_src/main-camellia-test.c [new file with mode: 0644]
test_src/main-cast5-test.c [new file with mode: 0644]
test_src/main-des-test.c [new file with mode: 0644]
test_src/main-entropium-test.c [new file with mode: 0644]
test_src/main-grain-test.c [new file with mode: 0644]
test_src/main-hmac-sha1-test.c [new file with mode: 0644]
test_src/main-hmac-sha256-test.c [new file with mode: 0644]
test_src/main-md5-test.c [new file with mode: 0644]
test_src/main-noekeon-test.c [new file with mode: 0644]
test_src/main-present-test.c [new file with mode: 0644]
test_src/main-rc5-test.c [new file with mode: 0644]
test_src/main-rc6-test.c [new file with mode: 0644]
test_src/main-seed-test.c [new file with mode: 0644]
test_src/main-serpent-test.c [new file with mode: 0644]
test_src/main-sha1-test.c [new file with mode: 0644]
test_src/main-sha256-test.c [new file with mode: 0644]
test_src/main-shabea-test.c [new file with mode: 0644]
test_src/main-shacal1_enc-test.c [new file with mode: 0644]
test_src/main-shacal2_enc-test.c [new file with mode: 0644]
test_src/main-skipjack-test.c [new file with mode: 0644]
test_src/main-tdes-test.c [new file with mode: 0644]
test_src/main-trivium-test.c [new file with mode: 0644]
test_src/main-xtea-test.c [new file with mode: 0644]
test_src/nessie_bc_test.c [new file with mode: 0644]
test_src/nessie_bc_test.h [new file with mode: 0644]
test_src/nessie_common.c [new file with mode: 0644]
test_src/nessie_common.h [new file with mode: 0644]
test_src/nessie_hash_test.c [new file with mode: 0644]
test_src/nessie_hash_test.h [new file with mode: 0644]
test_src/nessie_mac_test.c [new file with mode: 0644]
test_src/nessie_mac_test.h [new file with mode: 0644]
test_src/nessie_stream_test.c [new file with mode: 0644]
test_src/nessie_stream_test.h [new file with mode: 0644]
test_src/performance_test.c [new file with mode: 0644]
test_src/performance_test.h [new file with mode: 0644]
test_src/serial-tools.c [new file with mode: 0644]
test_src/serial-tools.h [new file with mode: 0644]
test_src/uart.c [new file with mode: 0644]
uart.c [deleted file]

index 8033ad2a7a703224878e8be9fdb29d4aa5e6cb0a..00d1f5f3f935dbcc5898a9351c2f23be7fe9913b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -19,10 +19,7 @@ $(1) = $(2)
 endef
 $(foreach a, $(ALGORITHMS_OBJ), $(eval $(call OBJinBINDIR_TEMPLATE, $(a), $(patsubst %.o,$(BIN_DIR)%.o,$($(a))))))
 ALGORITHMS_TEST_BIN = $(patsubst %,%_TEST_BIN, $(ALGORITHMS))
-$(foreach a, $(ALGORITHMS_TEST_BIN), $(eval $(call OBJinBINDIR_TEMPLATE, $(a), $(patsubst %.o,$(BIN_DIR)%.o,$($(a))))))
-#ALGORITHMS_TEST_BIN_MAIN = $(foreach a, $(ALGORITHMS_TEST_BIN), $(firstword $($(a))))
-#ALGORITHMS_TEST_BIN_MAIN_ELF = $(patsubst $(BIN_DIR)%.o, $(TESTBIN_DIR)%.elf, $(ALGORITHMS_TEST_BIN_MAIN))
-#ALGORITHMS_TEST_BIN_MAIN_HEX = $(patsubst $(BIN_DIR)%.o, $(TESTBIN_DIR)%.hex, $(ALGORITHMS_TEST_BIN_MAIN))
+$(foreach a, $(ALGORITHMS_TEST_BIN), $(eval $(call OBJinBINDIR_TEMPLATE, $(a), $(patsubst %.o,$(TESTBIN_DIR)%.o,$($(a))))))
 
 
 ALGORITHMS_TEST_BIN_IMM =  $(foreach a, $(ALGORITHMS_TEST_BIN), $($(a)))
@@ -41,18 +38,24 @@ all: $(foreach algo, $(ALGORITHMS), $(algo)_OBJ)
 
 #-------------------------------------------------------------------------------
 
-define BLA_TEMPLATE2
-$(2): $(3)
+define MAIN_OBJ_TEMPLATE
+$(2): $(3) $(4)
        @echo "[gcc]: $$@"
 #      echo $$^
        @$(CC) $(CFLAGS) $(LDFLAGS)$(patsubst %.elf,%.map,$(2)) -o \
        $(2) \
-       $(3) \
+       $(3) $(4) \
        $(LIBS)
 endef
 
-#$(foreach algo, $(ALGORITHMS), $(eval $(call BLA_TEMPLATE2, $(algo), $(patsubst $(BIN_DIR)%.o,$(TESTBIN_DIR)%.elf,$(firstword $($(algo)_TEST_BIN))), $(patsubst %.o,%.o,$($(algo)_TEST_BIN)) )))
-$(foreach algo, $(ALGORITHMS), $(eval $(call BLA_TEMPLATE2, $(algo), $(TESTBIN_DIR)main-$(call lc,$(algo))-test.elf, $(patsubst %.o,%.o,$($(algo)_TEST_BIN)) )))
+$(foreach algo, $(ALGORITHMS), $(eval $(call MAIN_OBJ_TEMPLATE, \
+   $(algo), \
+   $(TESTBIN_DIR)main-$(call lc,$(algo))-test.elf, \
+   $(patsubst %.o,%.o,$($(algo)_TEST_BIN)), \
+   $(patsubst %.o,%.o,$($(algo)_OBJ))  )))
+
+
+
 
 #-------------------------------------------------------------------------------
 .PHONY: help
@@ -70,6 +73,8 @@ info:
        @echo "    $(MACS)"
        @echo "  PRNG functions:"
        @echo "    $(PRNGS)"
+       @echo "  ALGORITHMS_TEST_BIN"
+       @echo "    $(ALGORITHMS_TEST_BIN)"
        @echo "  ALGORITHMS_TEST_TARGET_ELF:"
        @echo "    $(ALGORITHMS_TEST_TARGET_ELF)"
        
@@ -82,6 +87,15 @@ $(BIN_DIR)%.o: %.S
        @echo "[as] :  $@"
        @$(CC) $(ASFLAGS) -c -o $@ $<
 
+$(TESTBIN_DIR)%.o: $(TESTSRC_DIR)%.c
+       @echo "[gcc]:  $@"
+       @$(CC) $(CFLAGS)  -c -o $@ $<
+
+$(TESTBIN_DIR)%.o: $(TESTSRC_DIR)%.S
+       @echo "[as] :  $@"
+       @$(CC) $(ASFLAGS) -c -o $@ $<
+
+
 %.o: %.c
        @echo "[gcc]:  $@"
        @$(CC) $(CFLAGS)  -c -o $@ $<
index 3585afe3578eb8910393ec23b9abb961576a9274..0e09617d635b269fb00326303adddcc8b587c465 100644 (file)
@@ -7,6 +7,7 @@ FLASHCMD       = avrdude -p $(MCU_TARGET) -P /dev/ttyUSB0 -c avr911 -U flash:w:#
 DEP_DIR        = deps/
 BIN_DIR        = bin/
 TESTBIN_DIR    = test_bin/
+TESTSRC_DIR    = test_src/
 #uisp -dprog=bsd -dlpt=/dev/parport1 --upload if=$(PRG).hex
 ERASECMD       = 
 TESTPORT       = /dev/ttyUSB1
@@ -15,7 +16,7 @@ TESTLOG_DIR    = testlog/
 TESTPREFIX     = nessie-
 CC          = avr-gcc
 
-override CFLAGS        = -MMD -MF$(DEP_DIR)$(patsubst %.c,%.d,$<) -pedantic -std=c99 -Wall -Wstrict-prototypes  $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
+override CFLAGS        = -MMD -MF$(DEP_DIR)$(patsubst %.c,%.d,$<) -I. -pedantic -std=c99 -Wall -Wstrict-prototypes  $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
 
 override LDFLAGS       = -Wl,-Map,
 override ASFLAGS          = -mmcu=$(MCU_TARGET)
diff --git a/cli.c b/cli.c
deleted file mode 100644 (file)
index 8c15f5f..0000000
--- a/cli.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* cli.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/**
- * 
- * author: Daniel Otte
- * email:  daniel.otte@rub.de
- * license: GPLv3 or later
- * 
- * components to help implementing simple command based interaction
- * 
- **/
-#include <stdint.h>
-#include <string.h>
-#include <avr/pgmspace.h>
-
-int16_t findstring_d0(const char* str, const char* v){
-       uint8_t i=0;
-       while(*v){      
-               if(!strcmp(str, v)){
-                       return i;
-               }
-               while(*v++) /* go to the next string */
-               ;
-               ++i;
-       }
-       return -1;
-}
-int16_t findstring_d0_P(const char* str, PGM_P v){
-       uint8_t i=0;
-       while(pgm_read_byte(v)){        
-               if(!strcmp_P(str, v)){
-                       return i;
-               }
-               while(pgm_read_byte(v++)) /* go to the next string */
-               ;
-               ++i;
-       }
-       return -1;
-} 
-
-int16_t execcommand_d0_P(const char* str, PGM_P v, void(*fpt[])(void) ){
-       uint8_t i=0;
-       while(pgm_read_byte(v)){        
-               if(!strcmp_P(str, v)){
-                       (fpt[i])();
-                       return i;
-               }
-               while(pgm_read_byte(v++)) /* go to the next string */
-               ;
-               ++i;
-       }
-       return -1;
-}
-
-
diff --git a/cli.h b/cli.h
deleted file mode 100644 (file)
index c36a6e6..0000000
--- a/cli.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* cli.h */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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 CLI_H_
-#define CLI_H_
-
-#include <stdint.h>
-#include <avr/pgmspace.h>
-
-typedef void(*void_fpt)(void);
-
-int16_t findstring_d0(const char* str, const char* v);
-int16_t findstring_d0_P(const char* str, PGM_P v);
-
-int16_t execcommand_d0_P(const char* str, PGM_P v, void(*fpt[])(void) );
-#endif /*CLI_H_*/
diff --git a/debug.c b/debug.c
deleted file mode 100644 (file)
index 3b5fee4..0000000
--- a/debug.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* debug.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/***************************
-*
-*
-*
-****************************/
-#include "config.h"
-
-#if DEBUG == uart
- #include "uart.h"
-#else
-  #error "Your DEBUG methode is not suported!"
-#endif
-
-#ifdef DEBUG
- void debug_init(void){
- #if DBUG==uart
-  uart_init();
- #else
-  #error "Your DEBUG methode is not suported!"
- #endif
- }
- void debug_char(char c){
-       static char initialised = 0;
-       if (!initialised){
-               uart_init();
-               initialised=1;
-       }       
-       uart_putc(c);
- }
- void debug_str(char* s){
-       while (*s)
-               debug_char(*s++);
- }
-
-
- void debug_byte(char b){
-       char table[] = "0123456789ABCDEF";
-       debug_char(table[(b>>4) & 0xf]);
-       debug_char(table[b&0xf]);
- }
-
-#endif //DEBUG
-
diff --git a/deps/test_src b/deps/test_src
new file mode 120000 (symlink)
index 0000000..945c9b4
--- /dev/null
@@ -0,0 +1 @@
+.
\ No newline at end of file
diff --git a/main-arcfour-test.c b/main-arcfour-test.c
deleted file mode 100644 (file)
index 0e0be91..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/* main-arcfour-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * arcfour (RC4 compatible) test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "arcfour.h"
-#include "nessie_stream_test.h"
-
-#include <stdint.h>
-#include <string.h>
-
-char* cipher_name = "Arcfour";
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-void arcfour_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
-       arcfour_init(ctx, key, (keysize+7)/8);
-}
-
-
-
-void testrun_nessie_arcfour(void){
-       nessie_stream_ctx.outsize_b = 8; /* actually unused */
-       nessie_stream_ctx.keysize_b = 128; /* this is theone we have refrence vectors for */
-       nessie_stream_ctx.ivsize_b = (uint16_t)-1;
-       nessie_stream_ctx.name = cipher_name;
-       nessie_stream_ctx.ctx_size_B = sizeof(arcfour_ctx_t);
-       nessie_stream_ctx.cipher_genctx = (nessie_stream_genctx_fpt)arcfour_genctx_dummy;
-       nessie_stream_ctx.cipher_enc = (nessie_stream_genenc_fpt)arcfour_gen;
-       
-       nessie_stream_run();    
-}
-
-
-
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-int main (void){
-       char  str[20];
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
-       uart_putstr(cipher_name);
-       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-
-restart:
-       while(1){ 
-               if (!getnextwordn(str,20))  {DEBUG_S("DBG: W1\r\n"); goto error;}
-               if (strcmp(str, "nessie")) {DEBUG_S("DBG: 1b\r\n"); goto error;}
-                       testrun_nessie_arcfour();
-               goto restart;           
-               continue;
-       error:
-               uart_putstr("ERROR\r\n");
-       }
-       
-       
-}
-
diff --git a/main-camellia-test.c b/main-camellia-test.c
deleted file mode 100644 (file)
index 4d64a50..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/* main-camellia-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * camellia test-suit
- * 
- */
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "camellia.h"
-#include "nessie_bc_test.h"
-#include "performance_test.h"
-#include "cli.h"
-
-char* cipher_name = "Camellia";
-
-
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-#include <avr/pgmspace.h>
-
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-void camellia128_init_dummy(void* key, uint16_t keysize_b, void* ctx){
-       camellia128_init(key, ctx);
-}
-
-void testrun_nessie_camellia(void){
-       nessie_bc_ctx.blocksize_B =  16;
-       nessie_bc_ctx.keysize_b   = 128;
-       nessie_bc_ctx.name        = cipher_name;
-       nessie_bc_ctx.ctx_size_B  = sizeof(camellia128_ctx_t);
-       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)camellia128_enc;
-       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)camellia128_dec;
-       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)camellia128_init_dummy;
-       
-       nessie_bc_run();
-}
-
-
-void test_performance_camellia(void){
-       uint64_t t;
-       char str[6];
-       uint8_t key[16], data[16];
-       camellia128_ctx_t ctx;
-       
-       calibrateTimer();
-       print_overhead();
-       
-       memset(key,  0, 16);
-       memset(data, 0, 16);
-       
-       startTimer(1);
-       camellia128_init(key, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       
-       startTimer(1);
-       camellia128_enc(data, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       
-       startTimer(1);
-       camellia128_dec(data, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       uart_putstr_P(PSTR("\r\n"));
-}
-
-
-
-/*****************************************************************************
- *  self tests                                                                                                                          *
- *****************************************************************************/
-
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-int main (void){
-       char str[20];
-
-       
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
-       uart_putstr(cipher_name);
-       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-
-       PGM_P    u   = PSTR("nessie\0test\0performance\0");
-       void_fpt v[] = {testrun_nessie_camellia, testrun_nessie_camellia, test_performance_camellia};
-       
-       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");
-       }
-}
-
diff --git a/main-cast5-test.c b/main-cast5-test.c
deleted file mode 100644 (file)
index 2cfb3d1..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-/* main-cast5-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * cast5 test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "cast5.h"
-#include "nessie_bc_test.h"
-#include "performance_test.h"
-#include "cli.h"
-
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
-char* cipher_name = "cast-128 (cast5)";
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-
-void testrun_nessie_cast5(void){
-       nessie_bc_ctx.blocksize_B =   8;
-       nessie_bc_ctx.keysize_b   = 128;
-       nessie_bc_ctx.name        = cipher_name;
-       nessie_bc_ctx.ctx_size_B  = sizeof(cast5_ctx_t);
-       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)cast5_enc;
-       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)cast5_dec;
-       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)cast5_init;
-       
-       nessie_bc_run();
-}
-
-/*****************************************************************************
- *  self tests                                                                                                                          *
- *****************************************************************************/
-
-void cast5_ctx_dump(cast5_ctx_t *s){
-       uint8_t i;
-       uart_putstr("\r\n==== cast5_ctx_dump ====\r\n shortkey: ");
-       uart_putstr(s->shortkey?"yes":"no");
-       for(i=0;i<16;++i){
-               uint8_t r;
-               uart_putstr("\r\n Km"); uart_hexdump(&i, 1); uart_putc(':');
-               uart_hexdump(&(s->mask[i]), 4);
-               uart_putstr("\r\n Kr"); uart_hexdump(&i, 1); uart_putc(':');
-               r = (s->rotl[i/2]);
-               if (i&0x01) r >>= 4;
-               r &= 0xf;
-               r += (s->roth[i>>3]&(1<<(i&0x7)))?0x10:0x00;
-               uart_hexdump(&r, 1);
-       }
-}
-
-
-void test_encrypt(uint8_t *block, uint8_t *key, uint8_t keylength, bool print){
-       cast5_ctx_t s;
-       if (print){
-               uart_putstr("\r\nCAST5:\r\n key:\t");
-               uart_hexdump(key, keylength/8);
-               uart_putstr("\r\n plaintext:\t");
-               uart_hexdump(block, 8);
-       }
-       cast5_init(key, keylength, &s);
-       cast5_enc(block, &s);
-       if (print){
-               uart_putstr("\r\n ciphertext:\t");
-               uart_hexdump(block, 8);
-       }
-} 
-
-void test_decrypt(uint8_t *block, uint8_t *key, uint8_t keylength, bool print){
-       cast5_ctx_t s;
-       if (print){
-               uart_putstr("\r\nCAST5:\r\n key:\t");
-               uart_hexdump(key, keylength/8);
-               uart_putstr("\r\n ciphertext:\t");
-               uart_hexdump(block, 8);
-       }
-       cast5_init(key, keylength, &s);
-       cast5_dec(block, &s);
-       if (print){
-               uart_putstr("\r\n plaintext:\t");
-               uart_hexdump(block, 8);
-       }
-} 
-
-void testrun_cast5(void){
-       uint8_t block[8];
-       uint8_t key[16];
-       uint8_t *tda = (uint8_t*)"\x01\x23\x45\x67\x89\xAB\xCD\xEF",
-               *tka = (uint8_t*)"\x01\x23\x45\x67\x12\x34\x56\x78\x23\x45\x67\x89\x34\x56\x78\x9A";
-       memcpy(block, tda, 8);
-       memcpy(key, tka, 16);
-       test_encrypt(block, key, 128, true);
-       test_decrypt(block, key, 128, true);
-       memcpy(block, tda, 8);
-       memcpy(key, tka, 16);
-       test_encrypt(block, key, 80, true);
-       test_decrypt(block, key, 80, true);
-       memcpy(block, tda, 8);
-       memcpy(key, tka, 16);
-       test_encrypt(block, key, 40, true);
-       test_decrypt(block, key, 40, true);
-       
-/**** long test *****/
-       uart_putstr("\r\nmaintance-test");
-       uint8_t a[16]= {0x01, 0x23, 0x45, 0x67, 0x12,
-                                   0x34, 0x56, 0x78, 0x23, 0x45, 
-                                   0x67, 0x89, 0x34, 0x56, 0x78, 
-                                   0x9A}, 
-                       b[16]= {0x01, 0x23, 0x45, 0x67, 0x12,
-                                   0x34, 0x56, 0x78, 0x23, 0x45, 
-                                   0x67, 0x89, 0x34, 0x56, 0x78, 
-                                   0x9A};
-       uint32_t i;
-       for(i=0;i<1000000; ++i){
-               test_encrypt(&(a[0]), &(b[0]), 128, false);
-               test_encrypt(&(a[8]), &(b[0]), 128, false);
-               test_encrypt(&(b[0]), &(a[0]), 128, false);
-               test_encrypt(&(b[8]), &(a[0]), 128, false);
-               if ((i&0x000000ff) == 0){
-                       uart_putstr("\r\n");
-                       uart_hexdump(&i, 4);
-               }
-       }
-       uart_putstr("\r\na = "); uart_hexdump(a, 16);
-       uart_putstr("\r\nb = "); uart_hexdump(b, 16);
-
-}
-
-void testrun_performance_cast5(void){
-       uint64_t t;
-       char str[6];
-       uint8_t key[16], data[16];
-       cast5_ctx_t ctx;
-       
-       calibrateTimer();
-       print_overhead();
-       
-       memset(key,  0, 16);
-       memset(data, 0, 16);
-       
-       startTimer(1);
-       cast5_init(key, 128, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       
-       startTimer(1);
-       cast5_enc(data, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       
-       startTimer(1);
-       cast5_dec(data, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       uart_putstr_P(PSTR("\r\n"));
-}
-
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-int main (void){
-       char str[20];
-
-       
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
-       uart_putstr(cipher_name);
-       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-
-       PGM_P    u   = PSTR("nessie\0test\0performance\0");
-       void_fpt v[] = {testrun_nessie_cast5, testrun_cast5, testrun_performance_cast5};
-       
-       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");
-       }
-}
-
diff --git a/main-des-test.c b/main-des-test.c
deleted file mode 100644 (file)
index 714781c..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/* main-des-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * des test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "des.h"
-#include "nessie_bc_test.h"
-#include "cli.h"
-#include "performance_test.h"
-
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
-char* cipher_name = "DES";
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-void des_init_dummy(const void* key, uint16_t keysize_b, void* ctx){
-       memcpy(ctx, key, 8);
-}
-
-void des_enc_dummy(void* buffer, void* ctx){
-       des_enc(buffer, buffer, ctx);
-} 
-
-void des_dec_dummy(void* buffer, void* ctx){
-       des_dec(buffer, buffer, ctx);
-} 
-
-void testrun_nessie_des(void){
-       nessie_bc_init();
-       nessie_bc_ctx.blocksize_B =   8;
-       nessie_bc_ctx.keysize_b   =  64;
-       nessie_bc_ctx.name        = cipher_name;
-       nessie_bc_ctx.ctx_size_B  = 8;
-       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)des_enc_dummy;
-       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)des_dec_dummy;
-       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)des_init_dummy;
-       
-       nessie_bc_run();
-}
-
-
-void testrun_performance_des(void){
-       uint64_t t;
-       char str[16];
-       uint8_t key[8], data[8];
-       
-       
-       calibrateTimer();
-       print_overhead();
-       
-       memset(key,  0, 8);
-       memset(data, 0, 8);
-       
-       startTimer(1);
-       des_enc(data, data, key);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       startTimer(1);
-       des_dec(data, data, key);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       uart_putstr_P(PSTR("\r\n"));
-}
-/*****************************************************************************
- * main                                                
- *****************************************************************************/
-
-int main (void){
-       char  str[20];
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
-       uart_putstr(cipher_name);
-       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-
-       PGM_P    u   = PSTR("nessie\0test\0performance\0");
-       void_fpt v[] = {testrun_nessie_des, testrun_nessie_des, testrun_performance_des};
-
-       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");
-       }
-       
-}
-
diff --git a/main-entropium-test.c b/main-entropium-test.c
deleted file mode 100644 (file)
index 3384396..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/* main-entropium-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * entropium test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "entropium.h"
-#include "nessie_bc_test.h"
-#include "cli.h"
-#include "performance_test.h"
-
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
-char* cipher_name = "Entropium";
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-
-void testrun_entropium(void){
-       char c, str[16];
-       uint8_t data[32];
-       uint32_t i=0;
-       while(!uart_getc_nb(&c)){
-               entropium_getRandomBlock(data);
-               uart_putstr_P(PSTR("\r\n "));
-               ultoa(i, str, 10);
-               for(c=strlen(str); c<11; ++c){
-                       uart_putc(' ');
-               }
-               uart_putstr(str);
-               ++i;
-               uart_putstr_P(PSTR(" : "));
-               uart_hexdump(data, 32);
-       }
-       uart_putstr_P(PSTR("\r\n\r\n"));
-}
-
-
-void testrun_performance_entropium(void){
-       uint64_t t;
-       char str[16];
-       uint8_t data[32];
-       
-       calibrateTimer();
-       print_overhead();
-       
-       startTimer(1);
-       entropium_addEntropy(128, data);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tadd entropy time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       
-       startTimer(1);
-       entropium_getRandomBlock(data);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tget random time:  "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       uart_putstr_P(PSTR("\r\n"));
-}
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-int main (void){
-       char  str[20];
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
-       uart_putstr(cipher_name);
-       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-
-       PGM_P    u   = PSTR("nessie\0test\0performance\0");
-       void_fpt v[] = {testrun_entropium, testrun_entropium, testrun_performance_entropium};
-
-       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");
-       }
-       
-}
-
diff --git a/main-grain-test.c b/main-grain-test.c
deleted file mode 100644 (file)
index 44f08f8..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
-/* main-grain-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * grain test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-#include "cli.h"
-
-#include "grain.h"
-#include "nessie_stream_test.h"
-#include "performance_test.h"
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-
-char* cipher_name = "Grain";
-
-/*****************************************************************************
- *  additional validation-functions                                          *
- *****************************************************************************/
-void grain_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
-       uint8_t iv[8]={0};
-       grain_init(key, &iv, ctx);
-}
-
-uint8_t grain_getbyte_dummy(grain_ctx_t* ctx){
-       uint8_t i,ret=0;
-       for(i=0; i<8; ++i){
-               ret<<=1;
-               ret |= grain_enc(ctx);
-       }
-       return ret;
-}
-
-uint8_t grain_getbyte_dummy_rev(grain_ctx_t* ctx){
-       uint8_t i,ret=0;
-       for(i=0; i<8; ++i){
-               ret >>= 1;
-               ret |= grain_enc(ctx)?0x80:0x00;
-       }
-       return ret;
-}
-
-void testrun_nessie_grain(void){
-       nessie_stream_ctx.outsize_b =   8; /* actually unused */
-       nessie_stream_ctx.keysize_b =  80; /* this is the one we have refrence vectors for */
-       nessie_stream_ctx.ivsize_b  =  64;
-       nessie_stream_ctx.name = cipher_name;
-       nessie_stream_ctx.ctx_size_B = sizeof(grain_ctx_t);
-       nessie_stream_ctx.cipher_genctx = (nessie_stream_genctx_fpt)grain_genctx_dummy;
-       nessie_stream_ctx.cipher_enc = (nessie_stream_genenc_fpt)grain_getbyte_dummy_rev;
-       
-       nessie_stream_run();    
-}
-
-
-void testrun_std_grain(void){
-       grain_ctx_t ctx;
-       uint8_t i, key[10], iv[8], out[10];
-       
-       /* 1 */
-       memset(key, 0, 10);
-       memset(iv, 0, 8);
-       uart_putstr_P(PSTR("\r\n=== std test ==="));
-       uart_putstr_P(PSTR("\r\n key: "));
-       uart_hexdump(key, 10);
-       uart_putstr_P(PSTR("\r\n iv:  "));
-       uart_hexdump(key, 8);
-       grain_init(key, iv, &ctx);
-       for(i=0; i<10; ++i){
-               out[i] = grain_getbyte_dummy(&ctx);
-       }
-       uart_putstr_P(PSTR("\r\n out: "));
-       uart_hexdump(out, 10);
-       
-       /* 2 */
-       for(i=0; i<8; ++i){
-               key[i] = i*0x22+1;
-       }
-       key[8]=0x12;
-       key[9]=0x34;
-       
-       for(i=0; i<8; ++i){
-               iv[i] = i*0x22+1;
-       }
-       uart_putstr_P(PSTR("\r\n\r\n key: "));
-       uart_hexdump(key, 10);
-       uart_putstr_P(PSTR("\r\n iv:  "));
-       uart_hexdump(key, 8);
-       grain_init(key, iv, &ctx);
-       for(i=0; i<10; ++i){
-               out[i] = grain_getbyte_dummy(&ctx);
-       }
-       uart_putstr_P(PSTR("\r\n out: "));
-       uart_hexdump(out, 10);
-       
-       
-       uart_putstr_P(PSTR("\r\n\r\n"));
-}
-
-void testrun_performance_grain(void){
-       uint64_t t;
-       char str[16];
-       uint8_t key[10], iv[8];
-       grain_ctx_t ctx;
-       
-       calibrateTimer();
-       print_overhead();       
-       
-       memset(key,  0, 10);
-       memset(iv,  0, 8);
-       
-       startTimer(1);
-       grain_init(key, iv, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);       
-       
-       startTimer(1);
-       grain_enc(&ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);       
-       
-       uart_putstr_P(PSTR("\r\n"));
-}
-
-/*****************************************************************************
- *  main                                                                     *
- *****************************************************************************/
-
-int main (void){
-       char  str[20];
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
-       uart_putstr(cipher_name);
-       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-
-       PGM_P    u   = PSTR("nessie\0test\0performance\0");
-       void_fpt v[] = {testrun_nessie_grain, testrun_std_grain, testrun_performance_grain};
-
-       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");
-       }       
-}
-
-
-
diff --git a/main-hmac-sha1-test.c b/main-hmac-sha1-test.c
deleted file mode 100644 (file)
index 2a786df..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/* main-hmac-sha1-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * HMAC-SHA1 test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "sha1.h"
-#include "hmac-sha1.h"
-
-#include "nessie_mac_test.h"
-
-#include <stdint.h>
-#include <string.h>
-#include "cli.h"
-
-char* algo_name = "HMAC-SHA1";
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-void hmacsha1_next_dummy(void* buffer, void* ctx){
-       sha1_nextBlock(ctx, buffer);
-}
-
-void hmacsha1_init_dummy(void* key, uint16_t keysize_b, void* ctx){
-       hmac_sha1_init(ctx, key, keysize_b);
-}
-
-void hmacsha1_last_dummy(void* buffer, uint16_t size_b, void* key, uint16_t keysize_b, void* ctx){
-       sha1_lastBlock(ctx, buffer, size_b);
-       hmac_sha1_final(ctx, key, keysize_b);
-}
-
-void testrun_nessie_hmacsha1(void){
-       nessie_mac_ctx.macsize_b   = 160;
-       nessie_mac_ctx.keysize_b   = 512;
-       nessie_mac_ctx.blocksize_B = 512/8;
-       nessie_mac_ctx.ctx_size_B  = sizeof(hmac_sha1_ctx_t);
-       nessie_mac_ctx.name = algo_name;
-       nessie_mac_ctx.mac_init = (nessie_mac_init_fpt)hmacsha1_init_dummy;
-       nessie_mac_ctx.mac_next = (nessie_mac_next_fpt)hmacsha1_next_dummy;
-       nessie_mac_ctx.mac_last = (nessie_mac_last_fpt)hmacsha1_last_dummy;
-       nessie_mac_ctx.mac_conv = (nessie_mac_conv_fpt)sha1_ctx2hash;
-       
-       nessie_mac_run();
-}
-
-
-
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-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\0");
-       void_fpt v[] = {testrun_nessie_hmacsha1, testrun_nessie_hmacsha1};
-
-       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");
-       }
-       
-       
-}
-
diff --git a/main-hmac-sha256-test.c b/main-hmac-sha256-test.c
deleted file mode 100644 (file)
index 819ed57..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/* main-hmac-sha256-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * HMAC-SHA256 test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "sha256.h"
-#include "hmac-sha256.h"
-
-#include "nessie_mac_test.h"
-
-#include <stdint.h>
-#include <string.h>
-
-char* algo_name = "HMAC-SHA256";
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-void hmacsha256_next_dummy(void* buffer, void* ctx){
-       sha256_nextBlock(ctx, buffer);
-}
-
-void hmacsha256_init_dummy(void* key, uint16_t keysize_b, void* ctx){
-       hmac_sha256_init(ctx, key, keysize_b);
-}
-
-void hmacsha256_last_dummy(void* buffer, uint16_t size_b, void* key, uint16_t keysize_b, void* ctx){
-       sha256_lastBlock(ctx, buffer, size_b);
-       hmac_sha256_final(ctx, key, keysize_b);
-}
-
-void testrun_nessie_hmacsha256(void){
-       nessie_mac_ctx.macsize_b   = 256;
-       nessie_mac_ctx.keysize_b   = 512;
-       nessie_mac_ctx.blocksize_B = 512/8;
-       nessie_mac_ctx.ctx_size_B  = sizeof(hmac_sha256_ctx_t);
-       nessie_mac_ctx.name = algo_name;
-       nessie_mac_ctx.mac_init = (nessie_mac_init_fpt)hmacsha256_init_dummy;
-       nessie_mac_ctx.mac_next = (nessie_mac_next_fpt)hmacsha256_next_dummy;
-       nessie_mac_ctx.mac_last = (nessie_mac_last_fpt)hmacsha256_last_dummy;
-       nessie_mac_ctx.mac_conv = (nessie_mac_conv_fpt)sha256_ctx2hash;
-       
-       nessie_mac_run();
-}
-
-
-
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-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"));
-
-restart:
-       while(1){ 
-               if (!getnextwordn(str,20))  {DEBUG_S("DBG: W1\r\n"); goto error;}
-               if (strcmp(str, "nessie")) {DEBUG_S("DBG: 1b\r\n"); goto error;}
-                       testrun_nessie_hmacsha256();
-               goto restart;           
-               continue;
-       error:
-               uart_putstr("ERROR\r\n");
-       }
-       
-}
-
diff --git a/main-md5-test.c b/main-md5-test.c
deleted file mode 100644 (file)
index 490ee48..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-/* main-md5-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * md5 test suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "md5.h"
-#include "nessie_hash_test.h"
-#include "performance_test.h"
-
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-#include "cli.h"
-
-char* algo_name = "MD5";
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-void md5_next_dummy(void* buffer, void* ctx){
-       md5_nextBlock(ctx, buffer);
-}
-
-void md5_last_dummy(void* buffer, uint16_t size_b, void* ctx){
-       md5_lastBlock(ctx, buffer, size_b);
-}
-
-void md5_ctx2hash_dummy(void* buffer, void* ctx){
-       memcpy(buffer, ctx, 16);
-}
-
-
-void testrun_nessie_md5(void){
-       nessie_hash_ctx.hashsize_b  = 128;
-       nessie_hash_ctx.blocksize_B = 512/8;
-       nessie_hash_ctx.ctx_size_B  = sizeof(md5_ctx_t);
-       nessie_hash_ctx.name = algo_name;
-       nessie_hash_ctx.hash_init = (nessie_hash_init_fpt)md5_init;
-       nessie_hash_ctx.hash_next = (nessie_hash_next_fpt)md5_next_dummy;
-       nessie_hash_ctx.hash_last = (nessie_hash_last_fpt)md5_last_dummy;
-       nessie_hash_ctx.hash_conv = (nessie_hash_conv_fpt)md5_ctx2hash_dummy;
-       
-       nessie_hash_run();
-}
-
-/*****************************************************************************
- *  self tests                                                                                                                          *
- *****************************************************************************/
-
-/*
- * MD5 test suite:
- * MD5 ("") = d41d8cd98f00b204e9800998ecf8427e
- * MD5 ("a") = 0cc175b9c0f1b6a831c399e269772661
- * MD5 ("abc") = 900150983cd24fb0d6963f7d28e17f72
- * MD5 ("message digest") = f96b697d7cb7938d525a2f31aaf161d0
- * MD5 ("abcdefghijklmnopqrstuvwxyz") = c3fcd3d76192e4007dfb496cca67e13b
- * MD5 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =
- * d174ab98d277d9f5a5611c2c9f419d9f
- * MD5 ("123456789012345678901234567890123456789012345678901234567890123456
- * 78901234567890") = 57edf4a22be3c955ac49da2e2107b67a
- */
-
-void testrun_md5(void){
-       md5_ctx_t s;
-       char* testv[]={"", "a", "abc", "message digest", "abcdefghijklmnopqrstuvwxyz", 
-               "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 
-               "12345678901234567890123456789012345678901234567890123456789012345678901234567890"};
-       uint8_t i;
-       
-       uart_putstr("\r\n=== MD5 test suit ===");
-       for(i=0; i<7; ++i){
-               uart_putstr("\r\n MD5 (\"");
-               uart_putstr(testv[i]);
-               uart_putstr("\") = \r\n");
-               md5_init(&s);
-               md5_lastBlock(&s, testv[i], strlen(testv[i])*8);
-               uart_hexdump(&s.a[0], 16);
-       }
-}
-
-
-void testrun_performance_md5(void){
-       uint64_t t;
-       char str[16];
-       uint8_t data[32];
-       md5_ctx_t ctx;
-       
-       calibrateTimer();
-       print_overhead();
-       
-       memset(data, 0, 32);
-       
-       startTimer(1);
-       md5_init(&ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       
-       startTimer(1);
-       md5_nextBlock(&ctx, data);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tone-block time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       
-       startTimer(1);
-       md5_lastBlock(&ctx, data, 0);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tlast block time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       uart_putstr_P(PSTR("\r\n"));
-}
-
-
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-int main (void){
-       char str[20];
-
-       
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr("\r\n\r\nCrypto-VS (MD5)\r\nloaded and running\r\n");
-       PGM_P    u   = PSTR("nessie\0test\0performance\0");
-       void_fpt v[] = {testrun_nessie_md5, testrun_md5, testrun_performance_md5};
-
-       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");
-       }
-}
-
diff --git a/main-noekeon-test.c b/main-noekeon-test.c
deleted file mode 100644 (file)
index 851c7bc..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-/* main-noekeon-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * serpent test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "noekeon.h"
-#include "nessie_bc_test.h"
-#include "cli.h"
-#include "performance_test.h"
-
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
-char* cipher_name = "Noekeon";
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-void noekeon_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
-       noekeon_init(key, ctx);
-}
-
-void testrun_nessie_noekeon_indirect(void){
-       char str[strlen(cipher_name)+10];
-       strcpy(str, cipher_name);
-       strcat(str, "-indirect");
-       
-       nessie_bc_ctx.blocksize_B =  16;
-       nessie_bc_ctx.keysize_b   = 128;
-       nessie_bc_ctx.name        = str;
-       nessie_bc_ctx.ctx_size_B  = sizeof(noekeon_ctx_t);
-       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)noekeon_enc;
-       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)noekeon_dec;
-       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)noekeon_genctx_dummy;
-       
-       nessie_bc_run();
-}
-
-void noekeon_genctx_dummy_direct(uint8_t* key, uint16_t keysize, void* ctx){
-       memcpy(ctx, key, 16);
-}
-
-void testrun_nessie_noekeon_direct(void){
-       char str[strlen(cipher_name)+10];
-       strcpy(str, cipher_name);
-       strcat(str, "-Direct");
-       
-       nessie_bc_ctx.blocksize_B =  16;
-       nessie_bc_ctx.keysize_b   = 128;
-       nessie_bc_ctx.name        = str;
-       nessie_bc_ctx.ctx_size_B  = sizeof(noekeon_ctx_t);
-       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)noekeon_enc;
-       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)noekeon_dec;
-       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)noekeon_genctx_dummy_direct;
-       
-       nessie_bc_run();
-}
-
-void testrun_nessie_noekeon(void){
-       testrun_nessie_noekeon_direct();
-       testrun_nessie_noekeon_indirect();
-}
-
-
-void testrun_stdtest_rundirect(void* data, void* key){
-       uart_putstr_P(PSTR("\r\n                     "));
-       uart_putstr_P(PSTR("k = "));
-       uart_hexdump(key,16);
-       
-       uart_putstr_P(PSTR("\r\n                     "));
-       uart_putstr_P(PSTR("a = "));
-       uart_hexdump(data,16);
-       
-       noekeon_enc(data, key);
-       uart_putstr_P(PSTR("\r\nafter NESSIEencrypt, b = "));
-       uart_hexdump(data,16);
-       
-       noekeon_dec(data, key);
-       uart_putstr_P(PSTR("\r\nafter NESSIEdecrypt, a?= "));
-       uart_hexdump(data,16);
-       uart_putstr_P(PSTR("\r\n"));
-}
-
-void testrun_stdtest_runindirect(void* data, void* key){
-       noekeon_ctx_t ctx;
-       uart_putstr_P(PSTR("\r\n                     "));
-       uart_putstr_P(PSTR("k = "));
-       uart_hexdump(key,16);
-       
-       uart_putstr_P(PSTR("\r\n                     "));
-       uart_putstr_P(PSTR("a = "));
-       uart_hexdump(data,16);
-       noekeon_init(key, &ctx);
-       noekeon_enc(data, &ctx);
-       uart_putstr_P(PSTR("\r\nafter NESSIEencrypt, b = "));
-       uart_hexdump(data,16);
-       
-       noekeon_dec(data, &ctx);
-       uart_putstr_P(PSTR("\r\nafter NESSIEdecrypt, a?= "));
-       uart_hexdump(data,16);
-       uart_putstr_P(PSTR("\r\n"));
-}
-
-void testrun_stdtest_noekeon(void){
-       uint8_t key[16], data[16];
-       uint8_t key3[16];
-       noekeon_ctx_t ctx;
-       
-       uart_putstr_P(PSTR("\r\nTest vectors for block cipher Noekeon in Indirect-Key Mode:\r\n"));
-       
-       memset(key,  0, 16);
-       memset(data, 0, 16);
-       testrun_stdtest_runindirect(data, key);
-       
-       memset(key,  0xFF, 16);
-       memset(data, 0xFF, 16);
-       testrun_stdtest_runindirect(data, key);
-       
-       memset(key,  0, 16);
-       memset(data, 0, 16);
-       noekeon_init(key, &ctx);
-       noekeon_enc(data, &ctx);
-       memcpy(key3, data, 16);
-       memset(key,  0xFF, 16);
-       memset(data, 0xFF, 16);
-       noekeon_init(key, &ctx);
-       noekeon_enc(data, &ctx);
-       testrun_stdtest_runindirect(data, key3);
-       
-       uart_putstr_P(PSTR("\r\nTest vectors for block cipher Noekeon in Direct-Key Mode:\r\n"));
-       
-       memset(key,  0, 16);
-       memset(data, 0, 16);
-       testrun_stdtest_rundirect(data, key);
-       
-       memset(key,  0xFF, 16);
-       memset(data, 0xFF, 16);
-       testrun_stdtest_rundirect(data, key);
-       
-       memset(key,  0, 16);
-       memset(data, 0, 16);
-       noekeon_enc(data, key);
-       memcpy(key3, data, 16);
-       memset(key,  0xFF, 16);
-       memset(data, 0xFF, 16);
-       noekeon_enc(data, key);
-       testrun_stdtest_rundirect(data, key3);
-       
-}
-
-void testrun_performance_noekeon(void){
-       uint64_t t;
-       char str[16];
-       uint8_t key[16], data[16];
-       noekeon_ctx_t ctx;
-       
-       calibrateTimer();
-       print_overhead();
-       
-       memset(key,  0, 16);
-       memset(data, 0, 16);
-       
-       startTimer(1);
-       noekeon_init(key, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);       
-       
-       startTimer(1);
-       noekeon_enc(data, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);       
-       
-       startTimer(1);
-       noekeon_dec(data, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       uart_putstr_P(PSTR("\r\n"));
-}
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-int main (void){
-       char  str[20];
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
-       uart_putstr(cipher_name);
-       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-
-       PGM_P    u   = PSTR("nessie\0test\0direct\0indirect\0performance\0");
-       void_fpt v[] = {testrun_nessie_noekeon, 
-                           testrun_stdtest_noekeon,
-                           testrun_nessie_noekeon_direct, 
-                           testrun_nessie_noekeon_indirect,  
-                           testrun_performance_noekeon};
-
-       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");
-       }
-       
-}
-
diff --git a/main-present-test.c b/main-present-test.c
deleted file mode 100644 (file)
index 4c739bc..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/* main-present-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * present test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "present.h"
-#include "nessie_bc_test.h"
-#include "cli.h"
-#include "performance_test.h"
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-
-char* cipher_name = "Present";
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-void present_genctx_dummy(uint8_t* key, uint16_t keysize_b, present_ctx_t* ctx){
-       present_init(key, keysize_b, ctx);
-}
-
-void testrun_nessie_present(void){
-       nessie_bc_ctx.blocksize_B =   8;
-       nessie_bc_ctx.keysize_b   =  80;
-       nessie_bc_ctx.name        = cipher_name;
-       nessie_bc_ctx.ctx_size_B  = sizeof(present_ctx_t);
-       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)present_enc;
-       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)present_dec;
-       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)present_genctx_dummy;
-       
-       nessie_bc_run();        
-}
-
-void testrun_selfenc(uint8_t* key, uint8_t* buffer){
-       present_ctx_t ctx;
-       uart_putstr_P(PSTR("\r\nkey   : "));
-       uart_hexdump(key, 10);
-       uart_putstr_P(PSTR("\r\nplain : "));
-       uart_hexdump(buffer, 8);
-       present_init(key, 80, &ctx);
-       present_enc(buffer, &ctx);
-       uart_putstr_P(PSTR("\r\ncipher: "));
-       uart_hexdump(buffer, 8);
-       present_dec(buffer, &ctx);
-       uart_putstr_P(PSTR("\r\nplain : "));
-       uart_hexdump(buffer, 8);
-       uart_putstr_P(PSTR("\r\n"));
-}
-
-void testrun_self_present(void){
-       uint8_t buffer[8], key[10];
-       uart_putstr_P(PSTR("\r\n\r\n=== Testvectors from the paper ===\r\n"));
-       
-       memset(buffer, 0, 8);
-       memset(key, 0, 10);
-       testrun_selfenc(key, buffer);
-       
-       memset(buffer, 0, 8);
-       memset(key, 0xFF, 10);
-       testrun_selfenc(key, buffer);
-       
-       memset(buffer, 0xFF, 8);
-       memset(key, 0, 10);
-       testrun_selfenc(key, buffer);
-       
-       memset(buffer, 0xFF, 8);
-       memset(key, 0xFF, 10);
-       testrun_selfenc(key, buffer);
-       
-}
-
-void testrun_performance_present(void){
-       uint64_t t;
-       uint8_t key[10], data[8];
-       present_ctx_t ctx;
-       
-       calibrateTimer();
-       print_overhead();
-       
-       memset(key,  0, 10);
-       memset(data, 0,  8);
-       
-       startTimer(1);
-       present_init(key, 80, &ctx);
-       t = stopTimer();
-       print_time_P(PSTR("\tctx-gen time: "),t);
-       
-       startTimer(1);
-       present_enc(data, &ctx);
-       t = stopTimer();
-       print_time_P(PSTR("\tencrypt time: "), t);
-       
-       startTimer(1);
-       present_dec(data, &ctx);
-       t = stopTimer();
-       print_time_P(PSTR("\tdecrypt time: "), t);
-       
-       uart_putstr_P(PSTR("\r\n"));
-}
-
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-int main (void){
-       char  str[20];
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
-       uart_putstr(cipher_name);
-       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-
-       PGM_P    u   = PSTR("nessie\0test\0performance\0");
-       void_fpt v[] = {testrun_nessie_present, testrun_self_present, testrun_performance_present};
-
-       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");
-       }
-       
-}
diff --git a/main-rc5-test.c b/main-rc5-test.c
deleted file mode 100644 (file)
index 2c16aea..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/* main-rc5-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * rc5 test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "rc5.h"
-#include "nessie_bc_test.h"
-#include "cli.h"
-#include "performance_test.h"
-
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
-#define RC5_ROUNDS 12
-char* cipher_name = "RC5-32/12/16";
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-void rc5_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
-       rc5_init(key, keysize_b, RC5_ROUNDS, ctx);
-}
-
-void testrun_nessie_rc5(void){
-       nessie_bc_init();
-       nessie_bc_ctx.blocksize_B =   8;
-       nessie_bc_ctx.keysize_b   = 128;
-       nessie_bc_ctx.name        = cipher_name;
-       nessie_bc_ctx.ctx_size_B  = sizeof(rc5_ctx_t);
-       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)rc5_enc;
-       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)rc5_dec;
-       nessie_bc_ctx.cipher_free = (nessie_bc_free_fpt)rc5_free;
-       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)rc5_genctx_dummy;
-       
-       nessie_bc_run();
-}
-
-
-void testrun_performance_rc5(void){
-       uint64_t t;
-       char str[16];
-       uint8_t key[16], data[16];
-       rc5_ctx_t ctx;
-       
-       calibrateTimer();
-       print_overhead();
-       
-       memset(key,  0, 16);
-       memset(data, 0, 16);
-       
-       startTimer(1);
-       rc5_init(key, 128, RC5_ROUNDS, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);       
-       
-       startTimer(1);
-       rc5_enc(data, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       startTimer(1);
-       rc5_dec(data, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-
-       startTimer(1);
-       rc5_free(&ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tfree time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       uart_putstr_P(PSTR("\r\n"));
-}
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-int main (void){
-       char  str[20];
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
-       uart_putstr(cipher_name);
-       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-
-       PGM_P    u   = PSTR("nessie\0test\0performance\0");
-       void_fpt v[] = {testrun_nessie_rc5, testrun_nessie_rc5, testrun_performance_rc5};
-
-       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");
-       }
-       
-}
-
diff --git a/main-rc6-test.c b/main-rc6-test.c
deleted file mode 100644 (file)
index 5d7ecda..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/* main-rc6-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * rc5 test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "rc6.h"
-#include "nessie_bc_test.h"
-#include "cli.h"
-#include "performance_test.h"
-
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
-#define RC6_ROUNDS 20
-char* cipher_name = "RC6-32/20/16";
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-void rc6_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
-       rc6_initl(key, keysize_b, RC6_ROUNDS, ctx);
-}
-
-void testrun_nessie_rc6(void){
-       nessie_bc_init();
-       nessie_bc_ctx.blocksize_B =  16;
-       nessie_bc_ctx.keysize_b   = 128;
-       nessie_bc_ctx.name        = cipher_name;
-       nessie_bc_ctx.ctx_size_B  = sizeof(rc6_ctx_t);
-       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)rc6_enc;
-       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)rc6_dec;
-       nessie_bc_ctx.cipher_free = (nessie_bc_free_fpt)rc6_free;
-       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)rc6_init;
-       
-       nessie_bc_run();
-       
-       nessie_bc_ctx.keysize_b   = 192;
-       nessie_bc_run();
-       
-       nessie_bc_ctx.keysize_b   = 256;
-       nessie_bc_run();
-       
-}
-
-
-void testrun_performance_rc6(void){
-       uint64_t t;
-       char str[16];
-       uint8_t key[16], data[16];
-       rc6_ctx_t ctx;
-       
-       calibrateTimer();
-       print_overhead();
-       
-       memset(key,  0, 16);
-       memset(data, 0, 16);
-       
-       startTimer(1);
-       rc6_init(key, 128, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);       
-       
-       startTimer(1);
-       rc6_enc(data, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       startTimer(1);
-       rc6_dec(data, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-
-       startTimer(1);
-       rc6_free(&ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tfree time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       uart_putstr_P(PSTR("\r\n"));
-}
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-int main (void){
-       char  str[20];
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
-       uart_putstr(cipher_name);
-       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-
-       PGM_P    u   = PSTR("nessie\0test\0performance\0");
-       void_fpt v[] = {testrun_nessie_rc6, testrun_nessie_rc6, testrun_performance_rc6};
-
-       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");
-       }
-       
-}
-
diff --git a/main-seed-test.c b/main-seed-test.c
deleted file mode 100644 (file)
index 678d132..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/* main-seed-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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       main-seed-test.c
- * \author     Daniel Otte
- * \email      daniel.otte@rub.de
- * \date       2007-06-01
- * \brief      test suit for SEED
- * \par License        
- * GPLv3 or later
- * 
- */
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "seed.h"
-#include "nessie_bc_test.h"
-#include "cli.h"
-#include "performance_test.h"
-
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
-char* cipher_name = "Seed";
-
-/*****************************************************************************
- *  additional validation-functions                                          *
- *****************************************************************************/
-void seed_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
-       seed_init(key, ctx);
-}
-
-void testrun_nessie_seed(void){
-       nessie_bc_ctx.blocksize_B =  16;
-       nessie_bc_ctx.keysize_b   = 128;
-       nessie_bc_ctx.name        = cipher_name;
-       nessie_bc_ctx.ctx_size_B  = sizeof(seed_ctx_t);
-       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)seed_enc;
-       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)seed_dec;
-       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)seed_genctx_dummy;
-       
-       nessie_bc_run();
-       
-}
-
-
-void testrun_performance_seed(void){
-       uint64_t t;
-       char str[16];
-       uint8_t key[16], data[16];
-       seed_ctx_t ctx;
-       
-       calibrateTimer();
-       print_overhead();
-       
-       memset(key,  0, 16);
-       memset(data, 0, 16);
-       
-       startTimer(1);
-       seed_init(key, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       
-       startTimer(1);
-       seed_enc(data, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       
-       startTimer(1);
-       seed_dec(data, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       uart_putstr_P(PSTR("\r\n"));
-}
-
-/*****************************************************************************
- *  self tests                                                               *
- *****************************************************************************/
-
-void testencrypt(uint8_t* block, uint8_t* key){
-       seed_ctx_t ctx;
-       uart_putstr("\r\n==testy-encrypt==\r\n key: ");
-       uart_hexdump(key,16);
-       seed_init(key, &ctx);
-       uart_putstr("\r\n plain: ");
-       uart_hexdump(block,16);
-       seed_enc(block, &ctx);
-       uart_putstr("\r\n crypt: ");
-       uart_hexdump(block,16);
-}
-
-void testdecrypt(uint8_t* block, uint8_t* key){
-       seed_ctx_t ctx;
-       uart_putstr("\r\n==testy-decrypt==\r\n key: ");
-       uart_hexdump(key,16);
-       seed_init(key, &ctx);
-       uart_putstr("\r\n crypt: ");
-       uart_hexdump(block,16);
-       seed_dec(block, &ctx);
-       uart_putstr("\r\n plain: ");
-       uart_hexdump(block,16);
-}
-
-void testrun_seed(void){
-       uint8_t keys[4][16]=
-               { {     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
-                 {     0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
-                       0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
-                 { 0x47, 0x06, 0x48, 0x08, 0x51, 0xE6, 0x1B, 0xE8,
-                       0x5D, 0x74, 0xBF, 0xB3, 0xFD, 0x95, 0x61, 0x85 },
-                 { 0x28, 0xDB, 0xC3, 0xBC, 0x49, 0xFF, 0xD8, 0x7D,
-                       0xCF, 0xA5, 0x09, 0xB1, 0x1D, 0x42, 0x2B, 0xE7,}
-               };
-       uint8_t datas[4][16]=
-               { {     0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
-                       0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
-                 {     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
-                 { 0x83, 0xA2, 0xF8, 0xA2, 0x88, 0x64, 0x1F, 0xB9, 
-                       0xA4, 0xE9, 0xA5, 0xCC, 0x2F, 0x13, 0x1C, 0x7D },
-                 { 0xB4, 0x1E, 0x6B, 0xE2, 0xEB, 0xA8, 0x4A, 0x14, 
-                       0x8E, 0x2E, 0xED, 0x84, 0x59, 0x3C, 0x5E, 0xC7 }
-               };
-       uint8_t i=0;
-       for(i=0; i<4; ++i){
-               testencrypt(datas[i],keys[i]);
-               testdecrypt(datas[i],keys[i]);  
-       }
-}
-
-
-
-/*****************************************************************************
- *  main                                                                     *
- *****************************************************************************/
-
-int main (void){
-       char str[20];
-
-       DEBUG_INIT();
-
-       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
-       uart_putstr(cipher_name);
-       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-
-       PGM_P    u   = PSTR("nessie\0test\0performance\0");
-       void_fpt v[] = {testrun_nessie_seed, testrun_seed, testrun_performance_seed};
-
-       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");
-       }
-       
-}
-
diff --git a/main-serpent-test.c b/main-serpent-test.c
deleted file mode 100644 (file)
index 5c450b6..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/* main-serpent-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * serpent test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "serpent.h"
-#include "nessie_bc_test.h"
-#include "cli.h"
-#include "performance_test.h"
-
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
-char* cipher_name = "Serpent";
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-void serpent_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
-       serpent_init(key, keysize&0xff, ctx);
-}
-
-void testrun_nessie_serpent(void){
-       nessie_bc_ctx.blocksize_B =  16;
-       nessie_bc_ctx.keysize_b   = 128;
-       nessie_bc_ctx.name        = cipher_name;
-       nessie_bc_ctx.ctx_size_B  = sizeof(serpent_ctx_t);
-       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)serpent_enc;
-       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)serpent_dec;
-       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)serpent_genctx_dummy;
-       
-       nessie_bc_run();
-       
-       nessie_bc_ctx.keysize_b   = 192;
-       nessie_bc_run();
-       
-       nessie_bc_ctx.keysize_b   = 256;
-       nessie_bc_run();
-}
-
-
-void testrun_performance_serpent(void){
-       uint64_t t;
-       char str[16];
-       uint8_t key[32], data[16];
-       serpent_ctx_t ctx;
-       
-       calibrateTimer();
-       print_overhead();
-       
-       memset(key,  0, 32);
-       memset(data, 0, 16);
-       
-       startTimer(1);
-       serpent_init(key, 0, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       
-       startTimer(1);
-       serpent_enc(data, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       
-       startTimer(1);
-       serpent_dec(data, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       uart_putstr_P(PSTR("\r\n"));
-}
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-int main (void){
-       char  str[20];
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
-       uart_putstr(cipher_name);
-       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-
-       PGM_P    u   = PSTR("nessie\0test\0performance\0");
-       void_fpt v[] = {testrun_nessie_serpent, testrun_nessie_serpent, testrun_performance_serpent};
-
-       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");
-       }
-       
-}
-
diff --git a/main-sha1-test.c b/main-sha1-test.c
deleted file mode 100644 (file)
index 6f07227..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/* main-sha1-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * SHA-1 test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "sha1.h"
-#include "nessie_hash_test.h"
-#include "performance_test.h"
-
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-#include "cli.h"
-
-char* algo_name = "SHA-1";
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-void sha1_next_dummy(void* buffer, void* ctx){
-       sha1_nextBlock(ctx, buffer);
-}
-
-void sha1_last_dummy(void* buffer, uint16_t size_b, void* ctx){
-       sha1_lastBlock(ctx, buffer, size_b);
-}
-
-void testrun_nessie_sha1(void){
-       nessie_hash_ctx.hashsize_b  = 160;
-       nessie_hash_ctx.blocksize_B = 512/8;
-       nessie_hash_ctx.ctx_size_B  = sizeof(sha1_ctx_t);
-       nessie_hash_ctx.name = algo_name;
-       nessie_hash_ctx.hash_init = (nessie_hash_init_fpt)sha1_init;
-       nessie_hash_ctx.hash_next = (nessie_hash_next_fpt)sha1_next_dummy;
-       nessie_hash_ctx.hash_last = (nessie_hash_last_fpt)sha1_last_dummy;
-       nessie_hash_ctx.hash_conv = (nessie_hash_conv_fpt)sha1_ctx2hash;
-       
-       nessie_hash_run();
-}
-
-/*****************************************************************************
- *  self tests                                                                                                                          *
- *****************************************************************************/
-
-void sha1_ctx_dump(sha1_ctx_t *s){
-       uint8_t i;
-       uart_putstr("\r\n==== sha1_ctx_dump ====");
-       for(i=0;i<5;++i){
-               uart_putstr("\r\na["); uart_hexdump(&i, 1); uart_putstr("]: ");
-               uart_hexdump(&(s->h[i]), 4);
-       }
-       uart_putstr("\r\nlength"); uart_hexdump(&i, 8);
-} 
-
-void testrun_sha1(void){
-       sha1_hash_t hash;
-       sha1(&hash,"abc",3*8);
-       uart_putstr("\r\nsha1(\"abc\") = \r\n\t");
-       uart_hexdump(hash,SHA1_HASH_BITS/8);
-       
-       sha1(&hash,"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",448);
-       uart_putstr("\r\nsha1(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\") = \r\n\t");
-       uart_hexdump(hash,SHA1_HASH_BITS/8);
-       
-       uart_putstr("\r\nsha1(1,000,000 * 'a') = \r\n\t");
-       {
-               uint8_t block[SHA1_BLOCK_BITS/8];
-               uint16_t i;
-               sha1_ctx_t s;
-               memset(block,'a',SHA1_BLOCK_BITS/8);
-               sha1_init(&s);
-               for(i=0;i<15625; ++i){ /* (1000000/(SHA1_BLOCK_BITS/8)) */
-                       sha1_nextBlock(&s, block);
-               }
-               sha1_lastBlock(&s,block,0);
-               sha1_ctx2hash(&hash, &s);
-       }
-       uart_hexdump(hash,SHA1_HASH_BITS/8);
-       
-
-       uart_putstr("\r\nx");
-}
-
-void testrun_performance_sha1(void){
-       uint64_t t;
-       char str[16];
-       uint8_t data[32];
-       sha1_ctx_t ctx;
-       
-       calibrateTimer();
-       print_overhead();
-       
-       memset(data, 0, 32);
-       
-       startTimer(1);
-       sha1_init(&ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       
-       startTimer(1);
-       sha1_nextBlock(&ctx, data);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tone-block time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       
-       startTimer(1);
-       sha1_lastBlock(&ctx, data, 0);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tlast block time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       uart_putstr_P(PSTR("\r\n"));
-}
-
-
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-int main (void){
-       char str[20];
-
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr("\r\n\r\nCrypto-VS (SHA-1)\r\nloaded and running\r\n");
-
-       PGM_P    u   = PSTR("nessie\0test\0performance\0");
-       void_fpt v[] = {testrun_nessie_sha1, testrun_sha1, testrun_performance_sha1};
-
-       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");
-       }
-}
-
-
diff --git a/main-sha256-test.c b/main-sha256-test.c
deleted file mode 100644 (file)
index 9c3031d..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/* main-sha256-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * SHA-256 test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "sha256.h"
-#include "nessie_hash_test.h"
-#include "performance_test.h"
-
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-#include "cli.h"
-
-char* algo_name = "SHA-256";
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-void sha256_next_dummy(void* buffer, void* ctx){
-       sha256_nextBlock(ctx, buffer);
-}
-
-void sha256_last_dummy(void* buffer, uint16_t size_b, void* ctx){
-       sha256_lastBlock(ctx, buffer, size_b);
-}
-
-void testrun_nessie_sha256(void){
-       nessie_hash_ctx.hashsize_b  = 256;
-       nessie_hash_ctx.blocksize_B = 512/8;
-       nessie_hash_ctx.ctx_size_B  = sizeof(sha256_ctx_t);
-       nessie_hash_ctx.name = algo_name;
-       nessie_hash_ctx.hash_init = (nessie_hash_init_fpt)sha256_init;
-       nessie_hash_ctx.hash_next = (nessie_hash_next_fpt)sha256_next_dummy;
-       nessie_hash_ctx.hash_last = (nessie_hash_last_fpt)sha256_last_dummy;
-       nessie_hash_ctx.hash_conv = (nessie_hash_conv_fpt)sha256_ctx2hash;
-       
-       nessie_hash_run();
-}
-
-void testrun_performance_sha256(void){
-       uint64_t t;
-       char str[16];
-       uint8_t data[32];
-       sha256_ctx_t ctx;
-       
-       calibrateTimer();
-       print_overhead();
-       
-       memset(data, 0, 32);
-       
-       startTimer(1);
-       sha256_init(&ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       
-       startTimer(1);
-       sha256_nextBlock(&ctx, data);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tone-block time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       
-       startTimer(1);
-       sha256_lastBlock(&ctx, data, 0);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tlast block time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       uart_putstr_P(PSTR("\r\n"));
-}
-
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-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");
-       }
-}
-
diff --git a/main-shabea-test.c b/main-shabea-test.c
deleted file mode 100644 (file)
index f221fd5..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/* main-shabea-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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       main-shabea-test.c
- * \author     Daniel Otte 
- * \date       2007-06-07
- * \brief      test suit for SHABEA
- * \par License        
- * GPLv3 or later
- * 
- */
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "shabea.h"
-#include "nessie_bc_test.h"
-#include "cli.h"
-#include "performance_test.h"
-
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
-char* cipher_name = "Shabea";
-
-/*****************************************************************************
- *  additional validation-functions                                          *
- *****************************************************************************/
-void shabea_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
-       memcpy(ctx, key, (keysize_b+7)/8);
-}
-
-void shabea_enc_dummy(void* buffer, void* ctx){
-       shabea256(buffer, ctx, 256, 1, 16);
-}
-
-void shabea_dec_dummy(void* buffer, void* ctx){
-       shabea256(buffer, ctx, 256, 0, 16);
-}
-
-
-void testrun_nessie_shabea(void){
-       nessie_bc_ctx.blocksize_B =  32;
-       nessie_bc_ctx.keysize_b   = 256;
-       nessie_bc_ctx.name        = cipher_name;
-       nessie_bc_ctx.ctx_size_B  = 32;
-       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)shabea_enc_dummy;
-       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)shabea_dec_dummy;
-       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)shabea_genctx_dummy;
-       
-       nessie_bc_run();
-}
-
-
-void testrun_performance_shabea(void){
-       uint64_t t;
-       char str[16];
-       uint8_t key[32], data[32];
-       
-       calibrateTimer();
-       print_overhead();
-       
-       memset(key,  0, 32);
-       memset(data, 0, 32);
-       
-       startTimer(1);
-       shabea256(data, key, 256, 1, 16);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       
-       startTimer(1);
-       shabea256(data, key, 256, 0, 16);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       uart_putstr_P(PSTR("\r\n"));
-}
-
-/*****************************************************************************
- *  self tests                                                                                                                          *
- *****************************************************************************/
-
-void testencrypt(uint8_t* block, uint8_t* key){
-       uart_putstr("\r\n==testy-encrypt==\r\n key: ");
-       uart_hexdump(key,16);
-       uart_putstr("\r\n plain: ");
-       uart_hexdump(block,32);
-       shabea256(block,key,128,1,16);
-       uart_putstr("\r\n crypt: ");
-       uart_hexdump(block,32);
-}
-
-void testdecrypt(uint8_t* block, uint8_t* key){
-
-       uart_putstr("\r\n==testy-decrypt==\r\n key: ");
-       uart_hexdump(key,16);
-       uart_putstr("\r\n crypt: ");
-       uart_hexdump(block,32);
-       shabea256(block,key,128,0,16);
-       uart_putstr("\r\n plain: ");
-       uart_hexdump(block,32);
-}
-
-void testrun_shabea(void){
-       uint8_t keys[4][16]=
-               { {     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
-                 {     0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
-                       0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
-                 { 0x47, 0x06, 0x48, 0x08, 0x51, 0xE6, 0x1B, 0xE8,
-                       0x5D, 0x74, 0xBF, 0xB3, 0xFD, 0x95, 0x61, 0x85 },
-                 { 0x28, 0xDB, 0xC3, 0xBC, 0x49, 0xFF, 0xD8, 0x7D,
-                       0xCF, 0xA5, 0x09, 0xB1, 0x1D, 0x42, 0x2B, 0xE7,}
-               };
-       uint8_t datas[4][32]=
-               { {     0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
-                       0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
-                       0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
-                       0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
-                 {     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
-                 { 0x83, 0xA2, 0xF8, 0xA2, 0x88, 0x64, 0x1F, 0xB9, 
-                       0xA4, 0xE9, 0xA5, 0xCC, 0x2F, 0x13, 0x1C, 0x7D,
-                       0x83, 0xA2, 0xF8, 0xA2, 0x88, 0x64, 0x1F, 0xB9, 
-                       0xA4, 0xE9, 0xA5, 0xCC, 0x2F, 0x13, 0x1C, 0x7D },
-                 { 0xB4, 0x1E, 0x6B, 0xE2, 0xEB, 0xA8, 0x4A, 0x14, 
-                       0x8E, 0x2E, 0xED, 0x84, 0x59, 0x3C, 0x5E, 0xC7,
-                       0xB4, 0x1E, 0x6B, 0xE2, 0xEB, 0xA8, 0x4A, 0x14, 
-                       0x8E, 0x2E, 0xED, 0x84, 0x59, 0x3C, 0x5E, 0xC7 }
-               };
-       uint8_t i=0;
-       for(i=0; i<4; ++i){
-               testencrypt(datas[i],keys[i]);
-               testdecrypt(datas[i],keys[i]);  
-       }
-}
-
-
-
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-int main (void){
-       char str[20];
-
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
-       uart_putstr(cipher_name);
-       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-
-       PGM_P    u   = PSTR("nessie\0test\0performance\0");
-       void_fpt v[] = {testrun_nessie_shabea, testrun_shabea, testrun_performance_shabea};
-
-       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");
-       }
-       
-}
-
diff --git a/main-shacal1_enc-test.c b/main-shacal1_enc-test.c
deleted file mode 100644 (file)
index a4a0a1f..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/* main-shacal1_enc-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * Shacal1 encryption only test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "shacal1_enc.h"
-#include "nessie_bc_test.h"
-#include "cli.h"
-#include "performance_test.h"
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-
-char* cipher_name = "Shacal1 encryption only";
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-void shacal1_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
-       memcpy(ctx, key, (keysize_b+7)/8);
-}
-
-void shacal1_enc_dummy(void* buffer, void* ctx){
-       shacal1_enc(buffer, ctx, 512);
-}
-
-void testrun_nessie_shacal1enc(void){
-       nessie_bc_ctx.blocksize_B = SHACAL1_BLOCKSIZE_B;
-       nessie_bc_ctx.keysize_b   = SHACAL1_KEYSIZE;
-       nessie_bc_ctx.name        = cipher_name;
-       nessie_bc_ctx.ctx_size_B  = SHACAL1_KEYSIZE_B;
-       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)shacal1_enc_dummy;
-       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)NULL;
-       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)shacal1_genctx_dummy;
-       
-       nessie_bc_run();        
-}
-
-void testrun_performance_shacal1enc(void){
-       uint64_t t;
-       uint8_t key[SHACAL1_KEYSIZE_B], data[SHACAL1_BLOCKSIZE_B];
-       
-       calibrateTimer();
-       print_overhead();
-       
-       memset(key,  0, SHACAL1_KEYSIZE_B);
-       memset(data, 0, SHACAL1_BLOCKSIZE_B);
-       
-       
-       startTimer(1);
-       shacal1_enc(data, key, SHACAL1_KEYSIZE);
-       t = stopTimer();
-       print_time_P(PSTR("\tencrypt time: "), t);
-       
-       uart_putstr_P(PSTR("\r\n"));
-}
-
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-int main (void){
-       char  str[20];
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
-       uart_putstr(cipher_name);
-       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-
-       PGM_P    u   = PSTR("nessie\0test\0performance\0");
-       void_fpt v[] = {testrun_nessie_shacal1enc, 
-                           testrun_nessie_shacal1enc,
-                           testrun_performance_shacal1enc};
-
-       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");
-       }
-       
-}
diff --git a/main-shacal2_enc-test.c b/main-shacal2_enc-test.c
deleted file mode 100644 (file)
index 3ffd131..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/* main-shacal2_enc-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * Shacal2 encryption only test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "shacal2_enc.h"
-#include "nessie_bc_test.h"
-#include "cli.h"
-#include "performance_test.h"
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-
-char* cipher_name = "Shacal2 encryption only";
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-void shacal2_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
-       memcpy(ctx, key, (keysize_b+7)/8);
-}
-
-void shacal2_enc_dummy(void* buffer, void* ctx){
-       shacal2_enc(buffer, ctx, SHACAL2_KEYSIZE);
-}
-
-void testrun_nessie_shacal2enc(void){
-       nessie_bc_ctx.blocksize_B = SHACAL2_BLOCKSIZE_B;
-       nessie_bc_ctx.keysize_b   = SHACAL2_KEYSIZE;
-       nessie_bc_ctx.name        = cipher_name;
-       nessie_bc_ctx.ctx_size_B  = SHACAL2_KEYSIZE_B;
-       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)shacal2_enc_dummy;
-       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)NULL;
-       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)shacal2_genctx_dummy;
-       
-       nessie_bc_run();        
-}
-
-void testrun_performance_shacal2enc(void){
-       uint64_t t;
-       uint8_t key[SHACAL2_KEYSIZE_B], data[SHACAL2_BLOCKSIZE_B];
-       
-       calibrateTimer();
-       print_overhead();
-       
-       memset(key,  0, SHACAL2_KEYSIZE_B);
-       memset(data, 0, SHACAL2_BLOCKSIZE_B);
-       
-       
-       startTimer(1);
-       shacal2_enc(data, key, SHACAL2_KEYSIZE);
-       t = stopTimer();
-       print_time_P(PSTR("\tencrypt time: "), t);
-       
-       uart_putstr_P(PSTR("\r\n"));
-}
-
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-int main (void){
-       char  str[20];
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
-       uart_putstr(cipher_name);
-       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-
-       PGM_P    u   = PSTR("nessie\0test\0performance\0");
-       void_fpt v[] = {testrun_nessie_shacal2enc, 
-                           testrun_nessie_shacal2enc,
-                           testrun_performance_shacal2enc};
-
-       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");
-       }
-       
-}
diff --git a/main-skipjack-test.c b/main-skipjack-test.c
deleted file mode 100644 (file)
index a7f1165..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/* main-skipjack-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * skipjack test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "skipjack.h"
-#include "nessie_bc_test.h"
-#include "cli.h"
-#include "performance_test.h"
-
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
-
-char* cipher_name = "Skipjack";
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-void skipjack_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
-       memcpy(ctx, key, 10);
-}
-
-void testrun_nessie_skipjack(void){
-       nessie_bc_ctx.blocksize_B =   8;
-       nessie_bc_ctx.keysize_b   =  80;
-       nessie_bc_ctx.name        = cipher_name;
-       nessie_bc_ctx.ctx_size_B  = 10;
-       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)skipjack_enc;
-       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)skipjack_dec;
-       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)skipjack_genctx_dummy;
-       
-       nessie_bc_run();
-}
-
-
-void testrun_performance_skipjack(void){
-       uint64_t t;
-       char str[16];
-       uint8_t key[10], data[8];
-       
-       calibrateTimer();
-       print_overhead();
-       
-       memset(key,  0, 10);
-       memset(data, 0,  8);
-       
-       startTimer(1);
-       skipjack_enc(data, key);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       
-       startTimer(1);
-       skipjack_dec(data, key);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       uart_putstr_P(PSTR("\r\n"));
-}
-
-/*****************************************************************************
- *  self tests                                                                                                                          *
- *****************************************************************************/
-
-void testencrypt(uint8_t* block, uint8_t* key){
-       uart_putstr("\r\n==testy-encrypt==\r\n key: ");
-       uart_hexdump(key,10);
-       uart_putstr("\r\n plain: ");
-       uart_hexdump(block,8);
-       skipjack_enc(block,key);
-       uart_putstr("\r\n crypt: ");
-       uart_hexdump(block,8);
-}
-
-void testdecrypt(uint8_t* block, uint8_t* key){
-       uart_putstr("\r\n==testy-decrypt==\r\n key: ");
-       uart_hexdump(key,10);
-       uart_putstr("\r\n crypt: ");
-       uart_hexdump(block,8);
-       skipjack_dec(block,key);
-       uart_putstr("\r\n plain: ");
-       uart_hexdump(block,8);
-}
-
-void testrun_skipjack(void){
-       uint8_t key[]={ 0x00, 0x99, 0x88, 0x77, 0x66,
-                                       0x55, 0x44, 0x33, 0x22, 0x11};
-       uint8_t data[]={ 0x33, 0x22, 0x11, 0x00, 0xdd, 0xcc, 0xbb, 0xaa};
-       testencrypt(data,key);
-       testdecrypt(data,key);  
-}
-
-
-
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-int main (void){
-       char str[20];
-
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr("\r\n\r\nCrypto-VS (skipjack)\r\nloaded and running\r\n");
-
-       PGM_P    u   = PSTR("nessie\0test\0performance\0");
-       void_fpt v[] = {testrun_nessie_skipjack, testrun_skipjack, testrun_performance_skipjack};
-
-       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");
-       }
-       
-}
-
diff --git a/main-tdes-test.c b/main-tdes-test.c
deleted file mode 100644 (file)
index d5ae1a0..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/* main-tdes-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * tdes test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "des.h"
-#include "nessie_bc_test.h"
-#include "cli.h"
-#include "performance_test.h"
-
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
-char* cipher_name = "TDES";
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-void tdes_init_dummy(const void* key, uint16_t keysize_b, void* ctx){
-       memcpy(ctx, key, 8*3);
-}
-
-void tdes_enc_dummy(void* buffer, void* ctx){
-       tdes_enc(buffer, buffer, ctx);
-} 
-
-void tdes_dec_dummy(void* buffer, void* ctx){
-       tdes_dec(buffer, buffer, ctx);
-} 
-
-void testrun_nessie_tdes(void){
-       nessie_bc_init();
-       nessie_bc_ctx.blocksize_B =   8;
-       nessie_bc_ctx.keysize_b   = 192;
-       nessie_bc_ctx.name        = cipher_name;
-       nessie_bc_ctx.ctx_size_B  = sizeof(8*3);
-       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)tdes_enc_dummy;
-       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)tdes_dec_dummy;
-       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)tdes_init_dummy;
-
-       nessie_bc_run();
-}
-
-
-void testrun_performance_tdes(void){
-       uint64_t t;
-       char str[16];
-       uint8_t key[8*3], data[8];
-       
-       
-       calibrateTimer();
-       print_overhead();
-       
-       memset(key,  0, 8*3);
-       memset(data, 0, 8);
-       
-       startTimer(1);
-       tdes_enc(data, data, key);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       
-       startTimer(1);
-       tdes_dec(data, data, key);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);
-       uart_putstr_P(PSTR("\r\n"));
-}
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-int main (void){
-       char  str[20];
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
-       uart_putstr(cipher_name);
-       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-
-       PGM_P    u   = PSTR("nessie\0test\0performance\0");
-       void_fpt v[] = {testrun_nessie_tdes, testrun_nessie_tdes, testrun_performance_tdes};
-
-       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");
-       }
-       
-}
-
diff --git a/main-trivium-test.c b/main-trivium-test.c
deleted file mode 100644 (file)
index 4d4e3d2..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/* main-trivium-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * Mickey128 test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-#include "cli.h"
-
-#include "trivium.h"
-#include "nessie_stream_test.h"
-#include "performance_test.h"
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-
-char* cipher_name = "Trivium";
-
-/*****************************************************************************
- *  additional validation-functions                                                                                     *
- *****************************************************************************/
-void trivium_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
-       uint32_t iv=0;
-       trivium_init(key, 80, &iv, 32, ctx);
-}
-
-uint8_t trivium_getbyte_dummy(trivium_ctx_t* ctx){
-       uint8_t i,ret=0;
-       for(i=0; i<8; ++i){
-               ret<<=1;
-               ret |= trivium_enc(ctx);
-       }
-       return ret;
-}
-
-void testrun_nessie_trivium(void){
-       nessie_stream_ctx.outsize_b =   8; /* actually unused */
-       nessie_stream_ctx.keysize_b =  80; /* this is the one we have refrence vectors for */
-       nessie_stream_ctx.ivsize_b  =  32;
-       nessie_stream_ctx.name = cipher_name;
-       nessie_stream_ctx.ctx_size_B = sizeof(trivium_ctx_t);
-       nessie_stream_ctx.cipher_genctx = (nessie_stream_genctx_fpt)trivium_genctx_dummy;
-       nessie_stream_ctx.cipher_enc = (nessie_stream_genenc_fpt)trivium_getbyte_dummy;
-       
-       nessie_stream_run();    
-}
-
-void testrun_performance_trivium(void){
-       uint64_t t;
-       char str[16];
-       uint8_t key[10], iv[10];
-       trivium_ctx_t ctx;
-       
-       calibrateTimer();
-       print_overhead();
-       
-       memset(key,  0, 10);
-       memset(iv,  0, 10);
-       
-       startTimer(1);
-       trivium_init(key, 80, iv, 80, &ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);       
-       
-       startTimer(1);
-       trivium_enc(&ctx);
-       t = stopTimer();
-       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
-       ultoa((unsigned long)t, str, 10);
-       uart_putstr(str);       
-       
-       uart_putstr_P(PSTR("\r\n"));
-}
-
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-int main (void){
-       char  str[20];
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
-       uart_putstr(cipher_name);
-       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-
-       PGM_P    u   = PSTR("nessie\0test\0performance\0");
-       void_fpt v[] = {testrun_nessie_trivium, testrun_nessie_trivium, testrun_performance_trivium};
-
-       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");
-       }       
-}
diff --git a/main-xtea-test.c b/main-xtea-test.c
deleted file mode 100644 (file)
index 07fcffe..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/* main-xtea-test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * XTEA test-suit
- * 
-*/
-
-#include "config.h"
-#include "serial-tools.h"
-#include "uart.h"
-#include "debug.h"
-
-#include "xtea.h"
-#include "nessie_bc_test.h"
-#include "performance_test.h"
-#include "cli.h"
-
-#include <stdint.h>
-#include <string.h>
-
-char* cipher_name = "XTEA";
-
-void xtea_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
-       memcpy(ctx, key, (keysize+7)/8);
-}
-
-void xtea_enc_dummy(uint8_t* buffer, void* ctx){
-       xtea_enc((uint32_t*)buffer, (uint32_t*)buffer, ctx);
-}
-
-void xtea_dec_dummy(uint8_t* buffer, void* ctx){
-       xtea_dec((uint32_t*)buffer, (uint32_t*)buffer, ctx);
-}
-
-void testrun_nessie_xtea(void){
-       nessie_bc_ctx.blocksize_B =   8;
-       nessie_bc_ctx.keysize_b   = 128;
-       nessie_bc_ctx.name        = cipher_name;
-       nessie_bc_ctx.ctx_size_B  = 128/8;
-       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)xtea_enc_dummy;
-       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)xtea_dec_dummy;
-       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)xtea_genctx_dummy;
-       
-       nessie_bc_run();        
-}
-
-void testrun_performance_xtea(void){
-       uint64_t t;
-       uint8_t key[16], data[8];
-       
-       calibrateTimer();
-       print_overhead();
-       
-       memset(key,  0, 16);
-       memset(data, 0,  8);
-       
-       startTimer(1);
-       xtea_enc(data, data, key);
-       t = stopTimer();
-       print_time_P(PSTR("\tencrypt time: "), t);
-       
-       startTimer(1);
-       xtea_dec(data, data, key);
-       t = stopTimer();
-       print_time_P(PSTR("\tdecrypt time: "), t);
-       
-       uart_putstr_P(PSTR("\r\n"));
-}
-
-/*****************************************************************************
- *  main                                                                                                                                        *
- *****************************************************************************/
-
-int main (void){
-       char  str[20];
-       DEBUG_INIT();
-       uart_putstr("\r\n");
-
-       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
-       uart_putstr(cipher_name);
-       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-
-       PGM_P    u   = PSTR("nessie\0test\0performance\0");
-       void_fpt v[] = {testrun_nessie_xtea, testrun_nessie_xtea, testrun_performance_xtea};
-
-       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");
-       }
-}
index 6d89b623ff590183c836063980bbc4ec60a2d4ad..e4264befe114d4623dad663af9f02432e904de13 100644 (file)
@@ -6,7 +6,7 @@ STREAM_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := A5_1.o
 $(ALGO_NAME)_TEST_BIN := main-a5_1-test.o debug.o uart.o serial-tools.o \
-                         nessie_stream_test.o nessie_common.o A5_1.o
+                         nessie_stream_test.o nessie_common.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index a05f2363ff1476e4bbf33cec225fbc0bd19b2fb5..f5b4089818c099c46d91e1d4f563535cda88a6d7 100644 (file)
@@ -6,7 +6,7 @@ STREAM_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := arcfour-asm.o
 $(ALGO_NAME)_TEST_BIN := main-arcfour-test.o debug.o uart.o serial-tools.o \
-                         nessie_stream_test.o nessie_common.o arcfour-asm.o
+                         nessie_stream_test.o nessie_common.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index 8e70754bf845ba6df32da9ac0a4cdf15a68bbe84..21061a5eedc1e6697868a0528c88e95e1ae3730a 100644 (file)
@@ -6,7 +6,7 @@ STREAM_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := arcfour.o
 $(ALGO_NAME)_TEST_BIN := main-arcfour-test.o debug.o uart.o serial-tools.o \
-                         nessie_stream_test.o nessie_common.o arcfour.o
+                         nessie_stream_test.o nessie_common.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index a34d538bd1e4368cceb8b93bd0e91315bb8651e1..1e304a9debb7a892f3570f9c9b3c8f4f162e2b8c 100644 (file)
@@ -1,13 +1,12 @@
 # Makefile for camellia
 ALGO_NAME := CAMELLIA
 
-# comment out the following line for removement of serpent from the build process
+# comment out the following line for removement of Camellia from the build process
 BLOCK_CIPHERS += $(ALGO_NAME)
 
-# main-camellia-test.o debug.o uart.o serial-tools.o camellia.o camellia-asm.o
 $(ALGO_NAME)_OBJ      := camellia.o camellia-asm.o
 $(ALGO_NAME)_TEST_BIN := main-camellia-test.o debug.o uart.o serial-tools.o \
-                         camellia.o camellia-asm.o nessie_bc_test.o \
+                         nessie_bc_test.o \
                         nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
index b2b671b561b05794801c1f5cff9b48a6cac7f23f..33c32bad13a4297b4043320600258165f02b2e02 100644 (file)
@@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := cast5.o
 $(ALGO_NAME)_TEST_BIN := main-cast5-test.o debug.o uart.o serial-tools.o cli.o\
-                         cast5.o nessie_bc_test.o nessie_common.o performance_test.o
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index 2cc8d7c6eb81603604628bfdb6ab4a9faae04b85..15c16ec2751153ece251a375874573fdf248ac06 100644 (file)
@@ -5,7 +5,7 @@ ALGO_NAME := DES
 BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := des.o
-$(ALGO_NAME)_TEST_BIN := main-des-test.o debug.o uart.o serial-tools.o des.o \
+$(ALGO_NAME)_TEST_BIN := main-des-test.o debug.o uart.o serial-tools.o \
                          nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
index 589ff6f1638cb46f0076a96e2a1f46330a8978a4..e5806c3073416ea1f5f4bcb441059379bc21faf5 100644 (file)
@@ -6,7 +6,7 @@ PRNGS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := entropium.o sha256-asm.o
 $(ALGO_NAME)_TEST_BIN := main-entropium-test.o debug.o uart.o serial-tools.o \
-                         sha256-asm.o entropium.o cli.o performance_test.o
+                         cli.o performance_test.o
                          
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
index ed330a61a41684a7f234108c6ea254541569e935..4f026a985a4bb2dd876ee8ce6612ee545b2e19c4 100644 (file)
@@ -6,8 +6,8 @@ STREAM_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := grain.o
 $(ALGO_NAME)_TEST_BIN := main-grain-test.o debug.o uart.o serial-tools.o \
-                         nessie_stream_test.o nessie_common.o grain.o cli.o \
-                        performance_test.o
+                         nessie_stream_test.o nessie_common.o cli.o \
+                                    performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index 8d5c90a0bf63f9693ada1de0269d8f4816582adb..b63308ffafa73be31022f1e600860ec811d17ed0 100644 (file)
@@ -6,7 +6,7 @@ MACS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := hmac-sha1.o sha1-asm.o
 $(ALGO_NAME)_TEST_BIN := main-hmac-sha1-test.o debug.o uart.o serial-tools.o cli.o \
-                         hmac-sha1.o sha1-asm.o nessie_mac_test.o nessie_common.o
+                         nessie_mac_test.o nessie_common.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index 6d957b3b9cc5d183c1ab92d33c66a63e9824ab76..fe14892886cdb0d011f9b9207f56bb4953fa1873 100644 (file)
@@ -6,7 +6,7 @@ MACS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := hmac-sha256.o sha256-asm.o
 $(ALGO_NAME)_TEST_BIN := main-hmac-sha256-test.o debug.o uart.o serial-tools.o \
-                         hmac-sha256.o sha256-asm.o nessie_mac_test.o nessie_common.o
+                         nessie_mac_test.o nessie_common.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index b3d3de08ae9eac751023d5d022755216b50662bb..3fb9d65902e7f27dff63f61d3e25179172bf2325 100644 (file)
@@ -5,7 +5,7 @@ ALGO_NAME := MD5
 HASHES += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := md5.o
-$(ALGO_NAME)_TEST_BIN := main-md5-test.o debug.o uart.o serial-tools.o md5.o \
+$(ALGO_NAME)_TEST_BIN := main-md5-test.o debug.o uart.o serial-tools.o \
                          nessie_hash_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
index 3f1a313f887bbe3b7506538ead6b8462baf059d3..359aef37e5b258f45757bf418e8ab9850f3c3c44 100644 (file)
@@ -7,8 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := noekeon_asm.o
 $(ALGO_NAME)_TEST_BIN := main-noekeon-test.o debug.o uart.o serial-tools.o \
-                         noekeon_asm.o nessie_bc_test.o \
-                         nessie_common.o cli.o performance_test.o
+                         nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
 $(ALGO_NAME)_PEROFRMANCE_TEST := performance
 
index 48571d0f51471ebe5ac6b6aa2b516d2aa86e11c6..90d378d128e0b17a49c4ca7effb8974bd63b9dce 100644 (file)
@@ -7,8 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := noekeon.o
 $(ALGO_NAME)_TEST_BIN := main-noekeon-test.o debug.o uart.o serial-tools.o \
-                         noekeon.o nessie_bc_test.o \
-                         nessie_common.o cli.o performance_test.o
+                         nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
 $(ALGO_NAME)_PEROFRMANCE_TEST := performance
 
index 764acefad3e9ea0f8fd46ff1e06a813377868db4..e30c506624594f338e3e698154b5d3d77547dfef 100644 (file)
@@ -7,8 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := present.o
 $(ALGO_NAME)_TEST_BIN := main-present-test.o debug.o uart.o serial-tools.o \
-                         present.o nessie_bc_test.o nessie_common.o cli.o \
-                        performance_test.o
+                         nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index b45a610aee1b090814b58d2511ac1b74d59bc9f6..ff20873b03aa25344dbb99c7f986e287404bf04f 100644 (file)
@@ -7,7 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := rc5.o
 $(ALGO_NAME)_TEST_BIN := main-rc5-test.o debug.o uart.o serial-tools.o \
-                         rc5.o nessie_bc_test.o \
+                         nessie_bc_test.o \
                          nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
 $(ALGO_NAME)_PEROFRMANCE_TEST := performance
index 893b34fd2411df2047d16fb37a458816c7772914..47e2f00f6259f1f978fb4689a11f7efba3dd2da0 100644 (file)
@@ -7,8 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := rc6.o
 $(ALGO_NAME)_TEST_BIN := main-rc6-test.o debug.o uart.o serial-tools.o \
-                         rc6.o nessie_bc_test.o \
-                         nessie_common.o cli.o performance_test.o
+                         nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
 $(ALGO_NAME)_PEROFRMANCE_TEST := performance
 
index 515597c8a11125eef5e1a9e95076dfaac69bcb5f..35724f239e9840e85166e8d3d788645632c276ef 100644 (file)
@@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := seed.o seed-asm.o
 $(ALGO_NAME)_TEST_BIN := main-seed-test.o debug.o uart.o serial-tools.o \
-                         seed.o seed-asm.o nessie_bc_test.o nessie_common.o \
+                         nessie_bc_test.o nessie_common.o \
                          cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
index 5ddb0c452ec14dcc5cb041cb8a97aca14f6248e8..e17ab2820b2a5ad13750c6cc7f243f119f8a22aa 100644 (file)
@@ -5,10 +5,9 @@ ALGO_NAME := SERPENT_BITSLICE
 BLOCK_CIPHERS += $(ALGO_NAME)
 
 
-$(ALGO_NAME)_OBJ      := serpent.o serpent-sboxes-bitslice.o
+$(ALGO_NAME)_OBJ      := serpent.o serpent-sboxes-bitslice.o memxor.o
 $(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o serial-tools.o \
-                         serpent.o serpent-sboxes-bitslice.o nessie_bc_test.o \
-                         nessie_common.o cli.o performance_test.o
+                         nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index 03dad5b87f73de55fd4314cfac7ebe27caa6d539..5959aeab6db1500b85afacb46541482448f265c0 100644 (file)
@@ -5,10 +5,9 @@ ALGO_NAME := SERPENT
 BLOCK_CIPHERS += $(ALGO_NAME)
 
 
-$(ALGO_NAME)_OBJ      := serpent.o serpent-sboxes.o
+$(ALGO_NAME)_OBJ      := serpent.o serpent-sboxes.o memxor.o
 $(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o serial-tools.o \
-                         serpent.o serpent-sboxes.o nessie_bc_test.o \
-                         nessie_common.o cli.o performance_test.o
+                         nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index dc2eadef3926f3ff0984d15528e8d7cd397e6951..eb2d9196bb9a2515bbd7cda7efdb77ca66ec2c0f 100644 (file)
@@ -6,8 +6,7 @@ HASHES += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := sha1-asm.o
 $(ALGO_NAME)_TEST_BIN := main-sha1-test.o debug.o uart.o serial-tools.o \
-                         sha1-asm.o nessie_hash_test.o nessie_common.o cli.o \
-                        performance_test.o
+                         nessie_hash_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index bdfedf78b86b4a6c37d0cbbf4b935ecc0efb1774..061f7a9a073b299867fd91bebd997f9600f48dda 100644 (file)
@@ -6,7 +6,7 @@ HASHES += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := sha1.o
 $(ALGO_NAME)_TEST_BIN := main-sha1-test.o debug.o uart.o serial-tools.o \
-                         sha1.o nessie_hash_test.o nessie_common.o cli.o \
+                         nessie_hash_test.o nessie_common.o cli.o \
                         performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
index 0a2fe1c71994312f79d8d428f115e19155eb60c4..dcea21f2230b1677b2e1d944ddc1859ba55fd0a1 100644 (file)
@@ -6,8 +6,7 @@ HASHES += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := sha256-asm.o
 $(ALGO_NAME)_TEST_BIN := main-sha256-test.o debug.o uart.o serial-tools.o \
-                         sha256-asm.o nessie_hash_test.o nessie_common.o cli.o \
-                        performance_test.o
+                         nessie_hash_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index 8175ddc5b6c51938afc9ff3f0b86e0eb5968901b..cf850fcad6e09d5be4ea889961fa5bc1cadd9250 100644 (file)
@@ -6,8 +6,7 @@ HASHES += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := sha256.o
 $(ALGO_NAME)_TEST_BIN := main-sha256-test.o debug.o uart.o serial-tools.o \
-                         sha256.o nessie_hash_test.o nessie_common.o cli.o \
-                        performance_test.o
+                         nessie_hash_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index ee749ff7f2f3128392e28788bcbf0c8e7135f9d2..4e9acaffd453e85995ec77fbe31aa944229f55d8 100644 (file)
@@ -4,10 +4,9 @@ ALGO_NAME := SHABEA
 # comment out the following line for removement of SHABEA from the build process
 BLOCK_CIPHERS += $(ALGO_NAME)
 
-$(ALGO_NAME)_OBJ      := shabea.o sha256-asm.o
+$(ALGO_NAME)_OBJ      := shabea.o sha256-asm.o memxor.o
 $(ALGO_NAME)_TEST_BIN := main-shabea-test.o debug.o uart.o serial-tools.o \
-                         shabea.o sha256-asm.o nessie_bc_test.o \
-                        nessie_common.o cli.o performance_test.o memxor.o
+                         nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index 1e197943d58684879a3eb900970f3f98baca2a03..d329db79ec54beef13768d2c95721db4a85115df 100644 (file)
@@ -7,8 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := shacal1_enc.o sha1-asm.o
 $(ALGO_NAME)_TEST_BIN := main-shacal1_enc-test.o debug.o uart.o serial-tools.o \
-                         nessie_bc_test.o nessie_common.o cli.o \
-                        performance_test.o shacal1_enc.o sha1-asm.o
+                         nessie_bc_test.o nessie_common.o cli.o performance_test.o 
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index 44ba529437d54ec7183787b4dcc0437c40906c7c..739d9eb546bef97d2903ed9bb2b6941a08c1bace 100644 (file)
@@ -7,8 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := shacal2_enc.o sha256-asm.o
 $(ALGO_NAME)_TEST_BIN := main-shacal2_enc-test.o debug.o uart.o serial-tools.o \
-                         nessie_bc_test.o nessie_common.o cli.o \
-                        performance_test.o shacal2_enc.o sha256-asm.o
+                         nessie_bc_test.o nessie_common.o cli.o performance_test.o 
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index 2a117a9cc2236036391826a90ec46d8f85613956..e48d8b95f56306a212dcb9b88d9cb35a077f119f 100644 (file)
@@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := skipjack.o
 $(ALGO_NAME)_TEST_BIN := main-skipjack-test.o debug.o uart.o serial-tools.o \
-                         skipjack.o  nessie_bc_test.o nessie_common.o cli.o \
+                         nessie_bc_test.o nessie_common.o cli.o \
                         performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
index 66b51684e95566224fc216b23df46f391bb8e89d..f0b43e5d23c4dbf1b4a7362054e38509fb248146 100644 (file)
@@ -5,7 +5,7 @@ ALGO_NAME := TDES
 BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := des.o
-$(ALGO_NAME)_TEST_BIN := main-tdes-test.o debug.o uart.o serial-tools.o des.o \
+$(ALGO_NAME)_TEST_BIN := main-tdes-test.o debug.o uart.o serial-tools.o \
                          nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
index e2e348456a22b21834bc5f0776aab68cc440a7e4..45ee4f3250926d46f654272b09f7283535bbc3ab 100644 (file)
@@ -6,8 +6,8 @@ STREAM_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := trivium.o
 $(ALGO_NAME)_TEST_BIN := main-trivium-test.o debug.o uart.o serial-tools.o \
-                         nessie_stream_test.o nessie_common.o trivium.o cli.o \
-                        performance_test.o
+                         nessie_stream_test.o nessie_common.o cli.o \
+                         performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index 38f485bdc1a4862cab1287cff6b72848412f9145..b4edc30ba66fc917ff95d7a76dd110015c50c197 100644 (file)
@@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := xtea-asm.o
 $(ALGO_NAME)_TEST_BIN := main-xtea-test.o debug.o uart.o serial-tools.o \
-                         xtea-asm.o nessie_bc_test.o nessie_common.o \
-                        cli.o performance_test.o
+                         nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index 157df8783ab5911f8d74804b74512b368fe84f06..7ebbded885c89290c833929aadf59ca3c4826cf5 100644 (file)
@@ -6,8 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := xtea.o
 $(ALGO_NAME)_TEST_BIN := main-xtea-test.o debug.o uart.o serial-tools.o \
-                         xtea.o nessie_bc_test.o nessie_common.o \
-                        cli.o performance_test.o
+                         nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
diff --git a/nessie_bc_test.c b/nessie_bc_test.c
deleted file mode 100644 (file)
index f9a91e5..0000000
+++ /dev/null
@@ -1,212 +0,0 @@
-/* nessie_bc_test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/**
- * 
- * author: Daniel Otte
- * email:  daniel.otte@rub.de
- * license: GPLv3
- * 
- * a suit for running the nessie-tests for blockciphers
- * 
- * */
-#include <stdint.h>
-#include <string.h>
-#include "nessie_bc_test.h"
-#include "nessie_common.h"
-#include "uart.h"
-
-nessie_bc_ctx_t nessie_bc_ctx;
-
-void nessie_bc_init(void){
-       memset(&nessie_bc_ctx, 0, sizeof(nessie_bc_ctx_t));     
-}
-static
-void nessie_bc_free(void* ctx){
-       if(nessie_bc_ctx.cipher_free)
-               nessie_bc_ctx.cipher_free(ctx);
-}
-
-void nessie_bc_enc(uint8_t* key, uint8_t* pt){
-       uint8_t ctx[nessie_bc_ctx.ctx_size_B];
-       uint8_t buffer[nessie_bc_ctx.blocksize_B];
-       uint16_t i;
-       
-       /* single test */
-       nessie_print_item("key", key, (nessie_bc_ctx.keysize_b+7)/8);
-       nessie_bc_ctx.cipher_genctx(key, nessie_bc_ctx.keysize_b, ctx);
-       
-       memcpy(buffer, pt, nessie_bc_ctx.blocksize_B);
-       nessie_print_item("plain", buffer, nessie_bc_ctx.blocksize_B);
-       nessie_bc_ctx.cipher_enc(buffer, ctx);
-       nessie_print_item("cipher", buffer, nessie_bc_ctx.blocksize_B);
-       if(nessie_bc_ctx.cipher_dec){
-               nessie_bc_ctx.cipher_dec(buffer, ctx);
-               nessie_print_item("decrypted", buffer, nessie_bc_ctx.blocksize_B);
-       }
-       /* 100 times test */
-       memcpy(buffer, pt, nessie_bc_ctx.blocksize_B);
-       for(i=0; i<100; ++i){
-               nessie_bc_ctx.cipher_enc(buffer, ctx);
-       }
-       nessie_print_item("Iterated 100 times", buffer, nessie_bc_ctx.blocksize_B);
-#ifndef NESSIE_NO1KTEST        
-       /* 1000 times test, we use the 100 precedig steps to fasten things a bit */
-       for(; i<1000; ++i){
-               nessie_bc_ctx.cipher_enc(buffer, ctx);
-       }
-       nessie_print_item("Iterated 1000 times", buffer, nessie_bc_ctx.blocksize_B);
-#endif
-       nessie_bc_free(ctx);
-}
-
-void nessie_bc_dec(uint8_t* key, uint8_t* ct){
-       uint8_t ctx[nessie_bc_ctx.ctx_size_B];
-       uint8_t buffer[nessie_bc_ctx.blocksize_B];
-       
-       /* single test */
-       nessie_print_item("key", key, (nessie_bc_ctx.keysize_b+7)/8);
-       nessie_bc_ctx.cipher_genctx(key, nessie_bc_ctx.keysize_b, ctx);
-       memcpy(buffer, ct, nessie_bc_ctx.blocksize_B);
-       nessie_print_item("cipher", buffer, nessie_bc_ctx.blocksize_B);
-       nessie_bc_ctx.cipher_dec(buffer, ctx);
-       nessie_print_item("plain", buffer, nessie_bc_ctx.blocksize_B);
-       nessie_bc_ctx.cipher_enc(buffer, ctx);
-       nessie_print_item("encrypted", buffer, nessie_bc_ctx.blocksize_B);
-       nessie_bc_free(ctx);
-}
-
-void nessie_bc_run(void){
-       uint16_t i;
-       uint8_t set;
-       uint8_t key[(nessie_bc_ctx.keysize_b+7)/8];
-       uint8_t buffer[nessie_bc_ctx.blocksize_B];
-       
-       nessie_print_header(nessie_bc_ctx.name, nessie_bc_ctx.keysize_b,
-                           nessie_bc_ctx.blocksize_B*8, 0, 0, 0);
-       /* test set 1 */
-       set=1;
-       nessie_print_setheader(set);
-       for(i=0; i<nessie_bc_ctx.keysize_b; ++i){
-               nessie_print_set_vector(set, i);
-               memset(key, 0, (nessie_bc_ctx.keysize_b+7)/8);
-               key[i/8] |= 0x80>>(i%8);
-               memset(buffer, 0, nessie_bc_ctx.blocksize_B);
-               nessie_bc_enc(key, buffer);
-       }
-       /* test set 2 */
-       set=2;
-       nessie_print_setheader(set);
-       for(i=0; i<nessie_bc_ctx.blocksize_B*8; ++i){
-               nessie_print_set_vector(set, i);
-               memset(key, 0, (nessie_bc_ctx.keysize_b+7)/8);
-               memset(buffer, 0, nessie_bc_ctx.blocksize_B);
-               buffer[i/8] |= 0x80>>(i%8);
-               nessie_bc_enc(key, buffer);
-       }
-       /* test set 3 */
-       set=3;
-       nessie_print_setheader(set);
-       for(i=0; i<256; ++i){
-               nessie_print_set_vector(set, i);
-               memset(key, i, (nessie_bc_ctx.keysize_b+7)/8);
-               memset(buffer, i, nessie_bc_ctx.blocksize_B);
-               nessie_bc_enc(key, buffer);
-       }
-       /* test set 4 */
-       set=4;
-       nessie_print_setheader(set);
-       /* 4 - 0*/
-       nessie_print_set_vector(set, 0);
-       for(i=0; i<(nessie_bc_ctx.keysize_b+7)/8; ++i){
-               key[i]=i;
-       }
-       for(i=0; i<nessie_bc_ctx.blocksize_B; ++i){
-               buffer[i]=i*0x11;
-       }
-       nessie_bc_enc(key, buffer);
-       /* 4 - 1 */
-       nessie_print_set_vector(set, 1);        
-    /* This is the test vectors in Kasumi */
-    static uint8_t kasumi_key[] = {
-           0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC5, 0xB3, 0x00,
-           0x95, 0x2C, 0x49, 0x10, 0x48, 0x81, 0xFF, 0x48 };
-    static uint8_t kasumi_plain[]={
-           0xEA, 0x02, 0x47, 0x14, 0xAD, 0x5C, 0x4D, 0x84 };
-       for(i=0; i<(nessie_bc_ctx.keysize_b+7)/8; ++i){
-               key[i]=kasumi_key[i%sizeof(kasumi_key)];
-       }
-       for(i=0; i<nessie_bc_ctx.blocksize_B; ++i){
-               buffer[i]=kasumi_plain[i%sizeof(kasumi_plain)];
-       }
-       nessie_bc_enc(key, buffer);
-       /* half done ;-) */
-       if(nessie_bc_ctx.cipher_dec==NULL)
-               return;
-       /* test set 5 */
-       set=5;
-       nessie_print_setheader(set);
-       for(i=0; i<nessie_bc_ctx.keysize_b; ++i){
-               nessie_print_set_vector(set, i);
-               memset(key, 0, (nessie_bc_ctx.keysize_b+7)/8);
-               key[i/8] |= 0x80>>(i%8);
-               memset(buffer, 0, nessie_bc_ctx.blocksize_B);
-               nessie_bc_dec(key, buffer);
-       }
-       /* test set 6 */
-       set=6;
-       nessie_print_setheader(set);
-       for(i=0; i<nessie_bc_ctx.blocksize_B*8; ++i){
-               nessie_print_set_vector(set, i);
-               memset(key, 0, (nessie_bc_ctx.keysize_b+7)/8);
-               memset(buffer, 0, nessie_bc_ctx.blocksize_B);
-               buffer[i/8] |= 0x80>>(i%8);
-               nessie_bc_dec(key, buffer);
-       }
-       /* test set 7 */
-       set=7;
-       nessie_print_setheader(set);
-       for(i=0; i<256; ++i){
-               nessie_print_set_vector(set, i);
-               memset(key, i, (nessie_bc_ctx.keysize_b+7)/8);
-               memset(buffer, i, nessie_bc_ctx.blocksize_B);
-               nessie_bc_dec(key, buffer);
-       }
-       /* test set 8 */
-       set=8;
-       nessie_print_setheader(set);
-       /* 8 - 0*/
-       nessie_print_set_vector(set, 0);
-       for(i=0; i<(nessie_bc_ctx.keysize_b+7)/8; ++i){
-               key[i]=i;
-       }
-       for(i=0; i<nessie_bc_ctx.blocksize_B; ++i){
-               buffer[i]=i*0x11;
-       }
-       nessie_bc_dec(key, buffer);
-       /* 8 - 1 */
-       nessie_print_set_vector(set, 1);        
-       for(i=0; i<(nessie_bc_ctx.keysize_b+7)/8; ++i){
-               key[i]=kasumi_key[i%sizeof(kasumi_key)];
-       }
-       for(i=0; i<nessie_bc_ctx.blocksize_B; ++i){
-               buffer[i]=kasumi_plain[i%sizeof(kasumi_plain)];
-       }
-       nessie_bc_dec(key, buffer);
-       nessie_print_footer();
-}
diff --git a/nessie_bc_test.h b/nessie_bc_test.h
deleted file mode 100644 (file)
index 1bab98c..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/* nessie_bc_test.h */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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 NESSIE_BC_TEST_H_
-#define NESSIE_BC_TEST_H_
-
-#include <stdint.h>
-
-typedef void (*nessie_bc_gen_fpt)(uint8_t* key, uint16_t keysize_b, void* ctx);
-typedef void (*nessie_bc_free_fpt)(void* ctx);
-typedef void (*nessie_bc_enc_fpt)(void* buffer, void* ctx);
-typedef void (*nessie_bc_dec_fpt)(void* buffer, void* ctx);
-
-typedef struct nessie_bc_ctx_st{
-       uint16_t keysize_b;
-       uint16_t blocksize_B;
-       uint16_t ctx_size_B;
-       char* name; 
-       nessie_bc_gen_fpt  cipher_genctx;
-       nessie_bc_free_fpt cipher_free;
-       nessie_bc_enc_fpt  cipher_enc;
-       nessie_bc_dec_fpt  cipher_dec;
-} nessie_bc_ctx_t; 
-
-
-extern nessie_bc_ctx_t nessie_bc_ctx;
-
-void nessie_bc_run(void);
-void nessie_bc_init(void);
-
-
-#endif /*NESSIE_BC_TEST_H_*/
diff --git a/nessie_common.c b/nessie_common.c
deleted file mode 100644 (file)
index 020d5ab..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-/* nessie_common.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/**
- * 
- * author: Daniel Otte
- * email:  daniel.otte@rub.de
- * license: GPLv3
- * 
- * common function for nessie-tests
- * 
- * */
-
-#include <string.h>
-#include <stdint.h>
-#include <avr/pgmspace.h>
-#include <stdlib.h> /* utoa() */
-#include "uart.h"
-
-void nessie_print_block(uint8_t* block, uint16_t blocksize_bit){
-       char tab [] = {'0', '1', '2', '3', 
-                                  '4', '5', '6', '7', 
-                                  '8', '9', 'A', 'B', 
-                                  'C', 'D', 'E', 'F'};
-       uint16_t i;
-       for(i=0; i<(blocksize_bit+7)/8; ++i){
-               uart_putc(tab[(block[i])>>4]);
-               uart_putc(tab[(block[i])&0xf]);
-       }                                  
-}
-
-#define SPACES 31
-#define BYTESPERLINE 16
-
-void nessie_print_item(char* name, uint8_t* buffer, uint16_t size_B){
-       uint8_t name_len;
-       uint8_t i;
-       name_len=strlen(name);
-       if(name_len>SPACES-1){
-               uart_putstr_P(PSTR("\r\n!!! formatting error !!!\r\n"));
-               return;
-       }
-       uart_putstr_P(PSTR("\r\n"));
-       for(i=0; i<SPACES-name_len-1; ++i){
-               uart_putc(' ');
-       }
-       uart_putstr(name);
-       uart_putc('=');
-       /* now the data printing begins */
-       if(size_B<=BYTESPERLINE){
-               /* one line seems sufficient */
-               nessie_print_block(buffer, size_B*8);
-       } else {
-               /* we need more lines */
-               nessie_print_block(buffer, BYTESPERLINE*8); /* first line */
-               int16_t toprint = size_B - BYTESPERLINE;
-               buffer += BYTESPERLINE;
-               while(toprint > 0){
-                       uart_putstr_P(PSTR("\r\n"));
-                       for(i=0; i<SPACES; ++i){
-                               uart_putc(' ');
-                       }
-                       nessie_print_block(buffer, ((toprint>BYTESPERLINE)?BYTESPERLINE:toprint)*8);
-                       buffer  += BYTESPERLINE;
-                       toprint -= BYTESPERLINE;
-               }
-       }
-} 
-
-
-void nessie_print_set_vector(uint8_t set, uint16_t vector){
-       uart_putstr_P(PSTR("\r\n\r\nSet "));
-       uart_putc('0'+set%10);
-       uart_putstr_P(PSTR(", vector#"));
-       uart_putc((vector<100)?' ':'0'+vector/100);
-       uart_putc((vector<10 )?' ':'0'+(vector/10)%10);
-       uart_putc('0'+vector%10);
-       uart_putc(':');
-}
-
-/* example:
-Test vectors -- set 3
-=====================
- */ 
-void nessie_print_setheader(uint8_t set){
-       uart_putstr_P(PSTR("\r\n\r\nTest vectors -- set "));
-       uart_putc('0'+set%10);
-       uart_putstr_P(PSTR("\r\n====================="));
-}
-
-/* example:
-********************************************************************************
-*Project NESSIE - New European Schemes for Signature, Integrity, and Encryption*
-********************************************************************************
-
-Primitive Name: Serpent
-=======================
-Key size: 256 bits
-Block size: 128 bits
-*/
-
-void nessie_print_header(char* name,
-                         uint16_t keysize_b, 
-                         uint16_t blocksize_b,
-                         uint16_t hashsize_b, 
-                         uint16_t macsize_b,
-                         uint16_t ivsize_b ){
-       uint16_t i;
-       uart_putstr_P(PSTR("\r\n\r\n"
-       "********************************************************************************\r\n"
-       "* micro-crypt - crypto primitives for microcontrolles by Daniel Otte           *\r\n"
-       "********************************************************************************\r\n"
-       "\r\n"));
-       uart_putstr_P(PSTR("Primitive Name: "));
-       uart_putstr(name);
-       uart_putstr_P(PSTR("\r\n"));
-       /* underline */ 
-       for(i=0; i<16+strlen(name); ++i){
-               uart_putc('=');
-       }
-       char str[6]; /* must catch numbers up to 65535 + terminatin \0 */
-       if(keysize_b){
-               uart_putstr_P(PSTR("\r\nKey size: "));
-               utoa(keysize_b, str, 10);
-               uart_putstr(str);
-               uart_putstr_P(PSTR(" bits"));
-       }
-       if(blocksize_b){
-               uart_putstr_P(PSTR("\r\nBlock size: "));
-               utoa(blocksize_b, str, 10);
-               uart_putstr(str);
-               uart_putstr_P(PSTR(" bits"));
-       }
-       if(hashsize_b){
-               uart_putstr_P(PSTR("\r\nHash size: "));
-               utoa(hashsize_b, str, 10);
-               uart_putstr(str);
-               uart_putstr_P(PSTR(" bits"));
-       }
-       if(macsize_b){
-               uart_putstr_P(PSTR("\r\nMac size: "));
-               utoa(macsize_b, str, 10);
-               uart_putstr(str);
-               uart_putstr_P(PSTR(" bits"));
-       }
-       if(ivsize_b){
-               if(ivsize_b==(uint16_t)-1){
-                       uart_putstr_P(PSTR("\r\nNo initial value (IV) mode"));
-               }
-               {
-                       uart_putstr_P(PSTR("\r\nIV size: "));
-                       utoa(ivsize_b, str, 10);
-                       uart_putstr(str);
-                       uart_putstr_P(PSTR(" bits"));
-               }
-       }
-       uart_putstr_P(PSTR("\r\n"));
-}
-
-void nessie_print_footer(void){
-       uart_putstr_P(PSTR("\r\n\r\n\r\n\r\nEnd of test vectors\r\n\r\n"));
-}
-
diff --git a/nessie_common.h b/nessie_common.h
deleted file mode 100644 (file)
index 4090e32..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/* nessie_common.h */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/**
- * 
- * author: Daniel Otte
- * email:  daniel.otte@rub.de
- * license: GPLv3
- * 
- * common function for nessie-tests
- * 
- * */
-
-#ifndef NESSIE_COMMON_H_
-#define NESSIE_COMMON_H_
-
-
-#include <stdint.h>
-
-void nessie_print_block(uint8_t* block, uint16_t blocksize_bit);
-void nessie_print_item(char* name, uint8_t* buffer, uint16_t size_B);
-void nessie_print_set_vector(uint8_t set, uint16_t vector);
-void nessie_print_setheader(uint8_t set);
-void nessie_print_header(char* name,
-                         uint16_t keysize_b, 
-                         uint16_t blocksize_b,
-                         uint16_t hashsize_b, 
-                         uint16_t macsize_b,
-                         uint16_t ivsize_b );
-void nessie_print_footer(void);
-
-#endif /*NESSIE_COMMON_H_*/
diff --git a/nessie_hash_test.c b/nessie_hash_test.c
deleted file mode 100644 (file)
index a870b82..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-/* nessie_hash_test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/**
- * 
- * author: Daniel Otte
- * email:  daniel.otte@rub.de
- * license: GPLv3
- * 
- * a suit for running the nessie-tests for hashes
- * 
- * */
-#include <stdint.h>
-#include <string.h>
-#include "nessie_hash_test.h"
-#include "nessie_common.h"
-#include "uart.h"
-
-nessie_hash_ctx_t nessie_hash_ctx;
-
-static
-void ascii_hash(char* data, char* desc){
-       uint8_t ctx[nessie_hash_ctx.ctx_size_B];
-       uint8_t hash[(nessie_hash_ctx.hashsize_b+7)/8];
-       uint16_t sl;
-       
-       uart_putstr_P(PSTR("\r\n                       message="));
-       uart_putstr(desc);
-       nessie_hash_ctx.hash_init(ctx);
-       sl = strlen(data);
-       while(sl>=nessie_hash_ctx.blocksize_B){
-               nessie_hash_ctx.hash_next(data, ctx);
-               data += nessie_hash_ctx.blocksize_B;
-               sl   -= nessie_hash_ctx.blocksize_B;
-       }
-       nessie_hash_ctx.hash_last(data, sl*8, ctx);
-       nessie_hash_ctx.hash_conv(hash, ctx);
-       nessie_print_item("hash", hash, (nessie_hash_ctx.hashsize_b+7)/8);
-}
-
-// message=1 million times "a"
-
-static
-void amillion_hash(void){
-       uint8_t ctx[nessie_hash_ctx.ctx_size_B];
-       uint8_t hash[(nessie_hash_ctx.hashsize_b+7)/8];
-       uint8_t block[nessie_hash_ctx.blocksize_B];
-       uint32_t n=1000000LL;
-       
-       uart_putstr_P(PSTR("\r\n                       message="));
-       uart_putstr_P(PSTR("1 million times \"a\""));
-       memset(block, 'a', nessie_hash_ctx.blocksize_B);
-       nessie_hash_ctx.hash_init(ctx);
-       while(n>=nessie_hash_ctx.blocksize_B){
-               nessie_hash_ctx.hash_next(block, ctx);
-               n    -= nessie_hash_ctx.blocksize_B;
-       }
-       nessie_hash_ctx.hash_last(block, n*8, ctx);
-       nessie_hash_ctx.hash_conv(hash, ctx);
-       nessie_print_item("hash", hash, (nessie_hash_ctx.hashsize_b+7)/8);
-}
-
-
-static
-void zero_hash(uint16_t n){
-       uint8_t ctx[nessie_hash_ctx.ctx_size_B];
-       uint8_t hash[(nessie_hash_ctx.hashsize_b+7)/8];
-       uint8_t block[nessie_hash_ctx.blocksize_B];
-       
-       uart_putstr_P(PSTR("\r\n                       message="));
-       if(n>=10000)
-               uart_putc('0'+n/10000);
-       if(n>=1000)
-               uart_putc('0'+(n/1000)%10);
-       if(n>=100)
-               uart_putc('0'+(n/100)%10);
-       if(n>=10)
-               uart_putc('0'+(n/10)%10);
-       uart_putc('0'+n%10);
-       uart_putstr_P(PSTR(" zero bits"));
-       
-       memset(block, 0, nessie_hash_ctx.blocksize_B); 
-       nessie_hash_ctx.hash_init(ctx);
-       while(n>=nessie_hash_ctx.blocksize_B*8){
-               nessie_hash_ctx.hash_next(block, ctx);
-               n   -= nessie_hash_ctx.blocksize_B*8;
-       }
-       nessie_hash_ctx.hash_last(block, n, ctx);
-       nessie_hash_ctx.hash_conv(hash, ctx);
-       nessie_print_item("hash", hash, (nessie_hash_ctx.hashsize_b+7)/8);
-}
-
-static
-void one_in512_hash(uint16_t pos){
-       uint8_t ctx[nessie_hash_ctx.ctx_size_B];
-       uint8_t hash[(nessie_hash_ctx.hashsize_b+7)/8];
-       uint8_t block[nessie_hash_ctx.blocksize_B];
-       uint16_t n=512;
-       char* tab[8]={"80", "40", "20", "10", 
-                     "08", "04", "02", "01" };
-
-       pos&=511;
-       uart_putstr_P(PSTR("\r\n                       message="));
-       uart_putstr_P(PSTR("512-bit string: "));
-       if((pos/8) >=10){
-               uart_putc('0'+(pos/8/10)%10);
-       } else {
-               uart_putc(' ');
-       }
-       uart_putc('0'+(pos/8)%10);
-       uart_putstr_P(PSTR("*00,"));
-       uart_putstr(tab[pos&7]);
-       uart_putc(',');
-       if(63-(pos/8) >=10){
-               uart_putc('0'+((63-pos/8)/10)%10);
-       } else {
-               uart_putc(' ');
-       }
-       uart_putc('0'+(63-pos/8)%10);
-       uart_putstr_P(PSTR("*00"));
-       
-       /* now the real stuff */
-       memset(block, 0, 512/8);
-       block[pos>>3] = 0x80>>(pos&0x7);
-       nessie_hash_ctx.hash_init(ctx);
-       while(n>=nessie_hash_ctx.blocksize_B*8){
-               nessie_hash_ctx.hash_next(block, ctx);
-               n   -= nessie_hash_ctx.blocksize_B*8;
-       }
-       nessie_hash_ctx.hash_last(block, n, ctx);
-       nessie_hash_ctx.hash_conv(hash, ctx);
-       nessie_print_item("hash", hash, (nessie_hash_ctx.hashsize_b+7)/8);
-}
-
-static
-void tv4_hash(void){
-       uint8_t ctx[nessie_hash_ctx.ctx_size_B];
-       uint8_t hash[(nessie_hash_ctx.hashsize_b+7)/8];
-       uint8_t block[256/8];
-       uint16_t n=256;
-       uint32_t i;
-       
-       uart_putstr_P(PSTR("\r\n                       message="));
-       uart_putstr(PSTR("256 zero bits"));
-       memset(block, 0, 256/8);
-       
-       nessie_hash_ctx.hash_init(ctx);
-       while(n>=nessie_hash_ctx.blocksize_B*8){
-               nessie_hash_ctx.hash_next(block, ctx);
-               n    -= nessie_hash_ctx.blocksize_B*8;
-       }
-       nessie_hash_ctx.hash_last(block, n, ctx);
-       nessie_hash_ctx.hash_conv(hash, ctx);
-       nessie_print_item("hash", hash, (nessie_hash_ctx.hashsize_b+7)/8);
-       for(i=1; i<100000L; ++i){ /* this assumes BLOCKSIZE >= HASHSIZE */
-               nessie_hash_ctx.hash_init(ctx);
-               nessie_hash_ctx.hash_last(hash, nessie_hash_ctx.hashsize_b, ctx);
-               nessie_hash_ctx.hash_conv(hash, ctx);
-       }
-       nessie_print_item("iterated 100000 times", hash, (nessie_hash_ctx.hashsize_b+7)/8);
-}
-
-/*
-   "" (empty string)
-   message="a"
-   message="abc"
-   message="message digest"
-   message="abcdefghijklmnopqrstuvwxyz"
-   message="abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
-   message="A...Za...z0...9"
-   message=8 times "1234567890"
-*/
-
-
-void nessie_hash_run(void){
-       uint16_t i;
-       uint8_t set;
-       
-       nessie_print_header(nessie_hash_ctx.name, 0, 0, nessie_hash_ctx.hashsize_b, 0, 0);
-       /* test set 1 */
-       char* challange[8][2]= {
-               {"", "\"\" (empty string)"},
-               {"a", "\"a\""},
-               {"abc", "\"abc\""},
-               {"message digest", "\"message digest\""},
-               {"abcdefghijklmnopqrstuvwxyz","\"abcdefghijklmnopqrstuvwxyz\""},
-               {"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
-                       "\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\""},
-               {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                "abcdefghijklmnopqrstuvwxyz"
-                "0123456789"   , "\"A...Za...z0...9\""},
-               {"1234567890" "1234567890" "1234567890" "1234567890" 
-                "1234567890" "1234567890" "1234567890" "1234567890",
-                "8 times \"1234567890\""}      
-       };
-       set=1;
-       nessie_print_setheader(set);
-       for(i=0; i<8; ++i){
-               nessie_print_set_vector(set, i);
-               ascii_hash(challange[i][0], challange[i][1]);
-       }
-       nessie_print_set_vector(set, i);
-       amillion_hash();
-       /* test set 2 */
-       set=2;
-       nessie_print_setheader(set);
-       for(i=0; i<1024; ++i){
-               nessie_print_set_vector(set, i);
-               zero_hash(i);
-       }
-       /* test set 3 */
-       set=3;
-       nessie_print_setheader(set);
-       for(i=0; i<512; ++i){
-               nessie_print_set_vector(set, i);
-               one_in512_hash(i);
-       }
-       /* test set 4 */
-       set=4;
-       nessie_print_setheader(set);
-       nessie_print_set_vector(set, 0);
-       tv4_hash();
-
-       nessie_print_footer();
-}
diff --git a/nessie_hash_test.h b/nessie_hash_test.h
deleted file mode 100644 (file)
index aa88bdb..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/* nessie_hash_test.h */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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 NESSIE_HASH_TEST_H_
-#define NESSIE_HASH_TEST_H_
-
-#include <stdint.h>
-
-typedef void (*nessie_hash_init_fpt)(void* ctx);
-typedef void (*nessie_hash_next_fpt)(void* buffer, void* ctx);
-typedef void (*nessie_hash_last_fpt)(void* buffer, uint16_t size_b, void* ctx);
-typedef void (*nessie_hash_conv_fpt)(void* buffer, void* ctx);
-
-
-typedef struct nessie_hash_ctx_st{
-       uint16_t hashsize_b;
-       uint16_t blocksize_B;
-       uint16_t ctx_size_B;
-       char* name; 
-       nessie_hash_init_fpt hash_init;
-       nessie_hash_next_fpt hash_next;
-       nessie_hash_last_fpt hash_last;
-       nessie_hash_conv_fpt hash_conv;
-} nessie_hash_ctx_t; 
-
-
-extern nessie_hash_ctx_t nessie_hash_ctx;
-
-void nessie_hash_run(void);
-
-#endif /*NESSIE_HASH_TEST_H_*/
diff --git a/nessie_mac_test.c b/nessie_mac_test.c
deleted file mode 100644 (file)
index 12863df..0000000
+++ /dev/null
@@ -1,270 +0,0 @@
-/* nessie_mac_test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/**
- * 
- * author: Daniel Otte
- * email:  daniel.otte@rub.de
- * license: GPLv3
- * 
- * a suit for running the nessie-tests for MACs
- * 
- * */
-#include <stdint.h>
-#include <string.h>
-#include "nessie_mac_test.h"
-#include "nessie_common.h"
-#include "uart.h"
-
-nessie_mac_ctx_t nessie_mac_ctx;
-
-#define KEYSIZE_B ((nessie_mac_ctx.keysize_b+7)/8)
-#define MACSIZE_B ((nessie_mac_ctx.macsize_b+7)/8)
-
-#define PRINTKEY nessie_print_item("key", key, KEYSIZE_B)
-#define PRINTMAC nessie_print_item("MAC", mac, MACSIZE_B)
-
-static
-void ascii_mac(char* data, char* desc, uint8_t* key){
-       uint8_t ctx[nessie_mac_ctx.ctx_size_B];
-       uint8_t mac[MACSIZE_B];
-       uint16_t sl;
-       
-       uart_putstr_P(PSTR("\r\n                       message="));
-       uart_putstr(desc);
-       PRINTKEY;
-       nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b, ctx);
-       sl = strlen(data);
-       while(sl>=nessie_mac_ctx.blocksize_B){
-               nessie_mac_ctx.mac_next(data, ctx);
-               data += nessie_mac_ctx.blocksize_B;
-               sl   -= nessie_mac_ctx.blocksize_B;
-       }
-       nessie_mac_ctx.mac_last(data, sl*8, key, nessie_mac_ctx.keysize_b, ctx);
-       nessie_mac_ctx.mac_conv(mac, ctx);
-       PRINTMAC;
-}
-
-// message=1 million times "a"
-
-static
-void amillion_mac(uint8_t* key){
-       uint8_t ctx[nessie_mac_ctx.ctx_size_B];
-       uint8_t mac[MACSIZE_B];
-       uint8_t block[nessie_mac_ctx.blocksize_B];
-       uint32_t n=1000000LL;
-       
-       uart_putstr_P(PSTR("\r\n                       message="));
-       uart_putstr_P(PSTR("1 million times \"a\""));
-       PRINTKEY;
-       
-       memset(block, 'a', nessie_mac_ctx.blocksize_B);
-       nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b, ctx);
-       while(n>=nessie_mac_ctx.blocksize_B){
-               nessie_mac_ctx.mac_next(block, ctx);
-               n    -= nessie_mac_ctx.blocksize_B;
-       }
-       nessie_mac_ctx.mac_last(block, n*8, key, nessie_mac_ctx.keysize_b, ctx);
-       nessie_mac_ctx.mac_conv(mac, ctx);
-       PRINTMAC;
-}
-
-
-static
-void zero_mac(uint16_t n, uint8_t* key){
-       uint8_t ctx[nessie_mac_ctx.ctx_size_B];
-       uint8_t mac[MACSIZE_B];
-       uint8_t block[nessie_mac_ctx.blocksize_B];
-       
-       uart_putstr_P(PSTR("\r\n                       message="));
-       if(n>=10000)
-               uart_putc('0'+n/10000);
-       if(n>=1000)
-               uart_putc('0'+(n/1000)%10);
-       if(n>=100)
-               uart_putc('0'+(n/100)%10);
-       if(n>=10)
-               uart_putc('0'+(n/10)%10);
-       uart_putc('0'+n%10);
-       uart_putstr_P(PSTR(" zero bits"));
-       PRINTKEY;
-       
-       memset(block, 0, nessie_mac_ctx.blocksize_B); 
-       nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b,ctx);;
-       while(n>=nessie_mac_ctx.blocksize_B*8){
-               nessie_mac_ctx.mac_next(block, ctx);
-               n   -= nessie_mac_ctx.blocksize_B*8;
-       }
-       nessie_mac_ctx.mac_last(block, n, key, nessie_mac_ctx.keysize_b, ctx);
-       nessie_mac_ctx.mac_conv(mac, ctx);
-       PRINTMAC;
-}
-
-static
-void one_in512_mac(uint16_t pos, uint8_t* key){
-       uint8_t ctx[nessie_mac_ctx.ctx_size_B];
-       uint8_t mac[MACSIZE_B];
-       uint8_t block[nessie_mac_ctx.blocksize_B];
-       uint16_t n=512;
-       char* tab[8]={"80", "40", "20", "10", 
-                     "08", "04", "02", "01" };
-
-       pos&=511;
-       uart_putstr_P(PSTR("\r\n                       message="));
-       uart_putstr_P(PSTR("512-bit string: "));
-       if((pos/8) >=10){
-               uart_putc('0'+(pos/8/10)%10);
-       } else {
-               uart_putc(' ');
-       }
-       uart_putc('0'+(pos/8)%10);
-       uart_putstr_P(PSTR("*00,"));
-       uart_putstr(tab[pos&7]);
-       uart_putc(',');
-       if(63-(pos/8) >=10){
-               uart_putc('0'+((63-pos/8)/10)%10);
-       } else {
-               uart_putc(' ');
-       }
-       uart_putc('0'+(63-pos/8)%10);
-       uart_putstr_P(PSTR("*00"));
-       PRINTKEY;
-       
-       /* now the real stuff */
-       memset(block, 0, 512/8);
-       block[pos>>3] = 0x80>>(pos&0x7);
-       nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b, ctx);;
-       while(n>=nessie_mac_ctx.blocksize_B*8){
-               nessie_mac_ctx.mac_next(block, ctx);
-               n   -= nessie_mac_ctx.blocksize_B*8;
-       }
-       nessie_mac_ctx.mac_last(block, n, key, nessie_mac_ctx.keysize_b, ctx);
-       nessie_mac_ctx.mac_conv(mac, ctx);
-       PRINTMAC;
-}
-
-static
-void tv4_mac(uint8_t* key){
-       uint8_t ctx[nessie_mac_ctx.ctx_size_B];
-       uint8_t mac[MACSIZE_B];
-       uint8_t block[256/8];
-       uint16_t n=256;
-       uint32_t i;
-       
-       uart_putstr_P(PSTR("\r\n                       message="));
-       uart_putstr(PSTR("256 zero bits"));
-       memset(block, 0, 256/8);
-       
-       nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b, ctx);;
-       while(n>=nessie_mac_ctx.blocksize_B*8){
-               nessie_mac_ctx.mac_next(block, ctx);
-               n    -= nessie_mac_ctx.blocksize_B*8;
-       }
-       nessie_mac_ctx.mac_last(block, n, key, nessie_mac_ctx.keysize_b, ctx);
-       nessie_mac_ctx.mac_conv(mac, ctx);
-       PRINTMAC;
-       for(i=1; i<100000L; ++i){ /* this assumes BLOCKSIZE >= HASHSIZE */
-               nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b, ctx);;
-               nessie_mac_ctx.mac_last(mac, nessie_mac_ctx.macsize_b, key, nessie_mac_ctx.keysize_b, ctx);
-               nessie_mac_ctx.mac_conv(mac, ctx);
-       }
-       nessie_print_item("iterated 100000 times", mac, MACSIZE_B);
-}
-
-
-void nessie_mac_run(void){
-       uint16_t i;
-       uint8_t set;
-       uint8_t keyproto[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
-                          0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
-                          0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };
-       uint8_t key[KEYSIZE_B];
-       
-       nessie_print_header(nessie_mac_ctx.name, nessie_mac_ctx.keysize_b, 0, 0,
-                           nessie_mac_ctx.macsize_b, 0);
-       /* test set 1 */
-       char* challange[10][2]= {
-               {"", "\"\" (empty string)"},
-               {"a", "\"a\""},
-               {"abc", "\"abc\""},
-               {"message digest", "\"message digest\""},
-               {"abcdefghijklmnopqrstuvwxyz","\"abcdefghijklmnopqrstuvwxyz\""},
-               {"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
-                       "\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\""},
-               {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                "abcdefghijklmnopqrstuvwxyz"
-                "0123456789"   , "\"A...Za...z0...9\""},
-               {"1234567890" "1234567890" "1234567890" "1234567890" 
-                "1234567890" "1234567890" "1234567890" "1234567890",
-                "8 times \"1234567890\""},
-               {"Now is the time for all ", "\"Now is the time for all \""},
-               {"Now is the time for it", "\"Now is the time for it\""}
-       };
-       set=1;
-       nessie_print_setheader(set);
-       for(i=0; i<KEYSIZE_B; ++i){
-               key[i] = keyproto[i%sizeof(keyproto)];
-       }
-       for(i=0; i<10; ++i){
-               nessie_print_set_vector(set, i);
-               ascii_mac(challange[i][0], challange[i][1], key);
-       }
-       nessie_print_set_vector(set, i);
-       amillion_mac(key);
-       for(i=0; i<KEYSIZE_B; ++i){
-               key[i] = keyproto[16+i%8];
-       }
-       for(i=0; i<10; ++i){
-               nessie_print_set_vector(set, 11+i);
-               ascii_mac(challange[i][0], challange[i][1], key);
-       }
-       nessie_print_set_vector(set, 11+i);
-       amillion_mac(key);
-       /* test set 2 */
-       set=2;
-       for(i=0; i<KEYSIZE_B; ++i){
-               key[i] = keyproto[i%sizeof(keyproto)];
-       }
-       nessie_print_setheader(set);
-       for(i=0; i<1024; ++i){
-               nessie_print_set_vector(set, i);
-               zero_mac(i, key);
-       }
-       /* test set 3 */
-       set=3;
-       nessie_print_setheader(set);
-       /* we use the same key as above */
-       for(i=0; i<512; ++i){
-               nessie_print_set_vector(set, i);
-               one_in512_mac(i, key);
-       }
-       /* test set 4 */
-       set=4;
-       nessie_print_setheader(set);
-       /* we use the same key as above */
-       nessie_print_set_vector(set, 0);
-       tv4_mac(key);
-       /* test set 5 */
-       for(i=0; i<nessie_mac_ctx.keysize_b; ++i){
-               nessie_print_set_vector(set, i);
-               memset(key, 0, KEYSIZE_B);
-               key[i>>3]=0x80>>(i&0x7);
-               ascii_mac("ABC", "\"ABC\"", key);
-       }
-       nessie_print_footer();
-}
diff --git a/nessie_mac_test.h b/nessie_mac_test.h
deleted file mode 100644 (file)
index ed83133..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/* nessie_mac_test.h */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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 NESSIE_MAC_TEST_H_
-#define NESSIE_MAC_TEST_H_
-
-#include <stdint.h>
-
-typedef void (*nessie_mac_init_fpt)(void* key, uint16_t keysize_b, void* ctx);
-typedef void (*nessie_mac_next_fpt)(void* buffer, void* ctx);
-typedef void (*nessie_mac_last_fpt)(void* buffer, uint16_t size_b, void* key, uint16_t keysize_b, void* ctx);
-typedef void (*nessie_mac_conv_fpt)(void* buffer, void* ctx);
-
-
-typedef struct nessie_mac_ctx_st{
-       uint16_t macsize_b;
-       uint16_t keysize_b;
-       uint16_t blocksize_B;
-       uint16_t ctx_size_B;
-       char* name; 
-       nessie_mac_init_fpt mac_init;
-       nessie_mac_next_fpt mac_next;
-       nessie_mac_last_fpt mac_last;
-       nessie_mac_conv_fpt mac_conv;
-} nessie_mac_ctx_t; 
-
-
-extern nessie_mac_ctx_t nessie_mac_ctx;
-
-void nessie_mac_run(void);
-
-#endif /*NESSIE_MAC_TEST_H_*/
diff --git a/nessie_stream_test.c b/nessie_stream_test.c
deleted file mode 100644 (file)
index 3866b21..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-/* nessie_stream_test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/**
- * 
- * author: Daniel Otte
- * email:  daniel.otte@rub.de
- * license: GPLv3
- * 
- * a suit for running the nessie-tests for streamciphers
- * 
- * */
-#include <stdint.h>
-#include <string.h>
-#include "nessie_stream_test.h"
-#include "nessie_common.h"
-#include "uart.h"
-
-nessie_stream_ctx_t nessie_stream_ctx;
-
-
-#define BLOCKSIZE_B 64
-
-static
-void memxor(void* dest, void* src, uint8_t length){
-       while(length--){
-               *((uint8_t*)dest) ^= *((uint8_t*)src);
-               dest = (uint8_t*)dest +1;
-               src  = (uint8_t*)src +1;
-       }
-}
-
-
-static 
-void nessie_gen_block(void* ctx, uint8_t* block){
-       uint16_t i;
-       for(i=0; i<BLOCKSIZE_B; ++i){
-               block[i] = nessie_stream_ctx.cipher_enc(ctx);
-       }
-}
-
-static
-void nessie_stream_enc(uint8_t* key){
-       uint8_t ctx[nessie_stream_ctx.ctx_size_B];
-       uint8_t buffer[BLOCKSIZE_B];
-       uint8_t xorbuffer[BLOCKSIZE_B];
-       uint8_t i;
-       
-       memset(xorbuffer, 0, BLOCKSIZE_B);
-       
-       nessie_print_item("key", key, (nessie_stream_ctx.keysize_b+7)/8);
-       
-       nessie_stream_ctx.cipher_genctx(key, nessie_stream_ctx.keysize_b, ctx);
-       
-       nessie_gen_block(ctx, buffer);
-       memxor(xorbuffer, buffer, BLOCKSIZE_B);
-       nessie_print_item("stream[0..63]", buffer, BLOCKSIZE_B);
-       
-       for(i=0; i<((192-0)/BLOCKSIZE_B-1); ++i){
-               nessie_gen_block(ctx, buffer);
-               memxor(xorbuffer, buffer, BLOCKSIZE_B);
-       }
-       
-       nessie_gen_block(ctx, buffer);
-       memxor(xorbuffer, buffer, BLOCKSIZE_B);
-       nessie_print_item("stream[192..255]", buffer, BLOCKSIZE_B);
-       
-       nessie_gen_block(ctx, buffer);
-       memxor(xorbuffer, buffer, BLOCKSIZE_B);
-       nessie_print_item("stream[256..319]", buffer, BLOCKSIZE_B);
-       
-       for(i=0; i<((448-256)/BLOCKSIZE_B-1); ++i){
-               nessie_gen_block(ctx, buffer);
-               memxor(xorbuffer, buffer, BLOCKSIZE_B);
-       }
-       
-       nessie_gen_block(ctx, buffer);
-       memxor(xorbuffer, buffer, BLOCKSIZE_B);
-       nessie_print_item("stream[448..511]", buffer, BLOCKSIZE_B);
-       
-       nessie_print_item("stream[0..511]xored", xorbuffer, BLOCKSIZE_B);
-       
-}
-
-
-static
-void nessie_stream_enc_large(uint8_t* key){
-       uint8_t ctx[nessie_stream_ctx.ctx_size_B];
-       uint8_t buffer[BLOCKSIZE_B];
-       uint8_t xorbuffer[BLOCKSIZE_B];
-       uint32_t i;
-       
-       memset(xorbuffer, 0, BLOCKSIZE_B);
-       
-       nessie_print_item("key", key, (nessie_stream_ctx.keysize_b+7)/8);
-       
-       nessie_stream_ctx.cipher_genctx(key, nessie_stream_ctx.keysize_b, ctx);
-       
-       nessie_gen_block(ctx, buffer);
-       memxor(xorbuffer, buffer, BLOCKSIZE_B);
-       nessie_print_item("stream[0..63]", buffer, BLOCKSIZE_B);
-       
-       for(i=0; i<((65472-0)/BLOCKSIZE_B-1); ++i){
-               nessie_gen_block(ctx, buffer);
-               memxor(xorbuffer, buffer, BLOCKSIZE_B);
-       }
-       
-       nessie_gen_block(ctx, buffer);
-       memxor(xorbuffer, buffer, BLOCKSIZE_B);
-       nessie_print_item("stream[65472..65535]", buffer, BLOCKSIZE_B);
-       
-       nessie_gen_block(ctx, buffer);
-       memxor(xorbuffer, buffer, BLOCKSIZE_B);
-       nessie_print_item("stream[65536..65599]", buffer, BLOCKSIZE_B);
-       
-       for(i=0; i<((131008-65536)/BLOCKSIZE_B-1); ++i){
-               nessie_gen_block(ctx, buffer);
-               memxor(xorbuffer, buffer, BLOCKSIZE_B);
-       }
-       
-       nessie_gen_block(ctx, buffer);
-       memxor(xorbuffer, buffer, BLOCKSIZE_B);
-       nessie_print_item("stream[131008..131071]", buffer, BLOCKSIZE_B);
-       
-       nessie_print_item("stream[0..131071]xored", xorbuffer, BLOCKSIZE_B);
-       
-}
-
-void nessie_stream_run(void){
-       uint16_t i;
-       uint8_t set;
-       uint8_t key[(nessie_stream_ctx.keysize_b+7)/8];
-       
-       nessie_print_header(nessie_stream_ctx.name, nessie_stream_ctx.keysize_b,
-                           0, 0, 0, nessie_stream_ctx.ivsize_b);
-       /* test set 1 */
-       set=1;
-       nessie_print_setheader(set);
-       for(i=0; i<nessie_stream_ctx.keysize_b; ++i){
-               nessie_print_set_vector(set, i);
-               memset(key, 0, (nessie_stream_ctx.keysize_b+7)/8);
-               key[i/8] |= 0x80>>(i%8);
-               nessie_stream_enc(key);
-       }
-       /* test set 2 */
-       set=2;
-       nessie_print_setheader(set);
-       for(i=0; i<256; ++i){
-               nessie_print_set_vector(set, i);
-               memset(key, i, (nessie_stream_ctx.keysize_b+7)/8);
-               nessie_stream_enc(key);
-       }
-       /* test set 3 */
-       set=3;
-       nessie_print_setheader(set);
-       for(i=0; i<256; ++i){
-               uint8_t j;
-               nessie_print_set_vector(set, i);
-               for(j=0; j<(nessie_stream_ctx.keysize_b+7)/8; ++j){
-                       key[j]=(i+j)&0xff;
-               }
-               nessie_stream_enc(key);
-       }
-       /* test set 4 */
-       set=4;
-       nessie_print_setheader(set);
-       for(i=0; i<4; ++i){
-               uint8_t j;
-               nessie_print_set_vector(set, i);
-               for(j=0; j<(nessie_stream_ctx.keysize_b+7)/8; ++j){
-                       key[j]=(i*5+j*0x53)&0xff;
-               }
-               nessie_stream_enc_large(key);
-       }
-
-       nessie_print_footer();
-}
diff --git a/nessie_stream_test.h b/nessie_stream_test.h
deleted file mode 100644 (file)
index 8422f45..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/* nessie_stream_test.h */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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 NESSIE_STREAM_TEST_H_
-#define NESSIE_STREAM_TEST_H_
-
-#include <stdint.h>
-
-typedef void (*nessie_stream_genctx_fpt)(uint8_t* key, uint16_t keylength_b, void* ctx);
-typedef uint8_t (*nessie_stream_genenc_fpt)(void* ctx);
-
-typedef struct nessie_stream_ctx_st{
-       uint16_t keysize_b;
-       uint16_t ivsize_b;
-       uint16_t outsize_b;
-       uint16_t ctx_size_B;
-       char* name; 
-       nessie_stream_genctx_fpt cipher_genctx;
-       nessie_stream_genenc_fpt cipher_enc;
-} nessie_stream_ctx_t; 
-
-
-extern nessie_stream_ctx_t nessie_stream_ctx;
-
-void nessie_stream_run(void);
-
-#endif /*NESSIE_STREAM_TEST_H_*/
diff --git a/performance_test.c b/performance_test.c
deleted file mode 100644 (file)
index 04a26bd..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/* performance_test.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/*
- * author: Daniel Otte
- * email:  daniel.otte@rub.de
- * license: GPLv3
- * 
- * 
- **/
-#include "config.h"
-#include <string.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include <avr/pgmspace.h>
-#include "uart.h"
-#include "performance_test.h"
-
-
-#ifdef ATMEGA644
-       #define TIMSK TIMSK1
-#endif
-
-
-
-uint32_t ovfcounter;
-
-uint16_t const_overhead=0;
-uint16_t int_overhead=0;
-
-ISR(TIMER1_OVF_vect){
-       ovfcounter++;
-}
-
-void calibrateTimer(void){
-       startTimer(1);
-       stopTimer();
-       const_overhead = TCNT1;
-       startTimer(1);
-       TCNT1=0xFFFE;
-       ; ; ; ;
-//     asm volatile("NOP\n"::); asm volatile("NOP\n"::);
-       stopTimer();
-       int_overhead = TCNT1;
-}
-
-void startTimer(uint8_t granularity){
-       TCCR1B = 0; /* stop timer */
-       TCNT1  = 0;
-       ovfcounter = 0;
-       TCCR1A = 0x00;
-       TIMSK &= 0xC3;
-       TIMSK |= _BV(TOIE1); /* enable TOIE1 */
-       TCCR1B = granularity & 0x7;     /* start timer */
-}
-
-uint64_t stopTimer(void){
-       TCCR1B = 0; /* stop timer */
-       uint64_t ret;
-       ret = (ovfcounter<<16) | TCNT1;
-       ret -= const_overhead;
-       ret -= ovfcounter * int_overhead;
-       return ret;
-}
-
-void getOverhead(uint16_t* constoh, uint16_t* intoh){
-       *constoh = const_overhead;
-       *intoh   = int_overhead; 
-}
-
-void print_time_P(PGM_P s, uint64_t t){
-       char sv[16];
-       uint8_t c;
-       uart_putstr_P(PSTR("\r\n"));
-       uart_putstr_P(s);
-       ultoa((unsigned long)t, sv, 10);
-       for(c=strlen(sv); c<11; ++c){
-               uart_putc(' ');
-       }
-       uart_putstr(sv);
-}
-
-void print_overhead(void){
-       char str[16];
-       uart_putstr_P(PSTR("\r\n\r\n=== benchmark ==="));
-       utoa(const_overhead, str, 10);
-       uart_putstr_P(PSTR("\r\n\tconst overhead:     "));
-       uart_putstr(str);
-       utoa(int_overhead, str, 10);
-       uart_putstr_P(PSTR("\r\n\tinterrupt overhead: "));
-       uart_putstr(str);
-}
-
-
diff --git a/performance_test.h b/performance_test.h
deleted file mode 100644 (file)
index d8b1565..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/* performance_test.h */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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 PERFORMANCE_TEST_H_
-#define PERFORMANCE_TEST_H_
-
-#include <stdint.h>
-#include <avr/pgmspace.h>
-
-void calibrateTimer(void);
-void startTimer(uint8_t granularity);
-uint64_t stopTimer(void);
-void getOverhead(uint16_t* constoh, uint16_t* intoh);
-
-void print_time_P(PGM_P s, uint64_t t);
-void print_overhead(void);
-
-#endif /*PERFORMANCE_TEST_H_*/
diff --git a/serial-tools.c b/serial-tools.c
deleted file mode 100644 (file)
index 47b6439..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/* serial-tools.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/**
- * 
- * Author:     Daniel Otte
- * Date:               16.05.2006
- * 
- * This tools should help to parse some input. 
- * 
- */
-
-#include "config.h"
-#include "uart.h"
-#include <string.h>
-#include <stdint.h>
-
-int getnextwordn(char *s, int n){ /* words are seperated by spaces */
-       char c = ' ';
-       while ((c=uart_getc()) == ' ')
-               ;
-       *s++ = c;
-       while (n && (*s++=uart_getc())!=' ')
-               ;
-       *(s-1) = '\0';
-       return n;
-}
-
-
-void readhex2buffer(void* buffer, int n){
-       char c;
-       uint8_t i;
-       
-//     DEBUG_S("\r\nDBG: n="); DEBUG_B(n&0xff); DEBUG_S("\r\n");
-       for(i=0; i<n; ++i){
-               c = uart_getc();
-               if ('0'<= c && '9'>=c){
-                       ((uint8_t*)buffer)[i] = c - '0';
-               } else {
-                       c &= ~('A' ^ 'a'); /* make all uppercase */ 
-                       if ('A'<= c && 'F'>=c){
-                               ((uint8_t*)buffer)[i] = c - 'A' + 10;
-                       } else {
-                               /* oh shit, wrong char */
-                       }
-               }
-               
-               ((uint8_t*)buffer)[i] <<= 4;
-               
-               c = uart_getc();
-               if ('0'<= c && '9'>=c){
-                       ((uint8_t*)buffer)[i] |= c - '0';
-               } else {
-                       c &= ~('A' ^ 'a'); /* make all uppercase */ 
-                       if ('A'<= c && 'F'>=c){
-                               ((uint8_t*)buffer)[i] |= c - 'A' + 10;
-                       } else {
-                               /* oh shit, wrong char */
-                       }
-               }
-       } /* for i=0 .. n */
-}
-
-void uart_putptr(void* p){
-       uart_hexdump((void*) &p,2);
-}
-
diff --git a/serial-tools.h b/serial-tools.h
deleted file mode 100644 (file)
index c76b4d5..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/* serial-tools.h */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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 8c33bbe59c19d63a7f1568f49632a47930094c8b..8056eb41d03e1b9623d026e30d2b48db8548e1a7 100644 (file)
--- a/serpent.c
+++ b/serpent.c
 #include <stdint.h>
 #include <string.h> /* memset() */
 #include <avr/pgmspace.h>
+#include "memxor.h"
 #include "serpent.h"
 #include "serpent-sboxes.h"
 
 /******************************************************************************/
 
-void memxor(void * dest, void * src, uint8_t size){
-       while(size--){
-               *((uint8_t*)dest) ^= *((uint8_t*)src);
-               dest = (uint8_t*)dest +1;
-               src  = (uint8_t*)src  +1;
-       }
-}
-
-/******************************************************************************/
-
 uint32_t rotl32(uint32_t a, uint8_t n){
        return ((a<<n) | (a>>(32-n)));
 }
@@ -92,10 +83,10 @@ static uint32_t gen_w(uint32_t * b, uint8_t i){
 } 
 
 /* key must be 256bit (32 byte) large! */
-void serpent_init(void * key, uint8_t keysize, serpent_ctx_t * ctx){
+void serpent_init(const void* key, uint16_t keysize, serpent_ctx_t* ctx){
        uint32_t buffer[8];
        uint8_t i,j;
-       if(keysize){
+       if(keysize<256){
                /* keysize is less than 256 bit, padding needed */
                memset(buffer, 0, 32);
                memcpy(buffer, key, (keysize+7)/8);
@@ -117,7 +108,7 @@ void serpent_init(void * key, uint8_t keysize, serpent_ctx_t * ctx){
 }
 
 
-void serpent_enc(void* buffer, serpent_ctx_t * ctx){
+void serpent_enc(void* buffer, const serpent_ctx_t* ctx){
        uint8_t i;
        for(i=0; i<31; ++i){
                memxor((uint8_t*)buffer, ctx->k[i], 16);
@@ -130,7 +121,7 @@ void serpent_enc(void* buffer, serpent_ctx_t * ctx){
        memxor((uint8_t*)buffer, ctx->k[i], 16);
 }
 
-void serpent_dec(void* buffer, serpent_ctx_t * ctx){
+void serpent_dec(void* buffer, const serpent_ctx_t* ctx){
        int8_t i=32;
        
        memxor((uint8_t*)buffer, ctx->k[i], 16);
index 084b87acc63242d3eb3f1bd074d17cf920aaada9..3e90253a1aa15556d7483e7d1849e19adfdf2835 100644 (file)
--- a/serpent.h
+++ b/serpent.h
     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
-/* serpent.h
- * a bitsliced implementation of the serpent cipher for avr microcontrollers
- * author: Daniel Otte
- * license: GPLv3
+/** \file   serpent.h
+ * \author  Daniel Otte
+ * \license GPLv3
+ * \brief a implementation of the serpent cipher for avr microcontrollers
  */
 
 #ifndef SERPENT_H_
@@ -35,13 +35,13 @@ typedef struct serpent_ctx_st {
 
 #define SERPENT_KEY128 128
 #define SERPENT_KEY192 192
-#define SERPENT_KEY256   0
+#define SERPENT_KEY256 256
 
 
 /* key must be 256bit (32 byte) large! */
-void serpent_init(void * key, uint8_t keysize, serpent_ctx_t * ctx);
-void serpent_enc(void * buffer, serpent_ctx_t * ctx);
-void serpent_dec(void * buffer, serpent_ctx_t * ctx);
+void serpent_init(const void* key, uint16_t keysize, serpent_ctx_t* ctx);
+void serpent_enc(void* buffer, const serpent_ctx_t* ctx);
+void serpent_dec(void* buffer, const serpent_ctx_t* ctx);
 
 
 #endif /*SERPENT_H_*/
diff --git a/test_src/cli.c b/test_src/cli.c
new file mode 100644 (file)
index 0000000..8c15f5f
--- /dev/null
@@ -0,0 +1,73 @@
+/* cli.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/**
+ * 
+ * author: Daniel Otte
+ * email:  daniel.otte@rub.de
+ * license: GPLv3 or later
+ * 
+ * components to help implementing simple command based interaction
+ * 
+ **/
+#include <stdint.h>
+#include <string.h>
+#include <avr/pgmspace.h>
+
+int16_t findstring_d0(const char* str, const char* v){
+       uint8_t i=0;
+       while(*v){      
+               if(!strcmp(str, v)){
+                       return i;
+               }
+               while(*v++) /* go to the next string */
+               ;
+               ++i;
+       }
+       return -1;
+}
+int16_t findstring_d0_P(const char* str, PGM_P v){
+       uint8_t i=0;
+       while(pgm_read_byte(v)){        
+               if(!strcmp_P(str, v)){
+                       return i;
+               }
+               while(pgm_read_byte(v++)) /* go to the next string */
+               ;
+               ++i;
+       }
+       return -1;
+} 
+
+int16_t execcommand_d0_P(const char* str, PGM_P v, void(*fpt[])(void) ){
+       uint8_t i=0;
+       while(pgm_read_byte(v)){        
+               if(!strcmp_P(str, v)){
+                       (fpt[i])();
+                       return i;
+               }
+               while(pgm_read_byte(v++)) /* go to the next string */
+               ;
+               ++i;
+       }
+       return -1;
+}
+
+
diff --git a/test_src/cli.h b/test_src/cli.h
new file mode 100644 (file)
index 0000000..c36a6e6
--- /dev/null
@@ -0,0 +1,31 @@
+/* cli.h */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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 CLI_H_
+#define CLI_H_
+
+#include <stdint.h>
+#include <avr/pgmspace.h>
+
+typedef void(*void_fpt)(void);
+
+int16_t findstring_d0(const char* str, const char* v);
+int16_t findstring_d0_P(const char* str, PGM_P v);
+
+int16_t execcommand_d0_P(const char* str, PGM_P v, void(*fpt[])(void) );
+#endif /*CLI_H_*/
diff --git a/test_src/debug.c b/test_src/debug.c
new file mode 100644 (file)
index 0000000..3b5fee4
--- /dev/null
@@ -0,0 +1,64 @@
+/* debug.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/***************************
+*
+*
+*
+****************************/
+#include "config.h"
+
+#if DEBUG == uart
+ #include "uart.h"
+#else
+  #error "Your DEBUG methode is not suported!"
+#endif
+
+#ifdef DEBUG
+ void debug_init(void){
+ #if DBUG==uart
+  uart_init();
+ #else
+  #error "Your DEBUG methode is not suported!"
+ #endif
+ }
+ void debug_char(char c){
+       static char initialised = 0;
+       if (!initialised){
+               uart_init();
+               initialised=1;
+       }       
+       uart_putc(c);
+ }
+ void debug_str(char* s){
+       while (*s)
+               debug_char(*s++);
+ }
+
+
+ void debug_byte(char b){
+       char table[] = "0123456789ABCDEF";
+       debug_char(table[(b>>4) & 0xf]);
+       debug_char(table[b&0xf]);
+ }
+
+#endif //DEBUG
+
diff --git a/test_src/main-arcfour-test.c b/test_src/main-arcfour-test.c
new file mode 100644 (file)
index 0000000..0e0be91
--- /dev/null
@@ -0,0 +1,86 @@
+/* main-arcfour-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * arcfour (RC4 compatible) test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "arcfour.h"
+#include "nessie_stream_test.h"
+
+#include <stdint.h>
+#include <string.h>
+
+char* cipher_name = "Arcfour";
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+void arcfour_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
+       arcfour_init(ctx, key, (keysize+7)/8);
+}
+
+
+
+void testrun_nessie_arcfour(void){
+       nessie_stream_ctx.outsize_b = 8; /* actually unused */
+       nessie_stream_ctx.keysize_b = 128; /* this is theone we have refrence vectors for */
+       nessie_stream_ctx.ivsize_b = (uint16_t)-1;
+       nessie_stream_ctx.name = cipher_name;
+       nessie_stream_ctx.ctx_size_B = sizeof(arcfour_ctx_t);
+       nessie_stream_ctx.cipher_genctx = (nessie_stream_genctx_fpt)arcfour_genctx_dummy;
+       nessie_stream_ctx.cipher_enc = (nessie_stream_genenc_fpt)arcfour_gen;
+       
+       nessie_stream_run();    
+}
+
+
+
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+int main (void){
+       char  str[20];
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+       uart_putstr(cipher_name);
+       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+restart:
+       while(1){ 
+               if (!getnextwordn(str,20))  {DEBUG_S("DBG: W1\r\n"); goto error;}
+               if (strcmp(str, "nessie")) {DEBUG_S("DBG: 1b\r\n"); goto error;}
+                       testrun_nessie_arcfour();
+               goto restart;           
+               continue;
+       error:
+               uart_putstr("ERROR\r\n");
+       }
+       
+       
+}
+
diff --git a/test_src/main-camellia-test.c b/test_src/main-camellia-test.c
new file mode 100644 (file)
index 0000000..4d64a50
--- /dev/null
@@ -0,0 +1,135 @@
+/* main-camellia-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * camellia test-suit
+ * 
+ */
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "camellia.h"
+#include "nessie_bc_test.h"
+#include "performance_test.h"
+#include "cli.h"
+
+char* cipher_name = "Camellia";
+
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <avr/pgmspace.h>
+
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+void camellia128_init_dummy(void* key, uint16_t keysize_b, void* ctx){
+       camellia128_init(key, ctx);
+}
+
+void testrun_nessie_camellia(void){
+       nessie_bc_ctx.blocksize_B =  16;
+       nessie_bc_ctx.keysize_b   = 128;
+       nessie_bc_ctx.name        = cipher_name;
+       nessie_bc_ctx.ctx_size_B  = sizeof(camellia128_ctx_t);
+       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)camellia128_enc;
+       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)camellia128_dec;
+       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)camellia128_init_dummy;
+       
+       nessie_bc_run();
+}
+
+
+void test_performance_camellia(void){
+       uint64_t t;
+       char str[6];
+       uint8_t key[16], data[16];
+       camellia128_ctx_t ctx;
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(key,  0, 16);
+       memset(data, 0, 16);
+       
+       startTimer(1);
+       camellia128_init(key, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       camellia128_enc(data, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       camellia128_dec(data, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       uart_putstr_P(PSTR("\r\n"));
+}
+
+
+
+/*****************************************************************************
+ *  self tests                                                                                                                          *
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+int main (void){
+       char str[20];
+
+       
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+       uart_putstr(cipher_name);
+       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_nessie_camellia, testrun_nessie_camellia, test_performance_camellia};
+       
+       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");
+       }
+}
+
diff --git a/test_src/main-cast5-test.c b/test_src/main-cast5-test.c
new file mode 100644 (file)
index 0000000..2cfb3d1
--- /dev/null
@@ -0,0 +1,220 @@
+/* main-cast5-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * cast5 test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "cast5.h"
+#include "nessie_bc_test.h"
+#include "performance_test.h"
+#include "cli.h"
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+char* cipher_name = "cast-128 (cast5)";
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+
+void testrun_nessie_cast5(void){
+       nessie_bc_ctx.blocksize_B =   8;
+       nessie_bc_ctx.keysize_b   = 128;
+       nessie_bc_ctx.name        = cipher_name;
+       nessie_bc_ctx.ctx_size_B  = sizeof(cast5_ctx_t);
+       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)cast5_enc;
+       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)cast5_dec;
+       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)cast5_init;
+       
+       nessie_bc_run();
+}
+
+/*****************************************************************************
+ *  self tests                                                                                                                          *
+ *****************************************************************************/
+
+void cast5_ctx_dump(cast5_ctx_t *s){
+       uint8_t i;
+       uart_putstr("\r\n==== cast5_ctx_dump ====\r\n shortkey: ");
+       uart_putstr(s->shortkey?"yes":"no");
+       for(i=0;i<16;++i){
+               uint8_t r;
+               uart_putstr("\r\n Km"); uart_hexdump(&i, 1); uart_putc(':');
+               uart_hexdump(&(s->mask[i]), 4);
+               uart_putstr("\r\n Kr"); uart_hexdump(&i, 1); uart_putc(':');
+               r = (s->rotl[i/2]);
+               if (i&0x01) r >>= 4;
+               r &= 0xf;
+               r += (s->roth[i>>3]&(1<<(i&0x7)))?0x10:0x00;
+               uart_hexdump(&r, 1);
+       }
+}
+
+
+void test_encrypt(uint8_t *block, uint8_t *key, uint8_t keylength, bool print){
+       cast5_ctx_t s;
+       if (print){
+               uart_putstr("\r\nCAST5:\r\n key:\t");
+               uart_hexdump(key, keylength/8);
+               uart_putstr("\r\n plaintext:\t");
+               uart_hexdump(block, 8);
+       }
+       cast5_init(key, keylength, &s);
+       cast5_enc(block, &s);
+       if (print){
+               uart_putstr("\r\n ciphertext:\t");
+               uart_hexdump(block, 8);
+       }
+} 
+
+void test_decrypt(uint8_t *block, uint8_t *key, uint8_t keylength, bool print){
+       cast5_ctx_t s;
+       if (print){
+               uart_putstr("\r\nCAST5:\r\n key:\t");
+               uart_hexdump(key, keylength/8);
+               uart_putstr("\r\n ciphertext:\t");
+               uart_hexdump(block, 8);
+       }
+       cast5_init(key, keylength, &s);
+       cast5_dec(block, &s);
+       if (print){
+               uart_putstr("\r\n plaintext:\t");
+               uart_hexdump(block, 8);
+       }
+} 
+
+void testrun_cast5(void){
+       uint8_t block[8];
+       uint8_t key[16];
+       uint8_t *tda = (uint8_t*)"\x01\x23\x45\x67\x89\xAB\xCD\xEF",
+               *tka = (uint8_t*)"\x01\x23\x45\x67\x12\x34\x56\x78\x23\x45\x67\x89\x34\x56\x78\x9A";
+       memcpy(block, tda, 8);
+       memcpy(key, tka, 16);
+       test_encrypt(block, key, 128, true);
+       test_decrypt(block, key, 128, true);
+       memcpy(block, tda, 8);
+       memcpy(key, tka, 16);
+       test_encrypt(block, key, 80, true);
+       test_decrypt(block, key, 80, true);
+       memcpy(block, tda, 8);
+       memcpy(key, tka, 16);
+       test_encrypt(block, key, 40, true);
+       test_decrypt(block, key, 40, true);
+       
+/**** long test *****/
+       uart_putstr("\r\nmaintance-test");
+       uint8_t a[16]= {0x01, 0x23, 0x45, 0x67, 0x12,
+                                   0x34, 0x56, 0x78, 0x23, 0x45, 
+                                   0x67, 0x89, 0x34, 0x56, 0x78, 
+                                   0x9A}, 
+                       b[16]= {0x01, 0x23, 0x45, 0x67, 0x12,
+                                   0x34, 0x56, 0x78, 0x23, 0x45, 
+                                   0x67, 0x89, 0x34, 0x56, 0x78, 
+                                   0x9A};
+       uint32_t i;
+       for(i=0;i<1000000; ++i){
+               test_encrypt(&(a[0]), &(b[0]), 128, false);
+               test_encrypt(&(a[8]), &(b[0]), 128, false);
+               test_encrypt(&(b[0]), &(a[0]), 128, false);
+               test_encrypt(&(b[8]), &(a[0]), 128, false);
+               if ((i&0x000000ff) == 0){
+                       uart_putstr("\r\n");
+                       uart_hexdump(&i, 4);
+               }
+       }
+       uart_putstr("\r\na = "); uart_hexdump(a, 16);
+       uart_putstr("\r\nb = "); uart_hexdump(b, 16);
+
+}
+
+void testrun_performance_cast5(void){
+       uint64_t t;
+       char str[6];
+       uint8_t key[16], data[16];
+       cast5_ctx_t ctx;
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(key,  0, 16);
+       memset(data, 0, 16);
+       
+       startTimer(1);
+       cast5_init(key, 128, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       cast5_enc(data, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       cast5_dec(data, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       uart_putstr_P(PSTR("\r\n"));
+}
+
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+int main (void){
+       char str[20];
+
+       
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+       uart_putstr(cipher_name);
+       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_nessie_cast5, testrun_cast5, testrun_performance_cast5};
+       
+       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");
+       }
+}
+
diff --git a/test_src/main-des-test.c b/test_src/main-des-test.c
new file mode 100644 (file)
index 0000000..714781c
--- /dev/null
@@ -0,0 +1,123 @@
+/* main-des-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * des test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "des.h"
+#include "nessie_bc_test.h"
+#include "cli.h"
+#include "performance_test.h"
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+char* cipher_name = "DES";
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+void des_init_dummy(const void* key, uint16_t keysize_b, void* ctx){
+       memcpy(ctx, key, 8);
+}
+
+void des_enc_dummy(void* buffer, void* ctx){
+       des_enc(buffer, buffer, ctx);
+} 
+
+void des_dec_dummy(void* buffer, void* ctx){
+       des_dec(buffer, buffer, ctx);
+} 
+
+void testrun_nessie_des(void){
+       nessie_bc_init();
+       nessie_bc_ctx.blocksize_B =   8;
+       nessie_bc_ctx.keysize_b   =  64;
+       nessie_bc_ctx.name        = cipher_name;
+       nessie_bc_ctx.ctx_size_B  = 8;
+       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)des_enc_dummy;
+       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)des_dec_dummy;
+       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)des_init_dummy;
+       
+       nessie_bc_run();
+}
+
+
+void testrun_performance_des(void){
+       uint64_t t;
+       char str[16];
+       uint8_t key[8], data[8];
+       
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(key,  0, 8);
+       memset(data, 0, 8);
+       
+       startTimer(1);
+       des_enc(data, data, key);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       startTimer(1);
+       des_dec(data, data, key);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       uart_putstr_P(PSTR("\r\n"));
+}
+/*****************************************************************************
+ * main                                                
+ *****************************************************************************/
+
+int main (void){
+       char  str[20];
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+       uart_putstr(cipher_name);
+       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_nessie_des, testrun_nessie_des, testrun_performance_des};
+
+       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");
+       }
+       
+}
+
diff --git a/test_src/main-entropium-test.c b/test_src/main-entropium-test.c
new file mode 100644 (file)
index 0000000..3384396
--- /dev/null
@@ -0,0 +1,116 @@
+/* main-entropium-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * entropium test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "entropium.h"
+#include "nessie_bc_test.h"
+#include "cli.h"
+#include "performance_test.h"
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+char* cipher_name = "Entropium";
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+
+void testrun_entropium(void){
+       char c, str[16];
+       uint8_t data[32];
+       uint32_t i=0;
+       while(!uart_getc_nb(&c)){
+               entropium_getRandomBlock(data);
+               uart_putstr_P(PSTR("\r\n "));
+               ultoa(i, str, 10);
+               for(c=strlen(str); c<11; ++c){
+                       uart_putc(' ');
+               }
+               uart_putstr(str);
+               ++i;
+               uart_putstr_P(PSTR(" : "));
+               uart_hexdump(data, 32);
+       }
+       uart_putstr_P(PSTR("\r\n\r\n"));
+}
+
+
+void testrun_performance_entropium(void){
+       uint64_t t;
+       char str[16];
+       uint8_t data[32];
+       
+       calibrateTimer();
+       print_overhead();
+       
+       startTimer(1);
+       entropium_addEntropy(128, data);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tadd entropy time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       entropium_getRandomBlock(data);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tget random time:  "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       uart_putstr_P(PSTR("\r\n"));
+}
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+int main (void){
+       char  str[20];
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+       uart_putstr(cipher_name);
+       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_entropium, testrun_entropium, testrun_performance_entropium};
+
+       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");
+       }
+       
+}
+
diff --git a/test_src/main-grain-test.c b/test_src/main-grain-test.c
new file mode 100644 (file)
index 0000000..44f08f8
--- /dev/null
@@ -0,0 +1,180 @@
+/* main-grain-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * grain test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+#include "cli.h"
+
+#include "grain.h"
+#include "nessie_stream_test.h"
+#include "performance_test.h"
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+
+char* cipher_name = "Grain";
+
+/*****************************************************************************
+ *  additional validation-functions                                          *
+ *****************************************************************************/
+void grain_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
+       uint8_t iv[8]={0};
+       grain_init(key, &iv, ctx);
+}
+
+uint8_t grain_getbyte_dummy(grain_ctx_t* ctx){
+       uint8_t i,ret=0;
+       for(i=0; i<8; ++i){
+               ret<<=1;
+               ret |= grain_enc(ctx);
+       }
+       return ret;
+}
+
+uint8_t grain_getbyte_dummy_rev(grain_ctx_t* ctx){
+       uint8_t i,ret=0;
+       for(i=0; i<8; ++i){
+               ret >>= 1;
+               ret |= grain_enc(ctx)?0x80:0x00;
+       }
+       return ret;
+}
+
+void testrun_nessie_grain(void){
+       nessie_stream_ctx.outsize_b =   8; /* actually unused */
+       nessie_stream_ctx.keysize_b =  80; /* this is the one we have refrence vectors for */
+       nessie_stream_ctx.ivsize_b  =  64;
+       nessie_stream_ctx.name = cipher_name;
+       nessie_stream_ctx.ctx_size_B = sizeof(grain_ctx_t);
+       nessie_stream_ctx.cipher_genctx = (nessie_stream_genctx_fpt)grain_genctx_dummy;
+       nessie_stream_ctx.cipher_enc = (nessie_stream_genenc_fpt)grain_getbyte_dummy_rev;
+       
+       nessie_stream_run();    
+}
+
+
+void testrun_std_grain(void){
+       grain_ctx_t ctx;
+       uint8_t i, key[10], iv[8], out[10];
+       
+       /* 1 */
+       memset(key, 0, 10);
+       memset(iv, 0, 8);
+       uart_putstr_P(PSTR("\r\n=== std test ==="));
+       uart_putstr_P(PSTR("\r\n key: "));
+       uart_hexdump(key, 10);
+       uart_putstr_P(PSTR("\r\n iv:  "));
+       uart_hexdump(key, 8);
+       grain_init(key, iv, &ctx);
+       for(i=0; i<10; ++i){
+               out[i] = grain_getbyte_dummy(&ctx);
+       }
+       uart_putstr_P(PSTR("\r\n out: "));
+       uart_hexdump(out, 10);
+       
+       /* 2 */
+       for(i=0; i<8; ++i){
+               key[i] = i*0x22+1;
+       }
+       key[8]=0x12;
+       key[9]=0x34;
+       
+       for(i=0; i<8; ++i){
+               iv[i] = i*0x22+1;
+       }
+       uart_putstr_P(PSTR("\r\n\r\n key: "));
+       uart_hexdump(key, 10);
+       uart_putstr_P(PSTR("\r\n iv:  "));
+       uart_hexdump(key, 8);
+       grain_init(key, iv, &ctx);
+       for(i=0; i<10; ++i){
+               out[i] = grain_getbyte_dummy(&ctx);
+       }
+       uart_putstr_P(PSTR("\r\n out: "));
+       uart_hexdump(out, 10);
+       
+       
+       uart_putstr_P(PSTR("\r\n\r\n"));
+}
+
+void testrun_performance_grain(void){
+       uint64_t t;
+       char str[16];
+       uint8_t key[10], iv[8];
+       grain_ctx_t ctx;
+       
+       calibrateTimer();
+       print_overhead();       
+       
+       memset(key,  0, 10);
+       memset(iv,  0, 8);
+       
+       startTimer(1);
+       grain_init(key, iv, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);       
+       
+       startTimer(1);
+       grain_enc(&ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);       
+       
+       uart_putstr_P(PSTR("\r\n"));
+}
+
+/*****************************************************************************
+ *  main                                                                     *
+ *****************************************************************************/
+
+int main (void){
+       char  str[20];
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+       uart_putstr(cipher_name);
+       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_nessie_grain, testrun_std_grain, testrun_performance_grain};
+
+       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");
+       }       
+}
+
+
+
diff --git a/test_src/main-hmac-sha1-test.c b/test_src/main-hmac-sha1-test.c
new file mode 100644 (file)
index 0000000..2a786df
--- /dev/null
@@ -0,0 +1,100 @@
+/* main-hmac-sha1-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * HMAC-SHA1 test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "sha1.h"
+#include "hmac-sha1.h"
+
+#include "nessie_mac_test.h"
+
+#include <stdint.h>
+#include <string.h>
+#include "cli.h"
+
+char* algo_name = "HMAC-SHA1";
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+void hmacsha1_next_dummy(void* buffer, void* ctx){
+       sha1_nextBlock(ctx, buffer);
+}
+
+void hmacsha1_init_dummy(void* key, uint16_t keysize_b, void* ctx){
+       hmac_sha1_init(ctx, key, keysize_b);
+}
+
+void hmacsha1_last_dummy(void* buffer, uint16_t size_b, void* key, uint16_t keysize_b, void* ctx){
+       sha1_lastBlock(ctx, buffer, size_b);
+       hmac_sha1_final(ctx, key, keysize_b);
+}
+
+void testrun_nessie_hmacsha1(void){
+       nessie_mac_ctx.macsize_b   = 160;
+       nessie_mac_ctx.keysize_b   = 512;
+       nessie_mac_ctx.blocksize_B = 512/8;
+       nessie_mac_ctx.ctx_size_B  = sizeof(hmac_sha1_ctx_t);
+       nessie_mac_ctx.name = algo_name;
+       nessie_mac_ctx.mac_init = (nessie_mac_init_fpt)hmacsha1_init_dummy;
+       nessie_mac_ctx.mac_next = (nessie_mac_next_fpt)hmacsha1_next_dummy;
+       nessie_mac_ctx.mac_last = (nessie_mac_last_fpt)hmacsha1_last_dummy;
+       nessie_mac_ctx.mac_conv = (nessie_mac_conv_fpt)sha1_ctx2hash;
+       
+       nessie_mac_run();
+}
+
+
+
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+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\0");
+       void_fpt v[] = {testrun_nessie_hmacsha1, testrun_nessie_hmacsha1};
+
+       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");
+       }
+       
+       
+}
+
diff --git a/test_src/main-hmac-sha256-test.c b/test_src/main-hmac-sha256-test.c
new file mode 100644 (file)
index 0000000..819ed57
--- /dev/null
@@ -0,0 +1,96 @@
+/* main-hmac-sha256-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * HMAC-SHA256 test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "sha256.h"
+#include "hmac-sha256.h"
+
+#include "nessie_mac_test.h"
+
+#include <stdint.h>
+#include <string.h>
+
+char* algo_name = "HMAC-SHA256";
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+void hmacsha256_next_dummy(void* buffer, void* ctx){
+       sha256_nextBlock(ctx, buffer);
+}
+
+void hmacsha256_init_dummy(void* key, uint16_t keysize_b, void* ctx){
+       hmac_sha256_init(ctx, key, keysize_b);
+}
+
+void hmacsha256_last_dummy(void* buffer, uint16_t size_b, void* key, uint16_t keysize_b, void* ctx){
+       sha256_lastBlock(ctx, buffer, size_b);
+       hmac_sha256_final(ctx, key, keysize_b);
+}
+
+void testrun_nessie_hmacsha256(void){
+       nessie_mac_ctx.macsize_b   = 256;
+       nessie_mac_ctx.keysize_b   = 512;
+       nessie_mac_ctx.blocksize_B = 512/8;
+       nessie_mac_ctx.ctx_size_B  = sizeof(hmac_sha256_ctx_t);
+       nessie_mac_ctx.name = algo_name;
+       nessie_mac_ctx.mac_init = (nessie_mac_init_fpt)hmacsha256_init_dummy;
+       nessie_mac_ctx.mac_next = (nessie_mac_next_fpt)hmacsha256_next_dummy;
+       nessie_mac_ctx.mac_last = (nessie_mac_last_fpt)hmacsha256_last_dummy;
+       nessie_mac_ctx.mac_conv = (nessie_mac_conv_fpt)sha256_ctx2hash;
+       
+       nessie_mac_run();
+}
+
+
+
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+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"));
+
+restart:
+       while(1){ 
+               if (!getnextwordn(str,20))  {DEBUG_S("DBG: W1\r\n"); goto error;}
+               if (strcmp(str, "nessie")) {DEBUG_S("DBG: 1b\r\n"); goto error;}
+                       testrun_nessie_hmacsha256();
+               goto restart;           
+               continue;
+       error:
+               uart_putstr("ERROR\r\n");
+       }
+       
+}
+
diff --git a/test_src/main-md5-test.c b/test_src/main-md5-test.c
new file mode 100644 (file)
index 0000000..490ee48
--- /dev/null
@@ -0,0 +1,168 @@
+/* main-md5-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * md5 test suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "md5.h"
+#include "nessie_hash_test.h"
+#include "performance_test.h"
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include "cli.h"
+
+char* algo_name = "MD5";
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+void md5_next_dummy(void* buffer, void* ctx){
+       md5_nextBlock(ctx, buffer);
+}
+
+void md5_last_dummy(void* buffer, uint16_t size_b, void* ctx){
+       md5_lastBlock(ctx, buffer, size_b);
+}
+
+void md5_ctx2hash_dummy(void* buffer, void* ctx){
+       memcpy(buffer, ctx, 16);
+}
+
+
+void testrun_nessie_md5(void){
+       nessie_hash_ctx.hashsize_b  = 128;
+       nessie_hash_ctx.blocksize_B = 512/8;
+       nessie_hash_ctx.ctx_size_B  = sizeof(md5_ctx_t);
+       nessie_hash_ctx.name = algo_name;
+       nessie_hash_ctx.hash_init = (nessie_hash_init_fpt)md5_init;
+       nessie_hash_ctx.hash_next = (nessie_hash_next_fpt)md5_next_dummy;
+       nessie_hash_ctx.hash_last = (nessie_hash_last_fpt)md5_last_dummy;
+       nessie_hash_ctx.hash_conv = (nessie_hash_conv_fpt)md5_ctx2hash_dummy;
+       
+       nessie_hash_run();
+}
+
+/*****************************************************************************
+ *  self tests                                                                                                                          *
+ *****************************************************************************/
+
+/*
+ * MD5 test suite:
+ * MD5 ("") = d41d8cd98f00b204e9800998ecf8427e
+ * MD5 ("a") = 0cc175b9c0f1b6a831c399e269772661
+ * MD5 ("abc") = 900150983cd24fb0d6963f7d28e17f72
+ * MD5 ("message digest") = f96b697d7cb7938d525a2f31aaf161d0
+ * MD5 ("abcdefghijklmnopqrstuvwxyz") = c3fcd3d76192e4007dfb496cca67e13b
+ * MD5 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =
+ * d174ab98d277d9f5a5611c2c9f419d9f
+ * MD5 ("123456789012345678901234567890123456789012345678901234567890123456
+ * 78901234567890") = 57edf4a22be3c955ac49da2e2107b67a
+ */
+
+void testrun_md5(void){
+       md5_ctx_t s;
+       char* testv[]={"", "a", "abc", "message digest", "abcdefghijklmnopqrstuvwxyz", 
+               "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 
+               "12345678901234567890123456789012345678901234567890123456789012345678901234567890"};
+       uint8_t i;
+       
+       uart_putstr("\r\n=== MD5 test suit ===");
+       for(i=0; i<7; ++i){
+               uart_putstr("\r\n MD5 (\"");
+               uart_putstr(testv[i]);
+               uart_putstr("\") = \r\n");
+               md5_init(&s);
+               md5_lastBlock(&s, testv[i], strlen(testv[i])*8);
+               uart_hexdump(&s.a[0], 16);
+       }
+}
+
+
+void testrun_performance_md5(void){
+       uint64_t t;
+       char str[16];
+       uint8_t data[32];
+       md5_ctx_t ctx;
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(data, 0, 32);
+       
+       startTimer(1);
+       md5_init(&ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       md5_nextBlock(&ctx, data);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tone-block time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       md5_lastBlock(&ctx, data, 0);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tlast block time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       uart_putstr_P(PSTR("\r\n"));
+}
+
+
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+int main (void){
+       char str[20];
+
+       
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr("\r\n\r\nCrypto-VS (MD5)\r\nloaded and running\r\n");
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_nessie_md5, testrun_md5, testrun_performance_md5};
+
+       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");
+       }
+}
+
diff --git a/test_src/main-noekeon-test.c b/test_src/main-noekeon-test.c
new file mode 100644 (file)
index 0000000..851c7bc
--- /dev/null
@@ -0,0 +1,241 @@
+/* main-noekeon-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * serpent test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "noekeon.h"
+#include "nessie_bc_test.h"
+#include "cli.h"
+#include "performance_test.h"
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+char* cipher_name = "Noekeon";
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+void noekeon_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
+       noekeon_init(key, ctx);
+}
+
+void testrun_nessie_noekeon_indirect(void){
+       char str[strlen(cipher_name)+10];
+       strcpy(str, cipher_name);
+       strcat(str, "-indirect");
+       
+       nessie_bc_ctx.blocksize_B =  16;
+       nessie_bc_ctx.keysize_b   = 128;
+       nessie_bc_ctx.name        = str;
+       nessie_bc_ctx.ctx_size_B  = sizeof(noekeon_ctx_t);
+       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)noekeon_enc;
+       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)noekeon_dec;
+       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)noekeon_genctx_dummy;
+       
+       nessie_bc_run();
+}
+
+void noekeon_genctx_dummy_direct(uint8_t* key, uint16_t keysize, void* ctx){
+       memcpy(ctx, key, 16);
+}
+
+void testrun_nessie_noekeon_direct(void){
+       char str[strlen(cipher_name)+10];
+       strcpy(str, cipher_name);
+       strcat(str, "-Direct");
+       
+       nessie_bc_ctx.blocksize_B =  16;
+       nessie_bc_ctx.keysize_b   = 128;
+       nessie_bc_ctx.name        = str;
+       nessie_bc_ctx.ctx_size_B  = sizeof(noekeon_ctx_t);
+       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)noekeon_enc;
+       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)noekeon_dec;
+       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)noekeon_genctx_dummy_direct;
+       
+       nessie_bc_run();
+}
+
+void testrun_nessie_noekeon(void){
+       testrun_nessie_noekeon_direct();
+       testrun_nessie_noekeon_indirect();
+}
+
+
+void testrun_stdtest_rundirect(void* data, void* key){
+       uart_putstr_P(PSTR("\r\n                     "));
+       uart_putstr_P(PSTR("k = "));
+       uart_hexdump(key,16);
+       
+       uart_putstr_P(PSTR("\r\n                     "));
+       uart_putstr_P(PSTR("a = "));
+       uart_hexdump(data,16);
+       
+       noekeon_enc(data, key);
+       uart_putstr_P(PSTR("\r\nafter NESSIEencrypt, b = "));
+       uart_hexdump(data,16);
+       
+       noekeon_dec(data, key);
+       uart_putstr_P(PSTR("\r\nafter NESSIEdecrypt, a?= "));
+       uart_hexdump(data,16);
+       uart_putstr_P(PSTR("\r\n"));
+}
+
+void testrun_stdtest_runindirect(void* data, void* key){
+       noekeon_ctx_t ctx;
+       uart_putstr_P(PSTR("\r\n                     "));
+       uart_putstr_P(PSTR("k = "));
+       uart_hexdump(key,16);
+       
+       uart_putstr_P(PSTR("\r\n                     "));
+       uart_putstr_P(PSTR("a = "));
+       uart_hexdump(data,16);
+       noekeon_init(key, &ctx);
+       noekeon_enc(data, &ctx);
+       uart_putstr_P(PSTR("\r\nafter NESSIEencrypt, b = "));
+       uart_hexdump(data,16);
+       
+       noekeon_dec(data, &ctx);
+       uart_putstr_P(PSTR("\r\nafter NESSIEdecrypt, a?= "));
+       uart_hexdump(data,16);
+       uart_putstr_P(PSTR("\r\n"));
+}
+
+void testrun_stdtest_noekeon(void){
+       uint8_t key[16], data[16];
+       uint8_t key3[16];
+       noekeon_ctx_t ctx;
+       
+       uart_putstr_P(PSTR("\r\nTest vectors for block cipher Noekeon in Indirect-Key Mode:\r\n"));
+       
+       memset(key,  0, 16);
+       memset(data, 0, 16);
+       testrun_stdtest_runindirect(data, key);
+       
+       memset(key,  0xFF, 16);
+       memset(data, 0xFF, 16);
+       testrun_stdtest_runindirect(data, key);
+       
+       memset(key,  0, 16);
+       memset(data, 0, 16);
+       noekeon_init(key, &ctx);
+       noekeon_enc(data, &ctx);
+       memcpy(key3, data, 16);
+       memset(key,  0xFF, 16);
+       memset(data, 0xFF, 16);
+       noekeon_init(key, &ctx);
+       noekeon_enc(data, &ctx);
+       testrun_stdtest_runindirect(data, key3);
+       
+       uart_putstr_P(PSTR("\r\nTest vectors for block cipher Noekeon in Direct-Key Mode:\r\n"));
+       
+       memset(key,  0, 16);
+       memset(data, 0, 16);
+       testrun_stdtest_rundirect(data, key);
+       
+       memset(key,  0xFF, 16);
+       memset(data, 0xFF, 16);
+       testrun_stdtest_rundirect(data, key);
+       
+       memset(key,  0, 16);
+       memset(data, 0, 16);
+       noekeon_enc(data, key);
+       memcpy(key3, data, 16);
+       memset(key,  0xFF, 16);
+       memset(data, 0xFF, 16);
+       noekeon_enc(data, key);
+       testrun_stdtest_rundirect(data, key3);
+       
+}
+
+void testrun_performance_noekeon(void){
+       uint64_t t;
+       char str[16];
+       uint8_t key[16], data[16];
+       noekeon_ctx_t ctx;
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(key,  0, 16);
+       memset(data, 0, 16);
+       
+       startTimer(1);
+       noekeon_init(key, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);       
+       
+       startTimer(1);
+       noekeon_enc(data, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);       
+       
+       startTimer(1);
+       noekeon_dec(data, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       uart_putstr_P(PSTR("\r\n"));
+}
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+int main (void){
+       char  str[20];
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+       uart_putstr(cipher_name);
+       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+       PGM_P    u   = PSTR("nessie\0test\0direct\0indirect\0performance\0");
+       void_fpt v[] = {testrun_nessie_noekeon, 
+                           testrun_stdtest_noekeon,
+                           testrun_nessie_noekeon_direct, 
+                           testrun_nessie_noekeon_indirect,  
+                           testrun_performance_noekeon};
+
+       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");
+       }
+       
+}
+
diff --git a/test_src/main-present-test.c b/test_src/main-present-test.c
new file mode 100644 (file)
index 0000000..4c739bc
--- /dev/null
@@ -0,0 +1,152 @@
+/* main-present-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * present test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "present.h"
+#include "nessie_bc_test.h"
+#include "cli.h"
+#include "performance_test.h"
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+
+char* cipher_name = "Present";
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+void present_genctx_dummy(uint8_t* key, uint16_t keysize_b, present_ctx_t* ctx){
+       present_init(key, keysize_b, ctx);
+}
+
+void testrun_nessie_present(void){
+       nessie_bc_ctx.blocksize_B =   8;
+       nessie_bc_ctx.keysize_b   =  80;
+       nessie_bc_ctx.name        = cipher_name;
+       nessie_bc_ctx.ctx_size_B  = sizeof(present_ctx_t);
+       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)present_enc;
+       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)present_dec;
+       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)present_genctx_dummy;
+       
+       nessie_bc_run();        
+}
+
+void testrun_selfenc(uint8_t* key, uint8_t* buffer){
+       present_ctx_t ctx;
+       uart_putstr_P(PSTR("\r\nkey   : "));
+       uart_hexdump(key, 10);
+       uart_putstr_P(PSTR("\r\nplain : "));
+       uart_hexdump(buffer, 8);
+       present_init(key, 80, &ctx);
+       present_enc(buffer, &ctx);
+       uart_putstr_P(PSTR("\r\ncipher: "));
+       uart_hexdump(buffer, 8);
+       present_dec(buffer, &ctx);
+       uart_putstr_P(PSTR("\r\nplain : "));
+       uart_hexdump(buffer, 8);
+       uart_putstr_P(PSTR("\r\n"));
+}
+
+void testrun_self_present(void){
+       uint8_t buffer[8], key[10];
+       uart_putstr_P(PSTR("\r\n\r\n=== Testvectors from the paper ===\r\n"));
+       
+       memset(buffer, 0, 8);
+       memset(key, 0, 10);
+       testrun_selfenc(key, buffer);
+       
+       memset(buffer, 0, 8);
+       memset(key, 0xFF, 10);
+       testrun_selfenc(key, buffer);
+       
+       memset(buffer, 0xFF, 8);
+       memset(key, 0, 10);
+       testrun_selfenc(key, buffer);
+       
+       memset(buffer, 0xFF, 8);
+       memset(key, 0xFF, 10);
+       testrun_selfenc(key, buffer);
+       
+}
+
+void testrun_performance_present(void){
+       uint64_t t;
+       uint8_t key[10], data[8];
+       present_ctx_t ctx;
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(key,  0, 10);
+       memset(data, 0,  8);
+       
+       startTimer(1);
+       present_init(key, 80, &ctx);
+       t = stopTimer();
+       print_time_P(PSTR("\tctx-gen time: "),t);
+       
+       startTimer(1);
+       present_enc(data, &ctx);
+       t = stopTimer();
+       print_time_P(PSTR("\tencrypt time: "), t);
+       
+       startTimer(1);
+       present_dec(data, &ctx);
+       t = stopTimer();
+       print_time_P(PSTR("\tdecrypt time: "), t);
+       
+       uart_putstr_P(PSTR("\r\n"));
+}
+
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+int main (void){
+       char  str[20];
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+       uart_putstr(cipher_name);
+       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_nessie_present, testrun_self_present, testrun_performance_present};
+
+       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");
+       }
+       
+}
diff --git a/test_src/main-rc5-test.c b/test_src/main-rc5-test.c
new file mode 100644 (file)
index 0000000..2c16aea
--- /dev/null
@@ -0,0 +1,131 @@
+/* main-rc5-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * rc5 test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "rc5.h"
+#include "nessie_bc_test.h"
+#include "cli.h"
+#include "performance_test.h"
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+#define RC5_ROUNDS 12
+char* cipher_name = "RC5-32/12/16";
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+void rc5_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
+       rc5_init(key, keysize_b, RC5_ROUNDS, ctx);
+}
+
+void testrun_nessie_rc5(void){
+       nessie_bc_init();
+       nessie_bc_ctx.blocksize_B =   8;
+       nessie_bc_ctx.keysize_b   = 128;
+       nessie_bc_ctx.name        = cipher_name;
+       nessie_bc_ctx.ctx_size_B  = sizeof(rc5_ctx_t);
+       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)rc5_enc;
+       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)rc5_dec;
+       nessie_bc_ctx.cipher_free = (nessie_bc_free_fpt)rc5_free;
+       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)rc5_genctx_dummy;
+       
+       nessie_bc_run();
+}
+
+
+void testrun_performance_rc5(void){
+       uint64_t t;
+       char str[16];
+       uint8_t key[16], data[16];
+       rc5_ctx_t ctx;
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(key,  0, 16);
+       memset(data, 0, 16);
+       
+       startTimer(1);
+       rc5_init(key, 128, RC5_ROUNDS, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);       
+       
+       startTimer(1);
+       rc5_enc(data, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       startTimer(1);
+       rc5_dec(data, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+
+       startTimer(1);
+       rc5_free(&ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tfree time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       uart_putstr_P(PSTR("\r\n"));
+}
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+int main (void){
+       char  str[20];
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+       uart_putstr(cipher_name);
+       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_nessie_rc5, testrun_nessie_rc5, testrun_performance_rc5};
+
+       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");
+       }
+       
+}
+
diff --git a/test_src/main-rc6-test.c b/test_src/main-rc6-test.c
new file mode 100644 (file)
index 0000000..5d7ecda
--- /dev/null
@@ -0,0 +1,138 @@
+/* main-rc6-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * rc5 test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "rc6.h"
+#include "nessie_bc_test.h"
+#include "cli.h"
+#include "performance_test.h"
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+#define RC6_ROUNDS 20
+char* cipher_name = "RC6-32/20/16";
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+void rc6_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
+       rc6_initl(key, keysize_b, RC6_ROUNDS, ctx);
+}
+
+void testrun_nessie_rc6(void){
+       nessie_bc_init();
+       nessie_bc_ctx.blocksize_B =  16;
+       nessie_bc_ctx.keysize_b   = 128;
+       nessie_bc_ctx.name        = cipher_name;
+       nessie_bc_ctx.ctx_size_B  = sizeof(rc6_ctx_t);
+       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)rc6_enc;
+       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)rc6_dec;
+       nessie_bc_ctx.cipher_free = (nessie_bc_free_fpt)rc6_free;
+       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)rc6_init;
+       
+       nessie_bc_run();
+       
+       nessie_bc_ctx.keysize_b   = 192;
+       nessie_bc_run();
+       
+       nessie_bc_ctx.keysize_b   = 256;
+       nessie_bc_run();
+       
+}
+
+
+void testrun_performance_rc6(void){
+       uint64_t t;
+       char str[16];
+       uint8_t key[16], data[16];
+       rc6_ctx_t ctx;
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(key,  0, 16);
+       memset(data, 0, 16);
+       
+       startTimer(1);
+       rc6_init(key, 128, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);       
+       
+       startTimer(1);
+       rc6_enc(data, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       startTimer(1);
+       rc6_dec(data, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+
+       startTimer(1);
+       rc6_free(&ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tfree time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       uart_putstr_P(PSTR("\r\n"));
+}
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+int main (void){
+       char  str[20];
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+       uart_putstr(cipher_name);
+       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_nessie_rc6, testrun_nessie_rc6, testrun_performance_rc6};
+
+       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");
+       }
+       
+}
+
diff --git a/test_src/main-seed-test.c b/test_src/main-seed-test.c
new file mode 100644 (file)
index 0000000..678d132
--- /dev/null
@@ -0,0 +1,189 @@
+/* main-seed-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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       main-seed-test.c
+ * \author     Daniel Otte
+ * \email      daniel.otte@rub.de
+ * \date       2007-06-01
+ * \brief      test suit for SEED
+ * \par License        
+ * GPLv3 or later
+ * 
+ */
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "seed.h"
+#include "nessie_bc_test.h"
+#include "cli.h"
+#include "performance_test.h"
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+char* cipher_name = "Seed";
+
+/*****************************************************************************
+ *  additional validation-functions                                          *
+ *****************************************************************************/
+void seed_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
+       seed_init(key, ctx);
+}
+
+void testrun_nessie_seed(void){
+       nessie_bc_ctx.blocksize_B =  16;
+       nessie_bc_ctx.keysize_b   = 128;
+       nessie_bc_ctx.name        = cipher_name;
+       nessie_bc_ctx.ctx_size_B  = sizeof(seed_ctx_t);
+       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)seed_enc;
+       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)seed_dec;
+       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)seed_genctx_dummy;
+       
+       nessie_bc_run();
+       
+}
+
+
+void testrun_performance_seed(void){
+       uint64_t t;
+       char str[16];
+       uint8_t key[16], data[16];
+       seed_ctx_t ctx;
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(key,  0, 16);
+       memset(data, 0, 16);
+       
+       startTimer(1);
+       seed_init(key, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       seed_enc(data, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       seed_dec(data, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       uart_putstr_P(PSTR("\r\n"));
+}
+
+/*****************************************************************************
+ *  self tests                                                               *
+ *****************************************************************************/
+
+void testencrypt(uint8_t* block, uint8_t* key){
+       seed_ctx_t ctx;
+       uart_putstr("\r\n==testy-encrypt==\r\n key: ");
+       uart_hexdump(key,16);
+       seed_init(key, &ctx);
+       uart_putstr("\r\n plain: ");
+       uart_hexdump(block,16);
+       seed_enc(block, &ctx);
+       uart_putstr("\r\n crypt: ");
+       uart_hexdump(block,16);
+}
+
+void testdecrypt(uint8_t* block, uint8_t* key){
+       seed_ctx_t ctx;
+       uart_putstr("\r\n==testy-decrypt==\r\n key: ");
+       uart_hexdump(key,16);
+       seed_init(key, &ctx);
+       uart_putstr("\r\n crypt: ");
+       uart_hexdump(block,16);
+       seed_dec(block, &ctx);
+       uart_putstr("\r\n plain: ");
+       uart_hexdump(block,16);
+}
+
+void testrun_seed(void){
+       uint8_t keys[4][16]=
+               { {     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+                 {     0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                       0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+                 { 0x47, 0x06, 0x48, 0x08, 0x51, 0xE6, 0x1B, 0xE8,
+                       0x5D, 0x74, 0xBF, 0xB3, 0xFD, 0x95, 0x61, 0x85 },
+                 { 0x28, 0xDB, 0xC3, 0xBC, 0x49, 0xFF, 0xD8, 0x7D,
+                       0xCF, 0xA5, 0x09, 0xB1, 0x1D, 0x42, 0x2B, 0xE7,}
+               };
+       uint8_t datas[4][16]=
+               { {     0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                       0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+                 {     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+                 { 0x83, 0xA2, 0xF8, 0xA2, 0x88, 0x64, 0x1F, 0xB9, 
+                       0xA4, 0xE9, 0xA5, 0xCC, 0x2F, 0x13, 0x1C, 0x7D },
+                 { 0xB4, 0x1E, 0x6B, 0xE2, 0xEB, 0xA8, 0x4A, 0x14, 
+                       0x8E, 0x2E, 0xED, 0x84, 0x59, 0x3C, 0x5E, 0xC7 }
+               };
+       uint8_t i=0;
+       for(i=0; i<4; ++i){
+               testencrypt(datas[i],keys[i]);
+               testdecrypt(datas[i],keys[i]);  
+       }
+}
+
+
+
+/*****************************************************************************
+ *  main                                                                     *
+ *****************************************************************************/
+
+int main (void){
+       char str[20];
+
+       DEBUG_INIT();
+
+       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+       uart_putstr(cipher_name);
+       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_nessie_seed, testrun_seed, testrun_performance_seed};
+
+       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");
+       }
+       
+}
+
diff --git a/test_src/main-serpent-test.c b/test_src/main-serpent-test.c
new file mode 100644 (file)
index 0000000..5c450b6
--- /dev/null
@@ -0,0 +1,130 @@
+/* main-serpent-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * serpent test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "serpent.h"
+#include "nessie_bc_test.h"
+#include "cli.h"
+#include "performance_test.h"
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+char* cipher_name = "Serpent";
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+void serpent_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
+       serpent_init(key, keysize&0xff, ctx);
+}
+
+void testrun_nessie_serpent(void){
+       nessie_bc_ctx.blocksize_B =  16;
+       nessie_bc_ctx.keysize_b   = 128;
+       nessie_bc_ctx.name        = cipher_name;
+       nessie_bc_ctx.ctx_size_B  = sizeof(serpent_ctx_t);
+       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)serpent_enc;
+       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)serpent_dec;
+       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)serpent_genctx_dummy;
+       
+       nessie_bc_run();
+       
+       nessie_bc_ctx.keysize_b   = 192;
+       nessie_bc_run();
+       
+       nessie_bc_ctx.keysize_b   = 256;
+       nessie_bc_run();
+}
+
+
+void testrun_performance_serpent(void){
+       uint64_t t;
+       char str[16];
+       uint8_t key[32], data[16];
+       serpent_ctx_t ctx;
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(key,  0, 32);
+       memset(data, 0, 16);
+       
+       startTimer(1);
+       serpent_init(key, 0, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       serpent_enc(data, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       serpent_dec(data, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       uart_putstr_P(PSTR("\r\n"));
+}
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+int main (void){
+       char  str[20];
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+       uart_putstr(cipher_name);
+       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_nessie_serpent, testrun_nessie_serpent, testrun_performance_serpent};
+
+       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");
+       }
+       
+}
+
diff --git a/test_src/main-sha1-test.c b/test_src/main-sha1-test.c
new file mode 100644 (file)
index 0000000..6f07227
--- /dev/null
@@ -0,0 +1,171 @@
+/* main-sha1-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * SHA-1 test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "sha1.h"
+#include "nessie_hash_test.h"
+#include "performance_test.h"
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include "cli.h"
+
+char* algo_name = "SHA-1";
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+void sha1_next_dummy(void* buffer, void* ctx){
+       sha1_nextBlock(ctx, buffer);
+}
+
+void sha1_last_dummy(void* buffer, uint16_t size_b, void* ctx){
+       sha1_lastBlock(ctx, buffer, size_b);
+}
+
+void testrun_nessie_sha1(void){
+       nessie_hash_ctx.hashsize_b  = 160;
+       nessie_hash_ctx.blocksize_B = 512/8;
+       nessie_hash_ctx.ctx_size_B  = sizeof(sha1_ctx_t);
+       nessie_hash_ctx.name = algo_name;
+       nessie_hash_ctx.hash_init = (nessie_hash_init_fpt)sha1_init;
+       nessie_hash_ctx.hash_next = (nessie_hash_next_fpt)sha1_next_dummy;
+       nessie_hash_ctx.hash_last = (nessie_hash_last_fpt)sha1_last_dummy;
+       nessie_hash_ctx.hash_conv = (nessie_hash_conv_fpt)sha1_ctx2hash;
+       
+       nessie_hash_run();
+}
+
+/*****************************************************************************
+ *  self tests                                                                                                                          *
+ *****************************************************************************/
+
+void sha1_ctx_dump(sha1_ctx_t *s){
+       uint8_t i;
+       uart_putstr("\r\n==== sha1_ctx_dump ====");
+       for(i=0;i<5;++i){
+               uart_putstr("\r\na["); uart_hexdump(&i, 1); uart_putstr("]: ");
+               uart_hexdump(&(s->h[i]), 4);
+       }
+       uart_putstr("\r\nlength"); uart_hexdump(&i, 8);
+} 
+
+void testrun_sha1(void){
+       sha1_hash_t hash;
+       sha1(&hash,"abc",3*8);
+       uart_putstr("\r\nsha1(\"abc\") = \r\n\t");
+       uart_hexdump(hash,SHA1_HASH_BITS/8);
+       
+       sha1(&hash,"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",448);
+       uart_putstr("\r\nsha1(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\") = \r\n\t");
+       uart_hexdump(hash,SHA1_HASH_BITS/8);
+       
+       uart_putstr("\r\nsha1(1,000,000 * 'a') = \r\n\t");
+       {
+               uint8_t block[SHA1_BLOCK_BITS/8];
+               uint16_t i;
+               sha1_ctx_t s;
+               memset(block,'a',SHA1_BLOCK_BITS/8);
+               sha1_init(&s);
+               for(i=0;i<15625; ++i){ /* (1000000/(SHA1_BLOCK_BITS/8)) */
+                       sha1_nextBlock(&s, block);
+               }
+               sha1_lastBlock(&s,block,0);
+               sha1_ctx2hash(&hash, &s);
+       }
+       uart_hexdump(hash,SHA1_HASH_BITS/8);
+       
+
+       uart_putstr("\r\nx");
+}
+
+void testrun_performance_sha1(void){
+       uint64_t t;
+       char str[16];
+       uint8_t data[32];
+       sha1_ctx_t ctx;
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(data, 0, 32);
+       
+       startTimer(1);
+       sha1_init(&ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       sha1_nextBlock(&ctx, data);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tone-block time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       sha1_lastBlock(&ctx, data, 0);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tlast block time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       uart_putstr_P(PSTR("\r\n"));
+}
+
+
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+int main (void){
+       char str[20];
+
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr("\r\n\r\nCrypto-VS (SHA-1)\r\nloaded and running\r\n");
+
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_nessie_sha1, testrun_sha1, testrun_performance_sha1};
+
+       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");
+       }
+}
+
+
diff --git a/test_src/main-sha256-test.c b/test_src/main-sha256-test.c
new file mode 100644 (file)
index 0000000..9c3031d
--- /dev/null
@@ -0,0 +1,127 @@
+/* main-sha256-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * SHA-256 test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "sha256.h"
+#include "nessie_hash_test.h"
+#include "performance_test.h"
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include "cli.h"
+
+char* algo_name = "SHA-256";
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+void sha256_next_dummy(void* buffer, void* ctx){
+       sha256_nextBlock(ctx, buffer);
+}
+
+void sha256_last_dummy(void* buffer, uint16_t size_b, void* ctx){
+       sha256_lastBlock(ctx, buffer, size_b);
+}
+
+void testrun_nessie_sha256(void){
+       nessie_hash_ctx.hashsize_b  = 256;
+       nessie_hash_ctx.blocksize_B = 512/8;
+       nessie_hash_ctx.ctx_size_B  = sizeof(sha256_ctx_t);
+       nessie_hash_ctx.name = algo_name;
+       nessie_hash_ctx.hash_init = (nessie_hash_init_fpt)sha256_init;
+       nessie_hash_ctx.hash_next = (nessie_hash_next_fpt)sha256_next_dummy;
+       nessie_hash_ctx.hash_last = (nessie_hash_last_fpt)sha256_last_dummy;
+       nessie_hash_ctx.hash_conv = (nessie_hash_conv_fpt)sha256_ctx2hash;
+       
+       nessie_hash_run();
+}
+
+void testrun_performance_sha256(void){
+       uint64_t t;
+       char str[16];
+       uint8_t data[32];
+       sha256_ctx_t ctx;
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(data, 0, 32);
+       
+       startTimer(1);
+       sha256_init(&ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       sha256_nextBlock(&ctx, data);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tone-block time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       sha256_lastBlock(&ctx, data, 0);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tlast block time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       uart_putstr_P(PSTR("\r\n"));
+}
+
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+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");
+       }
+}
+
diff --git a/test_src/main-shabea-test.c b/test_src/main-shabea-test.c
new file mode 100644 (file)
index 0000000..f221fd5
--- /dev/null
@@ -0,0 +1,193 @@
+/* main-shabea-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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       main-shabea-test.c
+ * \author     Daniel Otte 
+ * \date       2007-06-07
+ * \brief      test suit for SHABEA
+ * \par License        
+ * GPLv3 or later
+ * 
+ */
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "shabea.h"
+#include "nessie_bc_test.h"
+#include "cli.h"
+#include "performance_test.h"
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+char* cipher_name = "Shabea";
+
+/*****************************************************************************
+ *  additional validation-functions                                          *
+ *****************************************************************************/
+void shabea_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
+       memcpy(ctx, key, (keysize_b+7)/8);
+}
+
+void shabea_enc_dummy(void* buffer, void* ctx){
+       shabea256(buffer, ctx, 256, 1, 16);
+}
+
+void shabea_dec_dummy(void* buffer, void* ctx){
+       shabea256(buffer, ctx, 256, 0, 16);
+}
+
+
+void testrun_nessie_shabea(void){
+       nessie_bc_ctx.blocksize_B =  32;
+       nessie_bc_ctx.keysize_b   = 256;
+       nessie_bc_ctx.name        = cipher_name;
+       nessie_bc_ctx.ctx_size_B  = 32;
+       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)shabea_enc_dummy;
+       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)shabea_dec_dummy;
+       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)shabea_genctx_dummy;
+       
+       nessie_bc_run();
+}
+
+
+void testrun_performance_shabea(void){
+       uint64_t t;
+       char str[16];
+       uint8_t key[32], data[32];
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(key,  0, 32);
+       memset(data, 0, 32);
+       
+       startTimer(1);
+       shabea256(data, key, 256, 1, 16);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       shabea256(data, key, 256, 0, 16);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       uart_putstr_P(PSTR("\r\n"));
+}
+
+/*****************************************************************************
+ *  self tests                                                                                                                          *
+ *****************************************************************************/
+
+void testencrypt(uint8_t* block, uint8_t* key){
+       uart_putstr("\r\n==testy-encrypt==\r\n key: ");
+       uart_hexdump(key,16);
+       uart_putstr("\r\n plain: ");
+       uart_hexdump(block,32);
+       shabea256(block,key,128,1,16);
+       uart_putstr("\r\n crypt: ");
+       uart_hexdump(block,32);
+}
+
+void testdecrypt(uint8_t* block, uint8_t* key){
+
+       uart_putstr("\r\n==testy-decrypt==\r\n key: ");
+       uart_hexdump(key,16);
+       uart_putstr("\r\n crypt: ");
+       uart_hexdump(block,32);
+       shabea256(block,key,128,0,16);
+       uart_putstr("\r\n plain: ");
+       uart_hexdump(block,32);
+}
+
+void testrun_shabea(void){
+       uint8_t keys[4][16]=
+               { {     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+                 {     0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                       0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+                 { 0x47, 0x06, 0x48, 0x08, 0x51, 0xE6, 0x1B, 0xE8,
+                       0x5D, 0x74, 0xBF, 0xB3, 0xFD, 0x95, 0x61, 0x85 },
+                 { 0x28, 0xDB, 0xC3, 0xBC, 0x49, 0xFF, 0xD8, 0x7D,
+                       0xCF, 0xA5, 0x09, 0xB1, 0x1D, 0x42, 0x2B, 0xE7,}
+               };
+       uint8_t datas[4][32]=
+               { {     0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                       0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+                       0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+                       0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
+                 {     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+                 { 0x83, 0xA2, 0xF8, 0xA2, 0x88, 0x64, 0x1F, 0xB9, 
+                       0xA4, 0xE9, 0xA5, 0xCC, 0x2F, 0x13, 0x1C, 0x7D,
+                       0x83, 0xA2, 0xF8, 0xA2, 0x88, 0x64, 0x1F, 0xB9, 
+                       0xA4, 0xE9, 0xA5, 0xCC, 0x2F, 0x13, 0x1C, 0x7D },
+                 { 0xB4, 0x1E, 0x6B, 0xE2, 0xEB, 0xA8, 0x4A, 0x14, 
+                       0x8E, 0x2E, 0xED, 0x84, 0x59, 0x3C, 0x5E, 0xC7,
+                       0xB4, 0x1E, 0x6B, 0xE2, 0xEB, 0xA8, 0x4A, 0x14, 
+                       0x8E, 0x2E, 0xED, 0x84, 0x59, 0x3C, 0x5E, 0xC7 }
+               };
+       uint8_t i=0;
+       for(i=0; i<4; ++i){
+               testencrypt(datas[i],keys[i]);
+               testdecrypt(datas[i],keys[i]);  
+       }
+}
+
+
+
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+int main (void){
+       char str[20];
+
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+       uart_putstr(cipher_name);
+       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_nessie_shabea, testrun_shabea, testrun_performance_shabea};
+
+       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");
+       }
+       
+}
+
diff --git a/test_src/main-shacal1_enc-test.c b/test_src/main-shacal1_enc-test.c
new file mode 100644 (file)
index 0000000..a4a0a1f
--- /dev/null
@@ -0,0 +1,110 @@
+/* main-shacal1_enc-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * Shacal1 encryption only test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "shacal1_enc.h"
+#include "nessie_bc_test.h"
+#include "cli.h"
+#include "performance_test.h"
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+
+char* cipher_name = "Shacal1 encryption only";
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+void shacal1_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
+       memcpy(ctx, key, (keysize_b+7)/8);
+}
+
+void shacal1_enc_dummy(void* buffer, void* ctx){
+       shacal1_enc(buffer, ctx, 512);
+}
+
+void testrun_nessie_shacal1enc(void){
+       nessie_bc_ctx.blocksize_B = SHACAL1_BLOCKSIZE_B;
+       nessie_bc_ctx.keysize_b   = SHACAL1_KEYSIZE;
+       nessie_bc_ctx.name        = cipher_name;
+       nessie_bc_ctx.ctx_size_B  = SHACAL1_KEYSIZE_B;
+       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)shacal1_enc_dummy;
+       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)NULL;
+       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)shacal1_genctx_dummy;
+       
+       nessie_bc_run();        
+}
+
+void testrun_performance_shacal1enc(void){
+       uint64_t t;
+       uint8_t key[SHACAL1_KEYSIZE_B], data[SHACAL1_BLOCKSIZE_B];
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(key,  0, SHACAL1_KEYSIZE_B);
+       memset(data, 0, SHACAL1_BLOCKSIZE_B);
+       
+       
+       startTimer(1);
+       shacal1_enc(data, key, SHACAL1_KEYSIZE);
+       t = stopTimer();
+       print_time_P(PSTR("\tencrypt time: "), t);
+       
+       uart_putstr_P(PSTR("\r\n"));
+}
+
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+int main (void){
+       char  str[20];
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+       uart_putstr(cipher_name);
+       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_nessie_shacal1enc, 
+                           testrun_nessie_shacal1enc,
+                           testrun_performance_shacal1enc};
+
+       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");
+       }
+       
+}
diff --git a/test_src/main-shacal2_enc-test.c b/test_src/main-shacal2_enc-test.c
new file mode 100644 (file)
index 0000000..3ffd131
--- /dev/null
@@ -0,0 +1,110 @@
+/* main-shacal2_enc-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * Shacal2 encryption only test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "shacal2_enc.h"
+#include "nessie_bc_test.h"
+#include "cli.h"
+#include "performance_test.h"
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+
+char* cipher_name = "Shacal2 encryption only";
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+void shacal2_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
+       memcpy(ctx, key, (keysize_b+7)/8);
+}
+
+void shacal2_enc_dummy(void* buffer, void* ctx){
+       shacal2_enc(buffer, ctx, SHACAL2_KEYSIZE);
+}
+
+void testrun_nessie_shacal2enc(void){
+       nessie_bc_ctx.blocksize_B = SHACAL2_BLOCKSIZE_B;
+       nessie_bc_ctx.keysize_b   = SHACAL2_KEYSIZE;
+       nessie_bc_ctx.name        = cipher_name;
+       nessie_bc_ctx.ctx_size_B  = SHACAL2_KEYSIZE_B;
+       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)shacal2_enc_dummy;
+       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)NULL;
+       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)shacal2_genctx_dummy;
+       
+       nessie_bc_run();        
+}
+
+void testrun_performance_shacal2enc(void){
+       uint64_t t;
+       uint8_t key[SHACAL2_KEYSIZE_B], data[SHACAL2_BLOCKSIZE_B];
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(key,  0, SHACAL2_KEYSIZE_B);
+       memset(data, 0, SHACAL2_BLOCKSIZE_B);
+       
+       
+       startTimer(1);
+       shacal2_enc(data, key, SHACAL2_KEYSIZE);
+       t = stopTimer();
+       print_time_P(PSTR("\tencrypt time: "), t);
+       
+       uart_putstr_P(PSTR("\r\n"));
+}
+
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+int main (void){
+       char  str[20];
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+       uart_putstr(cipher_name);
+       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_nessie_shacal2enc, 
+                           testrun_nessie_shacal2enc,
+                           testrun_performance_shacal2enc};
+
+       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");
+       }
+       
+}
diff --git a/test_src/main-skipjack-test.c b/test_src/main-skipjack-test.c
new file mode 100644 (file)
index 0000000..a7f1165
--- /dev/null
@@ -0,0 +1,150 @@
+/* main-skipjack-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * skipjack test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "skipjack.h"
+#include "nessie_bc_test.h"
+#include "cli.h"
+#include "performance_test.h"
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+
+char* cipher_name = "Skipjack";
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+void skipjack_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
+       memcpy(ctx, key, 10);
+}
+
+void testrun_nessie_skipjack(void){
+       nessie_bc_ctx.blocksize_B =   8;
+       nessie_bc_ctx.keysize_b   =  80;
+       nessie_bc_ctx.name        = cipher_name;
+       nessie_bc_ctx.ctx_size_B  = 10;
+       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)skipjack_enc;
+       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)skipjack_dec;
+       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)skipjack_genctx_dummy;
+       
+       nessie_bc_run();
+}
+
+
+void testrun_performance_skipjack(void){
+       uint64_t t;
+       char str[16];
+       uint8_t key[10], data[8];
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(key,  0, 10);
+       memset(data, 0,  8);
+       
+       startTimer(1);
+       skipjack_enc(data, key);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       skipjack_dec(data, key);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       uart_putstr_P(PSTR("\r\n"));
+}
+
+/*****************************************************************************
+ *  self tests                                                                                                                          *
+ *****************************************************************************/
+
+void testencrypt(uint8_t* block, uint8_t* key){
+       uart_putstr("\r\n==testy-encrypt==\r\n key: ");
+       uart_hexdump(key,10);
+       uart_putstr("\r\n plain: ");
+       uart_hexdump(block,8);
+       skipjack_enc(block,key);
+       uart_putstr("\r\n crypt: ");
+       uart_hexdump(block,8);
+}
+
+void testdecrypt(uint8_t* block, uint8_t* key){
+       uart_putstr("\r\n==testy-decrypt==\r\n key: ");
+       uart_hexdump(key,10);
+       uart_putstr("\r\n crypt: ");
+       uart_hexdump(block,8);
+       skipjack_dec(block,key);
+       uart_putstr("\r\n plain: ");
+       uart_hexdump(block,8);
+}
+
+void testrun_skipjack(void){
+       uint8_t key[]={ 0x00, 0x99, 0x88, 0x77, 0x66,
+                                       0x55, 0x44, 0x33, 0x22, 0x11};
+       uint8_t data[]={ 0x33, 0x22, 0x11, 0x00, 0xdd, 0xcc, 0xbb, 0xaa};
+       testencrypt(data,key);
+       testdecrypt(data,key);  
+}
+
+
+
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+int main (void){
+       char str[20];
+
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr("\r\n\r\nCrypto-VS (skipjack)\r\nloaded and running\r\n");
+
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_nessie_skipjack, testrun_skipjack, testrun_performance_skipjack};
+
+       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");
+       }
+       
+}
+
diff --git a/test_src/main-tdes-test.c b/test_src/main-tdes-test.c
new file mode 100644 (file)
index 0000000..d5ae1a0
--- /dev/null
@@ -0,0 +1,123 @@
+/* main-tdes-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * tdes test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "des.h"
+#include "nessie_bc_test.h"
+#include "cli.h"
+#include "performance_test.h"
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+char* cipher_name = "TDES";
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+void tdes_init_dummy(const void* key, uint16_t keysize_b, void* ctx){
+       memcpy(ctx, key, 8*3);
+}
+
+void tdes_enc_dummy(void* buffer, void* ctx){
+       tdes_enc(buffer, buffer, ctx);
+} 
+
+void tdes_dec_dummy(void* buffer, void* ctx){
+       tdes_dec(buffer, buffer, ctx);
+} 
+
+void testrun_nessie_tdes(void){
+       nessie_bc_init();
+       nessie_bc_ctx.blocksize_B =   8;
+       nessie_bc_ctx.keysize_b   = 192;
+       nessie_bc_ctx.name        = cipher_name;
+       nessie_bc_ctx.ctx_size_B  = sizeof(8*3);
+       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)tdes_enc_dummy;
+       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)tdes_dec_dummy;
+       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)tdes_init_dummy;
+
+       nessie_bc_run();
+}
+
+
+void testrun_performance_tdes(void){
+       uint64_t t;
+       char str[16];
+       uint8_t key[8*3], data[8];
+       
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(key,  0, 8*3);
+       memset(data, 0, 8);
+       
+       startTimer(1);
+       tdes_enc(data, data, key);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       startTimer(1);
+       tdes_dec(data, data, key);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       uart_putstr_P(PSTR("\r\n"));
+}
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+int main (void){
+       char  str[20];
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+       uart_putstr(cipher_name);
+       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_nessie_tdes, testrun_nessie_tdes, testrun_performance_tdes};
+
+       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");
+       }
+       
+}
+
diff --git a/test_src/main-trivium-test.c b/test_src/main-trivium-test.c
new file mode 100644 (file)
index 0000000..4d4e3d2
--- /dev/null
@@ -0,0 +1,123 @@
+/* main-trivium-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * Mickey128 test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+#include "cli.h"
+
+#include "trivium.h"
+#include "nessie_stream_test.h"
+#include "performance_test.h"
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+
+char* cipher_name = "Trivium";
+
+/*****************************************************************************
+ *  additional validation-functions                                                                                     *
+ *****************************************************************************/
+void trivium_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
+       uint32_t iv=0;
+       trivium_init(key, 80, &iv, 32, ctx);
+}
+
+uint8_t trivium_getbyte_dummy(trivium_ctx_t* ctx){
+       uint8_t i,ret=0;
+       for(i=0; i<8; ++i){
+               ret<<=1;
+               ret |= trivium_enc(ctx);
+       }
+       return ret;
+}
+
+void testrun_nessie_trivium(void){
+       nessie_stream_ctx.outsize_b =   8; /* actually unused */
+       nessie_stream_ctx.keysize_b =  80; /* this is the one we have refrence vectors for */
+       nessie_stream_ctx.ivsize_b  =  32;
+       nessie_stream_ctx.name = cipher_name;
+       nessie_stream_ctx.ctx_size_B = sizeof(trivium_ctx_t);
+       nessie_stream_ctx.cipher_genctx = (nessie_stream_genctx_fpt)trivium_genctx_dummy;
+       nessie_stream_ctx.cipher_enc = (nessie_stream_genenc_fpt)trivium_getbyte_dummy;
+       
+       nessie_stream_run();    
+}
+
+void testrun_performance_trivium(void){
+       uint64_t t;
+       char str[16];
+       uint8_t key[10], iv[10];
+       trivium_ctx_t ctx;
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(key,  0, 10);
+       memset(iv,  0, 10);
+       
+       startTimer(1);
+       trivium_init(key, 80, iv, 80, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);       
+       
+       startTimer(1);
+       trivium_enc(&ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);       
+       
+       uart_putstr_P(PSTR("\r\n"));
+}
+
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+int main (void){
+       char  str[20];
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+       uart_putstr(cipher_name);
+       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_nessie_trivium, testrun_nessie_trivium, testrun_performance_trivium};
+
+       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");
+       }       
+}
diff --git a/test_src/main-xtea-test.c b/test_src/main-xtea-test.c
new file mode 100644 (file)
index 0000000..07fcffe
--- /dev/null
@@ -0,0 +1,111 @@
+/* main-xtea-test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * XTEA test-suit
+ * 
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "xtea.h"
+#include "nessie_bc_test.h"
+#include "performance_test.h"
+#include "cli.h"
+
+#include <stdint.h>
+#include <string.h>
+
+char* cipher_name = "XTEA";
+
+void xtea_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
+       memcpy(ctx, key, (keysize+7)/8);
+}
+
+void xtea_enc_dummy(uint8_t* buffer, void* ctx){
+       xtea_enc((uint32_t*)buffer, (uint32_t*)buffer, ctx);
+}
+
+void xtea_dec_dummy(uint8_t* buffer, void* ctx){
+       xtea_dec((uint32_t*)buffer, (uint32_t*)buffer, ctx);
+}
+
+void testrun_nessie_xtea(void){
+       nessie_bc_ctx.blocksize_B =   8;
+       nessie_bc_ctx.keysize_b   = 128;
+       nessie_bc_ctx.name        = cipher_name;
+       nessie_bc_ctx.ctx_size_B  = 128/8;
+       nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)xtea_enc_dummy;
+       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)xtea_dec_dummy;
+       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)xtea_genctx_dummy;
+       
+       nessie_bc_run();        
+}
+
+void testrun_performance_xtea(void){
+       uint64_t t;
+       uint8_t key[16], data[8];
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(key,  0, 16);
+       memset(data, 0,  8);
+       
+       startTimer(1);
+       xtea_enc(data, data, key);
+       t = stopTimer();
+       print_time_P(PSTR("\tencrypt time: "), t);
+       
+       startTimer(1);
+       xtea_dec(data, data, key);
+       t = stopTimer();
+       print_time_P(PSTR("\tdecrypt time: "), t);
+       
+       uart_putstr_P(PSTR("\r\n"));
+}
+
+/*****************************************************************************
+ *  main                                                                                                                                        *
+ *****************************************************************************/
+
+int main (void){
+       char  str[20];
+       DEBUG_INIT();
+       uart_putstr("\r\n");
+
+       uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+       uart_putstr(cipher_name);
+       uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_nessie_xtea, testrun_nessie_xtea, testrun_performance_xtea};
+
+       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");
+       }
+}
diff --git a/test_src/nessie_bc_test.c b/test_src/nessie_bc_test.c
new file mode 100644 (file)
index 0000000..f9a91e5
--- /dev/null
@@ -0,0 +1,212 @@
+/* nessie_bc_test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/**
+ * 
+ * author: Daniel Otte
+ * email:  daniel.otte@rub.de
+ * license: GPLv3
+ * 
+ * a suit for running the nessie-tests for blockciphers
+ * 
+ * */
+#include <stdint.h>
+#include <string.h>
+#include "nessie_bc_test.h"
+#include "nessie_common.h"
+#include "uart.h"
+
+nessie_bc_ctx_t nessie_bc_ctx;
+
+void nessie_bc_init(void){
+       memset(&nessie_bc_ctx, 0, sizeof(nessie_bc_ctx_t));     
+}
+static
+void nessie_bc_free(void* ctx){
+       if(nessie_bc_ctx.cipher_free)
+               nessie_bc_ctx.cipher_free(ctx);
+}
+
+void nessie_bc_enc(uint8_t* key, uint8_t* pt){
+       uint8_t ctx[nessie_bc_ctx.ctx_size_B];
+       uint8_t buffer[nessie_bc_ctx.blocksize_B];
+       uint16_t i;
+       
+       /* single test */
+       nessie_print_item("key", key, (nessie_bc_ctx.keysize_b+7)/8);
+       nessie_bc_ctx.cipher_genctx(key, nessie_bc_ctx.keysize_b, ctx);
+       
+       memcpy(buffer, pt, nessie_bc_ctx.blocksize_B);
+       nessie_print_item("plain", buffer, nessie_bc_ctx.blocksize_B);
+       nessie_bc_ctx.cipher_enc(buffer, ctx);
+       nessie_print_item("cipher", buffer, nessie_bc_ctx.blocksize_B);
+       if(nessie_bc_ctx.cipher_dec){
+               nessie_bc_ctx.cipher_dec(buffer, ctx);
+               nessie_print_item("decrypted", buffer, nessie_bc_ctx.blocksize_B);
+       }
+       /* 100 times test */
+       memcpy(buffer, pt, nessie_bc_ctx.blocksize_B);
+       for(i=0; i<100; ++i){
+               nessie_bc_ctx.cipher_enc(buffer, ctx);
+       }
+       nessie_print_item("Iterated 100 times", buffer, nessie_bc_ctx.blocksize_B);
+#ifndef NESSIE_NO1KTEST        
+       /* 1000 times test, we use the 100 precedig steps to fasten things a bit */
+       for(; i<1000; ++i){
+               nessie_bc_ctx.cipher_enc(buffer, ctx);
+       }
+       nessie_print_item("Iterated 1000 times", buffer, nessie_bc_ctx.blocksize_B);
+#endif
+       nessie_bc_free(ctx);
+}
+
+void nessie_bc_dec(uint8_t* key, uint8_t* ct){
+       uint8_t ctx[nessie_bc_ctx.ctx_size_B];
+       uint8_t buffer[nessie_bc_ctx.blocksize_B];
+       
+       /* single test */
+       nessie_print_item("key", key, (nessie_bc_ctx.keysize_b+7)/8);
+       nessie_bc_ctx.cipher_genctx(key, nessie_bc_ctx.keysize_b, ctx);
+       memcpy(buffer, ct, nessie_bc_ctx.blocksize_B);
+       nessie_print_item("cipher", buffer, nessie_bc_ctx.blocksize_B);
+       nessie_bc_ctx.cipher_dec(buffer, ctx);
+       nessie_print_item("plain", buffer, nessie_bc_ctx.blocksize_B);
+       nessie_bc_ctx.cipher_enc(buffer, ctx);
+       nessie_print_item("encrypted", buffer, nessie_bc_ctx.blocksize_B);
+       nessie_bc_free(ctx);
+}
+
+void nessie_bc_run(void){
+       uint16_t i;
+       uint8_t set;
+       uint8_t key[(nessie_bc_ctx.keysize_b+7)/8];
+       uint8_t buffer[nessie_bc_ctx.blocksize_B];
+       
+       nessie_print_header(nessie_bc_ctx.name, nessie_bc_ctx.keysize_b,
+                           nessie_bc_ctx.blocksize_B*8, 0, 0, 0);
+       /* test set 1 */
+       set=1;
+       nessie_print_setheader(set);
+       for(i=0; i<nessie_bc_ctx.keysize_b; ++i){
+               nessie_print_set_vector(set, i);
+               memset(key, 0, (nessie_bc_ctx.keysize_b+7)/8);
+               key[i/8] |= 0x80>>(i%8);
+               memset(buffer, 0, nessie_bc_ctx.blocksize_B);
+               nessie_bc_enc(key, buffer);
+       }
+       /* test set 2 */
+       set=2;
+       nessie_print_setheader(set);
+       for(i=0; i<nessie_bc_ctx.blocksize_B*8; ++i){
+               nessie_print_set_vector(set, i);
+               memset(key, 0, (nessie_bc_ctx.keysize_b+7)/8);
+               memset(buffer, 0, nessie_bc_ctx.blocksize_B);
+               buffer[i/8] |= 0x80>>(i%8);
+               nessie_bc_enc(key, buffer);
+       }
+       /* test set 3 */
+       set=3;
+       nessie_print_setheader(set);
+       for(i=0; i<256; ++i){
+               nessie_print_set_vector(set, i);
+               memset(key, i, (nessie_bc_ctx.keysize_b+7)/8);
+               memset(buffer, i, nessie_bc_ctx.blocksize_B);
+               nessie_bc_enc(key, buffer);
+       }
+       /* test set 4 */
+       set=4;
+       nessie_print_setheader(set);
+       /* 4 - 0*/
+       nessie_print_set_vector(set, 0);
+       for(i=0; i<(nessie_bc_ctx.keysize_b+7)/8; ++i){
+               key[i]=i;
+       }
+       for(i=0; i<nessie_bc_ctx.blocksize_B; ++i){
+               buffer[i]=i*0x11;
+       }
+       nessie_bc_enc(key, buffer);
+       /* 4 - 1 */
+       nessie_print_set_vector(set, 1);        
+    /* This is the test vectors in Kasumi */
+    static uint8_t kasumi_key[] = {
+           0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC5, 0xB3, 0x00,
+           0x95, 0x2C, 0x49, 0x10, 0x48, 0x81, 0xFF, 0x48 };
+    static uint8_t kasumi_plain[]={
+           0xEA, 0x02, 0x47, 0x14, 0xAD, 0x5C, 0x4D, 0x84 };
+       for(i=0; i<(nessie_bc_ctx.keysize_b+7)/8; ++i){
+               key[i]=kasumi_key[i%sizeof(kasumi_key)];
+       }
+       for(i=0; i<nessie_bc_ctx.blocksize_B; ++i){
+               buffer[i]=kasumi_plain[i%sizeof(kasumi_plain)];
+       }
+       nessie_bc_enc(key, buffer);
+       /* half done ;-) */
+       if(nessie_bc_ctx.cipher_dec==NULL)
+               return;
+       /* test set 5 */
+       set=5;
+       nessie_print_setheader(set);
+       for(i=0; i<nessie_bc_ctx.keysize_b; ++i){
+               nessie_print_set_vector(set, i);
+               memset(key, 0, (nessie_bc_ctx.keysize_b+7)/8);
+               key[i/8] |= 0x80>>(i%8);
+               memset(buffer, 0, nessie_bc_ctx.blocksize_B);
+               nessie_bc_dec(key, buffer);
+       }
+       /* test set 6 */
+       set=6;
+       nessie_print_setheader(set);
+       for(i=0; i<nessie_bc_ctx.blocksize_B*8; ++i){
+               nessie_print_set_vector(set, i);
+               memset(key, 0, (nessie_bc_ctx.keysize_b+7)/8);
+               memset(buffer, 0, nessie_bc_ctx.blocksize_B);
+               buffer[i/8] |= 0x80>>(i%8);
+               nessie_bc_dec(key, buffer);
+       }
+       /* test set 7 */
+       set=7;
+       nessie_print_setheader(set);
+       for(i=0; i<256; ++i){
+               nessie_print_set_vector(set, i);
+               memset(key, i, (nessie_bc_ctx.keysize_b+7)/8);
+               memset(buffer, i, nessie_bc_ctx.blocksize_B);
+               nessie_bc_dec(key, buffer);
+       }
+       /* test set 8 */
+       set=8;
+       nessie_print_setheader(set);
+       /* 8 - 0*/
+       nessie_print_set_vector(set, 0);
+       for(i=0; i<(nessie_bc_ctx.keysize_b+7)/8; ++i){
+               key[i]=i;
+       }
+       for(i=0; i<nessie_bc_ctx.blocksize_B; ++i){
+               buffer[i]=i*0x11;
+       }
+       nessie_bc_dec(key, buffer);
+       /* 8 - 1 */
+       nessie_print_set_vector(set, 1);        
+       for(i=0; i<(nessie_bc_ctx.keysize_b+7)/8; ++i){
+               key[i]=kasumi_key[i%sizeof(kasumi_key)];
+       }
+       for(i=0; i<nessie_bc_ctx.blocksize_B; ++i){
+               buffer[i]=kasumi_plain[i%sizeof(kasumi_plain)];
+       }
+       nessie_bc_dec(key, buffer);
+       nessie_print_footer();
+}
diff --git a/test_src/nessie_bc_test.h b/test_src/nessie_bc_test.h
new file mode 100644 (file)
index 0000000..1bab98c
--- /dev/null
@@ -0,0 +1,47 @@
+/* nessie_bc_test.h */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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 NESSIE_BC_TEST_H_
+#define NESSIE_BC_TEST_H_
+
+#include <stdint.h>
+
+typedef void (*nessie_bc_gen_fpt)(uint8_t* key, uint16_t keysize_b, void* ctx);
+typedef void (*nessie_bc_free_fpt)(void* ctx);
+typedef void (*nessie_bc_enc_fpt)(void* buffer, void* ctx);
+typedef void (*nessie_bc_dec_fpt)(void* buffer, void* ctx);
+
+typedef struct nessie_bc_ctx_st{
+       uint16_t keysize_b;
+       uint16_t blocksize_B;
+       uint16_t ctx_size_B;
+       char* name; 
+       nessie_bc_gen_fpt  cipher_genctx;
+       nessie_bc_free_fpt cipher_free;
+       nessie_bc_enc_fpt  cipher_enc;
+       nessie_bc_dec_fpt  cipher_dec;
+} nessie_bc_ctx_t; 
+
+
+extern nessie_bc_ctx_t nessie_bc_ctx;
+
+void nessie_bc_run(void);
+void nessie_bc_init(void);
+
+
+#endif /*NESSIE_BC_TEST_H_*/
diff --git a/test_src/nessie_common.c b/test_src/nessie_common.c
new file mode 100644 (file)
index 0000000..020d5ab
--- /dev/null
@@ -0,0 +1,178 @@
+/* nessie_common.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/**
+ * 
+ * author: Daniel Otte
+ * email:  daniel.otte@rub.de
+ * license: GPLv3
+ * 
+ * common function for nessie-tests
+ * 
+ * */
+
+#include <string.h>
+#include <stdint.h>
+#include <avr/pgmspace.h>
+#include <stdlib.h> /* utoa() */
+#include "uart.h"
+
+void nessie_print_block(uint8_t* block, uint16_t blocksize_bit){
+       char tab [] = {'0', '1', '2', '3', 
+                                  '4', '5', '6', '7', 
+                                  '8', '9', 'A', 'B', 
+                                  'C', 'D', 'E', 'F'};
+       uint16_t i;
+       for(i=0; i<(blocksize_bit+7)/8; ++i){
+               uart_putc(tab[(block[i])>>4]);
+               uart_putc(tab[(block[i])&0xf]);
+       }                                  
+}
+
+#define SPACES 31
+#define BYTESPERLINE 16
+
+void nessie_print_item(char* name, uint8_t* buffer, uint16_t size_B){
+       uint8_t name_len;
+       uint8_t i;
+       name_len=strlen(name);
+       if(name_len>SPACES-1){
+               uart_putstr_P(PSTR("\r\n!!! formatting error !!!\r\n"));
+               return;
+       }
+       uart_putstr_P(PSTR("\r\n"));
+       for(i=0; i<SPACES-name_len-1; ++i){
+               uart_putc(' ');
+       }
+       uart_putstr(name);
+       uart_putc('=');
+       /* now the data printing begins */
+       if(size_B<=BYTESPERLINE){
+               /* one line seems sufficient */
+               nessie_print_block(buffer, size_B*8);
+       } else {
+               /* we need more lines */
+               nessie_print_block(buffer, BYTESPERLINE*8); /* first line */
+               int16_t toprint = size_B - BYTESPERLINE;
+               buffer += BYTESPERLINE;
+               while(toprint > 0){
+                       uart_putstr_P(PSTR("\r\n"));
+                       for(i=0; i<SPACES; ++i){
+                               uart_putc(' ');
+                       }
+                       nessie_print_block(buffer, ((toprint>BYTESPERLINE)?BYTESPERLINE:toprint)*8);
+                       buffer  += BYTESPERLINE;
+                       toprint -= BYTESPERLINE;
+               }
+       }
+} 
+
+
+void nessie_print_set_vector(uint8_t set, uint16_t vector){
+       uart_putstr_P(PSTR("\r\n\r\nSet "));
+       uart_putc('0'+set%10);
+       uart_putstr_P(PSTR(", vector#"));
+       uart_putc((vector<100)?' ':'0'+vector/100);
+       uart_putc((vector<10 )?' ':'0'+(vector/10)%10);
+       uart_putc('0'+vector%10);
+       uart_putc(':');
+}
+
+/* example:
+Test vectors -- set 3
+=====================
+ */ 
+void nessie_print_setheader(uint8_t set){
+       uart_putstr_P(PSTR("\r\n\r\nTest vectors -- set "));
+       uart_putc('0'+set%10);
+       uart_putstr_P(PSTR("\r\n====================="));
+}
+
+/* example:
+********************************************************************************
+*Project NESSIE - New European Schemes for Signature, Integrity, and Encryption*
+********************************************************************************
+
+Primitive Name: Serpent
+=======================
+Key size: 256 bits
+Block size: 128 bits
+*/
+
+void nessie_print_header(char* name,
+                         uint16_t keysize_b, 
+                         uint16_t blocksize_b,
+                         uint16_t hashsize_b, 
+                         uint16_t macsize_b,
+                         uint16_t ivsize_b ){
+       uint16_t i;
+       uart_putstr_P(PSTR("\r\n\r\n"
+       "********************************************************************************\r\n"
+       "* micro-crypt - crypto primitives for microcontrolles by Daniel Otte           *\r\n"
+       "********************************************************************************\r\n"
+       "\r\n"));
+       uart_putstr_P(PSTR("Primitive Name: "));
+       uart_putstr(name);
+       uart_putstr_P(PSTR("\r\n"));
+       /* underline */ 
+       for(i=0; i<16+strlen(name); ++i){
+               uart_putc('=');
+       }
+       char str[6]; /* must catch numbers up to 65535 + terminatin \0 */
+       if(keysize_b){
+               uart_putstr_P(PSTR("\r\nKey size: "));
+               utoa(keysize_b, str, 10);
+               uart_putstr(str);
+               uart_putstr_P(PSTR(" bits"));
+       }
+       if(blocksize_b){
+               uart_putstr_P(PSTR("\r\nBlock size: "));
+               utoa(blocksize_b, str, 10);
+               uart_putstr(str);
+               uart_putstr_P(PSTR(" bits"));
+       }
+       if(hashsize_b){
+               uart_putstr_P(PSTR("\r\nHash size: "));
+               utoa(hashsize_b, str, 10);
+               uart_putstr(str);
+               uart_putstr_P(PSTR(" bits"));
+       }
+       if(macsize_b){
+               uart_putstr_P(PSTR("\r\nMac size: "));
+               utoa(macsize_b, str, 10);
+               uart_putstr(str);
+               uart_putstr_P(PSTR(" bits"));
+       }
+       if(ivsize_b){
+               if(ivsize_b==(uint16_t)-1){
+                       uart_putstr_P(PSTR("\r\nNo initial value (IV) mode"));
+               }
+               {
+                       uart_putstr_P(PSTR("\r\nIV size: "));
+                       utoa(ivsize_b, str, 10);
+                       uart_putstr(str);
+                       uart_putstr_P(PSTR(" bits"));
+               }
+       }
+       uart_putstr_P(PSTR("\r\n"));
+}
+
+void nessie_print_footer(void){
+       uart_putstr_P(PSTR("\r\n\r\n\r\n\r\nEnd of test vectors\r\n\r\n"));
+}
+
diff --git a/test_src/nessie_common.h b/test_src/nessie_common.h
new file mode 100644 (file)
index 0000000..4090e32
--- /dev/null
@@ -0,0 +1,47 @@
+/* nessie_common.h */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/**
+ * 
+ * author: Daniel Otte
+ * email:  daniel.otte@rub.de
+ * license: GPLv3
+ * 
+ * common function for nessie-tests
+ * 
+ * */
+
+#ifndef NESSIE_COMMON_H_
+#define NESSIE_COMMON_H_
+
+
+#include <stdint.h>
+
+void nessie_print_block(uint8_t* block, uint16_t blocksize_bit);
+void nessie_print_item(char* name, uint8_t* buffer, uint16_t size_B);
+void nessie_print_set_vector(uint8_t set, uint16_t vector);
+void nessie_print_setheader(uint8_t set);
+void nessie_print_header(char* name,
+                         uint16_t keysize_b, 
+                         uint16_t blocksize_b,
+                         uint16_t hashsize_b, 
+                         uint16_t macsize_b,
+                         uint16_t ivsize_b );
+void nessie_print_footer(void);
+
+#endif /*NESSIE_COMMON_H_*/
diff --git a/test_src/nessie_hash_test.c b/test_src/nessie_hash_test.c
new file mode 100644 (file)
index 0000000..a870b82
--- /dev/null
@@ -0,0 +1,240 @@
+/* nessie_hash_test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/**
+ * 
+ * author: Daniel Otte
+ * email:  daniel.otte@rub.de
+ * license: GPLv3
+ * 
+ * a suit for running the nessie-tests for hashes
+ * 
+ * */
+#include <stdint.h>
+#include <string.h>
+#include "nessie_hash_test.h"
+#include "nessie_common.h"
+#include "uart.h"
+
+nessie_hash_ctx_t nessie_hash_ctx;
+
+static
+void ascii_hash(char* data, char* desc){
+       uint8_t ctx[nessie_hash_ctx.ctx_size_B];
+       uint8_t hash[(nessie_hash_ctx.hashsize_b+7)/8];
+       uint16_t sl;
+       
+       uart_putstr_P(PSTR("\r\n                       message="));
+       uart_putstr(desc);
+       nessie_hash_ctx.hash_init(ctx);
+       sl = strlen(data);
+       while(sl>=nessie_hash_ctx.blocksize_B){
+               nessie_hash_ctx.hash_next(data, ctx);
+               data += nessie_hash_ctx.blocksize_B;
+               sl   -= nessie_hash_ctx.blocksize_B;
+       }
+       nessie_hash_ctx.hash_last(data, sl*8, ctx);
+       nessie_hash_ctx.hash_conv(hash, ctx);
+       nessie_print_item("hash", hash, (nessie_hash_ctx.hashsize_b+7)/8);
+}
+
+// message=1 million times "a"
+
+static
+void amillion_hash(void){
+       uint8_t ctx[nessie_hash_ctx.ctx_size_B];
+       uint8_t hash[(nessie_hash_ctx.hashsize_b+7)/8];
+       uint8_t block[nessie_hash_ctx.blocksize_B];
+       uint32_t n=1000000LL;
+       
+       uart_putstr_P(PSTR("\r\n                       message="));
+       uart_putstr_P(PSTR("1 million times \"a\""));
+       memset(block, 'a', nessie_hash_ctx.blocksize_B);
+       nessie_hash_ctx.hash_init(ctx);
+       while(n>=nessie_hash_ctx.blocksize_B){
+               nessie_hash_ctx.hash_next(block, ctx);
+               n    -= nessie_hash_ctx.blocksize_B;
+       }
+       nessie_hash_ctx.hash_last(block, n*8, ctx);
+       nessie_hash_ctx.hash_conv(hash, ctx);
+       nessie_print_item("hash", hash, (nessie_hash_ctx.hashsize_b+7)/8);
+}
+
+
+static
+void zero_hash(uint16_t n){
+       uint8_t ctx[nessie_hash_ctx.ctx_size_B];
+       uint8_t hash[(nessie_hash_ctx.hashsize_b+7)/8];
+       uint8_t block[nessie_hash_ctx.blocksize_B];
+       
+       uart_putstr_P(PSTR("\r\n                       message="));
+       if(n>=10000)
+               uart_putc('0'+n/10000);
+       if(n>=1000)
+               uart_putc('0'+(n/1000)%10);
+       if(n>=100)
+               uart_putc('0'+(n/100)%10);
+       if(n>=10)
+               uart_putc('0'+(n/10)%10);
+       uart_putc('0'+n%10);
+       uart_putstr_P(PSTR(" zero bits"));
+       
+       memset(block, 0, nessie_hash_ctx.blocksize_B); 
+       nessie_hash_ctx.hash_init(ctx);
+       while(n>=nessie_hash_ctx.blocksize_B*8){
+               nessie_hash_ctx.hash_next(block, ctx);
+               n   -= nessie_hash_ctx.blocksize_B*8;
+       }
+       nessie_hash_ctx.hash_last(block, n, ctx);
+       nessie_hash_ctx.hash_conv(hash, ctx);
+       nessie_print_item("hash", hash, (nessie_hash_ctx.hashsize_b+7)/8);
+}
+
+static
+void one_in512_hash(uint16_t pos){
+       uint8_t ctx[nessie_hash_ctx.ctx_size_B];
+       uint8_t hash[(nessie_hash_ctx.hashsize_b+7)/8];
+       uint8_t block[nessie_hash_ctx.blocksize_B];
+       uint16_t n=512;
+       char* tab[8]={"80", "40", "20", "10", 
+                     "08", "04", "02", "01" };
+
+       pos&=511;
+       uart_putstr_P(PSTR("\r\n                       message="));
+       uart_putstr_P(PSTR("512-bit string: "));
+       if((pos/8) >=10){
+               uart_putc('0'+(pos/8/10)%10);
+       } else {
+               uart_putc(' ');
+       }
+       uart_putc('0'+(pos/8)%10);
+       uart_putstr_P(PSTR("*00,"));
+       uart_putstr(tab[pos&7]);
+       uart_putc(',');
+       if(63-(pos/8) >=10){
+               uart_putc('0'+((63-pos/8)/10)%10);
+       } else {
+               uart_putc(' ');
+       }
+       uart_putc('0'+(63-pos/8)%10);
+       uart_putstr_P(PSTR("*00"));
+       
+       /* now the real stuff */
+       memset(block, 0, 512/8);
+       block[pos>>3] = 0x80>>(pos&0x7);
+       nessie_hash_ctx.hash_init(ctx);
+       while(n>=nessie_hash_ctx.blocksize_B*8){
+               nessie_hash_ctx.hash_next(block, ctx);
+               n   -= nessie_hash_ctx.blocksize_B*8;
+       }
+       nessie_hash_ctx.hash_last(block, n, ctx);
+       nessie_hash_ctx.hash_conv(hash, ctx);
+       nessie_print_item("hash", hash, (nessie_hash_ctx.hashsize_b+7)/8);
+}
+
+static
+void tv4_hash(void){
+       uint8_t ctx[nessie_hash_ctx.ctx_size_B];
+       uint8_t hash[(nessie_hash_ctx.hashsize_b+7)/8];
+       uint8_t block[256/8];
+       uint16_t n=256;
+       uint32_t i;
+       
+       uart_putstr_P(PSTR("\r\n                       message="));
+       uart_putstr(PSTR("256 zero bits"));
+       memset(block, 0, 256/8);
+       
+       nessie_hash_ctx.hash_init(ctx);
+       while(n>=nessie_hash_ctx.blocksize_B*8){
+               nessie_hash_ctx.hash_next(block, ctx);
+               n    -= nessie_hash_ctx.blocksize_B*8;
+       }
+       nessie_hash_ctx.hash_last(block, n, ctx);
+       nessie_hash_ctx.hash_conv(hash, ctx);
+       nessie_print_item("hash", hash, (nessie_hash_ctx.hashsize_b+7)/8);
+       for(i=1; i<100000L; ++i){ /* this assumes BLOCKSIZE >= HASHSIZE */
+               nessie_hash_ctx.hash_init(ctx);
+               nessie_hash_ctx.hash_last(hash, nessie_hash_ctx.hashsize_b, ctx);
+               nessie_hash_ctx.hash_conv(hash, ctx);
+       }
+       nessie_print_item("iterated 100000 times", hash, (nessie_hash_ctx.hashsize_b+7)/8);
+}
+
+/*
+   "" (empty string)
+   message="a"
+   message="abc"
+   message="message digest"
+   message="abcdefghijklmnopqrstuvwxyz"
+   message="abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+   message="A...Za...z0...9"
+   message=8 times "1234567890"
+*/
+
+
+void nessie_hash_run(void){
+       uint16_t i;
+       uint8_t set;
+       
+       nessie_print_header(nessie_hash_ctx.name, 0, 0, nessie_hash_ctx.hashsize_b, 0, 0);
+       /* test set 1 */
+       char* challange[8][2]= {
+               {"", "\"\" (empty string)"},
+               {"a", "\"a\""},
+               {"abc", "\"abc\""},
+               {"message digest", "\"message digest\""},
+               {"abcdefghijklmnopqrstuvwxyz","\"abcdefghijklmnopqrstuvwxyz\""},
+               {"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+                       "\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\""},
+               {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                "abcdefghijklmnopqrstuvwxyz"
+                "0123456789"   , "\"A...Za...z0...9\""},
+               {"1234567890" "1234567890" "1234567890" "1234567890" 
+                "1234567890" "1234567890" "1234567890" "1234567890",
+                "8 times \"1234567890\""}      
+       };
+       set=1;
+       nessie_print_setheader(set);
+       for(i=0; i<8; ++i){
+               nessie_print_set_vector(set, i);
+               ascii_hash(challange[i][0], challange[i][1]);
+       }
+       nessie_print_set_vector(set, i);
+       amillion_hash();
+       /* test set 2 */
+       set=2;
+       nessie_print_setheader(set);
+       for(i=0; i<1024; ++i){
+               nessie_print_set_vector(set, i);
+               zero_hash(i);
+       }
+       /* test set 3 */
+       set=3;
+       nessie_print_setheader(set);
+       for(i=0; i<512; ++i){
+               nessie_print_set_vector(set, i);
+               one_in512_hash(i);
+       }
+       /* test set 4 */
+       set=4;
+       nessie_print_setheader(set);
+       nessie_print_set_vector(set, 0);
+       tv4_hash();
+
+       nessie_print_footer();
+}
diff --git a/test_src/nessie_hash_test.h b/test_src/nessie_hash_test.h
new file mode 100644 (file)
index 0000000..aa88bdb
--- /dev/null
@@ -0,0 +1,46 @@
+/* nessie_hash_test.h */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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 NESSIE_HASH_TEST_H_
+#define NESSIE_HASH_TEST_H_
+
+#include <stdint.h>
+
+typedef void (*nessie_hash_init_fpt)(void* ctx);
+typedef void (*nessie_hash_next_fpt)(void* buffer, void* ctx);
+typedef void (*nessie_hash_last_fpt)(void* buffer, uint16_t size_b, void* ctx);
+typedef void (*nessie_hash_conv_fpt)(void* buffer, void* ctx);
+
+
+typedef struct nessie_hash_ctx_st{
+       uint16_t hashsize_b;
+       uint16_t blocksize_B;
+       uint16_t ctx_size_B;
+       char* name; 
+       nessie_hash_init_fpt hash_init;
+       nessie_hash_next_fpt hash_next;
+       nessie_hash_last_fpt hash_last;
+       nessie_hash_conv_fpt hash_conv;
+} nessie_hash_ctx_t; 
+
+
+extern nessie_hash_ctx_t nessie_hash_ctx;
+
+void nessie_hash_run(void);
+
+#endif /*NESSIE_HASH_TEST_H_*/
diff --git a/test_src/nessie_mac_test.c b/test_src/nessie_mac_test.c
new file mode 100644 (file)
index 0000000..12863df
--- /dev/null
@@ -0,0 +1,270 @@
+/* nessie_mac_test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/**
+ * 
+ * author: Daniel Otte
+ * email:  daniel.otte@rub.de
+ * license: GPLv3
+ * 
+ * a suit for running the nessie-tests for MACs
+ * 
+ * */
+#include <stdint.h>
+#include <string.h>
+#include "nessie_mac_test.h"
+#include "nessie_common.h"
+#include "uart.h"
+
+nessie_mac_ctx_t nessie_mac_ctx;
+
+#define KEYSIZE_B ((nessie_mac_ctx.keysize_b+7)/8)
+#define MACSIZE_B ((nessie_mac_ctx.macsize_b+7)/8)
+
+#define PRINTKEY nessie_print_item("key", key, KEYSIZE_B)
+#define PRINTMAC nessie_print_item("MAC", mac, MACSIZE_B)
+
+static
+void ascii_mac(char* data, char* desc, uint8_t* key){
+       uint8_t ctx[nessie_mac_ctx.ctx_size_B];
+       uint8_t mac[MACSIZE_B];
+       uint16_t sl;
+       
+       uart_putstr_P(PSTR("\r\n                       message="));
+       uart_putstr(desc);
+       PRINTKEY;
+       nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b, ctx);
+       sl = strlen(data);
+       while(sl>=nessie_mac_ctx.blocksize_B){
+               nessie_mac_ctx.mac_next(data, ctx);
+               data += nessie_mac_ctx.blocksize_B;
+               sl   -= nessie_mac_ctx.blocksize_B;
+       }
+       nessie_mac_ctx.mac_last(data, sl*8, key, nessie_mac_ctx.keysize_b, ctx);
+       nessie_mac_ctx.mac_conv(mac, ctx);
+       PRINTMAC;
+}
+
+// message=1 million times "a"
+
+static
+void amillion_mac(uint8_t* key){
+       uint8_t ctx[nessie_mac_ctx.ctx_size_B];
+       uint8_t mac[MACSIZE_B];
+       uint8_t block[nessie_mac_ctx.blocksize_B];
+       uint32_t n=1000000LL;
+       
+       uart_putstr_P(PSTR("\r\n                       message="));
+       uart_putstr_P(PSTR("1 million times \"a\""));
+       PRINTKEY;
+       
+       memset(block, 'a', nessie_mac_ctx.blocksize_B);
+       nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b, ctx);
+       while(n>=nessie_mac_ctx.blocksize_B){
+               nessie_mac_ctx.mac_next(block, ctx);
+               n    -= nessie_mac_ctx.blocksize_B;
+       }
+       nessie_mac_ctx.mac_last(block, n*8, key, nessie_mac_ctx.keysize_b, ctx);
+       nessie_mac_ctx.mac_conv(mac, ctx);
+       PRINTMAC;
+}
+
+
+static
+void zero_mac(uint16_t n, uint8_t* key){
+       uint8_t ctx[nessie_mac_ctx.ctx_size_B];
+       uint8_t mac[MACSIZE_B];
+       uint8_t block[nessie_mac_ctx.blocksize_B];
+       
+       uart_putstr_P(PSTR("\r\n                       message="));
+       if(n>=10000)
+               uart_putc('0'+n/10000);
+       if(n>=1000)
+               uart_putc('0'+(n/1000)%10);
+       if(n>=100)
+               uart_putc('0'+(n/100)%10);
+       if(n>=10)
+               uart_putc('0'+(n/10)%10);
+       uart_putc('0'+n%10);
+       uart_putstr_P(PSTR(" zero bits"));
+       PRINTKEY;
+       
+       memset(block, 0, nessie_mac_ctx.blocksize_B); 
+       nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b,ctx);;
+       while(n>=nessie_mac_ctx.blocksize_B*8){
+               nessie_mac_ctx.mac_next(block, ctx);
+               n   -= nessie_mac_ctx.blocksize_B*8;
+       }
+       nessie_mac_ctx.mac_last(block, n, key, nessie_mac_ctx.keysize_b, ctx);
+       nessie_mac_ctx.mac_conv(mac, ctx);
+       PRINTMAC;
+}
+
+static
+void one_in512_mac(uint16_t pos, uint8_t* key){
+       uint8_t ctx[nessie_mac_ctx.ctx_size_B];
+       uint8_t mac[MACSIZE_B];
+       uint8_t block[nessie_mac_ctx.blocksize_B];
+       uint16_t n=512;
+       char* tab[8]={"80", "40", "20", "10", 
+                     "08", "04", "02", "01" };
+
+       pos&=511;
+       uart_putstr_P(PSTR("\r\n                       message="));
+       uart_putstr_P(PSTR("512-bit string: "));
+       if((pos/8) >=10){
+               uart_putc('0'+(pos/8/10)%10);
+       } else {
+               uart_putc(' ');
+       }
+       uart_putc('0'+(pos/8)%10);
+       uart_putstr_P(PSTR("*00,"));
+       uart_putstr(tab[pos&7]);
+       uart_putc(',');
+       if(63-(pos/8) >=10){
+               uart_putc('0'+((63-pos/8)/10)%10);
+       } else {
+               uart_putc(' ');
+       }
+       uart_putc('0'+(63-pos/8)%10);
+       uart_putstr_P(PSTR("*00"));
+       PRINTKEY;
+       
+       /* now the real stuff */
+       memset(block, 0, 512/8);
+       block[pos>>3] = 0x80>>(pos&0x7);
+       nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b, ctx);;
+       while(n>=nessie_mac_ctx.blocksize_B*8){
+               nessie_mac_ctx.mac_next(block, ctx);
+               n   -= nessie_mac_ctx.blocksize_B*8;
+       }
+       nessie_mac_ctx.mac_last(block, n, key, nessie_mac_ctx.keysize_b, ctx);
+       nessie_mac_ctx.mac_conv(mac, ctx);
+       PRINTMAC;
+}
+
+static
+void tv4_mac(uint8_t* key){
+       uint8_t ctx[nessie_mac_ctx.ctx_size_B];
+       uint8_t mac[MACSIZE_B];
+       uint8_t block[256/8];
+       uint16_t n=256;
+       uint32_t i;
+       
+       uart_putstr_P(PSTR("\r\n                       message="));
+       uart_putstr(PSTR("256 zero bits"));
+       memset(block, 0, 256/8);
+       
+       nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b, ctx);;
+       while(n>=nessie_mac_ctx.blocksize_B*8){
+               nessie_mac_ctx.mac_next(block, ctx);
+               n    -= nessie_mac_ctx.blocksize_B*8;
+       }
+       nessie_mac_ctx.mac_last(block, n, key, nessie_mac_ctx.keysize_b, ctx);
+       nessie_mac_ctx.mac_conv(mac, ctx);
+       PRINTMAC;
+       for(i=1; i<100000L; ++i){ /* this assumes BLOCKSIZE >= HASHSIZE */
+               nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b, ctx);;
+               nessie_mac_ctx.mac_last(mac, nessie_mac_ctx.macsize_b, key, nessie_mac_ctx.keysize_b, ctx);
+               nessie_mac_ctx.mac_conv(mac, ctx);
+       }
+       nessie_print_item("iterated 100000 times", mac, MACSIZE_B);
+}
+
+
+void nessie_mac_run(void){
+       uint16_t i;
+       uint8_t set;
+       uint8_t keyproto[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+                          0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
+                          0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };
+       uint8_t key[KEYSIZE_B];
+       
+       nessie_print_header(nessie_mac_ctx.name, nessie_mac_ctx.keysize_b, 0, 0,
+                           nessie_mac_ctx.macsize_b, 0);
+       /* test set 1 */
+       char* challange[10][2]= {
+               {"", "\"\" (empty string)"},
+               {"a", "\"a\""},
+               {"abc", "\"abc\""},
+               {"message digest", "\"message digest\""},
+               {"abcdefghijklmnopqrstuvwxyz","\"abcdefghijklmnopqrstuvwxyz\""},
+               {"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+                       "\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\""},
+               {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                "abcdefghijklmnopqrstuvwxyz"
+                "0123456789"   , "\"A...Za...z0...9\""},
+               {"1234567890" "1234567890" "1234567890" "1234567890" 
+                "1234567890" "1234567890" "1234567890" "1234567890",
+                "8 times \"1234567890\""},
+               {"Now is the time for all ", "\"Now is the time for all \""},
+               {"Now is the time for it", "\"Now is the time for it\""}
+       };
+       set=1;
+       nessie_print_setheader(set);
+       for(i=0; i<KEYSIZE_B; ++i){
+               key[i] = keyproto[i%sizeof(keyproto)];
+       }
+       for(i=0; i<10; ++i){
+               nessie_print_set_vector(set, i);
+               ascii_mac(challange[i][0], challange[i][1], key);
+       }
+       nessie_print_set_vector(set, i);
+       amillion_mac(key);
+       for(i=0; i<KEYSIZE_B; ++i){
+               key[i] = keyproto[16+i%8];
+       }
+       for(i=0; i<10; ++i){
+               nessie_print_set_vector(set, 11+i);
+               ascii_mac(challange[i][0], challange[i][1], key);
+       }
+       nessie_print_set_vector(set, 11+i);
+       amillion_mac(key);
+       /* test set 2 */
+       set=2;
+       for(i=0; i<KEYSIZE_B; ++i){
+               key[i] = keyproto[i%sizeof(keyproto)];
+       }
+       nessie_print_setheader(set);
+       for(i=0; i<1024; ++i){
+               nessie_print_set_vector(set, i);
+               zero_mac(i, key);
+       }
+       /* test set 3 */
+       set=3;
+       nessie_print_setheader(set);
+       /* we use the same key as above */
+       for(i=0; i<512; ++i){
+               nessie_print_set_vector(set, i);
+               one_in512_mac(i, key);
+       }
+       /* test set 4 */
+       set=4;
+       nessie_print_setheader(set);
+       /* we use the same key as above */
+       nessie_print_set_vector(set, 0);
+       tv4_mac(key);
+       /* test set 5 */
+       for(i=0; i<nessie_mac_ctx.keysize_b; ++i){
+               nessie_print_set_vector(set, i);
+               memset(key, 0, KEYSIZE_B);
+               key[i>>3]=0x80>>(i&0x7);
+               ascii_mac("ABC", "\"ABC\"", key);
+       }
+       nessie_print_footer();
+}
diff --git a/test_src/nessie_mac_test.h b/test_src/nessie_mac_test.h
new file mode 100644 (file)
index 0000000..ed83133
--- /dev/null
@@ -0,0 +1,47 @@
+/* nessie_mac_test.h */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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 NESSIE_MAC_TEST_H_
+#define NESSIE_MAC_TEST_H_
+
+#include <stdint.h>
+
+typedef void (*nessie_mac_init_fpt)(void* key, uint16_t keysize_b, void* ctx);
+typedef void (*nessie_mac_next_fpt)(void* buffer, void* ctx);
+typedef void (*nessie_mac_last_fpt)(void* buffer, uint16_t size_b, void* key, uint16_t keysize_b, void* ctx);
+typedef void (*nessie_mac_conv_fpt)(void* buffer, void* ctx);
+
+
+typedef struct nessie_mac_ctx_st{
+       uint16_t macsize_b;
+       uint16_t keysize_b;
+       uint16_t blocksize_B;
+       uint16_t ctx_size_B;
+       char* name; 
+       nessie_mac_init_fpt mac_init;
+       nessie_mac_next_fpt mac_next;
+       nessie_mac_last_fpt mac_last;
+       nessie_mac_conv_fpt mac_conv;
+} nessie_mac_ctx_t; 
+
+
+extern nessie_mac_ctx_t nessie_mac_ctx;
+
+void nessie_mac_run(void);
+
+#endif /*NESSIE_MAC_TEST_H_*/
diff --git a/test_src/nessie_stream_test.c b/test_src/nessie_stream_test.c
new file mode 100644 (file)
index 0000000..3866b21
--- /dev/null
@@ -0,0 +1,192 @@
+/* nessie_stream_test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/**
+ * 
+ * author: Daniel Otte
+ * email:  daniel.otte@rub.de
+ * license: GPLv3
+ * 
+ * a suit for running the nessie-tests for streamciphers
+ * 
+ * */
+#include <stdint.h>
+#include <string.h>
+#include "nessie_stream_test.h"
+#include "nessie_common.h"
+#include "uart.h"
+
+nessie_stream_ctx_t nessie_stream_ctx;
+
+
+#define BLOCKSIZE_B 64
+
+static
+void memxor(void* dest, void* src, uint8_t length){
+       while(length--){
+               *((uint8_t*)dest) ^= *((uint8_t*)src);
+               dest = (uint8_t*)dest +1;
+               src  = (uint8_t*)src +1;
+       }
+}
+
+
+static 
+void nessie_gen_block(void* ctx, uint8_t* block){
+       uint16_t i;
+       for(i=0; i<BLOCKSIZE_B; ++i){
+               block[i] = nessie_stream_ctx.cipher_enc(ctx);
+       }
+}
+
+static
+void nessie_stream_enc(uint8_t* key){
+       uint8_t ctx[nessie_stream_ctx.ctx_size_B];
+       uint8_t buffer[BLOCKSIZE_B];
+       uint8_t xorbuffer[BLOCKSIZE_B];
+       uint8_t i;
+       
+       memset(xorbuffer, 0, BLOCKSIZE_B);
+       
+       nessie_print_item("key", key, (nessie_stream_ctx.keysize_b+7)/8);
+       
+       nessie_stream_ctx.cipher_genctx(key, nessie_stream_ctx.keysize_b, ctx);
+       
+       nessie_gen_block(ctx, buffer);
+       memxor(xorbuffer, buffer, BLOCKSIZE_B);
+       nessie_print_item("stream[0..63]", buffer, BLOCKSIZE_B);
+       
+       for(i=0; i<((192-0)/BLOCKSIZE_B-1); ++i){
+               nessie_gen_block(ctx, buffer);
+               memxor(xorbuffer, buffer, BLOCKSIZE_B);
+       }
+       
+       nessie_gen_block(ctx, buffer);
+       memxor(xorbuffer, buffer, BLOCKSIZE_B);
+       nessie_print_item("stream[192..255]", buffer, BLOCKSIZE_B);
+       
+       nessie_gen_block(ctx, buffer);
+       memxor(xorbuffer, buffer, BLOCKSIZE_B);
+       nessie_print_item("stream[256..319]", buffer, BLOCKSIZE_B);
+       
+       for(i=0; i<((448-256)/BLOCKSIZE_B-1); ++i){
+               nessie_gen_block(ctx, buffer);
+               memxor(xorbuffer, buffer, BLOCKSIZE_B);
+       }
+       
+       nessie_gen_block(ctx, buffer);
+       memxor(xorbuffer, buffer, BLOCKSIZE_B);
+       nessie_print_item("stream[448..511]", buffer, BLOCKSIZE_B);
+       
+       nessie_print_item("stream[0..511]xored", xorbuffer, BLOCKSIZE_B);
+       
+}
+
+
+static
+void nessie_stream_enc_large(uint8_t* key){
+       uint8_t ctx[nessie_stream_ctx.ctx_size_B];
+       uint8_t buffer[BLOCKSIZE_B];
+       uint8_t xorbuffer[BLOCKSIZE_B];
+       uint32_t i;
+       
+       memset(xorbuffer, 0, BLOCKSIZE_B);
+       
+       nessie_print_item("key", key, (nessie_stream_ctx.keysize_b+7)/8);
+       
+       nessie_stream_ctx.cipher_genctx(key, nessie_stream_ctx.keysize_b, ctx);
+       
+       nessie_gen_block(ctx, buffer);
+       memxor(xorbuffer, buffer, BLOCKSIZE_B);
+       nessie_print_item("stream[0..63]", buffer, BLOCKSIZE_B);
+       
+       for(i=0; i<((65472-0)/BLOCKSIZE_B-1); ++i){
+               nessie_gen_block(ctx, buffer);
+               memxor(xorbuffer, buffer, BLOCKSIZE_B);
+       }
+       
+       nessie_gen_block(ctx, buffer);
+       memxor(xorbuffer, buffer, BLOCKSIZE_B);
+       nessie_print_item("stream[65472..65535]", buffer, BLOCKSIZE_B);
+       
+       nessie_gen_block(ctx, buffer);
+       memxor(xorbuffer, buffer, BLOCKSIZE_B);
+       nessie_print_item("stream[65536..65599]", buffer, BLOCKSIZE_B);
+       
+       for(i=0; i<((131008-65536)/BLOCKSIZE_B-1); ++i){
+               nessie_gen_block(ctx, buffer);
+               memxor(xorbuffer, buffer, BLOCKSIZE_B);
+       }
+       
+       nessie_gen_block(ctx, buffer);
+       memxor(xorbuffer, buffer, BLOCKSIZE_B);
+       nessie_print_item("stream[131008..131071]", buffer, BLOCKSIZE_B);
+       
+       nessie_print_item("stream[0..131071]xored", xorbuffer, BLOCKSIZE_B);
+       
+}
+
+void nessie_stream_run(void){
+       uint16_t i;
+       uint8_t set;
+       uint8_t key[(nessie_stream_ctx.keysize_b+7)/8];
+       
+       nessie_print_header(nessie_stream_ctx.name, nessie_stream_ctx.keysize_b,
+                           0, 0, 0, nessie_stream_ctx.ivsize_b);
+       /* test set 1 */
+       set=1;
+       nessie_print_setheader(set);
+       for(i=0; i<nessie_stream_ctx.keysize_b; ++i){
+               nessie_print_set_vector(set, i);
+               memset(key, 0, (nessie_stream_ctx.keysize_b+7)/8);
+               key[i/8] |= 0x80>>(i%8);
+               nessie_stream_enc(key);
+       }
+       /* test set 2 */
+       set=2;
+       nessie_print_setheader(set);
+       for(i=0; i<256; ++i){
+               nessie_print_set_vector(set, i);
+               memset(key, i, (nessie_stream_ctx.keysize_b+7)/8);
+               nessie_stream_enc(key);
+       }
+       /* test set 3 */
+       set=3;
+       nessie_print_setheader(set);
+       for(i=0; i<256; ++i){
+               uint8_t j;
+               nessie_print_set_vector(set, i);
+               for(j=0; j<(nessie_stream_ctx.keysize_b+7)/8; ++j){
+                       key[j]=(i+j)&0xff;
+               }
+               nessie_stream_enc(key);
+       }
+       /* test set 4 */
+       set=4;
+       nessie_print_setheader(set);
+       for(i=0; i<4; ++i){
+               uint8_t j;
+               nessie_print_set_vector(set, i);
+               for(j=0; j<(nessie_stream_ctx.keysize_b+7)/8; ++j){
+                       key[j]=(i*5+j*0x53)&0xff;
+               }
+               nessie_stream_enc_large(key);
+       }
+
+       nessie_print_footer();
+}
diff --git a/test_src/nessie_stream_test.h b/test_src/nessie_stream_test.h
new file mode 100644 (file)
index 0000000..8422f45
--- /dev/null
@@ -0,0 +1,42 @@
+/* nessie_stream_test.h */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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 NESSIE_STREAM_TEST_H_
+#define NESSIE_STREAM_TEST_H_
+
+#include <stdint.h>
+
+typedef void (*nessie_stream_genctx_fpt)(uint8_t* key, uint16_t keylength_b, void* ctx);
+typedef uint8_t (*nessie_stream_genenc_fpt)(void* ctx);
+
+typedef struct nessie_stream_ctx_st{
+       uint16_t keysize_b;
+       uint16_t ivsize_b;
+       uint16_t outsize_b;
+       uint16_t ctx_size_B;
+       char* name; 
+       nessie_stream_genctx_fpt cipher_genctx;
+       nessie_stream_genenc_fpt cipher_enc;
+} nessie_stream_ctx_t; 
+
+
+extern nessie_stream_ctx_t nessie_stream_ctx;
+
+void nessie_stream_run(void);
+
+#endif /*NESSIE_STREAM_TEST_H_*/
diff --git a/test_src/performance_test.c b/test_src/performance_test.c
new file mode 100644 (file)
index 0000000..04a26bd
--- /dev/null
@@ -0,0 +1,112 @@
+/* performance_test.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/*
+ * author: Daniel Otte
+ * email:  daniel.otte@rub.de
+ * license: GPLv3
+ * 
+ * 
+ **/
+#include "config.h"
+#include <string.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <avr/pgmspace.h>
+#include "uart.h"
+#include "performance_test.h"
+
+
+#ifdef ATMEGA644
+       #define TIMSK TIMSK1
+#endif
+
+
+
+uint32_t ovfcounter;
+
+uint16_t const_overhead=0;
+uint16_t int_overhead=0;
+
+ISR(TIMER1_OVF_vect){
+       ovfcounter++;
+}
+
+void calibrateTimer(void){
+       startTimer(1);
+       stopTimer();
+       const_overhead = TCNT1;
+       startTimer(1);
+       TCNT1=0xFFFE;
+       ; ; ; ;
+//     asm volatile("NOP\n"::); asm volatile("NOP\n"::);
+       stopTimer();
+       int_overhead = TCNT1;
+}
+
+void startTimer(uint8_t granularity){
+       TCCR1B = 0; /* stop timer */
+       TCNT1  = 0;
+       ovfcounter = 0;
+       TCCR1A = 0x00;
+       TIMSK &= 0xC3;
+       TIMSK |= _BV(TOIE1); /* enable TOIE1 */
+       TCCR1B = granularity & 0x7;     /* start timer */
+}
+
+uint64_t stopTimer(void){
+       TCCR1B = 0; /* stop timer */
+       uint64_t ret;
+       ret = (ovfcounter<<16) | TCNT1;
+       ret -= const_overhead;
+       ret -= ovfcounter * int_overhead;
+       return ret;
+}
+
+void getOverhead(uint16_t* constoh, uint16_t* intoh){
+       *constoh = const_overhead;
+       *intoh   = int_overhead; 
+}
+
+void print_time_P(PGM_P s, uint64_t t){
+       char sv[16];
+       uint8_t c;
+       uart_putstr_P(PSTR("\r\n"));
+       uart_putstr_P(s);
+       ultoa((unsigned long)t, sv, 10);
+       for(c=strlen(sv); c<11; ++c){
+               uart_putc(' ');
+       }
+       uart_putstr(sv);
+}
+
+void print_overhead(void){
+       char str[16];
+       uart_putstr_P(PSTR("\r\n\r\n=== benchmark ==="));
+       utoa(const_overhead, str, 10);
+       uart_putstr_P(PSTR("\r\n\tconst overhead:     "));
+       uart_putstr(str);
+       utoa(int_overhead, str, 10);
+       uart_putstr_P(PSTR("\r\n\tinterrupt overhead: "));
+       uart_putstr(str);
+}
+
+
diff --git a/test_src/performance_test.h b/test_src/performance_test.h
new file mode 100644 (file)
index 0000000..d8b1565
--- /dev/null
@@ -0,0 +1,33 @@
+/* performance_test.h */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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 PERFORMANCE_TEST_H_
+#define PERFORMANCE_TEST_H_
+
+#include <stdint.h>
+#include <avr/pgmspace.h>
+
+void calibrateTimer(void);
+void startTimer(uint8_t granularity);
+uint64_t stopTimer(void);
+void getOverhead(uint16_t* constoh, uint16_t* intoh);
+
+void print_time_P(PGM_P s, uint64_t t);
+void print_overhead(void);
+
+#endif /*PERFORMANCE_TEST_H_*/
diff --git a/test_src/serial-tools.c b/test_src/serial-tools.c
new file mode 100644 (file)
index 0000000..47b6439
--- /dev/null
@@ -0,0 +1,82 @@
+/* serial-tools.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/**
+ * 
+ * Author:     Daniel Otte
+ * Date:               16.05.2006
+ * 
+ * This tools should help to parse some input. 
+ * 
+ */
+
+#include "config.h"
+#include "uart.h"
+#include <string.h>
+#include <stdint.h>
+
+int getnextwordn(char *s, int n){ /* words are seperated by spaces */
+       char c = ' ';
+       while ((c=uart_getc()) == ' ')
+               ;
+       *s++ = c;
+       while (n && (*s++=uart_getc())!=' ')
+               ;
+       *(s-1) = '\0';
+       return n;
+}
+
+
+void readhex2buffer(void* buffer, int n){
+       char c;
+       uint8_t i;
+       
+//     DEBUG_S("\r\nDBG: n="); DEBUG_B(n&0xff); DEBUG_S("\r\n");
+       for(i=0; i<n; ++i){
+               c = uart_getc();
+               if ('0'<= c && '9'>=c){
+                       ((uint8_t*)buffer)[i] = c - '0';
+               } else {
+                       c &= ~('A' ^ 'a'); /* make all uppercase */ 
+                       if ('A'<= c && 'F'>=c){
+                               ((uint8_t*)buffer)[i] = c - 'A' + 10;
+                       } else {
+                               /* oh shit, wrong char */
+                       }
+               }
+               
+               ((uint8_t*)buffer)[i] <<= 4;
+               
+               c = uart_getc();
+               if ('0'<= c && '9'>=c){
+                       ((uint8_t*)buffer)[i] |= c - '0';
+               } else {
+                       c &= ~('A' ^ 'a'); /* make all uppercase */ 
+                       if ('A'<= c && 'F'>=c){
+                               ((uint8_t*)buffer)[i] |= c - 'A' + 10;
+                       } else {
+                               /* oh shit, wrong char */
+                       }
+               }
+       } /* for i=0 .. n */
+}
+
+void uart_putptr(void* p){
+       uart_hexdump((void*) &p,2);
+}
+
diff --git a/test_src/serial-tools.h b/test_src/serial-tools.h
new file mode 100644 (file)
index 0000000..c76b4d5
--- /dev/null
@@ -0,0 +1,27 @@
+/* serial-tools.h */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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_*/
diff --git a/test_src/uart.c b/test_src/uart.c
new file mode 100644 (file)
index 0000000..e35106c
--- /dev/null
@@ -0,0 +1,324 @@
+/* uart.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/* USART-Init beim ATmegaXX */
+
+#include "config.h"
+
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <stdlib.h>
+
+#include "uart.h"
+
+#ifdef ATMEGA128
+#define UCSRB UCSR0B
+#define UCSRC UCSR0C
+#define UDR UDR0
+#define UBRRH UBRR0H
+#define UBRRL UBRR0L
+#define URSEL UMSEL
+#endif
+
+#ifdef ATMEGA644
+#define UCSRB UCSR0B
+#define UCSRC UCSR0C
+#define UDR UDR0
+#define UBRRH UBRR0H
+#define UBRRL UBRR0L
+#define URSEL UMSEL00
+#define USART_UDRE_vect USART0_UDRE_vect
+#define USART_RXC_vect USART0_RX_vect
+#define UDRIE UDRIE0
+#define TXEN TXEN0
+#define UMSEL UMSEL0
+#define RXEN RXEN0
+#define RXCIE RXCIE0
+#define UCSZ0 UCSZ00
+#define UCSRA UCSR0A
+#define UDRE UDRE0
+#define RXC RXC0
+#endif
+
+
+#ifdef UART_XON_XOFF
+ #ifdef UART_INTERRUPT
+  void uart_insertc(char c);
+ #else
+  #define uart_insertc uart_putc
+ #endif /* UART_INTERRUPT */
+#endif
+
+#define UART_BAUD_CALC(UART_BAUD_RATE,F_OSC) ((F_OSC)/((UART_BAUD_RATE)*16L)-1)
+
+#ifdef UART_XON_XOFF
+       typedef enum{go=1,nogo=0} gonogo;
+       static gonogo txon=go;
+       static gonogo rxon=go;
+#endif
+
+#ifdef UART_INTERRUPT
+volatile static char rxbuf[UART_RXBUFSIZE];
+volatile static char txbuf[UART_TXBUFSIZE];
+volatile static char *volatile rxhead, *volatile rxtail;
+volatile static char *volatile txhead, *volatile txtail;
+
+#ifdef UART_HOOK       
+        void (*uart_hook) (uint8_t) = (void*)0;        /* this is a pointer to a function ;-) */
+#endif
+
+ISR(USART_UDRE_vect) {
+#ifdef UART_LEDS       
+       PORTC ^= 0x01;
+#endif
+       
+       if ( txhead == txtail ) {
+               UCSRB &= ~(1 << UDRIE);         /* disable data register empty IRQ */
+       } else {
+               #ifdef UART_XON_XOFF
+                       while(txon==nogo)
+                               ;
+               #endif
+               UDR = *txtail;                  /* schreibt das Zeichen x auf die Schnittstelle */
+               if (++txtail == (txbuf + UART_TXBUFSIZE)) txtail = txbuf;
+       }
+}
+
+ISR(USART_RXC_vect) {
+       int diff; 
+       char c;
+#ifdef UART_HOOK       
+       static volatile uint8_t hook_running=0;
+#endif
+#ifdef UART_LEDS
+       PORTC ^= 0x02;
+#endif
+       c=UDR;
+       #ifdef UART_XON_XOFF
+        if (c==XON){
+                 txon=go;
+                 return;
+        }
+        if (c==XOFF){
+                txon=nogo;
+                return;
+        }
+       #endif
+       /* buffer full? */
+       diff = rxhead - rxtail;
+       if (diff < 0) diff += UART_RXBUFSIZE; /* diff is the amount of bytes in buffer */
+       if (diff < UART_RXBUFSIZE -1) {
+               // buffer NOT full
+#ifdef UART_HOOK
+               if(!hook_running && uart_hook){
+                       uint8_t t=c;    
+                       hook_running = 1;
+                       sei(); /* reenable interrupts, avoid recursion!!! */
+                       do {
+                               uart_hook(t);
+                       } while(uart_getc_nb((char*)&t));
+                       hook_running = 0;
+               } else {
+                       *rxhead = c;
+                       ++rxhead;
+                       if (rxhead == (rxbuf + UART_RXBUFSIZE)) rxhead = rxbuf;
+               }
+#else  
+               *rxhead = c;
+               ++rxhead;
+               if (rxhead == (rxbuf + UART_RXBUFSIZE))
+                       rxhead = rxbuf;
+#endif
+       } else {
+                                               //reads the buffer to clear the interrupt condition
+       }
+#ifdef UART_XON_XOFF   
+       if((diff > UART_XON_XOFF_THRESHOLD_1) && (rxon==go)){
+               rxon=nogo;
+               uart_insertc(XOFF);
+       }
+       if((diff < UART_XON_XOFF_THRESHOLD_2) && (rxon==nogo)){
+               rxon=go;
+               uart_insertc(XON);
+       }
+#endif
+}
+
+#endif // UART_INTERRUPT
+
+
+void uart_init() {
+       PORTD |= 0x01;                          //Pullup an RXD an
+       
+       UCSRB |= (1<<TXEN);                     //UART TX einschalten
+#ifdef ATMEGA644
+       UCSRA = 0;
+       UCSRC = (3<<UCSZ0);                 //Asynchron 8N1
+#else  
+    UCSRA = 0;
+       UCSRC |= (1<<URSEL)|(3<<UCSZ0);         //Asynchron 8N1
+#endif
+       UCSRB |= ( 1 << RXEN );                 //Uart RX einschalten
+
+       UBRRH=(uint8_t)(UART_BAUD_CALC(UART_BAUD_RATE,F_CPU)>>8);
+       UBRRL=(uint8_t)(UART_BAUD_CALC(UART_BAUD_RATE,F_CPU));
+
+#ifdef UART_INTERRUPT
+       // init buffers
+       rxhead = rxtail = rxbuf;
+       txhead = txtail = txbuf;
+
+       // activate rx IRQ
+       UCSRB |= _BV(RXCIE) | _BV(UDRIE);
+       sei();
+//     #ifdef ATMEGA644
+//     UCSRB |= _BV(UDRIE);
+//     #endif
+#endif // UART_INTERRUPT
+}
+
+#ifdef UART_INTERRUPT
+#ifdef UART_XON_XOFF
+
+void uart_insertc(char c){
+       volatile int diff;
+       do {
+               diff = txhead - txtail;
+               if ( diff < 0 ) diff += UART_TXBUFSIZE;
+       } while ( diff >= UART_TXBUFSIZE -1 );
+
+       cli();
+       if (--txtail == (txbuf-1)) txtail += UART_TXBUFSIZE;
+       *txtail = c;
+       
+       UCSRB |= (1 << UDRIE);          /* enable data register empty IRQ */
+       sei();
+}
+#endif /* UART_XON_XOFF */
+void uart_putc(char c) {
+       volatile int diff;
+
+       /* buffer full? */
+       do {
+               diff = txhead - txtail;
+               if ( diff < 0 ) diff += UART_TXBUFSIZE;
+       } while ( diff >= UART_TXBUFSIZE -1 );
+
+       cli();
+       *txhead = c;
+       if (++txhead == (txbuf + UART_TXBUFSIZE)) txhead = txbuf;
+
+       UCSRB |= (1 << UDRIE);          /* enable data register empty IRQ */
+       sei();
+}
+#else  // WITHOUT INTERRUPT
+void uart_putc(char c) {
+       while (!(UCSRA & (1<<UDRE))) /* warten bis Senden moeglich */
+               ; 
+       #ifdef UART_XON_XOFF
+       while (txon==nogo)                       /* warte bis XON empfangen */
+               ;
+       #endif
+       UDR = c;                  /* schreibt das Zeichen x auf die Schnittstelle */
+}
+#endif // UART_INTERRUPT
+
+
+void uart_putstr(char *str) {
+       while(*str) {
+               uart_putc(*str++);
+       }
+}
+
+void uart_putstr_P(PGM_P str) {
+       char tmp;
+       while((tmp = pgm_read_byte(str))) {
+               uart_putc(tmp);
+               str++;
+       }
+}
+
+void uart_hexdump(const void* buf, int len)
+{
+       unsigned char table[]={'0','1','2','3','4','5','6','7',
+                                  '8','9','a','b','c','d','e','f'};
+       while(len--){
+               uart_putc(table[((*((char*)buf))>>4)&0xf]);
+               uart_putc(table[(*((char*)buf))&0xf]);
+               uart_putc(' ');
+               buf=(uint8_t*)buf+1;
+       }
+}
+
+
+#ifdef UART_INTERRUPT
+char uart_getc(void)
+{
+       char val;
+
+       while(rxhead==rxtail)
+               ;
+
+       val = *rxtail;
+       ++rxtail;
+       if (rxtail == (rxbuf + UART_RXBUFSIZE))
+               rxtail = rxbuf;
+
+       return val;
+}
+#else  // WITHOUT INTERRUPT
+char uart_getc(void)
+{
+       char t;
+       while (!(UCSRA & (1<<RXC)))
+               ;       // warten bis Zeichen verfuegbar
+       t=UDR;
+       #ifdef UART_XON_XOFF
+       if (t==XON)  txon=go;
+       if (t==XOFF) txon=nogo;
+       #endif
+       return t;                       // Zeichen aus UDR zurueckgeben
+}
+#endif // UART_INTERRUPT
+
+// returns 1 on success
+#ifdef UART_INTERRUPT
+char uart_getc_nb(char *c)
+{
+       if (rxhead==rxtail) return 0;
+
+       *c = *rxtail;
+       if (++rxtail == (rxbuf + UART_RXBUFSIZE)) rxtail = rxbuf;
+
+       return 1;
+}
+#else  // WITHOUT INTERRUPT
+char uart_getc_nb(char *c)
+{
+       if (UCSRA & (1<<RXC)) {         // Zeichen verfuegbar
+               *c = UDR;
+               #ifdef UART_XON_XOFF
+                       if (*c==XON)  txon=go;
+                       if (*c==XOFF) txon=nogo;
+               #endif
+               return 1;
+       }
+
+       return 0;
+}
+#endif // UART_INTERRUPT
diff --git a/uart.c b/uart.c
deleted file mode 100644 (file)
index e35106c..0000000
--- a/uart.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/* uart.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/* USART-Init beim ATmegaXX */
-
-#include "config.h"
-
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include <stdlib.h>
-
-#include "uart.h"
-
-#ifdef ATMEGA128
-#define UCSRB UCSR0B
-#define UCSRC UCSR0C
-#define UDR UDR0
-#define UBRRH UBRR0H
-#define UBRRL UBRR0L
-#define URSEL UMSEL
-#endif
-
-#ifdef ATMEGA644
-#define UCSRB UCSR0B
-#define UCSRC UCSR0C
-#define UDR UDR0
-#define UBRRH UBRR0H
-#define UBRRL UBRR0L
-#define URSEL UMSEL00
-#define USART_UDRE_vect USART0_UDRE_vect
-#define USART_RXC_vect USART0_RX_vect
-#define UDRIE UDRIE0
-#define TXEN TXEN0
-#define UMSEL UMSEL0
-#define RXEN RXEN0
-#define RXCIE RXCIE0
-#define UCSZ0 UCSZ00
-#define UCSRA UCSR0A
-#define UDRE UDRE0
-#define RXC RXC0
-#endif
-
-
-#ifdef UART_XON_XOFF
- #ifdef UART_INTERRUPT
-  void uart_insertc(char c);
- #else
-  #define uart_insertc uart_putc
- #endif /* UART_INTERRUPT */
-#endif
-
-#define UART_BAUD_CALC(UART_BAUD_RATE,F_OSC) ((F_OSC)/((UART_BAUD_RATE)*16L)-1)
-
-#ifdef UART_XON_XOFF
-       typedef enum{go=1,nogo=0} gonogo;
-       static gonogo txon=go;
-       static gonogo rxon=go;
-#endif
-
-#ifdef UART_INTERRUPT
-volatile static char rxbuf[UART_RXBUFSIZE];
-volatile static char txbuf[UART_TXBUFSIZE];
-volatile static char *volatile rxhead, *volatile rxtail;
-volatile static char *volatile txhead, *volatile txtail;
-
-#ifdef UART_HOOK       
-        void (*uart_hook) (uint8_t) = (void*)0;        /* this is a pointer to a function ;-) */
-#endif
-
-ISR(USART_UDRE_vect) {
-#ifdef UART_LEDS       
-       PORTC ^= 0x01;
-#endif
-       
-       if ( txhead == txtail ) {
-               UCSRB &= ~(1 << UDRIE);         /* disable data register empty IRQ */
-       } else {
-               #ifdef UART_XON_XOFF
-                       while(txon==nogo)
-                               ;
-               #endif
-               UDR = *txtail;                  /* schreibt das Zeichen x auf die Schnittstelle */
-               if (++txtail == (txbuf + UART_TXBUFSIZE)) txtail = txbuf;
-       }
-}
-
-ISR(USART_RXC_vect) {
-       int diff; 
-       char c;
-#ifdef UART_HOOK       
-       static volatile uint8_t hook_running=0;
-#endif
-#ifdef UART_LEDS
-       PORTC ^= 0x02;
-#endif
-       c=UDR;
-       #ifdef UART_XON_XOFF
-        if (c==XON){
-                 txon=go;
-                 return;
-        }
-        if (c==XOFF){
-                txon=nogo;
-                return;
-        }
-       #endif
-       /* buffer full? */
-       diff = rxhead - rxtail;
-       if (diff < 0) diff += UART_RXBUFSIZE; /* diff is the amount of bytes in buffer */
-       if (diff < UART_RXBUFSIZE -1) {
-               // buffer NOT full
-#ifdef UART_HOOK
-               if(!hook_running && uart_hook){
-                       uint8_t t=c;    
-                       hook_running = 1;
-                       sei(); /* reenable interrupts, avoid recursion!!! */
-                       do {
-                               uart_hook(t);
-                       } while(uart_getc_nb((char*)&t));
-                       hook_running = 0;
-               } else {
-                       *rxhead = c;
-                       ++rxhead;
-                       if (rxhead == (rxbuf + UART_RXBUFSIZE)) rxhead = rxbuf;
-               }
-#else  
-               *rxhead = c;
-               ++rxhead;
-               if (rxhead == (rxbuf + UART_RXBUFSIZE))
-                       rxhead = rxbuf;
-#endif
-       } else {
-                                               //reads the buffer to clear the interrupt condition
-       }
-#ifdef UART_XON_XOFF   
-       if((diff > UART_XON_XOFF_THRESHOLD_1) && (rxon==go)){
-               rxon=nogo;
-               uart_insertc(XOFF);
-       }
-       if((diff < UART_XON_XOFF_THRESHOLD_2) && (rxon==nogo)){
-               rxon=go;
-               uart_insertc(XON);
-       }
-#endif
-}
-
-#endif // UART_INTERRUPT
-
-
-void uart_init() {
-       PORTD |= 0x01;                          //Pullup an RXD an
-       
-       UCSRB |= (1<<TXEN);                     //UART TX einschalten
-#ifdef ATMEGA644
-       UCSRA = 0;
-       UCSRC = (3<<UCSZ0);                 //Asynchron 8N1
-#else  
-    UCSRA = 0;
-       UCSRC |= (1<<URSEL)|(3<<UCSZ0);         //Asynchron 8N1
-#endif
-       UCSRB |= ( 1 << RXEN );                 //Uart RX einschalten
-
-       UBRRH=(uint8_t)(UART_BAUD_CALC(UART_BAUD_RATE,F_CPU)>>8);
-       UBRRL=(uint8_t)(UART_BAUD_CALC(UART_BAUD_RATE,F_CPU));
-
-#ifdef UART_INTERRUPT
-       // init buffers
-       rxhead = rxtail = rxbuf;
-       txhead = txtail = txbuf;
-
-       // activate rx IRQ
-       UCSRB |= _BV(RXCIE) | _BV(UDRIE);
-       sei();
-//     #ifdef ATMEGA644
-//     UCSRB |= _BV(UDRIE);
-//     #endif
-#endif // UART_INTERRUPT
-}
-
-#ifdef UART_INTERRUPT
-#ifdef UART_XON_XOFF
-
-void uart_insertc(char c){
-       volatile int diff;
-       do {
-               diff = txhead - txtail;
-               if ( diff < 0 ) diff += UART_TXBUFSIZE;
-       } while ( diff >= UART_TXBUFSIZE -1 );
-
-       cli();
-       if (--txtail == (txbuf-1)) txtail += UART_TXBUFSIZE;
-       *txtail = c;
-       
-       UCSRB |= (1 << UDRIE);          /* enable data register empty IRQ */
-       sei();
-}
-#endif /* UART_XON_XOFF */
-void uart_putc(char c) {
-       volatile int diff;
-
-       /* buffer full? */
-       do {
-               diff = txhead - txtail;
-               if ( diff < 0 ) diff += UART_TXBUFSIZE;
-       } while ( diff >= UART_TXBUFSIZE -1 );
-
-       cli();
-       *txhead = c;
-       if (++txhead == (txbuf + UART_TXBUFSIZE)) txhead = txbuf;
-
-       UCSRB |= (1 << UDRIE);          /* enable data register empty IRQ */
-       sei();
-}
-#else  // WITHOUT INTERRUPT
-void uart_putc(char c) {
-       while (!(UCSRA & (1<<UDRE))) /* warten bis Senden moeglich */
-               ; 
-       #ifdef UART_XON_XOFF
-       while (txon==nogo)                       /* warte bis XON empfangen */
-               ;
-       #endif
-       UDR = c;                  /* schreibt das Zeichen x auf die Schnittstelle */
-}
-#endif // UART_INTERRUPT
-
-
-void uart_putstr(char *str) {
-       while(*str) {
-               uart_putc(*str++);
-       }
-}
-
-void uart_putstr_P(PGM_P str) {
-       char tmp;
-       while((tmp = pgm_read_byte(str))) {
-               uart_putc(tmp);
-               str++;
-       }
-}
-
-void uart_hexdump(const void* buf, int len)
-{
-       unsigned char table[]={'0','1','2','3','4','5','6','7',
-                                  '8','9','a','b','c','d','e','f'};
-       while(len--){
-               uart_putc(table[((*((char*)buf))>>4)&0xf]);
-               uart_putc(table[(*((char*)buf))&0xf]);
-               uart_putc(' ');
-               buf=(uint8_t*)buf+1;
-       }
-}
-
-
-#ifdef UART_INTERRUPT
-char uart_getc(void)
-{
-       char val;
-
-       while(rxhead==rxtail)
-               ;
-
-       val = *rxtail;
-       ++rxtail;
-       if (rxtail == (rxbuf + UART_RXBUFSIZE))
-               rxtail = rxbuf;
-
-       return val;
-}
-#else  // WITHOUT INTERRUPT
-char uart_getc(void)
-{
-       char t;
-       while (!(UCSRA & (1<<RXC)))
-               ;       // warten bis Zeichen verfuegbar
-       t=UDR;
-       #ifdef UART_XON_XOFF
-       if (t==XON)  txon=go;
-       if (t==XOFF) txon=nogo;
-       #endif
-       return t;                       // Zeichen aus UDR zurueckgeben
-}
-#endif // UART_INTERRUPT
-
-// returns 1 on success
-#ifdef UART_INTERRUPT
-char uart_getc_nb(char *c)
-{
-       if (rxhead==rxtail) return 0;
-
-       *c = *rxtail;
-       if (++rxtail == (rxbuf + UART_RXBUFSIZE)) rxtail = rxbuf;
-
-       return 1;
-}
-#else  // WITHOUT INTERRUPT
-char uart_getc_nb(char *c)
-{
-       if (UCSRA & (1<<RXC)) {         // Zeichen verfuegbar
-               *c = UDR;
-               #ifdef UART_XON_XOFF
-                       if (*c==XON)  txon=go;
-                       if (*c==XOFF) txon=nogo;
-               #endif
-               return 1;
-       }
-
-       return 0;
-}
-#endif // UART_INTERRUPT