]> git.cryptolib.org Git - avr-crypto-lib.git/commitdiff
nessie for the rest (skipjack seems broken, shabea req. more testing)
authorbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Wed, 9 Jul 2008 05:41:43 +0000 (05:41 +0000)
committerbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Wed, 9 Jul 2008 05:41:43 +0000 (05:41 +0000)
17 files changed:
avr-makefile.inc
main-md5-test.c
main-seed-test.c
main-sha1-test.c
main-sha256-test.c
main-shabea-test.c
main-skipjack-test.c
mkfiles/md5.mk
mkfiles/seed.mk
mkfiles/sha1.mk
mkfiles/sha256.mk
mkfiles/shabea.mk
mkfiles/skipjack.mk
seed.c
seed.h
shabea.c
shabea.h

index f0ea6c8d22fabe6fcfe54ab439c4a3433aae03d3..4d9555ca6385158cec223a2e68f21b02690ccd69 100644 (file)
@@ -12,7 +12,7 @@ ERASECMD       =
 
 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,$<) -pedantic -std=c99 -Wall -Wstrict-prototypes  $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
 
 override LDFLAGS       = -Wl,-Map,
 override ASFLAGS          = -mmcu=$(MCU_TARGET)
index 3ed1a1a5d1c4670ffad60ff8b6d29a913b475c7d..921b4084e43093e0a784f792d9e66e32b57afae1 100644 (file)
 #include "debug.h"
 
 #include "md5.h"
+#include "nessie_hash_test.h"
 
 #include <stdint.h>
 #include <string.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                                                                                                                          *
@@ -85,15 +113,17 @@ int main (void){
        uart_putstr("\r\n");
 
        uart_putstr("\r\n\r\nCrypto-VS (MD5)\r\nloaded and running\r\n");
-restart:
+       PGM_P    u   = PSTR("nessie\0test\0");
+       void_fpt v[] = {testrun_nessie_md5, testrun_md5};
+
        while(1){ 
-               if (!getnextwordn(str,20))  {DEBUG_S("DBG: W1\r\n"); goto error;}
-               if (strcmp(str, "test")) {DEBUG_S("DBG: 1b\r\n"); goto error;}
-                       testrun_md5();
-               goto restart;           
+               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");
-       } /* while (1) */
+       }
 }
 
index 813cb5c1d9c083e25ccde595a0f3e2b3600739f8..1dc4259b8be8daa6b280aa936771aac1f8dde9d3 100644 (file)
 #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 <util/delay.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_encrypt;
+       nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)seed_decrypt;
+       nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)seed_genctx_dummy;
+       
+       nessie_bc_run();
+       
+}
+
+
+void testrun_performance_seed(void){
+       uint16_t i,c;
+       uint64_t t;
+       char str[16];
+       uint8_t key[16], data[16];
+       seed_ctx_t ctx;
+       
+       calibrateTimer();
+       getOverhead(&c, &i);
+       uart_putstr_P(PSTR("\r\n\r\n=== benchmark ==="));
+       utoa(c, str, 10);
+       uart_putstr_P(PSTR("\r\n\tconst overhead:     "));
+       uart_putstr(str);
+       utoa(i, str, 10);
+       uart_putstr_P(PSTR("\r\n\tinterrupt overhead: "));
+       uart_putstr(str);
+       
+       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_encrypt(data, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       seed_decrypt(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                                                               *
@@ -49,30 +117,24 @@ 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(&ctx, key);
+       seed_init(key, &ctx);
        uart_putstr("\r\n plain: ");
        uart_hexdump(block,16);
-       _delay_ms(50);
-       seed_encrypt(&ctx, block);
+       seed_encrypt(block, &ctx);
        uart_putstr("\r\n crypt: ");
        uart_hexdump(block,16);
-//     uart_putstr("\r\n post-state: ");
-//     uart_hexdump(ctx.k,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(&ctx, key);
+       seed_init(key, &ctx);
        uart_putstr("\r\n crypt: ");
        uart_hexdump(block,16);
-       _delay_ms(50);
-       seed_decrypt(&ctx, block);
+       seed_decrypt(block, &ctx);
        uart_putstr("\r\n plain: ");
        uart_hexdump(block,16);
-//     uart_putstr("\r\n post-state: ");
-//     uart_hexdump(ctx.k,16);
 }
 
 void testrun_seed(void){
@@ -101,7 +163,6 @@ void testrun_seed(void){
                testencrypt(datas[i],keys[i]);
                testdecrypt(datas[i],keys[i]);  
        }
-//     testdecrypt(data,key);  
 }
 
 
@@ -114,21 +175,23 @@ int main (void){
        char str[20];
 
        DEBUG_INIT();
-       uart_putstr("\r\n");
 
-       uart_putstr("\r\n\r\nCrypto-VS (seed)\r\nloaded and running\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_seed, testrun_seed, testrun_performance_seed};
 
-restart:
        while(1){ 
-               if (!getnextwordn(str,20))  {DEBUG_S("DBG: W1\r\n"); goto error;}
-               if (strcmp(str, "test")) {DEBUG_S("DBG: 1b\r\n"); goto error;}
-                       testrun_seed();
-               goto restart;           
+               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 c30c3c725737c9b1be75a25f75fc106ea06e2f60..3fb74bdad8a8e9ec68ed1e39399afd25dd6a2e9a 100644 (file)
 #include "debug.h"
 
 #include "sha1.h"
+#include "nessie_hash_test.h"
 
 #include <stdint.h>
 #include <string.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                                                                                                                          *
@@ -93,17 +116,18 @@ int main (void){
 
        uart_putstr("\r\n\r\nCrypto-VS (SHA-1)\r\nloaded and running\r\n");
 
-restart:
+       PGM_P    u   = PSTR("nessie\0test\0");
+       void_fpt v[] = {testrun_nessie_sha1, testrun_sha1};
+
        while(1){ 
-               if (!getnextwordn(str,20))  {DEBUG_S("DBG: W1\r\n"); goto error;}
-               if (strcmp(str, "test")) {DEBUG_S("DBG: 1b\r\n"); goto error;}
-                       testrun_sha1();
-               goto restart;           
+               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 4f8346f114db58671500662c6aa7f682e8ca4a25..552356c4a3c1ebfe8d5a4ab8ba089dd1b2e59390 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <stdint.h>
 #include <string.h>
+#include "cli.h"
 
 char* algo_name = "SHA-256";
 
@@ -73,16 +74,17 @@ int main (void){
        uart_putstr(algo_name);
        uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
 
-restart:
+       PGM_P    u   = PSTR("nessie\0test\0");
+       void_fpt v[] = {testrun_nessie_sha256, testrun_nessie_sha256};
+
        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_sha256();
-               goto restart;           
+               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 a83d0c7b114909c21633642063449b4d7568ff9c..418bcf6fff1da329791f375e4afb92124c281ceb 100644 (file)
 #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 <util/delay.h>
+#include <stdlib.h>
+
+char* cipher_name = "Shabea";
 
 /*****************************************************************************
  *  additional validation-functions                                                                                     *
  *****************************************************************************/
+void shabea_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
+       memcpy(ctx, key, keysize);
+}
+
+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){
+       uint16_t i,c;
+       uint64_t t;
+       char str[16];
+       uint8_t key[32], data[32];
+       
+       calibrateTimer();
+       getOverhead(&c, &i);
+       uart_putstr_P(PSTR("\r\n\r\n=== benchmark ==="));
+       utoa(c, str, 10);
+       uart_putstr_P(PSTR("\r\n\tconst overhead:     "));
+       uart_putstr(str);
+       utoa(i, str, 10);
+       uart_putstr_P(PSTR("\r\n\tinterrupt overhead: "));
+       uart_putstr(str);
+       
+       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                                                                                                                          *
@@ -49,7 +116,6 @@ void testencrypt(uint8_t* block, uint8_t* key){
        uart_hexdump(key,16);
        uart_putstr("\r\n plain: ");
        uart_hexdump(block,32);
-       _delay_ms(50);
        shabea256(block,key,128,1,16);
        uart_putstr("\r\n crypt: ");
        uart_hexdump(block,32);
@@ -61,7 +127,6 @@ void testdecrypt(uint8_t* block, uint8_t* key){
        uart_hexdump(key,16);
        uart_putstr("\r\n crypt: ");
        uart_hexdump(block,32);
-       _delay_ms(50);
        shabea256(block,key,128,0,16);
        uart_putstr("\r\n plain: ");
        uart_hexdump(block,32);
@@ -101,7 +166,6 @@ void testrun_shabea(void){
                testencrypt(datas[i],keys[i]);
                testdecrypt(datas[i],keys[i]);  
        }
-//     testdecrypt(data,key);  
 }
 
 
@@ -116,19 +180,22 @@ int main (void){
        DEBUG_INIT();
        uart_putstr("\r\n");
 
-       uart_putstr("\r\n\r\nCrypto-VS (shabea)\r\nloaded and running\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};
 
-restart:
        while(1){ 
-               if (!getnextwordn(str,20))  {DEBUG_S("DBG: W1\r\n"); goto error;}
-               if (strcmp(str, "test")) {DEBUG_S("DBG: 1b\r\n"); goto error;}
-                       testrun_shabea();
-               goto restart;           
+               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 7218d990e0773b4ff39b022a79fd86df8da9b91d..65f0d1ff39190650747d2ef3a486d99887b08784 100644 (file)
 #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){
+       uint16_t i,c;
+       uint64_t t;
+       char str[16];
+       uint8_t key[10], data[8];
+       
+       calibrateTimer();
+       getOverhead(&c, &i);
+       uart_putstr_P(PSTR("\r\n\r\n=== benchmark ==="));
+       utoa(c, str, 10);
+       uart_putstr_P(PSTR("\r\n\tconst overhead:     "));
+       uart_putstr(str);
+       utoa(i, str, 10);
+       uart_putstr_P(PSTR("\r\n\tinterrupt overhead: "));
+       uart_putstr(str);
+       
+       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                                                                                                                          *
@@ -82,17 +141,18 @@ int main (void){
 
        uart_putstr("\r\n\r\nCrypto-VS (skipjack)\r\nloaded and running\r\n");
 
-restart:
+       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 (strcmp(str, "test")) {DEBUG_S("DBG: 1b\r\n"); goto error;}
-                       testrun_skipjack();
-               goto restart;           
+               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 e6aeaa49303b2ac3f439e77d774f29b420439f01..047fb2174f1930aee88f1e785bc1bf7b0688c5ae 100644 (file)
@@ -5,7 +5,8 @@ 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 md5.o \
+                         nessie_hash_test.o nessie_common.o cli.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index 37888a5724bcb240ba98ae4623c2171fbfbd3b87..515597c8a11125eef5e1a9e95076dfaac69bcb5f 100644 (file)
@@ -6,7 +6,8 @@ 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
+                         seed.o seed-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 96595e9e60fe4edc23586610a29b5f97fa1b8ea1..d4c1b5a7705146a5f0ecc478b58c3f6123deb728 100644 (file)
@@ -6,7 +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
+                         sha1-asm.o nessie_hash_test.o nessie_common.o cli.o 
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index 9d9dbaa5e80015d50eaad3057df5ade5d6782fc6..c1a3d58a4e1d663ced45809348c311944c44245e 100644 (file)
@@ -6,7 +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
+                         sha256-asm.o nessie_hash_test.o nessie_common.o cli.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
 
index 3accd1f3decb9db518bcd66337cad330343d4e2f..8c9cc951f2cea5fb88189354d824bd66d8e1f53d 100644 (file)
@@ -6,7 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := shabea.o sha256-asm.o
 $(ALGO_NAME)_TEST_BIN := main-shabea-test.o debug.o uart.o serial-tools.o \
-                         shabea.o sha256-asm.o
+                         shabea.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 a04ba8a572dc7ef59ec226cdacad3bf5f0092ced..2a117a9cc2236036391826a90ec46d8f85613956 100644 (file)
@@ -6,7 +6,8 @@ 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
+                         skipjack.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/seed.c b/seed.c
index da240bdbbaaadbdf5964df91f84bc5d26ed10494..29cd9913a11838749c898773f58d4a0790135ee0 100644 (file)
--- a/seed.c
+++ b/seed.c
@@ -220,7 +220,7 @@ typedef struct{
 
 /******************************************************************************/
 
-void seed_init(seed_ctx_t * ctx, uint8_t * key){
+void seed_init(uint8_t * key, seed_ctx_t * ctx){
        memcpy(ctx->k, key, 128/8);
 }
 
@@ -229,7 +229,7 @@ void seed_init(seed_ctx_t * ctx, uint8_t * key){
 #define L (((uint64_t*)buffer)[0])
 #define R (((uint64_t*)buffer)[1])
 
-void seed_encrypt(seed_ctx_t * ctx, void * buffer){
+void seed_encrypt(void * buffer, seed_ctx_t * ctx){
        uint8_t r;
        keypair_t k;
        for(r=0; r<8; ++r){
@@ -262,7 +262,7 @@ void seed_encrypt(seed_ctx_t * ctx, void * buffer){
 #define L (((uint64_t*)buffer)[0])
 #define R (((uint64_t*)buffer)[1])
 
-void seed_decrypt(seed_ctx_t * ctx, void * buffer){
+void seed_decrypt(void * buffer, seed_ctx_t * ctx){
        int8_t r;
        keypair_t k;
        for(r=7; r>=0; --r){
diff --git a/seed.h b/seed.h
index 330944d419679bf6cf3919bc9c63b6c7fa1777f7..04b3566f5678843eb370e9e6ec68c89fa155ee20 100644 (file)
--- a/seed.h
+++ b/seed.h
@@ -36,8 +36,8 @@ typedef struct{
 
 /******************************************************************************/
 
-void seed_init(seed_ctx_t * ctx, uint8_t * key);
-void seed_encrypt(seed_ctx_t * ctx, void * buffer);
-void seed_decrypt(seed_ctx_t * ctx, void * buffer);
+void seed_init(uint8_t * key, seed_ctx_t * ctx);
+void seed_encrypt(void * buffer, seed_ctx_t * ctx);
+void seed_decrypt(void * buffer, seed_ctx_t * ctx);
        
 #endif /*SEED_H_*/
index 62ff6b4a27e72b5af76223f3e8c06f09bd2df6de..49a13215b18de29dfa8827504f46aef574ea257a 100644 (file)
--- a/shabea.c
+++ b/shabea.c
@@ -55,26 +55,26 @@ void memxor(uint8_t * dest, uint8_t * src, uint8_t length){
 
 #define L ((uint8_t*)block+ 0)
 #define R ((uint8_t*)block+16)
-void shabea256(void * block, void * key, uint16_t keysize, uint8_t enc, uint8_t rounds){
+void shabea256(void * block, void * key, uint16_t keysize_b, uint8_t enc, uint8_t rounds){
        int8_t r;               /**/
-       uint8_t tb[HALFSIZEB+2+(keysize+7)/8];  /**/
+       uint8_t tb[HALFSIZEB+2+(keysize_b+7)/8];        /**/
        uint16_t kbs;   /* bytes used for the key / temporary block */
        sha256_hash_t hash;
        
        r = (enc?0:(rounds-1));
-       kbs = (keysize+7)/8;
+       kbs = (keysize_b+7)/8;
        memcpy(tb+HALFSIZEB+2, key, kbs); /* copy key to temporary block */
        tb[HALFSIZEB+0] = 0;    /* set round counter high value to zero */
        
        for(;r!=(enc?(rounds):-1);enc?r++:r--){ /* enc: 0..(rounds-1) ; !enc: (rounds-1)..0 */
                memcpy(tb, R, HALFSIZEB); /* copy right half into tb */
                tb[HALFSIZEB+1] = r;
-               sha256(&hash, tb, HALFSIZE+16+keysize);
+               sha256(&hash, tb, HALFSIZE+16+keysize_b);
                if(!(r==(enc?(rounds-1):0))){   
                        /* swap */
-                       memxor(hash, L, HALFSIZE);
-                       memcpy(L, R, HALFSIZE);
-                       memcpy(R, hash, HALFSIZE);
+                       memxor(hash, L, HALFSIZEB);
+                       memcpy(L, R, HALFSIZEB);
+                       memcpy(R, hash, HALFSIZEB);
                } else {
                        /* no swap */
                        memxor(L, hash, HALFSIZE);      
index b2d4227de4a822953e36d7895f2464efc5e44dd1..0adaadec1c209d02876ac8b1fd9f68b51e53d805 100644 (file)
--- a/shabea.h
+++ b/shabea.h
@@ -31,5 +31,5 @@
 #ifndef SHABEA_H_
 #define SHABEA_H_
 
-void shabea256(void * block, void * key, uint16_t keysize, uint8_t enc, uint8_t rounds);
+void shabea256(void * block, void * key, uint16_t keysize_b, uint8_t enc, uint8_t rounds);
 #endif /*SHABEA_H_*/