new makefile and modified build process

This commit is contained in:
bg 2009-08-06 13:31:40 +00:00
parent 7701e318e4
commit 4f50c75ee5
164 changed files with 3164 additions and 430 deletions

458
Makefile
View File

@ -2,71 +2,212 @@
# author: Daniel Otte
SHELL = sh
BLOCK_CIPHERS :=
STREAM_CIPHERS :=
BLOCK_CIPHERS :=
STREAM_CIPHERS :=
HASHES :=
MACS :=
PRNGS :=
PRNGS :=
ENCODINGS :=
AUX :=
# we use the gnu make standard library
include gmsl
include avr-makefile.inc
#-------------------------------------------------------------------------------
# inclusion of make stubs
include mkfiles/*.mk
ALGORITHMS = $(BLOCK_CIPHERS) $(STREAM_CIPHERS) $(HASHES) $(PRNGS) $(MACS) $(ENCODINGS) $(AUX)
#-------------------------------------------------------------------------------
ALGORITHMS = $(BLOCK_CIPHERS) $(STREAM_CIPHERS) $(HASHES) $(PRNGS) $(MACS) \
$(ENCODINGS) $(AUX)
ALGORITHMS_OBJ = $(patsubst %,%_OBJ, $(ALGORITHMS))
ALGORITHMS_TEST_BIN = $(patsubst %,%_TEST_BIN, $(ALGORITHMS))
define OBJinBINDIR_TEMPLATE
#-------------------------------------------------------------------------------
# define binary object in $(BIN_DIR)$(ALGO)/<obj>
define Assert_Template
$(1) = $(2)
endef
$(foreach a, $(ALGORITHMS_OBJ), $(eval $(call OBJinBINDIR_TEMPLATE, $(a), $(patsubst %.o,$(BIN_DIR)%.o,$($(a))))))
$(foreach a, $(ALGORITHMS), $(eval $(call Assert_Template, \
$(a)_BINOBJ, \
$(addprefix $(BIN_DIR)$(call lc,$(a))/,$($(a)_OBJ)) \
)))
$(foreach a, $(ALGORITHMS_TEST_BIN), $(eval $(call OBJinBINDIR_TEMPLATE, $(a), $(patsubst %.o,$(TESTBIN_DIR)%.o,$($(a))))))
$(foreach a, $(ALGORITHMS), $(eval $(call Assert_Template, \
$(a)_TESTBINOBJ, \
$(addprefix $(BIN_DIR)$(call lc,$(a))/$(TEST_DIR),$($(a)_TEST_BIN)) \
)))
#ALGORITHMS_TEST_BIN_IMM = $(foreach a, $(ALGORITHMS_TEST_BIN), $($(a)))
ALGORITHMS_NESSIE_TEST = $(patsubst %,%_NESSIE_TEST, $(ALGORITHMS))
ALGORITHMS_PERFORMANCE_TEST = $(patsubst %,%_PERORMANCE_TEST, $(ALGORITHMS))
ALGORITHMS_LC = $(call lc,$(ALGORITHMS))
ALGORITHMS_TEST_TARGET_ELF = $(patsubst %, $(TESTBIN_DIR)main-%-test.elf, $(ALGORITHMS_LC))
ALGORITHMS_TEST_TARGET_HEX = $(patsubst %, $(TESTBIN_DIR)main-%-test.hex, $(ALGORITHMS_LC))
#$(foreach a, $(ALGORITHMS), \
# $(if $(def $(a)_DIR), \
# $(eval $(call Assert_Template, \
# $(a)_DIR, \
# . \
# ) \
# )) \
#)
#
#$(foreach a, $(ALGORITHMS), \
# $(if $(call seq($(strip($($(a)_DIR))),)), \
# $(eval $(call Assert_Template, \
# $(a)_DIR, \
# . \
# ) \
# )) \
#)
#-------------------------------------------------------------------------------
#
### ifeq 'blafoo' ''
### $(error no source ($(2)) for $(1) in TargetSource_Template)
### endif
all: $(foreach algo, $(ALGORITHMS), $(algo)_OBJ)
define TargetSource_Template
$(1): $(2)
@echo "[cc]: $(1) <-- $(2)"
@mkdir -p $(dir $(1))
@$(CC) $(CFLAGS_A) -I./$(strip $(3)) -c -o $(1) $(2)
endef
$(foreach a, $(ALGORITHMS), \
$(foreach b, $($(a)_OBJ), \
$(eval $(call TargetSource_Template, \
$(BIN_DIR)$(call lc, $(a))/$(b), \
$(filter %.S %.c, $(wildcard $($(a)_DIR)$(notdir $(patsubst %.o,%,$(b))).*)), \
$($(a)_DIR) \
)) \
) \
)
$(foreach a, $(ALGORITHMS), \
$(foreach b, $($(a)_TEST_BIN), \
$(eval $(call TargetSource_Template, \
$(BIN_DIR)$(call lc, $(a))/$(TEST_DIR)$(b), \
$(if $(call sne,$(strip $(filter %.S %.c, $(wildcard $(TESTSRC_DIR)$(notdir $(patsubst %.o,%,$(b))).*))),), \
$(filter %.S %.c, $(wildcard $(TESTSRC_DIR)$(notdir $(patsubst %.o,%,$(b))).*)), \
$(filter %.S %.c, $(wildcard ./$(notdir $(patsubst %.o,%,$(b))).*))\
), \
$($(a)_DIR) \
)) \
) \
)
#-------------------------------------------------------------------------------
define MAIN_OBJ_TEMPLATE
$(2): $(3) $(4)
@echo "[ld] : $$@"
# echo $$^
@$(CC) $(CFLAGS) $(LDFLAGS)$(patsubst %.elf,%.map,$(2)) -o \
$(2) \
$(3) $(4) \
define MainTestElf_Template
$(1): $(2) $(3)
@echo "[ld]: $(1)"
@$(CC) $(CFLAGS_A) $(LDFLAGS)$(patsubst %.elf,%.map,$(1)) -o \
$(1) \
$(2) $(3) \
$(LIBS)
endef
$(foreach algo, $(ALGORITHMS), $(eval $(call MAIN_OBJ_TEMPLATE, \
$(algo), \
$(TESTBIN_DIR)main-$(call lc,$(algo))-test.elf, \
$(patsubst %.o,%.o,$($(algo)_TEST_BIN)), \
$(patsubst %.o,%.o,$($(algo)_OBJ)) )))
$(foreach a, $(ALGORITHMS), \
$(eval $(call MainTestElf_Template, \
$(BIN_DIR)$(call lc, $(a))/$(TEST_DIR)main-$(call lc, $(a))-test.elf, \
$($(a)_BINOBJ), \
$($(a)_TESTBINOBJ) \
)) \
)
#-------------------------------------------------------------------------------
all: $(foreach algo, $(ALGORITHMS), $($(algo)_BINOBJ))
#-------------------------------------------------------------------------------
define TestBin_TEMPLATE
$(1)_TEST_BIN: $(2)
endef
$(foreach algo, $(ALGORITHMS), $(eval $(call TestBin_TEMPLATE, \
$(algo), \
$(BIN_DIR)$(call lc, $(algo))/$(TEST_DIR)main-$(call lc, $(algo))-test.elf \
)))
#-------------------------------------------------------------------------------
%.hex: %.elf
@echo "[objcopy]: $@"
@$(OBJCOPY) -j .text -j .data -O ihex $< $@
#-------------------------------------------------------------------------------
define Flash_Template
$(1)_FLASH: $(2)
@echo "[flash]: $(2)"
@$(FLASHCMD)$(call first,$(2))
endef
$(foreach algo, $(ALGORITHMS), $(eval $(call Flash_Template, \
$(algo), \
$(BIN_DIR)$(call lc, $(algo))/$(TEST_DIR)main-$(call lc, $(algo))-test.hex \
)))
#-------------------------------------------------------------------------------
.PHONY: tests
tests: $(foreach a, $(ALGORITHMS), $(a)_TEST_BIN)
#-------------------------------------------------------------------------------
define TestRun_Template
$(1)_TESTRUN: $(1)_FLASH
@echo "[test]: $(1)"
$(RUBY) $(GET_TEST) $(TESTPORT) $(TESTPORTBAUDR) 8 1 nessie $(TESTLOG_DIR)$(TESTPREFIX) $(2)
endef
$(foreach algo, $(ALGORITHMS),$(eval $(call TestRun_Template, $(algo), $(call lc,$(algo)) )))
all_testrun: $(foreach algo, $(ALGORITHMS), $(algo)_TESTRUN)
#-------------------------------------------------------------------------------
define Obj_Template
$(1)_OBJ: $(2)
endef
$(foreach algo, $(ALGORITHMS), \
$(eval $(call Obj_Template, \
$(algo), \
$($(algo)_BINOBJ)\
))\
)
.PHONY: cores
cores: $(foreach algo, $(ALGORITHMS), $(algo)_OBJ)
.PHONY: blockchiphers
blockciphers: $(foreach algo, $(BLOCK_CIPHERS), $(algo)_OBJ)
.PHONY: streamchiphers
streamciphers: $(foreach algo, $(STREAM_CIPHERS), $(algo)_OBJ)
.PHONY: hashes
hashes: $(foreach algo, $(HASHES), $(algo)_OBJ)
.PHONY: macs
macs: $(foreach algo, $(MACS), $(algo)_OBJ)
.PHONY: prngs
prngs: $(foreach algo, $(PRNGS), $(algo)_OBJ)
.PHONY: encodings
encodings: $(foreach algo, $(ENCODINGS), $(algo)_OBJ)
.PHONY: aux
aux: $(foreach algo, $(AUX), $(algo)_OBJ)
#-------------------------------------------------------------------------------
.PHONY: help
help: info
.PHONY: info
info:
@echo "infos on AVR-Crypto-lib:"
@echo " block ciphers:"
@ -81,10 +222,6 @@ info:
@echo " $(PRNGS)"
@echo " encodings:"
@echo " $(ENCODINGS)"
# @echo " ALGORITHMS_TEST_BIN:"
# @echo " $(ALGORITHMS_TEST_BIN)"
# @echo " ALGORITHMS_TEST_TARGET_ELF:"
# @echo " $(ALGORITHMS_TEST_TARGET_ELF)"
@echo " targets:"
@echo " all - all algorithm cores"
@echo " cores - all algorithm cores"
@ -99,266 +236,27 @@ info:
@echo " all_testrun - testrun all algorithms"
@echo " docu - build doxygen documentation"
@echo " clean - remove a lot of builded files"
@echo " xclean - also remove dependency files"
@echo " depclean - also remove dependency files"
@echo " *_TEST_BIN - build test program"
@echo " *_TESTRUN - run nessie test"
@echo " *_OBJ - build algorithm core"
@echo " *_FLASH - flash test program"
@echo " *_LIST - build assembler listing"
#-------------------------------------------------------------------------------
define SOURCEFILE_TEMPLATE
$(BIN_DIR)$(1): $(2)/$(3).c
$(CC) $(CFLAGS) -c -o $@ $<
endef
#-------------------------------------------------------------------------------
$(BIN_DIR)%.o: %.c
@echo "[gcc]: $@"
@$(CC) $(CFLAGS) -c -o $@ $<
$(BIN_DIR)%.o: %.S
@echo "[as] : $@"
@$(CC) $(ASFLAGS) -c -o $@ $<
$(TESTBIN_DIR)%.o: $(TESTSRC_DIR)%.c
@echo "[gcc]: $@"
@$(CC) $(CFLAGS) -c -o $@ $<
$(TESTBIN_DIR)%.o: $(TESTSRC_DIR)%.S
@echo "[as] : $@"
@$(CC) $(ASFLAGS) -c -o $@ $<
$(TESTBIN_DIR)%.o: %.c
@echo "[gcc]: $@"
@$(CC) $(CFLAGS) -c -o $@ $<
$(TESTBIN_DIR)%.o: %.S
@echo "[as] : $@"
@$(CC) $(ASFLAGS) -c -o $@ $<
%.o: %.c
@echo "[gcc]: $@"
@$(CC) $(CFLAGS) -c -o $@ $<
%.o: %.S
@echo "[as] : $@"
@$(CC) $(ASFLAGS) -c -o $@ $<
#-------------------------------------------------------------------------------
define OBJ_TEMPLATE
$(1)_OBJ: $(2)
# @echo " ALGO: $(1)"
# @echo " REQ: $(2)"
endef
$(foreach algo, $(ALGORITHMS), $(eval $(call OBJ_TEMPLATE, $(algo), $($(algo)_OBJ))))
#-------------------------------------------------------------------------------
define TESTBIN_TEMPLATE
$(1)_TEST_BIN: $(2)
endef
$(foreach algo, $(ALGORITHMS), $(eval $(call TESTBIN_TEMPLATE, $(algo), $($(algo)_TEST_BIN))))
#-------------------------------------------------------------------------------
$(BLOCK_CIPHERS_OBJ): $(patsubst %,%_OBJ, $(BLOCK_CIPHERS))
$(STREAM_CIPHERS_OBJ): $(patsubst %,%_OBJ, $(STREAM_CIPHERS))
$(HASHES_OBJ): $(patsubst %,%_OBJ, $(HASHES))
$(PRNGS_OBJ): $(patsubst %,%_OBJ, $(PRNGS))
$(MACS_OBJ): $(patsubst %,%_OBJ, $(MACS))
$(ENCODINGS_OBJ): $(patsubst %,%_OBJ, $(ENCODINGS))
#-------------------------------------------------------------------------------
define SIZE_TEMPLATE
$(1)_size.txt: $(2)
@echo "[size]: $(1)_size.txt"
@$(SIZE) $(2) > $(1)_size.txt
endef
$(foreach algo, $(ALGORITHMS), $(eval $(call SIZE_TEMPLATE, $(STAT_DIR)$(call lc,$(algo)), $($(algo)_OBJ))))
#-------------------------------------------------------------------------------
define FLASH_TEMPLATE
$(1)_FLASH: $(2)
@echo "[flash]: $(2)"
@$(FLASHCMD)$(call first,$(2))
endef
$(foreach algo, $(ALGORITHMS),$(eval $(call FLASH_TEMPLATE, $(algo), $(TESTBIN_DIR)main-$(call lc,$(algo))-test.hex) ))
#-------------------------------------------------------------------------------
define TESTRUN_TEMPLATE
$(1)_TESTRUN: $(1)_FLASH
@echo "[test]: $(1)"
$(RUBY) $(GET_TEST) $(TESTPORT) $(TESTPORTBAUDR) 8 1 nessie $(TESTLOG_DIR)$(TESTPREFIX) $(2)
endef
$(foreach algo, $(ALGORITHMS),$(eval $(call TESTRUN_TEMPLATE, $(algo), $(call lc,$(algo)) )))
all_testrun: $(foreach algo, $(ALGORITHMS), $(algo)_TESTRUN)
#-------------------------------------------------------------------------------
define TESTSPEED_TEMPLATE
$(1)_TESTSPEED: $(1)_FLASH
@echo "[speed]: $(1)"
$(RUBY) $(GET_PERFORMANCE) $(TESTPORT) $(TESTPORTBAUDR) 8 1 performance $(SPEEDLOG_DIR)$(SPEEDPREFIX) $(2)
endef
$(foreach algo, $(ALGORITHMS),$(eval $(call TESTSPEED_TEMPLATE, $(algo), $(call lc,$(algo)) )))
all_testspeed: $(foreach algo, $(ALGORITHMS), $(algo)_TESTSPEED)
hash_testspeed: $(foreach algo, $(HASHES), $(algo)_TESTSPEED)
#-------------------------------------------------------------------------------
define LISTING_TEMPLATE
$(1)_LIST: $(2)
endef
$(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))
$(LIST_DIR)%.lst: $(TESTBIN_DIR)%.elf
$(OBJDUMP) -h -S $< > $@
$(LIST_DIR)%.lst: $(BIN_DIR)%.o
$(OBJDUMP) -h -S $< > $@
$(LIST_DIR)%.lst: $(TESTBIN_DIR)%.o
$(OBJDUMP) -h -S $< > $@
#-------------------------------------------------------------------------------
.PHONY: cores
cores: $(ALGORITHMS_OBJ)
.PHONY: blockciphers
blockciphers: $(patsubst %, %_OBJ, $(BLOCK_CIPHERS))
.PHONY: streamciphers
streamciphers: $(patsubst %, %_OBJ, $(STREAM_CIPHERS))
.PHONY: hashes
hashes: $(patsubst %, %_OBJ, $(HASHES))
.PHONY: macs
macs: $(patsubst %, %_OBJ, $(MACS))
.PHONY: prngs
prngs: $(patsubst %, %_OBJ, $(PRNGS))
.PHONY: encodings
encodings: $(patsubst %, %_OBJ, $(ENCODINGS))
tests: $(ALGORITHMS_TEST_BIN) \
$(ALGORITHMS_TEST_TARGET_ELF) \
$(ALGORITHMS_TEST_TARGET_HEX)
.PHONY: stats
stats: $(SIZESTAT_FILE)
@cat $(STAT_DIR)$(SIZESTAT_FILE)
$(SIZESTAT_FILE): $(patsubst %, $(STAT_DIR)%_size.txt, $(ALGORITHMS_LC))
$(RUBY) sumsize.rb $^ > $(STAT_DIR)$(SIZESTAT_FILE)
#-------------------------------------------------------------------------------
.PHONY: clean
clean:
rm -rf $(BIN_DIR)*.o *.o $(TESTBIN_DIR)*.elf $(TESTBIN_DIR)* *.elf *.eps *.png *.pdf *.bak
rm -rf *.lst *.map $(EXTRA_CLEAN_FILES) $(STAT_DIR)$(SIZESTAT_FILE) $(STAT_DIR)*_size.txt
xclean: clean
rm -rf $(DEP_DIR)*.d $(AUTOASM_DIR)*.s
rm -rf $(BIN_DIR)*
docu:
doxygen
make.dump: Makefile
$(MAKE) -p -B -n -f $^ > $@
make.dot: make.dump
$(MAKE2GRAPH) $^ > $@
make.png: make.dot
$(TWOPI) -Tpng -o $@ $^
make.svg: make.dot
$(TWOPI) -Tsvg -o $@ $^
.PHONY: make-info
make-info: make.png make.svg
# Rules for building the .text rom images
%.hex: %.elf
@echo "[objcopy]: $@"
@$(OBJCOPY) -j .text -j .data -O ihex $< $@
%.srec: %.elf
@echo "[objcopy]: $@"
@$(OBJCOPY) -j .text -j .data -O srec $< $@
%.bin: %.elf
@echo "[objcopy]: $@"
@$(OBJCOPY) -j .text -j .data -O binary $< $@
# Rules for building the .eeprom rom images
%_eeprom.hex: %.elf
@echo "[objcopy]: $@"
@$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
%_eeprom.srec: %.elf
@echo "[objcopy]: $@"
@$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@
%_eeprom.bin: %.elf
@echo "[objcopy]: $@"
@$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
#-------------------------------------------------------------------------------
$(AUTOASM_DIR)%.s: %.c
$(CC) $(CFLAGS) $(AUTOASM_OPT) -o $@ $<
%.s: %.c
$(CC) $(CFLAGS) $(AUTOASM_OPT) -o $@ $<
.PHONY: depclean
depclean: clean
rm $(DEP_DIR)*.d
#-------------------------------------------------------------------------------
FIG2DEV = fig2dev
EXTRA_CLEAN_FILES = *.hex *.bin *.srec
%.eps: %.fig
$(FIG2DEV) -L eps $< $@
%.pdf: %.fig
$(FIG2DEV) -L pdf $< $@
%.png: %.fig
$(FIG2DEV) -L png $< $@
# dependency inclusion
#
DEPS := $(wildcard $(DEP_DIR)*.d)

View File

82
aes/gf256mul.S Normal file
View File

@ -0,0 +1,82 @@
/* gf256mul.S */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* File: gf256mul.S
* Author: Daniel Otte
* Date: 2008-12-19
* License: GPLv3 or later
* Description: peasant's algorithm for multiplication in GF(2^8)
*
*/
#include <avr/io.h>
#define OPTIMIZE_SMALL_A
/*
* param a: r24
* param b: r22
* param reducer: r20
*/
A = 23
B = 22
P = 24
.global gf256mul
#ifdef OPTIMIZE_SMALL_A
gf256mul:
mov A, r24
clr r24
1:
lsr A
breq 4f
brcc 2f
eor P, B
2:
lsl B
brcc 3f
eor B, r20
3:
rjmp 1b
4:
brcc 2f
eor P, B
2:
ret
#else
gf256mul:
mov r21, r24
clr r24
ldi r25, 8
1:
lsr A
brcc 2f
eor P, B
2:
lsl B
brcc 3f
eor B, r20
3:
dec r25
brne 1b
ret
#endif

37
aes/gf256mul.h Normal file
View File

@ -0,0 +1,37 @@
/* gf256mul.h */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GF256MUL_H_
#define GF256MUL_H_
/**
* \author Daniel Otte
* \email daniel.otte@rub.de
* \date 2008-12-19
* \license GPLv3
* \brief
*
*
*/
#include <stdint.h>
uint8_t gf256mul(uint8_t a, uint8_t b, uint8_t reducer);
#endif /* GF256MUL_H_ */

View File

@ -6,11 +6,12 @@ DEFS = -D$(call uc, $(MCU_TARGET))
FLASHCMD = avrdude -p $(MCU_TARGET) -P /dev/ttyUSB0 -c $(PROGRAMMER) -U flash:w:# no space at the end
#FLASHCMD = avrdude -p $(MCU_TARGET) -c usbasp -U flash:w:# no space at the end
DEP_DIR = deps/
TEST_DIR = test/
BIN_DIR = bin/
TESTBIN_DIR = test_bin/
TESTSRC_DIR = test_src/
#uisp -dprog=bsd -dlpt=/dev/parport1 --upload if=$(PRG).hex
ERASECMD =
ERASECMD =
TESTPORT = /dev/ttyUSB1
TESTPORTBAUDR = 38400
TESTLOG_DIR = testlog/
@ -24,7 +25,8 @@ AUTOASM_OPT = -S
CC = avr-gcc
CSTD = c99
override CFLAGS = -MMD -MF$(DEP_DIR)$(patsubst %.c,%.d,$(patsubst $(TESTSRC_DIR)%,%,$<)) -I. -Itest_src -gdwarf-2 -pedantic -std=$(CSTD) -Wall -Wstrict-prototypes $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
override CFLAGS_A = -MMD -MF$(DEP_DIR)$(patsubst %.o,%.d,$(notdir $(1))) -I. -Itest_src -gdwarf-2 -pedantic -std=$(CSTD) -Wall -Wstrict-prototypes $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
override CFLAGS = -MMD -MF$(DEP_DIR)$(patsubst %.o,%.d,$(notdir $@)) -I. -Itest_src -gdwarf-2 -pedantic -std=$(CSTD) -Wall -Wstrict-prototypes $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
override LDFLAGS = -gdwarf-2 -Wl,-Map,
override ASFLAGS = -mmcu=$(MCU_TARGET) -Wa,--gdwarf-2

66
blake/memxor.S Normal file
View File

@ -0,0 +1,66 @@
/* memxor.S */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* File: memxor.S
* Author: Daniel Otte
* Date: 2008-08-07
* License: GPLv3 or later
* Description: memxor, XORing one block into another
*
*/
/*
* void memxor(void* dest, const void* src, uint16_t n);
*/
/*
* param dest is passed in r24:r25
* param src is passed in r22:r23
* param n is passed in r20:r21
*/
.global memxor
memxor:
movw r30, r24
movw r26, r22
movw r24, r20
adiw r24, 0
breq 2f
1:
ld r20, X+
ld r21, Z
eor r20, r21
st Z+, r20
sbiw r24, 1
brne 1b
2:
ret

7
blake/memxor.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef MEMXOR_H_
#define MEMXOR_H_
#include <stdint.h>
void memxor(void* dest, const void* src, uint16_t n);
#endif

View File

@ -37,7 +37,7 @@
#define UART0_DATABITS UART_DATABITS_8
#define UART0_RXBUFFER_SIZE 64
#define UART0_TXBUFFER_SIZE 64
#define UART0_SWFLOWCTRL 0
#define UART0_SWFLOWCTRL 1
#define UART0_THRESH_LOW 10
#define UART0_THRESH_HIGH 48

23
groestl/aes_sbox.c Normal file
View File

@ -0,0 +1,23 @@
/* aes sbox */
#include <stdint.h>
#include <avr/pgmspace.h>
uint8_t aes_sbox[256] PROGMEM = {
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
};

33
groestl/aes_sbox.h Normal file
View File

@ -0,0 +1,33 @@
/* aes_sbox.h */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file aes_sbox.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2008-12-30
* \license GPLv3 or later
*
*/
#ifndef AES_SBOX_H_
#define AES_SBOX_H_
#include <stdint.h>
extern uint8_t aes_sbox[];
#endif

82
groestl/gf256mul.S Normal file
View File

@ -0,0 +1,82 @@
/* gf256mul.S */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* File: gf256mul.S
* Author: Daniel Otte
* Date: 2008-12-19
* License: GPLv3 or later
* Description: peasant's algorithm for multiplication in GF(2^8)
*
*/
#include <avr/io.h>
#define OPTIMIZE_SMALL_A
/*
* param a: r24
* param b: r22
* param reducer: r20
*/
A = 23
B = 22
P = 24
.global gf256mul
#ifdef OPTIMIZE_SMALL_A
gf256mul:
mov A, r24
clr r24
1:
lsr A
breq 4f
brcc 2f
eor P, B
2:
lsl B
brcc 3f
eor B, r20
3:
rjmp 1b
4:
brcc 2f
eor P, B
2:
ret
#else
gf256mul:
mov r21, r24
clr r24
ldi r25, 8
1:
lsr A
brcc 2f
eor P, B
2:
lsl B
brcc 3f
eor B, r20
3:
dec r25
brne 1b
ret
#endif

37
groestl/gf256mul.h Normal file
View File

@ -0,0 +1,37 @@
/* gf256mul.h */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GF256MUL_H_
#define GF256MUL_H_
/**
* \author Daniel Otte
* \email daniel.otte@rub.de
* \date 2008-12-19
* \license GPLv3
* \brief
*
*
*/
#include <stdint.h>
uint8_t gf256mul(uint8_t a, uint8_t b, uint8_t reducer);
#endif /* GF256MUL_H_ */

66
groestl/memxor.S Normal file
View File

@ -0,0 +1,66 @@
/* memxor.S */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* File: memxor.S
* Author: Daniel Otte
* Date: 2008-08-07
* License: GPLv3 or later
* Description: memxor, XORing one block into another
*
*/
/*
* void memxor(void* dest, const void* src, uint16_t n);
*/
/*
* param dest is passed in r24:r25
* param src is passed in r22:r23
* param n is passed in r20:r21
*/
.global memxor
memxor:
movw r30, r24
movw r26, r22
movw r24, r20
adiw r24, 0
breq 2f
1:
ld r20, X+
ld r21, Z
eor r20, r21
st Z+, r20
sbiw r24, 1
brne 1b
2:
ret

7
groestl/memxor.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef MEMXOR_H_
#define MEMXOR_H_
#include <stdint.h>
void memxor(void* dest, const void* src, uint16_t n);
#endif

View File

@ -133,6 +133,7 @@ $algo_select = ARGV[4]
init_system()
errors = 0
for i in (5..(ARGV.size-1))
errors = run_test(ARGV[i])
if errors == 0

View File

@ -17,15 +17,15 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
/*
* File: memxor.S
* Author: Daniel Otte
* Date: 2008-08-07
* License: GPLv3 or later
* Description: memxor, XORing one block into another
*
*
*/
/*
* void memxor(void* dest, const void* src, uint16_t n);
*/
@ -39,9 +39,7 @@ memxor:
movw r30, r24
movw r26, r22
movw r24, r20
tst r24
brne 1f
tst r25
adiw r24, 0
breq 2f
1:
ld r20, X+
@ -52,17 +50,17 @@ memxor:
brne 1b
2:
ret

View File

@ -4,9 +4,9 @@ ALGO_NAME := AES
# comment out the following line for removement of AES from the build process
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_DIR := aes/
$(ALGO_NAME)_OBJ := aes_enc-asm.o aes_dec-asm.o aes_sbox-asm.o aes_invsbox-asm.o \
aes_keyschedule-asm.o
aes_keyschedule-asm.o
$(ALGO_NAME)_TEST_BIN := main-aes-test.o $(CLI_STD) \
nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie

View File

@ -5,8 +5,9 @@ ALGO_NAME := AES_FASTER
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_DIR := aes/
$(ALGO_NAME)_OBJ := aes_enc-asm.o aes_dec-asm_faster.o aes_sbox-asm.o aes_invsbox-asm.o \
aes_keyschedule-asm.o
aes_keyschedule-asm.o
$(ALGO_NAME)_TEST_BIN := main-aes-test.o $(CLI_STD) \
nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie

View File

@ -5,6 +5,7 @@ ALGO_NAME := AES_C
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_DIR := aes/
$(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 \

View File

@ -4,7 +4,7 @@ ALGO_NAME := BLAKE_C
# comment out the following line for removement of Blake from the build process
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_DIR := blake/
$(ALGO_NAME)_OBJ := blake_small.o blake_large.o blake_common.o memxor.o
$(ALGO_NAME)_TEST_BIN := main-blake-test.o hfal_blake_small.o hfal_blake_large.o $(CLI_STD) $(HFAL_STD)
$(ALGO_NAME)_NESSIE_TEST := test nessie

View File

@ -4,6 +4,7 @@ ALGO_NAME := CAMELLIA
# comment out the following line for removement of Camellia from the build process
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_DIR := camellia/
$(ALGO_NAME)_OBJ := camellia128-stub.o camellia-asm.o
$(ALGO_NAME)_TEST_BIN := main-camellia-test.o $(CLI_STD) nessie_bc_test.o \
nessie_common.o performance_test.o

View File

@ -4,7 +4,7 @@ ALGO_NAME := GROESTL_C
# comment out the following line for removement of Grøstl from the build process
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_DIR := groestl/
$(ALGO_NAME)_OBJ := groestl_small.o groestl_large.o memxor.o aes_sbox.o gf256mul.o
$(ALGO_NAME)_TEST_BIN := hfal_groestl_large.o hfal_groestl_small.o main-groestl-test.o $(CLI_STD) $(HFAL_STD)
$(ALGO_NAME)_NESSIE_TEST := test nessie

View File

@ -4,6 +4,7 @@ ALGO_NAME := MUGI_C
# comment out the following line for removement of MUGI_C from the build process
STREAM_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_DIR := mugi/
$(ALGO_NAME)_OBJ := mugi.o gf256mul.o aes_sbox.o
$(ALGO_NAME)_TEST_BIN := main-mugi-test.o $(CLI_STD) \
nessie_stream_test.o nessie_common.o \

View File

@ -4,7 +4,7 @@ ALGO_NAME := SHABAL
# comment out the following line for removement of Skein from the build process
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_DIR := shabal/
$(ALGO_NAME)_OBJ := shabal-asm.o shabal192-asm.o shabal224-asm.o \
shabal256-asm.o shabal384-asm.o shabal512-asm.o
$(ALGO_NAME)_TEST_BIN := main-shabal-test.o hfal_shabal.o $(CLI_STD) $(HFAL_STD)

View File

@ -4,7 +4,7 @@ ALGO_NAME := SHABAL_C
# comment out the following line for removement of Skein from the build process
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_DIR := shabal/
$(ALGO_NAME)_OBJ := shabal.o shabal192.o shabal224.o shabal256.o shabal384.o shabal512.o
$(ALGO_NAME)_TEST_BIN := main-shabal-test.o hfal_shabal.o $(CLI_STD) $(HFAL_STD)
$(ALGO_NAME)_NESSIE_TEST := test nessie

View File

@ -4,7 +4,7 @@ ALGO_NAME := SKEIN
# comment out the following line for removement of Skein from the build process
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_DIR := skein/
$(ALGO_NAME)_OBJ := threefish_mix.o \
threefish256_enc_asm.o ubi256_asm.o skein256_asm.o \
threefish512_enc_asm.o ubi512_asm.o skein512_asm.o \

View File

@ -4,7 +4,7 @@ ALGO_NAME := THREEFISH
# comment out the following line for removement of threefish from the build process
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_DIR := skein/
$(ALGO_NAME)_OBJ := threefish256_enc_asm.o threefish512_enc_asm.o threefish1024_enc_asm.o\
threefish_mix.o threefish_invmix.o \
threefish256_dec_asm.o threefish512_dec_asm.o threefish1024_dec_asm.o

View File

@ -4,6 +4,7 @@ ALGO_NAME := TWISTER
# comment out the following line for removement of TWISTER from the build process
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_DIR := twister/
$(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 \

View File

@ -4,6 +4,7 @@ ALGO_NAME := TWISTER_C
# comment out the following line for removement of TWISTER from the build process
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_DIR := twister/
$(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)

View File

@ -4,7 +4,7 @@ ALGO_NAME := UBI
# comment out the following line for removement of ubi from the build process
AUX += $(ALGO_NAME)
$(ALGO_NAME)_DIR := skein/
$(ALGO_NAME)_OBJ := threefish_mix.o threefish256_enc_asm.o ubi256_asm.o \
threefish512_enc_asm.o ubi512_asm.o threefish1024_enc_asm.o \
ubi1024_asm.o memxor.o

23
mugi/aes_sbox.c Normal file
View File

@ -0,0 +1,23 @@
/* aes sbox */
#include <stdint.h>
#include <avr/pgmspace.h>
uint8_t aes_sbox[256] PROGMEM = {
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
};

33
mugi/aes_sbox.h Normal file
View File

@ -0,0 +1,33 @@
/* aes_sbox.h */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file aes_sbox.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2008-12-30
* \license GPLv3 or later
*
*/
#ifndef AES_SBOX_H_
#define AES_SBOX_H_
#include <stdint.h>
extern uint8_t aes_sbox[];
#endif

82
mugi/gf256mul.S Normal file
View File

@ -0,0 +1,82 @@
/* gf256mul.S */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* File: gf256mul.S
* Author: Daniel Otte
* Date: 2008-12-19
* License: GPLv3 or later
* Description: peasant's algorithm for multiplication in GF(2^8)
*
*/
#include <avr/io.h>
#define OPTIMIZE_SMALL_A
/*
* param a: r24
* param b: r22
* param reducer: r20
*/
A = 23
B = 22
P = 24
.global gf256mul
#ifdef OPTIMIZE_SMALL_A
gf256mul:
mov A, r24
clr r24
1:
lsr A
breq 4f
brcc 2f
eor P, B
2:
lsl B
brcc 3f
eor B, r20
3:
rjmp 1b
4:
brcc 2f
eor P, B
2:
ret
#else
gf256mul:
mov r21, r24
clr r24
ldi r25, 8
1:
lsr A
brcc 2f
eor P, B
2:
lsl B
brcc 3f
eor B, r20
3:
dec r25
brne 1b
ret
#endif

37
mugi/gf256mul.h Normal file
View File

@ -0,0 +1,37 @@
/* gf256mul.h */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GF256MUL_H_
#define GF256MUL_H_
/**
* \author Daniel Otte
* \email daniel.otte@rub.de
* \date 2008-12-19
* \license GPLv3
* \brief
*
*
*/
#include <stdint.h>
uint8_t gf256mul(uint8_t a, uint8_t b, uint8_t reducer);
#endif /* GF256MUL_H_ */

View File

View File

123
shabal/shabal_shorttest.log Normal file
View File

@ -0,0 +1,123 @@
test
Test vectors for Shabal (192 bits):
message:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
hash:
0F 70 6E CB 97 CF 4D CE 00 BF BB D2 FB 64 53 0C
32 87 0C B4 48 39 73 0D
Test vectors for Shabal (192 bits):
message:
61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70
71 72 73 74 75 76 77 78 79 7A 2D 30 31 32 33 34
35 36 37 38 39 2D 41 42 43 44 45 46 47 48 49 4A
4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A
2D 30 31 32 33 34 35 36 37 38 39 2D 61 62 63 64
65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74
75 76 77 78 79 7A
hash:
69 0F AE 79 22 6D 95 76 0A E8 FD B4 F5 8C 05 37
11 17 56 55 7D 30 7B 15
Test vectors for Shabal (224 bits):
message:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
hash:
99 DD A6 14 F9 07 D2 E8 81 76 18 F7 30 69 6F 32
00 AE CA 8B 5F 85 F4 25 43 BA 20 31
Test vectors for Shabal (224 bits):
message:
61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70
71 72 73 74 75 76 77 78 79 7A 2D 30 31 32 33 34
35 36 37 38 39 2D 41 42 43 44 45 46 47 48 49 4A
4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A
2D 30 31 32 33 34 35 36 37 38 39 2D 61 62 63 64
65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74
75 76 77 78 79 7A
hash:
C7 D6 2D 8D 2A 34 74 B4 F4 A9 D1 1A 52 DB 3D 43
5B F1 58 CF 45 4C 5D 56 1D 71 25 F5
Test vectors for Shabal (256 bits):
message:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
hash:
DA 8F 08 C0 2A 67 BA 9A 56 BD D0 79 8E 48 AE 07
14 21 5E 09 3B 5B 85 06 49 A3 77 18 99 3F 54 A2
Test vectors for Shabal (256 bits):
message:
61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70
71 72 73 74 75 76 77 78 79 7A 2D 30 31 32 33 34
35 36 37 38 39 2D 41 42 43 44 45 46 47 48 49 4A
4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A
2D 30 31 32 33 34 35 36 37 38 39 2D 61 62 63 64
65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74
75 76 77 78 79 7A
hash:
B4 9F 34 BF 51 86 4C 30 53 3C C4 6C C2 54 2B DE
C2 F9 6F D0 6F 5C 53 9A FF 6E AD 58 83 F7 32 7A
Test vectors for Shabal (384 bits):
message:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
hash:
9D DE 12 33 91 0D 85 DA 3A 5C 78 03 12 B1 11 C6
FC CA 1B 5D D2 55 37 03 5E E0 8E 3B 4E 1E 25 15
4F 72 6A 63 84 E5 A8 F0 AF EA AB 4A C4 C0 2F 12
Test vectors for Shabal (384 bits):
message:
61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70
71 72 73 74 75 76 77 78 79 7A 2D 30 31 32 33 34
35 36 37 38 39 2D 41 42 43 44 45 46 47 48 49 4A
4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A
2D 30 31 32 33 34 35 36 37 38 39 2D 61 62 63 64
65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74
75 76 77 78 79 7A
hash:
30 01 2C 0E 3E DC 46 0B D7 86 27 C2 C3 09 44 D2
A1 89 66 9A FA 2D 7A 97 13 EF 2F 77 4C 44 74 A4
3A F1 CB CE C5 FA B4 24 8C 08 73 F0 38 FB EB A0
Test vectors for Shabal (512 bits):
message:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
hash:
15 80 16 C6 C8 1F 3F 0A 52 D9 8D 68 ED 2F 9E 8E
78 95 EF 23 CB A7 E2 BC 61 09 D8 A5 32 E6 C9 E6
A6 A5 01 97 9F B8 37 F0 4E C4 C6 20 E7 31 79 DC
82 AB B5 2B 32 CD AD B3 56 50 E2 9C 98 5E 30 22
Test vectors for Shabal (512 bits):
message:
61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70
71 72 73 74 75 76 77 78 79 7A 2D 30 31 32 33 34
35 36 37 38 39 2D 41 42 43 44 45 46 47 48 49 4A
4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A
2D 30 31 32 33 34 35 36 37 38 39 2D 61 62 63 64
65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74
75 76 77 78 79 7A
hash:
67 7E 6F 7F 12 D7 0A F0 B3 35 66 2F 59 B5 68 51
F3 65 3E 66 64 7D 33 86 DF DA 01 43 25 4C C8 A5
DB 3E 21 94 06 8C 6F 71 59 7D 7B 60 98 4D 22 B4
7A 1F 60 D9 1C A8 DF CB 17 5D 65 B9 73 59 CE CF
>

View File

@ -0,0 +1,713 @@
%!PS-Adobe-3.0
%%BoundingBox: 24 24 571 818
%%Title: Enscript Output
%%For:
%%Creator: GNU enscript 1.6.4
%%CreationDate: Mon Apr 27 00:59:17 2009
%%Orientation: Portrait
%%Pages: (atend)
%%DocumentMedia: A4 595 842 0 () ()
%%DocumentNeededResources: (atend)
%%EndComments
%%BeginProlog
%%BeginResource: procset Enscript-Prolog 1.6 4
%
% Procedures.
%
/_S { % save current state
/_s save def
} def
/_R { % restore from saved state
_s restore
} def
/S { % showpage protecting gstate
gsave
showpage
grestore
} bind def
/MF { % fontname newfontname -> - make a new encoded font
/newfontname exch def
/fontname exch def
/fontdict fontname findfont def
/newfont fontdict maxlength dict def
fontdict {
exch
dup /FID eq {
% skip FID pair
pop pop
} {
% copy to the new font dictionary
exch newfont 3 1 roll put
} ifelse
} forall
newfont /FontName newfontname put
% insert only valid encoding vectors
encoding_vector length 256 eq {
newfont /Encoding encoding_vector put
} if
newfontname newfont definefont pop
} def
/MF_PS { % fontname newfontname -> - make a new font preserving its enc
/newfontname exch def
/fontname exch def
/fontdict fontname findfont def
/newfont fontdict maxlength dict def
fontdict {
exch
dup /FID eq {
% skip FID pair
pop pop
} {
% copy to the new font dictionary
exch newfont 3 1 roll put
} ifelse
} forall
newfont /FontName newfontname put
newfontname newfont definefont pop
} def
/SF { % fontname width height -> - set a new font
/height exch def
/width exch def
findfont
[width 0 0 height 0 0] makefont setfont
} def
/SUF { % fontname width height -> - set a new user font
/height exch def
/width exch def
/F-gs-user-font MF
/F-gs-user-font width height SF
} def
/SUF_PS { % fontname width height -> - set a new user font preserving its enc
/height exch def
/width exch def
/F-gs-user-font MF_PS
/F-gs-user-font width height SF
} def
/M {moveto} bind def
/s {show} bind def
/Box { % x y w h -> - define box path
/d_h exch def /d_w exch def /d_y exch def /d_x exch def
d_x d_y moveto
d_w 0 rlineto
0 d_h rlineto
d_w neg 0 rlineto
closepath
} def
/bgs { % x y height blskip gray str -> - show string with bg color
/str exch def
/gray exch def
/blskip exch def
/height exch def
/y exch def
/x exch def
gsave
x y blskip sub str stringwidth pop height Box
gray setgray
fill
grestore
x y M str s
} def
/bgcs { % x y height blskip red green blue str -> - show string with bg color
/str exch def
/blue exch def
/green exch def
/red exch def
/blskip exch def
/height exch def
/y exch def
/x exch def
gsave
x y blskip sub str stringwidth pop height Box
red green blue setrgbcolor
fill
grestore
x y M str s
} def
% Highlight bars.
/highlight_bars { % nlines lineheight output_y_margin gray -> -
gsave
setgray
/ymarg exch def
/lineheight exch def
/nlines exch def
% This 2 is just a magic number to sync highlight lines to text.
0 d_header_y ymarg sub 2 sub translate
/cw d_output_w cols div def
/nrows d_output_h ymarg 2 mul sub lineheight div cvi def
% for each column
0 1 cols 1 sub {
cw mul /xp exch def
% for each rows
0 1 nrows 1 sub {
/rn exch def
rn lineheight mul neg /yp exch def
rn nlines idiv 2 mod 0 eq {
% Draw highlight bar. 4 is just a magic indentation.
xp 4 add yp cw 8 sub lineheight neg Box fill
} if
} for
} for
grestore
} def
% Line highlight bar.
/line_highlight { % x y width height gray -> -
gsave
/gray exch def
Box gray setgray fill
grestore
} def
% Column separator lines.
/column_lines {
gsave
.1 setlinewidth
0 d_footer_h translate
/cw d_output_w cols div def
1 1 cols 1 sub {
cw mul 0 moveto
0 d_output_h rlineto stroke
} for
grestore
} def
% Column borders.
/column_borders {
gsave
.1 setlinewidth
0 d_footer_h moveto
0 d_output_h rlineto
d_output_w 0 rlineto
0 d_output_h neg rlineto
closepath stroke
grestore
} def
% Do the actual underlay drawing
/draw_underlay {
ul_style 0 eq {
ul_str true charpath stroke
} {
ul_str show
} ifelse
} def
% Underlay
/underlay { % - -> -
gsave
0 d_page_h translate
d_page_h neg d_page_w atan rotate
ul_gray setgray
ul_font setfont
/dw d_page_h dup mul d_page_w dup mul add sqrt def
ul_str stringwidth pop dw exch sub 2 div ul_h_ptsize -2 div moveto
draw_underlay
grestore
} def
/user_underlay { % - -> -
gsave
ul_x ul_y translate
ul_angle rotate
ul_gray setgray
ul_font setfont
0 0 ul_h_ptsize 2 div sub moveto
draw_underlay
grestore
} def
% Page prefeed
/page_prefeed { % bool -> -
statusdict /prefeed known {
statusdict exch /prefeed exch put
} {
pop
} ifelse
} def
% Wrapped line markers
/wrapped_line_mark { % x y charwith charheight type -> -
/type exch def
/h exch def
/w exch def
/y exch def
/x exch def
type 2 eq {
% Black boxes (like TeX does)
gsave
0 setlinewidth
x w 4 div add y M
0 h rlineto w 2 div 0 rlineto 0 h neg rlineto
closepath fill
grestore
} {
type 3 eq {
% Small arrows
gsave
.2 setlinewidth
x w 2 div add y h 2 div add M
w 4 div 0 rlineto
x w 4 div add y lineto stroke
x w 4 div add w 8 div add y h 4 div add M
x w 4 div add y lineto
w 4 div h 8 div rlineto stroke
grestore
} {
% do nothing
} ifelse
} ifelse
} def
% EPSF import.
/BeginEPSF {
/b4_Inc_state save def % Save state for cleanup
/dict_count countdictstack def % Count objects on dict stack
/op_count count 1 sub def % Count objects on operand stack
userdict begin
/showpage { } def
0 setgray 0 setlinecap
1 setlinewidth 0 setlinejoin
10 setmiterlimit [ ] 0 setdash newpath
/languagelevel where {
pop languagelevel
1 ne {
false setstrokeadjust false setoverprint
} if
} if
} bind def
/EndEPSF {
count op_count sub { pos } repeat % Clean up stacks
countdictstack dict_count sub { end } repeat
b4_Inc_state restore
} bind def
% Check PostScript language level.
/languagelevel where {
pop /gs_languagelevel languagelevel def
} {
/gs_languagelevel 1 def
} ifelse
%%EndResource
%%BeginResource: procset Enscript-Encoding-88591 1.6 4
/encoding_vector [
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/space /exclam /quotedbl /numbersign
/dollar /percent /ampersand /quoteright
/parenleft /parenright /asterisk /plus
/comma /hyphen /period /slash
/zero /one /two /three
/four /five /six /seven
/eight /nine /colon /semicolon
/less /equal /greater /question
/at /A /B /C
/D /E /F /G
/H /I /J /K
/L /M /N /O
/P /Q /R /S
/T /U /V /W
/X /Y /Z /bracketleft
/backslash /bracketright /asciicircum /underscore
/quoteleft /a /b /c
/d /e /f /g
/h /i /j /k
/l /m /n /o
/p /q /r /s
/t /u /v /w
/x /y /z /braceleft
/bar /braceright /tilde /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/space /exclamdown /cent /sterling
/currency /yen /brokenbar /section
/dieresis /copyright /ordfeminine /guillemotleft
/logicalnot /hyphen /registered /macron
/degree /plusminus /twosuperior /threesuperior
/acute /mu /paragraph /bullet
/cedilla /onesuperior /ordmasculine /guillemotright
/onequarter /onehalf /threequarters /questiondown
/Agrave /Aacute /Acircumflex /Atilde
/Adieresis /Aring /AE /Ccedilla
/Egrave /Eacute /Ecircumflex /Edieresis
/Igrave /Iacute /Icircumflex /Idieresis
/Eth /Ntilde /Ograve /Oacute
/Ocircumflex /Otilde /Odieresis /multiply
/Oslash /Ugrave /Uacute /Ucircumflex
/Udieresis /Yacute /Thorn /germandbls
/agrave /aacute /acircumflex /atilde
/adieresis /aring /ae /ccedilla
/egrave /eacute /ecircumflex /edieresis
/igrave /iacute /icircumflex /idieresis
/eth /ntilde /ograve /oacute
/ocircumflex /otilde /odieresis /divide
/oslash /ugrave /uacute /ucircumflex
/udieresis /yacute /thorn /ydieresis
] def
%%EndResource
%%EndProlog
%%BeginSetup
%%IncludeResource: font Courier-Bold
%%IncludeResource: font Courier
/HFpt_w 10 def
/HFpt_h 10 def
/Courier-Bold /HF-gs-font MF
/HF /HF-gs-font findfont [HFpt_w 0 0 HFpt_h 0 0] makefont def
/Courier /F-gs-font MF
/F-gs-font 10 10 SF
/#copies 1 def
% Pagedevice definitions:
gs_languagelevel 1 gt {
<<
/PageSize [595 842]
>> setpagedevice
} if
%%BeginResource: procset Enscript-Header-simple 1.6 4
/do_header { % print default simple header
gsave
d_header_x d_header_y HFpt_h 3 div add translate
HF setfont
user_header_p {
5 0 moveto user_header_left_str show
d_header_w user_header_center_str stringwidth pop sub 2 div
0 moveto user_header_center_str show
d_header_w user_header_right_str stringwidth pop sub 5 sub
0 moveto user_header_right_str show
} {
5 0 moveto fname show
45 0 rmoveto fmodstr show
45 0 rmoveto pagenumstr show
} ifelse
grestore
} def
%%EndResource
/d_page_w 547 def
/d_page_h 794 def
/d_header_x 0 def
/d_header_y 779 def
/d_header_w 547 def
/d_header_h 15 def
/d_footer_x 0 def
/d_footer_y 0 def
/d_footer_w 547 def
/d_footer_h 0 def
/d_output_w 547 def
/d_output_h 779 def
/cols 1 def
%%EndSetup
%%Page: (1) 1
%%BeginPageSetup
_S
24 24 translate
/pagenum 1 def
/fname (shabal_shorttest.log) def
/fdir () def
/ftail (shabal_shorttest.log) def
% User defined strings:
/fmodstr (Mon Apr 27 00:58:21 2009) def
/pagenumstr (1) def
/user_header_p false def
/user_footer_p false def
%%EndPageSetup
do_header
5 766 M
(test) s
5 744 M
(Test vectors for Shabal \(192 bits\):) s
5 733 M
(message:) s
5 722 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 711 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 700 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 689 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 678 M
(hash:) s
5 667 M
( 0F 70 6E CB 97 CF 4D CE 00 BF BB D2 FB 64 53 0C ) s
5 656 M
( 32 87 0C B4 48 39 73 0D ) s
5 634 M
(Test vectors for Shabal \(192 bits\):) s
5 623 M
(message:) s
5 612 M
( 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 ) s
5 601 M
( 71 72 73 74 75 76 77 78 79 7A 2D 30 31 32 33 34 ) s
5 590 M
( 35 36 37 38 39 2D 41 42 43 44 45 46 47 48 49 4A ) s
5 579 M
( 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A ) s
5 568 M
( 2D 30 31 32 33 34 35 36 37 38 39 2D 61 62 63 64 ) s
5 557 M
( 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 ) s
5 546 M
( 75 76 77 78 79 7A ) s
5 535 M
(hash:) s
5 524 M
( 69 0F AE 79 22 6D 95 76 0A E8 FD B4 F5 8C 05 37 ) s
5 513 M
( 11 17 56 55 7D 30 7B 15 ) s
5 491 M
(Test vectors for Shabal \(224 bits\):) s
5 480 M
(message:) s
5 469 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 458 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 447 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 436 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 425 M
(hash:) s
5 414 M
( 99 DD A6 14 F9 07 D2 E8 81 76 18 F7 30 69 6F 32 ) s
5 403 M
( 00 AE CA 8B 5F 85 F4 25 43 BA 20 31 ) s
5 381 M
(Test vectors for Shabal \(224 bits\):) s
5 370 M
(message:) s
5 359 M
( 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 ) s
5 348 M
( 71 72 73 74 75 76 77 78 79 7A 2D 30 31 32 33 34 ) s
5 337 M
( 35 36 37 38 39 2D 41 42 43 44 45 46 47 48 49 4A ) s
5 326 M
( 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A ) s
5 315 M
( 2D 30 31 32 33 34 35 36 37 38 39 2D 61 62 63 64 ) s
5 304 M
( 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 ) s
5 293 M
( 75 76 77 78 79 7A ) s
5 282 M
(hash:) s
5 271 M
( C7 D6 2D 8D 2A 34 74 B4 F4 A9 D1 1A 52 DB 3D 43 ) s
5 260 M
( 5B F1 58 CF 45 4C 5D 56 1D 71 25 F5 ) s
5 238 M
(Test vectors for Shabal \(256 bits\):) s
5 227 M
(message:) s
5 216 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 205 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 194 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 183 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 172 M
(hash:) s
5 161 M
( DA 8F 08 C0 2A 67 BA 9A 56 BD D0 79 8E 48 AE 07 ) s
5 150 M
( 14 21 5E 09 3B 5B 85 06 49 A3 77 18 99 3F 54 A2 ) s
5 128 M
(Test vectors for Shabal \(256 bits\):) s
5 117 M
(message:) s
5 106 M
( 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 ) s
5 95 M
( 71 72 73 74 75 76 77 78 79 7A 2D 30 31 32 33 34 ) s
5 84 M
( 35 36 37 38 39 2D 41 42 43 44 45 46 47 48 49 4A ) s
5 73 M
( 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A ) s
5 62 M
( 2D 30 31 32 33 34 35 36 37 38 39 2D 61 62 63 64 ) s
5 51 M
( 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 ) s
5 40 M
( 75 76 77 78 79 7A ) s
5 29 M
(hash:) s
5 18 M
( B4 9F 34 BF 51 86 4C 30 53 3C C4 6C C2 54 2B DE ) s
5 7 M
( C2 F9 6F D0 6F 5C 53 9A FF 6E AD 58 83 F7 32 7A ) s
_R
S
%%Page: (2) 2
%%BeginPageSetup
_S
24 24 translate
/pagenum 2 def
/fname (shabal_shorttest.log) def
/fdir () def
/ftail (shabal_shorttest.log) def
% User defined strings:
/fmodstr (Mon Apr 27 00:58:21 2009) def
/pagenumstr (2) def
/user_header_p false def
/user_footer_p false def
%%EndPageSetup
do_header
5 755 M
(Test vectors for Shabal \(384 bits\):) s
5 744 M
(message:) s
5 733 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 722 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 711 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 700 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 689 M
(hash:) s
5 678 M
( 9D DE 12 33 91 0D 85 DA 3A 5C 78 03 12 B1 11 C6 ) s
5 667 M
( FC CA 1B 5D D2 55 37 03 5E E0 8E 3B 4E 1E 25 15 ) s
5 656 M
( 4F 72 6A 63 84 E5 A8 F0 AF EA AB 4A C4 C0 2F 12 ) s
5 634 M
(Test vectors for Shabal \(384 bits\):) s
5 623 M
(message:) s
5 612 M
( 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 ) s
5 601 M
( 71 72 73 74 75 76 77 78 79 7A 2D 30 31 32 33 34 ) s
5 590 M
( 35 36 37 38 39 2D 41 42 43 44 45 46 47 48 49 4A ) s
5 579 M
( 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A ) s
5 568 M
( 2D 30 31 32 33 34 35 36 37 38 39 2D 61 62 63 64 ) s
5 557 M
( 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 ) s
5 546 M
( 75 76 77 78 79 7A ) s
5 535 M
(hash:) s
5 524 M
( 30 01 2C 0E 3E DC 46 0B D7 86 27 C2 C3 09 44 D2 ) s
5 513 M
( A1 89 66 9A FA 2D 7A 97 13 EF 2F 77 4C 44 74 A4 ) s
5 502 M
( 3A F1 CB CE C5 FA B4 24 8C 08 73 F0 38 FB EB A0 ) s
5 480 M
(Test vectors for Shabal \(512 bits\):) s
5 469 M
(message:) s
5 458 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 447 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 436 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 425 M
( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ) s
5 414 M
(hash:) s
5 403 M
( 15 80 16 C6 C8 1F 3F 0A 52 D9 8D 68 ED 2F 9E 8E ) s
5 392 M
( 78 95 EF 23 CB A7 E2 BC 61 09 D8 A5 32 E6 C9 E6 ) s
5 381 M
( A6 A5 01 97 9F B8 37 F0 4E C4 C6 20 E7 31 79 DC ) s
5 370 M
( 82 AB B5 2B 32 CD AD B3 56 50 E2 9C 98 5E 30 22 ) s
5 348 M
(Test vectors for Shabal \(512 bits\):) s
5 337 M
(message:) s
5 326 M
( 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 ) s
5 315 M
( 71 72 73 74 75 76 77 78 79 7A 2D 30 31 32 33 34 ) s
5 304 M
( 35 36 37 38 39 2D 41 42 43 44 45 46 47 48 49 4A ) s
5 293 M
( 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A ) s
5 282 M
( 2D 30 31 32 33 34 35 36 37 38 39 2D 61 62 63 64 ) s
5 271 M
( 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 ) s
5 260 M
( 75 76 77 78 79 7A ) s
5 249 M
(hash:) s
5 238 M
( 67 7E 6F 7F 12 D7 0A F0 B3 35 66 2F 59 B5 68 51 ) s
5 227 M
( F3 65 3E 66 64 7D 33 86 DF DA 01 43 25 4C C8 A5 ) s
5 216 M
( DB 3E 21 94 06 8C 6F 71 59 7D 7B 60 98 4D 22 B4 ) s
5 205 M
( 7A 1F 60 D9 1C A8 DF CB 17 5D 65 B9 73 59 CE CF ) s
5 194 M
(>) s
_R
S
%%Trailer
%%Pages: 2
%%DocumentNeededResources: font Courier-Bold Courier
%%EOF

66
skein/memxor.S Normal file
View File

@ -0,0 +1,66 @@
/* memxor.S */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* File: memxor.S
* Author: Daniel Otte
* Date: 2008-08-07
* License: GPLv3 or later
* Description: memxor, XORing one block into another
*
*/
/*
* void memxor(void* dest, const void* src, uint16_t n);
*/
/*
* param dest is passed in r24:r25
* param src is passed in r22:r23
* param n is passed in r20:r21
*/
.global memxor
memxor:
movw r30, r24
movw r26, r22
movw r24, r20
adiw r24, 0
breq 2f
1:
ld r20, X+
ld r21, Z
eor r20, r21
st Z+, r20
sbiw r24, 1
brne 1b
2:
ret

7
skein/memxor.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef MEMXOR_H_
#define MEMXOR_H_
#include <stdint.h>
void memxor(void* dest, const void* src, uint16_t n);
#endif

202
skein/skein-speed.log Normal file
View File

@ -0,0 +1,202 @@
performance
=== Skein-256-128 performance ===
type: hashfunction
hashsize (bits): 128
ctxsize (bytes): 50
blocksize (bits): 256
init (cycles): 42999
nextBlock (cycles): 42003
lastBlock (cycles): 41706
ctx2hash (cycles): 42912
=== Skein-256-160 performance ===
type: hashfunction
hashsize (bits): 160
ctxsize (bytes): 50
blocksize (bits): 256
init (cycles): 42999
nextBlock (cycles): 42003
lastBlock (cycles): 41713
ctx2hash (cycles): 42940
=== Skein-256-224 performance ===
type: hashfunction
hashsize (bits): 224
ctxsize (bytes): 50
blocksize (bits): 256
init (cycles): 43006
nextBlock (cycles): 42003
lastBlock (cycles): 41713
ctx2hash (cycles): 42996
=== Skein-256-256 performance ===
type: hashfunction
hashsize (bits): 256
ctxsize (bytes): 50
blocksize (bits): 256
init (cycles): 43006
nextBlock (cycles): 42003
lastBlock (cycles): 41706
ctx2hash (cycles): 43026
=== Skein-256-384 performance ===
type: hashfunction
hashsize (bits): 384
ctxsize (bytes): 50
blocksize (bits): 256
init (cycles): 42999
nextBlock (cycles): 42003
lastBlock (cycles): 41706
ctx2hash (cycles): 20054
=== Skein-256-512 performance ===
type: hashfunction
hashsize (bits): 512
ctxsize (bytes): 50
blocksize (bits): 256
init (cycles): 42999
nextBlock (cycles): 42003
lastBlock (cycles): 41706
ctx2hash (cycles): 20165
=== Skein-512-128 performance ===
type: hashfunction
hashsize (bits): 128
ctxsize (bytes): 82
blocksize (bits): 512
init (cycles): 30522
nextBlock (cycles): 29183
lastBlock (cycles): 28526
ctx2hash (cycles): 30515
=== Skein-512-160 performance ===
type: hashfunction
hashsize (bits): 160
ctxsize (bytes): 82
blocksize (bits): 512
init (cycles): 30522
nextBlock (cycles): 29183
lastBlock (cycles): 28526
ctx2hash (cycles): 30536
=== Skein-512-224 performance ===
type: hashfunction
hashsize (bits): 224
ctxsize (bytes): 82
blocksize (bits): 512
init (cycles): 30522
nextBlock (cycles): 29176
lastBlock (cycles): 28526
ctx2hash (cycles): 30592
=== Skein-512-256 performance ===
type: hashfunction
hashsize (bits): 256
ctxsize (bytes): 82
blocksize (bits): 512
init (cycles): 30522
nextBlock (cycles): 29176
lastBlock (cycles): 28533
ctx2hash (cycles): 30620
=== Skein-512-384 performance ===
type: hashfunction
hashsize (bits): 384
ctxsize (bytes): 82
blocksize (bits): 512
init (cycles): 30529
nextBlock (cycles): 29176
lastBlock (cycles): 28533
ctx2hash (cycles): 30732
=== Skein-512-512 performance ===
type: hashfunction
hashsize (bits): 512
ctxsize (bytes): 82
blocksize (bits): 512
init (cycles): 30529
nextBlock (cycles): 29176
lastBlock (cycles): 28533
ctx2hash (cycles): 30846
=== Skein-512-1024 performance ===
type: hashfunction
hashsize (bits): 1024
ctxsize (bytes): 82
blocksize (bits): 512
init (cycles): 30529
nextBlock (cycles): 29176
lastBlock (cycles): 28526
ctx2hash (cycles): 61119
=== Skein-1024-128 performance ===
type: hashfunction
hashsize (bits): 128
ctxsize (bytes): 146
blocksize (bits): 1024
init (cycles): 28976
nextBlock (cycles): 26263
lastBlock (cycles): 23978
ctx2hash (cycles): 27216
=== Skein-1024-160 performance ===
type: hashfunction
hashsize (bits): 160
ctxsize (bytes): 146
blocksize (bits): 1024
init (cycles): 28983
nextBlock (cycles): 26256
lastBlock (cycles): 23978
ctx2hash (cycles): 27244
=== Skein-1024-224 performance ===
type: hashfunction
hashsize (bits): 224
ctxsize (bytes): 146
blocksize (bits): 1024
init (cycles): 28983
nextBlock (cycles): 26256
lastBlock (cycles): 23978
ctx2hash (cycles): 27307
=== Skein-1024-256 performance ===
type: hashfunction
hashsize (bits): 256
ctxsize (bytes): 146
blocksize (bits): 1024
init (cycles): 28983
nextBlock (cycles): 26263
lastBlock (cycles): 23971
ctx2hash (cycles): 27335
=== Skein-1024-384 performance ===
type: hashfunction
hashsize (bits): 384
ctxsize (bytes): 146
blocksize (bits): 1024
init (cycles): 28983
nextBlock (cycles): 26263
lastBlock (cycles): 23971
ctx2hash (cycles): 27447
=== Skein-1024-512 performance ===
type: hashfunction
hashsize (bits): 512
ctxsize (bytes): 146
blocksize (bits): 1024
init (cycles): 28983
nextBlock (cycles): 26263
lastBlock (cycles): 23971
ctx2hash (cycles): 27559
=== Skein-1024-1024 performance ===
type: hashfunction
hashsize (bits): 1024
ctxsize (bytes): 146
blocksize (bits): 1024
init (cycles): 28983
nextBlock (cycles): 26263
lastBlock (cycles): 23971
ctx2hash (cycles): 28002
>

Some files were not shown because too many files have changed in this diff Show More