From: bg Date: Tue, 10 Feb 2009 00:37:51 +0000 (+0000) Subject: updated sha1 X-Git-Url: https://git.cryptolib.org/?a=commitdiff_plain;h=74fe0d1999c8dee4babb971174648da906886874;p=avr-crypto-lib.git updated sha1 --- diff --git a/config.h b/config.h index 21404d4..00d10ef 100644 --- a/config.h +++ b/config.h @@ -19,9 +19,9 @@ #ifndef __CONFIG_H__ #define __CONFIG_H__ #include - -#define F_CPU 16000000 /* Oszillator-Frequenz in Hz */ -// #define F_CPU 14745600 +#define F_CPU 20000000 +// #define F_CPU 16000000 /* Oszillator-Frequenz in Hz */ +// #define F_CPU 14745600 diff --git a/hashfunction_descriptor.h b/hashfunction_descriptor.h index 3440cd0..e1347dc 100644 --- a/hashfunction_descriptor.h +++ b/hashfunction_descriptor.h @@ -15,7 +15,7 @@ typedef void(*hf_nextBlock_fpt)(void*, const void*); typedef void(*hf_lastBlock_fpt)(void*, const void*, uint16_t); typedef void(*hf_ctx2hash_fpt)(void*, void*); typedef void(*hf_free_fpt)(void*); -typedef void(*hf_mem_fpt)(void*, void*, uint32_t); +typedef void(*hf_mem_fpt)(void*, const void*, uint32_t); #define HFDESC_TYPE_HASHFUNCTION 0x02 diff --git a/hfal-basic.c b/hfal-basic.c index b0ec35c..1be95d3 100644 --- a/hfal-basic.c +++ b/hfal-basic.c @@ -88,13 +88,13 @@ void hfal_hash_mem(const hfdesc_t* hash_descriptor, void* dest, const void* msg, } } -uint16_t hfal_hash_getBlocksize(const* hash_descriptor){ +uint16_t hfal_hash_getBlocksize(const hfdesc_t* hash_descriptor){ uint16_t ret; ret = pgm_read_word(&(hash_descriptor->blocksize_b)); return ret; } -uint16_t hfal_hash_getHashsize(const* hash_descriptor){ +uint16_t hfal_hash_getHashsize(const hfdesc_t* hash_descriptor){ uint16_t ret; ret = pgm_read_word(&(hash_descriptor->hashsize_b)); return ret; diff --git a/hfal-basic.h b/hfal-basic.h index b00e46b..7737e05 100644 --- a/hfal-basic.h +++ b/hfal-basic.h @@ -29,7 +29,7 @@ void hfal_hash_lastBlock(hfgen_ctx_t* ctx, const void* block, uint16_t length_b) void hfal_hash_ctx2hash(void* dest, hfgen_ctx_t* ctx); void hfal_hash_free(hfgen_ctx_t* ctx); void hfal_hash_mem(const hfdesc_t* hash_descriptor, void* dest, const void* msg, uint32_t length_b); -uint16_t hfal_hash_getBlocksize(const* hash_descriptor); -uint16_t hfal_hash_getHashsize(const* hash_descriptor); +uint16_t hfal_hash_getBlocksize(const hfdesc_t* hash_descriptor); +uint16_t hfal_hash_getHashsize(const hfdesc_t* hash_descriptor); #endif /* HFAL_BASIC_H_ */ diff --git a/host/get_test.rb b/host/get_test.rb index cfc3b33..2a12de1 100644 --- a/host/get_test.rb +++ b/host/get_test.rb @@ -60,8 +60,9 @@ def readTestVector(param) if(m) fname+=m[1]+"."; end + return false if lb==nil buffer+=lb; - lb = read_line(); + lb = read_line(); end if(param!="") fname+=param+"."; diff --git a/mkfiles/a5_1.mk b/mkfiles/a5_1.mk index d4617f0..1264b31 100644 --- a/mkfiles/a5_1.mk +++ b/mkfiles/a5_1.mk @@ -5,7 +5,7 @@ ALGO_NAME := A51 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 \ +$(ALGO_NAME)_TEST_BIN := main-a5_1-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_stream_test.o nessie_common.o cli.o string-extras.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/aes.mk b/mkfiles/aes.mk index bfb0b8a..950f740 100644 --- a/mkfiles/aes.mk +++ b/mkfiles/aes.mk @@ -7,7 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := aes_enc-asm.o aes_dec-asm.o aes_sbox-asm.o aes_invsbox-asm.o \ aes_keyschedule-asm.o -$(ALGO_NAME)_TEST_BIN := main-aes-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-aes-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/aes_asm_faster.mk b/mkfiles/aes_asm_faster.mk index 6a6079b..75ae39e 100644 --- a/mkfiles/aes_asm_faster.mk +++ b/mkfiles/aes_asm_faster.mk @@ -7,7 +7,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := aes_enc-asm.o aes_dec-asm_faster.o aes_sbox-asm.o aes_invsbox-asm.o \ aes_keyschedule-asm.o -$(ALGO_NAME)_TEST_BIN := main-aes-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-aes-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/aes_c.mk b/mkfiles/aes_c.mk index dcd2240..81da3cb 100644 --- a/mkfiles/aes_c.mk +++ b/mkfiles/aes_c.mk @@ -9,7 +9,7 @@ $(ALGO_NAME)_OBJ := aes_enc.o aes_dec.o aes_sbox.o aes_invsbox.o \ aes_keyschedule.o gf256mul.o \ aes128_enc.o aes128_dec.o aes192_enc.o aes192_dec.o \ aes256_enc.o aes256_dec.o -$(ALGO_NAME)_TEST_BIN := main-aes-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-aes-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/arcfour.mk b/mkfiles/arcfour.mk index 7e8e33b..7c37869 100644 --- a/mkfiles/arcfour.mk +++ b/mkfiles/arcfour.mk @@ -5,7 +5,7 @@ ALGO_NAME := ARCFOUR 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 \ +$(ALGO_NAME)_TEST_BIN := main-arcfour-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_stream_test.o nessie_common.o cli.o string-extras.o \ performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" diff --git a/mkfiles/arcfour_c.mk b/mkfiles/arcfour_c.mk index b349614..33ce65f 100644 --- a/mkfiles/arcfour_c.mk +++ b/mkfiles/arcfour_c.mk @@ -5,7 +5,7 @@ ALGO_NAME := ARCFOUR_C STREAM_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := arcfour.o -$(ALGO_NAME)_TEST_BIN := main-arcfour-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-arcfour-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_stream_test.o nessie_common.o cli.o string-extras.o \ performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" diff --git a/mkfiles/camellia.mk b/mkfiles/camellia.mk index db85f50..4b7974b 100644 --- a/mkfiles/camellia.mk +++ b/mkfiles/camellia.mk @@ -5,7 +5,7 @@ ALGO_NAME := CAMELLIA BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := camellia128-stub.o camellia-asm.o -$(ALGO_NAME)_TEST_BIN := main-camellia-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-camellia-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o \ nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" diff --git a/mkfiles/cast5.mk b/mkfiles/cast5.mk index dacc177..18dd483 100644 --- a/mkfiles/cast5.mk +++ b/mkfiles/cast5.mk @@ -5,7 +5,7 @@ ALGO_NAME := CAST5 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 string-extras.o\ +$(ALGO_NAME)_TEST_BIN := main-cast5-test.o debug.o uart.o hexdigit_tab.o serial-tools.o cli.o string-extras.o\ nessie_bc_test.o nessie_common.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/des.mk b/mkfiles/des.mk index 8e2b162..7a12873 100644 --- a/mkfiles/des.mk +++ b/mkfiles/des.mk @@ -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 \ +$(ALGO_NAME)_TEST_BIN := main-des-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/entropium.mk b/mkfiles/entropium.mk index 2ee6de6..14cc8bd 100644 --- a/mkfiles/entropium.mk +++ b/mkfiles/entropium.mk @@ -5,7 +5,7 @@ ALGO_NAME := ENTROPIUM 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 \ +$(ALGO_NAME)_TEST_BIN := main-entropium-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" diff --git a/mkfiles/grain.mk b/mkfiles/grain.mk index 8d83a81..406bc4d 100644 --- a/mkfiles/grain.mk +++ b/mkfiles/grain.mk @@ -5,7 +5,7 @@ ALGO_NAME := GRAIN STREAM_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := grain.o -$(ALGO_NAME)_TEST_BIN := main-grain-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-grain-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_stream_test.o nessie_common.o cli.o string-extras.o \ performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" diff --git a/mkfiles/hmac-sha1.mk b/mkfiles/hmac-sha1.mk index 428177b..d5bec03 100644 --- a/mkfiles/hmac-sha1.mk +++ b/mkfiles/hmac-sha1.mk @@ -5,7 +5,7 @@ ALGO_NAME := HMAC-SHA1 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 string-extras.o \ +$(ALGO_NAME)_TEST_BIN := main-hmac-sha1-test.o debug.o uart.o hexdigit_tab.o serial-tools.o cli.o string-extras.o \ nessie_mac_test.o nessie_common.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/hmac-sha256.mk b/mkfiles/hmac-sha256.mk index e7ec3d8..adfe48c 100644 --- a/mkfiles/hmac-sha256.mk +++ b/mkfiles/hmac-sha256.mk @@ -5,7 +5,7 @@ ALGO_NAME := HMAC-SHA256 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 \ +$(ALGO_NAME)_TEST_BIN := main-hmac-sha256-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_mac_test.o nessie_common.o cli.o string-extras.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/md5.mk b/mkfiles/md5.mk index de4498b..1d55c1e 100644 --- a/mkfiles/md5.mk +++ b/mkfiles/md5.mk @@ -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 \ +$(ALGO_NAME)_TEST_BIN := main-md5-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_hash_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/md5_asm.mk b/mkfiles/md5_asm.mk index a0603b7..41dcac8 100644 --- a/mkfiles/md5_asm.mk +++ b/mkfiles/md5_asm.mk @@ -5,7 +5,7 @@ ALGO_NAME := MD5_ASM HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := md5-asm.o -$(ALGO_NAME)_TEST_BIN := main-md5-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-md5-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_hash_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/noekeon.mk b/mkfiles/noekeon.mk index db2252b..b3fdccf 100644 --- a/mkfiles/noekeon.mk +++ b/mkfiles/noekeon.mk @@ -6,7 +6,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 \ +$(ALGO_NAME)_TEST_BIN := main-noekeon-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/noekeon_c.mk b/mkfiles/noekeon_c.mk index d69c370..ad0aa59 100644 --- a/mkfiles/noekeon_c.mk +++ b/mkfiles/noekeon_c.mk @@ -6,7 +6,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 \ +$(ALGO_NAME)_TEST_BIN := main-noekeon-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/omac_noekeon.mk b/mkfiles/omac_noekeon.mk index f5a8d0c..d59b22f 100644 --- a/mkfiles/omac_noekeon.mk +++ b/mkfiles/omac_noekeon.mk @@ -6,7 +6,7 @@ MACS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := noekeon_asm.o omac_noekeon.o memxor.o -$(ALGO_NAME)_TEST_BIN := main-omac-noekeon-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-omac-noekeon-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_mac_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/omac_noekeon_c.mk b/mkfiles/omac_noekeon_c.mk index fedd271..efd6e6c 100644 --- a/mkfiles/omac_noekeon_c.mk +++ b/mkfiles/omac_noekeon_c.mk @@ -6,7 +6,7 @@ MACS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := noekeon_asm.o omac_noekeon_C.o memxor.o -$(ALGO_NAME)_TEST_BIN := main-omac-noekeon-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-omac-noekeon-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_mac_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/present.mk b/mkfiles/present.mk index 6a1a614..b60eb81 100644 --- a/mkfiles/present.mk +++ b/mkfiles/present.mk @@ -6,7 +6,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 \ +$(ALGO_NAME)_TEST_BIN := main-present-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/rc5.mk b/mkfiles/rc5.mk index d165950..3852d7b 100644 --- a/mkfiles/rc5.mk +++ b/mkfiles/rc5.mk @@ -6,7 +6,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 \ +$(ALGO_NAME)_TEST_BIN := main-rc5-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o \ nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := test nessie diff --git a/mkfiles/rc6.mk b/mkfiles/rc6.mk index 4f15d03..1b357eb 100644 --- a/mkfiles/rc6.mk +++ b/mkfiles/rc6.mk @@ -6,7 +6,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 \ +$(ALGO_NAME)_TEST_BIN := main-rc6-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := test nessie $(ALGO_NAME)_PERFORMANCE_TEST := performance diff --git a/mkfiles/seed.mk b/mkfiles/seed.mk index 25723b4..a79f78a 100644 --- a/mkfiles/seed.mk +++ b/mkfiles/seed.mk @@ -5,7 +5,7 @@ ALGO_NAME := SEED BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := seed-asm.o -$(ALGO_NAME)_TEST_BIN := main-seed-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-seed-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o \ cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" diff --git a/mkfiles/seed_C.mk b/mkfiles/seed_C.mk index 970c3dd..05fd25d 100644 --- a/mkfiles/seed_C.mk +++ b/mkfiles/seed_C.mk @@ -5,7 +5,7 @@ ALGO_NAME := SEED_C BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := seed_C.o -$(ALGO_NAME)_TEST_BIN := main-seed-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-seed-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o \ cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" diff --git a/mkfiles/serpent-bitslice.mk b/mkfiles/serpent-bitslice.mk index 4fa8936..4d68c22 100644 --- a/mkfiles/serpent-bitslice.mk +++ b/mkfiles/serpent-bitslice.mk @@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := serpent-asm.o serpent-sboxes-bitslice-asm.o memxor.o -$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/serpent_asm_bitslice.mk b/mkfiles/serpent_asm_bitslice.mk index 731bf7b..80e69bf 100644 --- a/mkfiles/serpent_asm_bitslice.mk +++ b/mkfiles/serpent_asm_bitslice.mk @@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := serpent-sboxes-bitslice-asm.o serpent-asm.o memxor.o -$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/serpent_asm_fast.mk b/mkfiles/serpent_asm_fast.mk index b73460f..195f83a 100644 --- a/mkfiles/serpent_asm_fast.mk +++ b/mkfiles/serpent_asm_fast.mk @@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := serpent-asm.o serpent-sboxes-fast.o memxor.o -$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/serpent_asm_small.mk b/mkfiles/serpent_asm_small.mk index c0f5509..46ad45e 100644 --- a/mkfiles/serpent_asm_small.mk +++ b/mkfiles/serpent_asm_small.mk @@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := serpent-asm.o serpent-sboxes-small.o memxor.o -$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/serpent_c.mk b/mkfiles/serpent_c.mk index bc2411f..c6162a7 100644 --- a/mkfiles/serpent_c.mk +++ b/mkfiles/serpent_c.mk @@ -6,7 +6,7 @@ BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := serpent.o serpent-sboxes_c.o memxor.o -$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/sha1.mk b/mkfiles/sha1.mk index ebedba0..335cafb 100644 --- a/mkfiles/sha1.mk +++ b/mkfiles/sha1.mk @@ -5,7 +5,7 @@ ALGO_NAME := SHA1 HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := sha1-asm.o -$(ALGO_NAME)_TEST_BIN := main-sha1-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-sha1-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_hash_test.o nessie_common.o cli.o string-extras.o \ performance_test.o hfal-basic.o hfal_sha1.o shavs.o dump.o $(ALGO_NAME)_NESSIE_TEST := "nessie" diff --git a/mkfiles/sha1_c.mk b/mkfiles/sha1_c.mk index 16d1377..8a141c4 100644 --- a/mkfiles/sha1_c.mk +++ b/mkfiles/sha1_c.mk @@ -5,7 +5,7 @@ ALGO_NAME := SHA1_C HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := sha1.o -$(ALGO_NAME)_TEST_BIN := main-sha1-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-sha1-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_hash_test.o nessie_common.o cli.o string-extras.o \ performance_test.o hfal-basic.o hfal_sha1.o shavs.o dump.o $(ALGO_NAME)_NESSIE_TEST := "nessie" diff --git a/mkfiles/sha256.mk b/mkfiles/sha256.mk index ef14ba4..35c271a 100644 --- a/mkfiles/sha256.mk +++ b/mkfiles/sha256.mk @@ -5,7 +5,7 @@ ALGO_NAME := SHA256 HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := sha256-asm.o -$(ALGO_NAME)_TEST_BIN := main-sha256-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-sha256-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_hash_test.o nessie_common.o cli.o string-extras.o performance_test.o \ hfal-basic.o hfal_sha256.o shavs.o dump.o $(ALGO_NAME)_NESSIE_TEST := "nessie" diff --git a/mkfiles/sha256_c.mk b/mkfiles/sha256_c.mk index ceca8f8..7ad81d0 100644 --- a/mkfiles/sha256_c.mk +++ b/mkfiles/sha256_c.mk @@ -5,7 +5,7 @@ ALGO_NAME := SHA256_C HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := sha256.o -$(ALGO_NAME)_TEST_BIN := main-sha256-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-sha256-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_hash_test.o nessie_common.o cli.o string-extras.o performance_test.o \ hfal-basic.o hfal_sha256.o shavs.o dump.o $(ALGO_NAME)_NESSIE_TEST := "nessie" diff --git a/mkfiles/shabea.mk b/mkfiles/shabea.mk index eb9ff26..29525e6 100644 --- a/mkfiles/shabea.mk +++ b/mkfiles/shabea.mk @@ -5,7 +5,7 @@ ALGO_NAME := SHABEA BLOCK_CIPHERS += $(ALGO_NAME) $(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 \ +$(ALGO_NAME)_TEST_BIN := main-shabea-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/shacal1enc.mk b/mkfiles/shacal1enc.mk index b4a99ab..0bccab1 100644 --- a/mkfiles/shacal1enc.mk +++ b/mkfiles/shacal1enc.mk @@ -6,7 +6,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 \ +$(ALGO_NAME)_TEST_BIN := main-shacal1_enc-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/shacal2enc.mk b/mkfiles/shacal2enc.mk index 77f0334..0265b10 100644 --- a/mkfiles/shacal2enc.mk +++ b/mkfiles/shacal2enc.mk @@ -6,7 +6,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 \ +$(ALGO_NAME)_TEST_BIN := main-shacal2_enc-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/skipjack.mk b/mkfiles/skipjack.mk index e0db90b..e546ea3 100644 --- a/mkfiles/skipjack.mk +++ b/mkfiles/skipjack.mk @@ -5,7 +5,7 @@ ALGO_NAME := SKIPJACK BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := skipjack.o -$(ALGO_NAME)_TEST_BIN := main-skipjack-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-skipjack-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o \ performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" diff --git a/mkfiles/tdes.mk b/mkfiles/tdes.mk index 898b7c2..4e03c9f 100644 --- a/mkfiles/tdes.mk +++ b/mkfiles/tdes.mk @@ -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 \ +$(ALGO_NAME)_TEST_BIN := main-tdes-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/trivium.mk b/mkfiles/trivium.mk index 79cfeb6..4f4f0ef 100644 --- a/mkfiles/trivium.mk +++ b/mkfiles/trivium.mk @@ -5,7 +5,7 @@ ALGO_NAME := TRIVIUM STREAM_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := trivium.o -$(ALGO_NAME)_TEST_BIN := main-trivium-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-trivium-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_stream_test.o nessie_common.o cli.o string-extras.o \ performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" diff --git a/mkfiles/twister224.mk b/mkfiles/twister224.mk index 65b7851..d57e00d 100644 --- a/mkfiles/twister224.mk +++ b/mkfiles/twister224.mk @@ -5,7 +5,7 @@ ALGO_NAME := TWISTER224 HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := twister-small-asm.o twister-asm.o twister224.o -$(ALGO_NAME)_TEST_BIN := main-twister224-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-twister224-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_hash_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/twister224_c.mk b/mkfiles/twister224_c.mk index 5e5f0e7..6ea6ad6 100644 --- a/mkfiles/twister224_c.mk +++ b/mkfiles/twister224_c.mk @@ -5,7 +5,7 @@ ALGO_NAME := TWISTER224_C HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := twister.o twister-small.o memxor.o gf256mul.o -$(ALGO_NAME)_TEST_BIN := main-twister224-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-twister224-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_hash_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/twister256.mk b/mkfiles/twister256.mk index a95aeaa..8bd3ff8 100644 --- a/mkfiles/twister256.mk +++ b/mkfiles/twister256.mk @@ -5,7 +5,7 @@ ALGO_NAME := TWISTER256 HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := twister-asm.o twister-small-asm.o twister256.o -$(ALGO_NAME)_TEST_BIN := main-twister256-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-twister256-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_hash_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/twister256_c.mk b/mkfiles/twister256_c.mk index e9cac66..39d2829 100644 --- a/mkfiles/twister256_c.mk +++ b/mkfiles/twister256_c.mk @@ -5,7 +5,7 @@ ALGO_NAME := TWISTER256_C HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := twister.o twister-small.o memxor.o gf256mul.o -$(ALGO_NAME)_TEST_BIN := main-twister256-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-twister256-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_hash_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/twister384.mk b/mkfiles/twister384.mk index ef04aa8..dcc4013 100644 --- a/mkfiles/twister384.mk +++ b/mkfiles/twister384.mk @@ -5,7 +5,7 @@ ALGO_NAME := TWISTER384 HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := twister-asm.o twister-big-asm.o twister384.o -$(ALGO_NAME)_TEST_BIN := main-twister384-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-twister384-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_hash_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/twister384_c.mk b/mkfiles/twister384_c.mk index 247d4d9..3358dec 100644 --- a/mkfiles/twister384_c.mk +++ b/mkfiles/twister384_c.mk @@ -5,7 +5,7 @@ ALGO_NAME := TWISTER384_C HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := twister.o twister-big.o memxor.o gf256mul.o -$(ALGO_NAME)_TEST_BIN := main-twister384-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-twister384-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_hash_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/twister512.mk b/mkfiles/twister512.mk index 0d7455b..acd7bab 100644 --- a/mkfiles/twister512.mk +++ b/mkfiles/twister512.mk @@ -5,7 +5,7 @@ ALGO_NAME := TWISTER512 HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := twister-asm.o twister-big-asm.o twister512.o -$(ALGO_NAME)_TEST_BIN := main-twister512-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-twister512-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_hash_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/twister512_c.mk b/mkfiles/twister512_c.mk index 07ce27a..75b23e0 100644 --- a/mkfiles/twister512_c.mk +++ b/mkfiles/twister512_c.mk @@ -5,7 +5,7 @@ ALGO_NAME := TWISTER512_C HASHES += $(ALGO_NAME) $(ALGO_NAME)_OBJ := twister.o twister-big.o memxor.o gf256mul.o -$(ALGO_NAME)_TEST_BIN := main-twister512-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-twister512-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_hash_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/xtea.mk b/mkfiles/xtea.mk index bfe5f17..01dcedf 100644 --- a/mkfiles/xtea.mk +++ b/mkfiles/xtea.mk @@ -5,7 +5,7 @@ ALGO_NAME := XTEA 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 \ +$(ALGO_NAME)_TEST_BIN := main-xtea-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/mkfiles/xtea_c.mk b/mkfiles/xtea_c.mk index 6d88540..b5b59b7 100644 --- a/mkfiles/xtea_c.mk +++ b/mkfiles/xtea_c.mk @@ -5,7 +5,7 @@ ALGO_NAME := XTEA_C BLOCK_CIPHERS += $(ALGO_NAME) $(ALGO_NAME)_OBJ := xtea.o -$(ALGO_NAME)_TEST_BIN := main-xtea-test.o debug.o uart.o serial-tools.o \ +$(ALGO_NAME)_TEST_BIN := main-xtea-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \ nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o $(ALGO_NAME)_NESSIE_TEST := "nessie" $(ALGO_NAME)_PERFORMANCE_TEST := "performance" diff --git a/sha1-asm.S b/sha1-asm.S index 74d7c11..577d9e8 100644 --- a/sha1-asm.S +++ b/sha1-asm.S @@ -799,10 +799,13 @@ sha1_nextBlock_KTable: .int 0x8f1bbcdc .int 0xca62c1d6 sha1_nextBlock_JumpTable: -jmp sha1_nextBlock_Ch -jmp sha1_nextBlock_Parity -jmp sha1_nextBlock_Maj -jmp sha1_nextBlock_Parity +rjmp sha1_nextBlock_Ch + nop +rjmp sha1_nextBlock_Parity + nop +rjmp sha1_nextBlock_Maj + nop +rjmp sha1_nextBlock_Parity /* X and Y still point at a[1] aka b ; return value in tmp1 */ sha1_nextBlock_Ch: @@ -814,13 +817,6 @@ sha1_nextBlock_Ch: ldd tmp3, Y+7 /* load from d */ and tmp2, tmp3 eor tmp1, tmp2 - /** - precall - ldi r24, lo8(ch_str) - ldi r25, hi8(ch_str) - call uart_putstr_P - postcall - /**/ ret sha1_nextBlock_Maj: @@ -833,13 +829,6 @@ sha1_nextBlock_Maj: eor tmp1, tmp2 and tmp3, tmp4 eor tmp1, tmp3 - /** - precall - ldi r24, lo8(maj_str) - ldi r25, hi8(maj_str) - call uart_putstr_P - postcall - /**/ ret sha1_nextBlock_Parity: @@ -848,14 +837,6 @@ sha1_nextBlock_Parity: eor tmp1, tmp2 ldd tmp2, Y+7 /* load from d */ eor tmp1, tmp2 - - /** - precall - ldi r24, lo8(parity_str) - ldi r25, hi8(parity_str) - call uart_putstr_P - postcall - /**/ ret /* ch_str: .asciz "\r\nCh" diff --git a/test_src/cli.c b/test_src/cli.c index 12f4a0a..68d6cf6 100644 --- a/test_src/cli.c +++ b/test_src/cli.c @@ -34,6 +34,7 @@ #include "string-extras.h" #include "cli.h" #include "config.h" +#include "hexdigit_tab.h" cli_rx_fpt cli_rx = NULL; cli_tx_fpt cli_tx = NULL; @@ -126,34 +127,43 @@ uint8_t cli_getsn(char* s, uint16_t n){ * will have 2*n continous hexadecimal characters. */ void cli_hexdump(void* data, uint16_t length){ - char hex_tab[] = {'0', '1', '2', '3', - '4', '5', '6', '7', - '8', '9', 'A', 'B', - 'C', 'D', 'E', 'F'}; if(!cli_tx) return; while(length--){ - cli_tx(hex_tab[(*((uint8_t*)data))>>4]); - cli_tx(hex_tab[(*((uint8_t*)data))&0xf]); + cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))>>4))); + cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))&0xf))); data = (uint8_t*)data +1; } } +/** + * \brief dumps the contents of a buffer to the console + * This function behaves like cli_hexdump except that the + * bytes are dumped in reverse order. This is usefull to dump + * integers which ar e in little endian order. + */ +void cli_hexdump_rev(void* data, uint16_t length){ + if(!cli_tx) + return; + data = (uint8_t*)data + length -1; + while(length--){ + cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))>>4))); + cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))&0xf))); + data = (uint8_t*)data -1; + } +} + /** * \brief dumps the contents of a buffer to the console * Like cli_hexdump but bytes are seperated with a single space * on the console output. */ void cli_hexdump2(void* data, uint16_t length){ - char hex_tab[] = {'0', '1', '2', '3', - '4', '5', '6', '7', - '8', '9', 'A', 'B', - 'C', 'D', 'E', 'F'}; if(!cli_tx) return; while(length--){ - cli_tx(hex_tab[(*((uint8_t*)data))>>4]); - cli_tx(hex_tab[(*((uint8_t*)data))&0xf]); + cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))>>4))); + cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))&0xf))); cli_tx(' '); data = (uint8_t*)data +1; } @@ -193,7 +203,7 @@ void cli_auto_help(uint16_t maxcmdlength, PGM_VOID_P cmdlist){ cli_putstr_P(PSTR(" \t- 0x")); } } - cli_hexdump(&item.cmd_function, 2); + cli_hexdump_rev(&item.cmd_function, 2); cli_putstr_P(PSTR("\r\n")); } } diff --git a/test_src/cli.h b/test_src/cli.h index 018c4da..3156d7e 100644 --- a/test_src/cli.h +++ b/test_src/cli.h @@ -60,6 +60,7 @@ uint8_t cli_getsn(char* s, uint16_t n); void cli_putstr(char* s); void cli_putstr_P(PGM_P s); void cli_hexdump(void* data, uint16_t length); +void cli_hexdump_rev(void* data, uint16_t length); void cli_hexdump2(void* data, uint16_t length); void echo_ctrl(char* s); int8_t cmd_interface(PGM_VOID_P cmd_desc); diff --git a/test_src/uart.c b/test_src/uart.c index 06b3cec..0c9943c 100644 --- a/test_src/uart.c +++ b/test_src/uart.c @@ -23,7 +23,7 @@ #include #include #include - +#include "hexdigit_tab.h" #include "uart.h" #ifdef ATMEGA128 @@ -279,11 +279,9 @@ void uart_putstr_P(PGM_P 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(pgm_read_byte(hexdigit_tab_P + ((*((uint8_t*)buf))>>4))); + uart_putc(pgm_read_byte(hexdigit_tab_P + ((*((uint8_t*)buf))&0xf))); uart_putc(' '); buf=(uint8_t*)buf+1; }