moved twister naming from big to large

This commit is contained in:
bg 2009-05-14 14:28:59 +00:00
parent 052cd5b120
commit bce0505abf
11 changed files with 69 additions and 68 deletions

View File

@ -28,7 +28,7 @@
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "hashfunction_descriptor.h"
#include "twister-big.h"
#include "twister-large.h"
static const char twister384_str[] PROGMEM = "Twister-384";

View File

@ -28,7 +28,7 @@
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "hashfunction_descriptor.h"
#include "twister-big.h"
#include "twister-large.h"
static const char twister512_str[] PROGMEM = "Twister-512";

View File

@ -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)

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
/**
* \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

View File

@ -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 <string.h>
#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);
}

View File

@ -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 <stdint.h>
#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_ */

View File

@ -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

View File

@ -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