From bce0505abf49276430f7439960829683b4daf53b Mon Sep 17 00:00:00 2001 From: bg Date: Thu, 14 May 2009 14:28:59 +0000 Subject: [PATCH] moved twister naming from big to large --- hfal_twister384.c | 2 +- hfal_twister512.c | 2 +- mkfiles/twister.mk | 2 +- mkfiles/twister_c.mk | 2 +- test_src/main-twister-test.c | 1 + twister-asm.S | 4 +- twister-big-asm.S => twister-large-asm.S | 30 ++++++------- twister-big.c => twister-large.c | 56 ++++++++++++------------ twister-big.h => twister-large.h | 22 +++++----- twister384.S | 8 ++-- twister512.S | 8 ++-- 11 files changed, 69 insertions(+), 68 deletions(-) rename twister-big-asm.S => twister-large-asm.S (92%) rename twister-big.c => twister-large.c (81%) rename twister-big.h => twister-large.h (66%) diff --git a/hfal_twister384.c b/hfal_twister384.c index de97177..888078e 100644 --- a/hfal_twister384.c +++ b/hfal_twister384.c @@ -28,7 +28,7 @@ #include #include #include "hashfunction_descriptor.h" -#include "twister-big.h" +#include "twister-large.h" static const char twister384_str[] PROGMEM = "Twister-384"; diff --git a/hfal_twister512.c b/hfal_twister512.c index f672344..4f6e7b0 100644 --- a/hfal_twister512.c +++ b/hfal_twister512.c @@ -28,7 +28,7 @@ #include #include #include "hashfunction_descriptor.h" -#include "twister-big.h" +#include "twister-large.h" static const char twister512_str[] PROGMEM = "Twister-512"; diff --git a/mkfiles/twister.mk b/mkfiles/twister.mk index 24fc9bc..f6196ef 100644 --- a/mkfiles/twister.mk +++ b/mkfiles/twister.mk @@ -4,7 +4,7 @@ ALGO_NAME := TWISTER # comment out the following line for removement of TWISTER from the build process HASHES += $(ALGO_NAME) -$(ALGO_NAME)_OBJ := twister-small-asm.o twister-big-asm.o twister-asm.o \ +$(ALGO_NAME)_OBJ := twister-small-asm.o twister-large-asm.o twister-asm.o \ twister224.o twister256.o twister384.o twister512.o $(ALGO_NAME)_TEST_BIN := main-twister-test.o hfal_twister224.o hfal_twister256.o \ hfal_twister384.o hfal_twister512.o $(CLI_STD) $(HFAL_STD) diff --git a/mkfiles/twister_c.mk b/mkfiles/twister_c.mk index 11eeca1..7d6ec36 100644 --- a/mkfiles/twister_c.mk +++ b/mkfiles/twister_c.mk @@ -4,7 +4,7 @@ ALGO_NAME := TWISTER_C # comment out the following line for removement of TWISTER from the build process HASHES += $(ALGO_NAME) -$(ALGO_NAME)_OBJ := twister.o twister-small.o twister-big.o memxor.o gf256mul.o +$(ALGO_NAME)_OBJ := twister.o twister-small.o twister-large.o memxor.o gf256mul.o $(ALGO_NAME)_TEST_BIN := main-twister-test.o hfal_twister224.o hfal_twister256.o \ hfal_twister384.o hfal_twister512.o $(CLI_STD) $(HFAL_STD) $(ALGO_NAME)_NESSIE_TEST := "nessie" diff --git a/test_src/main-twister-test.c b/test_src/main-twister-test.c index 794c054..505bbaf 100644 --- a/test_src/main-twister-test.c +++ b/test_src/main-twister-test.c @@ -27,6 +27,7 @@ #include "debug.h" #include "twister-small.h" +#include "twister-large.h" #include "nessie_hash_test.h" #include "performance_test.h" #include "hfal_twister224.h" diff --git a/twister-asm.S b/twister-asm.S index 7ae3842..746ea09 100644 --- a/twister-asm.S +++ b/twister-asm.S @@ -301,7 +301,7 @@ TMP_SAVE1 = 17 .global twister_ctx2hash .global twister_small_ctx2hash -.global twister_big_ctx2hash +.global twister_large_ctx2hash .global twister224_ctx2hash .global twister256_ctx2hash .global twister384_ctx2hash @@ -327,7 +327,7 @@ twister512_ctx2hash: ldi r21, hi8(512) ; rjmp twister_ctx2hash -twister_big_ctx2hash: +twister_large_ctx2hash: twister_small_ctx2hash: twister_ctx2hash: push_range 10, 17 diff --git a/twister-big-asm.S b/twister-large-asm.S similarity index 92% rename from twister-big-asm.S rename to twister-large-asm.S index a274cf4..be10546 100644 --- a/twister-big-asm.S +++ b/twister-large-asm.S @@ -1,4 +1,4 @@ -/* twister-big-asm.S */ +/* twister-large-asm.S */ /* This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) @@ -17,7 +17,7 @@ along with this program. If not, see . */ /** - * \file twister-big-asm.S + * \file twister-large-asm.S * \email daniel.otte@rub.de * \author Daniel Otte * \date 2008-12-27 @@ -27,7 +27,7 @@ #include "avr-asm-macros.S" -/* void checksum_update(twister_big_ctx_t* ctx, uint8_t col) */ +/* void checksum_update(twister_large_ctx_t* ctx, uint8_t col) */ /* * param ctx: r24:r25 * param col: r22 @@ -117,7 +117,7 @@ checksum_update: ret /*********************************************************************/ -/* void twister_big_init(twister_big_ctx_t* ctx, uint16_t hashsize_b)*/ +/* void twister_large_init(twister_large_ctx_t* ctx, uint16_t hashsize_b)*/ /* * param ctx: r24:r25 * param hashsize_b: r22:r23 @@ -126,15 +126,15 @@ checksum_update: twister384_init: ldi r22, lo8(384) ldi r23, hi8(384) - rjmp twister_big_init + rjmp twister_large_init .global twister512_init twister512_init: ldi r22, lo8(512) ldi r23, hi8(512) -.global twister_big_init -twister_big_init: +.global twister_large_init +twister_large_init: movw r30, r24 ldi r24, 64 1: @@ -163,7 +163,7 @@ twister_big_init: ret /*********************************************************************/ -/* void twister_big_nextBlock(twister_state_t* ctx, void* msg) */ +/* void twister_large_nextBlock(twister_state_t* ctx, void* msg) */ /* * param ctx: r24:r25 * param msg: r22:r23 @@ -174,13 +174,13 @@ TMP_SAVE0 = 12 TMP_SAVE1 = 13 MSG_SAVE0 = 28 MSG_SAVE1 = 29 -.global twister_big_nextBlock +.global twister_large_nextBlock .global twister384_nextBlock .global twister512_nextBlock twister384_nextBlock: twister512_nextBlock: -twister_big_nextBlock: +twister_large_nextBlock: push_range 12, 15 push r28 push r29 @@ -350,7 +350,7 @@ twister_big_nextBlock: ret /*********************************************************************/ -/* void twister_big_lastBlock(twister_state_t* ctx, void* msg, uint16_t length_b) */ +/* void twister_large_lastBlock(twister_state_t* ctx, void* msg, uint16_t length_b) */ /* * param ctx: r24:r25 * param msg: r22:r23 @@ -364,13 +364,13 @@ LEN_SAVE0 = 16 LEN_SAVE1 = 17 MSG_SAVE0 = 28 MSG_SAVE1 = 29 -.global twister_big_lastBlock +.global twister_large_lastBlock .global twister384_lastBlock .global twister512_lastBlock twister384_lastBlock: twister512_lastBlock: -twister_big_lastBlock: +twister_large_lastBlock: push_range 12, 17 push r28 push r29 @@ -385,7 +385,7 @@ twister_big_lastBlock: brmi 2f movw r24, CTX_SAVE0 movw r22, MSG_SAVE0 - rcall twister_big_nextBlock + rcall twister_large_nextBlock adiw MSG_SAVE0, 8 subi LEN_SAVE1, 2 rjmp 1b @@ -433,7 +433,7 @@ twister_big_lastBlock: 7: movw r24, CTX_SAVE0 movw r22, TMP_SAVE0 - rcall twister_big_nextBlock + rcall twister_large_nextBlock ldi r19, 2 clr r18 diff --git a/twister-big.c b/twister-large.c similarity index 81% rename from twister-big.c rename to twister-large.c index 1c0c56f..1775488 100644 --- a/twister-big.c +++ b/twister-large.c @@ -1,4 +1,4 @@ -/* twister-big.c */ +/* twister-large.c */ /* This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) @@ -21,12 +21,12 @@ #include #include "memxor.h" #include "twister.h" -#include "twister-big.h" +#include "twister-large.h" /*********************************************************************/ static -void checksum_update(twister_big_ctx_t* ctx, uint8_t col){ +void checksum_update(twister_large_ctx_t* ctx, uint8_t col){ uint8_t i, col2; uint8_t carry = 0; int sum = 0; @@ -46,7 +46,7 @@ void checksum_update(twister_big_ctx_t* ctx, uint8_t col){ /*********************************************************************/ -void twister_big_init(twister_big_ctx_t* ctx, uint16_t hashsize_b){ +void twister_large_init(twister_large_ctx_t* ctx, uint16_t hashsize_b){ memset(ctx->state.s, 0, 64); memset(ctx->checksum, 0, 64); ctx->state.counter=0xffffffffffffffffLL; @@ -57,7 +57,7 @@ void twister_big_init(twister_big_ctx_t* ctx, uint16_t hashsize_b){ /*********************************************************************/ -void twister_big_nextBlock(twister_big_ctx_t* ctx, const void* msg){ +void twister_large_nextBlock(twister_large_ctx_t* ctx, const void* msg){ uint8_t tmp[8][8]; /* 1st maxi round */ @@ -108,24 +108,24 @@ void twister_big_nextBlock(twister_big_ctx_t* ctx, const void* msg){ /*********************************************************************/ -void twister_inject_chksum(twister_big_ctx_t* ctx, uint8_t col){ +void twister_inject_chksum(twister_large_ctx_t* ctx, uint8_t col){ *((uint64_t*)(&ctx->state.s[7][0])) ^= *((uint64_t*)(&ctx->checksum[col][0])); twister_blank_round(&ctx->state); } /*********************************************************************/ -void twister_big_lastBlock(twister_big_ctx_t* ctx, const void* msg, uint16_t length_b){ +void twister_large_lastBlock(twister_large_ctx_t* ctx, const void* msg, uint16_t length_b){ uint8_t tmp[64]; while(length_b>=512){ - twister_big_nextBlock(ctx, msg); + twister_large_nextBlock(ctx, msg); msg = ((uint8_t*)msg)+64; length_b -= 512; } memset(tmp, 0, 64); memcpy(tmp, msg, (length_b+7)/8); tmp[length_b/8] |= 0x80 >> (length_b&0x07); - twister_big_nextBlock(ctx, tmp); + twister_large_nextBlock(ctx, tmp); ctx->state.length_counter_b -= 512 - length_b; twister_mini_round(&(ctx->state), &(ctx->state.length_counter_b)); @@ -151,7 +151,7 @@ void twister_big_lastBlock(twister_big_ctx_t* ctx, const void* msg, uint16_t len /*********************************************************************/ -void twister_big_ctx2hash(void* dest, twister_big_ctx_t* ctx, uint16_t hashsize_b){ +void twister_large_ctx2hash(void* dest, twister_large_ctx_t* ctx, uint16_t hashsize_b){ twister_ctx2hash(dest, &(ctx->state), hashsize_b); } @@ -159,39 +159,39 @@ void twister_big_ctx2hash(void* dest, twister_big_ctx_t* ctx, uint16_t hashsize_ /*********************************************************************/ void twister384_init(twister384_ctx_t* ctx){ - twister_big_init(ctx, 384); + twister_large_init(ctx, 384); } /*********************************************************************/ void twister384_nextBlock(twister384_ctx_t* ctx, const void* msg){ - twister_big_nextBlock(ctx, msg); + twister_large_nextBlock(ctx, msg); } /*********************************************************************/ void twister384_lastBlock(twister384_ctx_t* ctx, const void* msg, uint16_t length_b){ - twister_big_lastBlock(ctx, msg, length_b); + twister_large_lastBlock(ctx, msg, length_b); } /*********************************************************************/ void twister384_ctx2hash(void* dest, twister384_ctx_t* ctx){ - twister_big_ctx2hash(dest, ctx, 384); + twister_large_ctx2hash(dest, ctx, 384); } /*********************************************************************/ void twister384(void* dest, const void* msg, uint32_t msg_length_b){ - twister_big_ctx_t ctx; - twister_big_init(&ctx, 384); + twister_large_ctx_t ctx; + twister_large_init(&ctx, 384); while(msg_length_b >=512){ - twister_big_nextBlock(&ctx, msg); + twister_large_nextBlock(&ctx, msg); msg = (uint8_t*)msg + 512/8; msg_length_b -= 512; } - twister_big_lastBlock(&ctx, msg, msg_length_b); - twister_big_ctx2hash(dest, &ctx, 384); + twister_large_lastBlock(&ctx, msg, msg_length_b); + twister_large_ctx2hash(dest, &ctx, 384); } /*********************************************************************/ @@ -199,39 +199,39 @@ void twister384(void* dest, const void* msg, uint32_t msg_length_b){ void twister512_init(twister512_ctx_t* ctx){ - twister_big_init(ctx, 512); + twister_large_init(ctx, 512); } /*********************************************************************/ void twister512_nextBlock(twister512_ctx_t* ctx, const void* msg){ - twister_big_nextBlock(ctx, msg); + twister_large_nextBlock(ctx, msg); } /*********************************************************************/ void twister512_lastBlock(twister512_ctx_t* ctx, const void* msg, uint16_t length_b){ - twister_big_lastBlock(ctx, msg, length_b); + twister_large_lastBlock(ctx, msg, length_b); } /*********************************************************************/ void twister512_ctx2hash(void* dest, twister512_ctx_t* ctx){ - twister_big_ctx2hash(dest, ctx, 512); + twister_large_ctx2hash(dest, ctx, 512); } /*********************************************************************/ void twister512(void* dest, const void* msg, uint32_t msg_length_b){ - twister_big_ctx_t ctx; - twister_big_init(&ctx, 512); + twister_large_ctx_t ctx; + twister_large_init(&ctx, 512); while(msg_length_b >=512){ - twister_big_nextBlock(&ctx, msg); + twister_large_nextBlock(&ctx, msg); msg = (uint8_t*)msg + 512/8; msg_length_b -= 512; } - twister_big_lastBlock(&ctx, msg, msg_length_b); - twister_big_ctx2hash(dest, &ctx, 512); + twister_large_lastBlock(&ctx, msg, msg_length_b); + twister_large_ctx2hash(dest, &ctx, 512); } diff --git a/twister-big.h b/twister-large.h similarity index 66% rename from twister-big.h rename to twister-large.h index b10c0f0..45de18b 100644 --- a/twister-big.h +++ b/twister-large.h @@ -1,7 +1,7 @@ -/* twister-big.h */ +/* twister-large.h */ -#ifndef TWISTER_BIG_H_ -#define TWISTER_BIG_H_ +#ifndef TWISTER_large_H_ +#define TWISTER_large_H_ #include #include "twister.h" @@ -12,17 +12,17 @@ typedef uint8_t twister512_hash_t[512/8]; typedef struct { twister_state_t state; twister_checksum_t checksum; -} twister_big_ctx_t; +} twister_large_ctx_t; -typedef twister_big_ctx_t twister384_ctx_t; -typedef twister_big_ctx_t twister512_ctx_t; +typedef twister_large_ctx_t twister384_ctx_t; +typedef twister_large_ctx_t twister512_ctx_t; /*********************************************************************/ -void twister_big_nextBlock(twister_big_ctx_t* ctx, const void* msg); -void twister_big_init(twister_big_ctx_t* ctx, uint16_t hashsize_b); -void twister_big_lastBlock(twister_big_ctx_t* ctx, const void* msg, uint16_t length_b); -void twister_big_ctx2hash(void* dest, twister_big_ctx_t* ctx, uint16_t hashsize_b); +void twister_large_nextBlock(twister_large_ctx_t* ctx, const void* msg); +void twister_large_init(twister_large_ctx_t* ctx, uint16_t hashsize_b); +void twister_large_lastBlock(twister_large_ctx_t* ctx, const void* msg, uint16_t length_b); +void twister_large_ctx2hash(void* dest, twister_large_ctx_t* ctx, uint16_t hashsize_b); /*********************************************************************/ @@ -41,5 +41,5 @@ void twister512_ctx2hash(void* dest, twister512_ctx_t* ctx); void twister512(void* dest, const void* msg, uint32_t msg_length_b); -#endif /* TWISTER_BIG_H_ */ +#endif /* TWISTER_large_H_ */ diff --git a/twister384.S b/twister384.S index e586243..6a15fc5 100644 --- a/twister384.S +++ b/twister384.S @@ -60,7 +60,7 @@ twister384: movw r24, CTX_SAVE0 ldi r22, lo8(384) ldi r23, hi8(384) - rcall twister_big_init + rcall twister_large_init 1: tst MSG_LEN3 brne 2f @@ -71,7 +71,7 @@ twister384: 2: movw r24, CTX_SAVE0 movw r22, MSG_SAVE0 - rcall twister_big_nextBlock + rcall twister_large_nextBlock adiw MSG_SAVE0, 63 adiw MSG_SAVE0, 1 subi MSG_LEN1, 2 @@ -82,13 +82,13 @@ twister384: movw r24, CTX_SAVE0 movw r22, MSG_SAVE0 movw r20, MSG_LEN0 - rcall twister_big_lastBlock + rcall twister_large_lastBlock movw r24, DST_SAVE0 movw r22, CTX_SAVE0 ldi r20, lo8(384) ldi r21, hi8(384) - rcall twister_big_ctx2hash + rcall twister_large_ctx2hash stack_free_large2 64+2*8+64 pop r29 diff --git a/twister512.S b/twister512.S index f2f701f..0aece4d 100644 --- a/twister512.S +++ b/twister512.S @@ -60,7 +60,7 @@ twister512: movw r24, CTX_SAVE0 ldi r22, lo8(512) ldi r23, hi8(512) - rcall twister_big_init + rcall twister_large_init 1: tst MSG_LEN3 brne 2f @@ -71,7 +71,7 @@ twister512: 2: movw r24, CTX_SAVE0 movw r22, MSG_SAVE0 - rcall twister_big_nextBlock + rcall twister_large_nextBlock adiw MSG_SAVE0, 63 adiw MSG_SAVE0, 1 subi MSG_LEN1, 2 @@ -82,13 +82,13 @@ twister512: movw r24, CTX_SAVE0 movw r22, MSG_SAVE0 movw r20, MSG_LEN0 - rcall twister_big_lastBlock + rcall twister_large_lastBlock movw r24, DST_SAVE0 movw r22, CTX_SAVE0 ldi r20, lo8(512) ldi r21, hi8(512) - rcall twister_big_ctx2hash + rcall twister_large_ctx2hash stack_free_large2 64+2*8+64 pop r29 -- 2.39.5