]> git.cryptolib.org Git - avr-crypto-lib.git/commitdiff
unifoming omac nameing; +auto help
authorbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Wed, 27 Aug 2008 03:21:27 +0000 (03:21 +0000)
committerbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Wed, 27 Aug 2008 03:21:27 +0000 (03:21 +0000)
Makefile
config.h
omac_noekeon.h
test_src/cli.c
test_src/main-omac-noekeon-test.c

index 6a0e04dc1287bffd72a4f75f40f98de1bfa15688..57abdad406c1e7b32247567ef4b6bda16b0709ed 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -164,7 +164,11 @@ define LISTING_TEMPLATE
 $(1)_LIST: $(2)
 endef
 
-$(foreach algo, $(ALGORITHMS),$(eval $(call LISTING_TEMPLATE,$(call uc, $(algo)), $(patsubst %.o,%.lst,$(algo)_OBJ) )))
+$(foreach algo, $(ALGORITHMS),$(eval $(call LISTING_TEMPLATE,$(call uc, $(algo)), \
+ $(patsubst %,$(LIST_DIR)%, \
+  $(patsubst $(BIN_DIR)%,%, \
+  $(patsubst $(TESTBIN_DIR)%,%, \
+  $(patsubst %.o,%.lst,$($(algo)_OBJ)))) ))))
 
 listings: $(patsubst %,%_LIST,$(ALGORITHMS))
 
index a4624a67c4efa3230f67ac4a7d84906dd135a37f..06548bdf2675a4b878cd88f5f0a60d0ea393b5c2 100644 (file)
--- a/config.h
+++ b/config.h
@@ -43,5 +43,7 @@
 
 //#define ATMEGA644 /* this is now done by make */
 
+#define CLI_AUTO_HELP 
+
 #endif
 
index a5c73d2407288cc31f4bf660a978098d9c104be5..6f1e4014c6006e716cdc71e8318c0164b0184cc2 100644 (file)
@@ -4,14 +4,14 @@
 #include "noekeon.h"
 #include <stdint.h>
 
-typedef uint8_t noekeon_omac_ctx_t[16];
+typedef uint8_t omac_noekeon_ctx_t[16];
 
-void omac_noekeon_init(noekeon_omac_ctx_t* ctx);
-void omac_noekeont_tweak(uint8_t t, const void* key, noekeon_omac_ctx_t* ctx);
+void omac_noekeon_init(omac_noekeon_ctx_t* ctx);
+void omac_noekeont_tweak(uint8_t t, const void* key, omac_noekeon_ctx_t* ctx);
 void omac_noekeon_next(const void* buffer, const void* key, 
-                       noekeon_omac_ctx_t* ctx);
+                       omac_noekeon_ctx_t* ctx);
 void omac_noekeon_last(const void* buffer, uint8_t length_b, const void* key, 
-                       noekeon_omac_ctx_t* ctx);
+                       omac_noekeon_ctx_t* ctx);
 void omac_noekeon(void* dest, const void* msg, uint16_t msglength_b,
                   const void* key, uint8_t t);
 
index 8c15f5fb4e58e256873e007ce86b09432f07d897..f01547d03ddf07200e9d0f5c9f7db005530437b6 100644 (file)
@@ -29,6 +29,7 @@
 #include <stdint.h>
 #include <string.h>
 #include <avr/pgmspace.h>
+#include "config.h"
 
 int16_t findstring_d0(const char* str, const char* v){
        uint8_t i=0;
@@ -56,8 +57,26 @@ int16_t findstring_d0_P(const char* str, PGM_P v){
        return -1;
 } 
 
+#ifdef CLI_AUTO_HELP
+#include "uart.h"
+
+void cli_auto_help_P(PGM_P dbzstr){
+       char c;
+       uart_putstr_P(PSTR("\r\n[auto help] available commands are:\r\n\t"));
+       do{
+               while((c=pgm_read_byte(dbzstr++))!=0){
+                       uart_putc(c);
+               }
+               uart_putstr_P(PSTR("\r\n\t"));
+       }while((c=pgm_read_byte(dbzstr))!=0);
+       uart_putstr_P(PSTR("\r\n"));
+}
+
+#endif
+
 int16_t execcommand_d0_P(const char* str, PGM_P v, void(*fpt[])(void) ){
        uint8_t i=0;
+       PGM_P commands=v;
        while(pgm_read_byte(v)){        
                if(!strcmp_P(str, v)){
                        (fpt[i])();
@@ -67,6 +86,7 @@ int16_t execcommand_d0_P(const char* str, PGM_P v, void(*fpt[])(void) ){
                ;
                ++i;
        }
+       cli_auto_help_P(commands);
        return -1;
 }
 
index 2ec240813ee246be095668aaec4da65bcbdf1f11..c34d675712774f16896647c57b638f264fdfaf83 100644 (file)
@@ -31,7 +31,9 @@
 
 #include "cli.h"
 #include "nessie_mac_test.h"
+#include "performance_test.h"
 
+#include <stdlib.h>
 #include <stdint.h>
 #include <string.h>
 
@@ -56,7 +58,7 @@ void test_mac(void* key, void* data, uint16_t datalength_b){
        
 }
 
-void testrun_test_noekeonomac(void){
+void testrun_test_omac_noekeon(void){
        uint8_t key[16], data[64];
        uint16_t i;
        memset(key,  0xAA, 16);
@@ -70,16 +72,16 @@ void testrun_test_noekeonomac(void){
 
 uint8_t stat_key[16];
 
-void noekeonomac_next_dummy(void* buffer, void* ctx){
+void omac_noekeon_next_dummy(void* buffer, void* ctx){
        omac_noekeon_next(buffer, stat_key, ctx);
 }
 
-void noekeonomac_init_dummy(void* key, uint16_t keysize_b, void* ctx){
+void omac_noekeon_init_dummy(void* key, uint16_t keysize_b, void* ctx){
        omac_noekeon_init(ctx);
        memcpy(stat_key, key, 16);
 }
 
-void noekeonomac_last_dummy(void* buffer, uint16_t size_b, void* key, uint16_t keysize_b, void* ctx){
+void omac_noekeon_last_dummy(void* buffer, uint16_t size_b, void* key, uint16_t keysize_b, void* ctx){
        while(size_b>128){
                omac_noekeon_next(buffer, key, ctx);
                size_b -= 128;
@@ -88,26 +90,63 @@ void noekeonomac_last_dummy(void* buffer, uint16_t size_b, void* key, uint16_t k
        omac_noekeon_last(buffer, size_b, key, ctx);
 }
 
-void noekeonomac_conv_dummy(void* buffer, void* ctx){
+void omac_noekeon_conv_dummy(void* buffer, void* ctx){
        memcpy(buffer, ctx, 16);
 }
 
-void testrun_nessie_noekeonomac(void){
+void testrun_nessie_omac_noekeon(void){
        nessie_mac_ctx.macsize_b   = 128;
        nessie_mac_ctx.keysize_b   = 128;
        nessie_mac_ctx.blocksize_B = 16;
-       nessie_mac_ctx.ctx_size_B  = sizeof(noekeon_omac_ctx_t);
+       nessie_mac_ctx.ctx_size_B  = sizeof(omac_noekeon_ctx_t);
        nessie_mac_ctx.name = algo_name;
-       nessie_mac_ctx.mac_init = noekeonomac_init_dummy;
-       nessie_mac_ctx.mac_next = noekeonomac_next_dummy;
-       nessie_mac_ctx.mac_last = noekeonomac_last_dummy;
-       nessie_mac_ctx.mac_conv = noekeonomac_conv_dummy;
+       nessie_mac_ctx.mac_init = omac_noekeon_init_dummy;
+       nessie_mac_ctx.mac_next = omac_noekeon_next_dummy;
+       nessie_mac_ctx.mac_last = omac_noekeon_last_dummy;
+       nessie_mac_ctx.mac_conv = omac_noekeon_conv_dummy;
        
        nessie_mac_run();
 }
 
+/******************************************************************************/
 
-
+void testrun_performance_omac_noekeon(void){
+       uint64_t t;
+       char str[16];
+       uint8_t data[16], key[16];
+       omac_noekeon_ctx_t ctx;
+       
+       calibrateTimer();
+       print_overhead();
+       
+       memset(data, 0, 16);
+       memset(key,  0, 16);
+       
+       startTimer(1);
+       omac_noekeon_init(&ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       omac_noekeon_next(data, key, &ctx);
+       t = stopTimer();
+       uart_putstr_P(PSTR("\r\n\tone-block time: "));
+       ultoa((unsigned long)t, str, 10);
+       uart_putstr(str);
+       
+       
+       startTimer(1);
+       omac_noekeon_last(data, 128, key, &ctx);
+       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                                                                                                                                        *
@@ -122,8 +161,10 @@ int main (void){
        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_noekeonomac, testrun_test_noekeonomac};
+       PGM_P    u   = PSTR("nessie\0test\0performance\0");
+       void_fpt v[] = {testrun_nessie_omac_noekeon, 
+                           testrun_test_omac_noekeon,
+                           testrun_performance_omac_noekeon};
 
        while(1){ 
                if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;}