updated build system

This commit is contained in:
bg 2010-09-26 18:22:40 +02:00
parent d00ed9a275
commit d70d1d77ba
174 changed files with 2667 additions and 426 deletions

105
Makefile
View File

@ -1,4 +1,4 @@
# Makefile for the AVR-Crypto-Lib project
# Makefile for the ARM-Crypto-Lib project
#
# This file is part of the AVR-Crypto-Lib.
# Copyright (C) 2010 Daniel Otte (daniel.otte@rub.de)
@ -28,10 +28,14 @@ SIGNATURE :=
PK_CIPHERS :=
AUX :=
# we use the gnu make standard library
include gmsl
include arm-makefile.inc
GLOBAL_INCDIR := ./ $(TESTSRC_DIR)
#-------------------------------------------------------------------------------
# inclusion of make stubs
include mkfiles/*.mk
@ -59,29 +63,8 @@ $(foreach a, $(ALGORITHMS), $(eval $(call Assert_Template, \
)))
#$(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
define TargetSource_Template
$(1): $(2)
@ -90,11 +73,26 @@ $(1): $(2)
@$(CC) $(CFLAGS_A) -I./$(strip $(3)) -c -o $(1) $(2)
endef
# ----------------------------------------------------------------------------
# Function: find_source_file
# Arguments: 1: name of the binary file (.o extension) to search
# 2: list of directorys to search for file
# Returns: Returns paths to source file (mathing the pattern in
# $(SOURCE_PATTERN)
# ----------------------------------------------------------------------------
SOURCE_PATTERN := %.S %.c
find_source_file = $(firstword $(foreach d, $(2), \
$(filter $(SOURCE_PATTERN), \
$(wildcard $(d)$(notdir $(patsubst %.o,%,$1)).*) \
) \
) )
$(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))).*)), \
$(call find_source_file, $(b), $($(a)_DIR) $($(a)_INCDIR) $(GLOBAL_INCDIR) ),\
$($(a)_DIR) \
)) \
) \
@ -103,15 +101,13 @@ $(foreach a, $(ALGORITHMS), \
$(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))).*))\
), \
$(BIN_DIR)$(call lc, $(a))/$(TEST_DIR)$(b), \
$(call find_source_file, $(b), $($(a)_DIR) $($(a)_INCDIR) $(GLOBAL_INCDIR) ),\
$($(a)_DIR) \
)) \
) \
)
#-------------------------------------------------------------------------------
define MainTestElf_Template
@ -162,7 +158,7 @@ endef
$(foreach algo, $(ALGORITHMS), $(eval $(call Flash_Template, \
$(algo), \
$(BIN_DIR)$(call lc, $(algo))/$(TEST_DIR)main-$(call lc, $(algo))-test.elf \
$(BIN_DIR)$(call lc, $(algo))/$(TEST_DIR)main-$(call lc, $(algo))-test.hex \
)))
#-------------------------------------------------------------------------------
@ -179,6 +175,8 @@ $(foreach algo, $(ALGORITHMS), $(eval $(call Speed_Template, \
.PHONY: hash_speed
hash_speed: $(foreach algo, $(HASHES), $(algo)_SPEED)
.PHONY: blockcipher_speed
blockcipher_speed: $(foreach algo, $(BLOCK_CIPHERS), $(algo)_SPEED)
#-------------------------------------------------------------------------------
@ -195,6 +193,9 @@ $(foreach algo, $(ALGORITHMS), $(eval $(call Size_Template, \
.PHONY: hash_size
hash_size: $(foreach algo, $(HASHES), $(algo)_SIZE)
.PHONY: blockcipher_size
blockcipher_size: $(foreach algo, $(BLOCK_CIPHERS), $(algo)_SIZE)
#-------------------------------------------------------------------------------
.PHONY: tests
@ -277,27 +278,29 @@ info:
@echo " auxiliary functions:"
@echo " $(AUX)"
@echo " targets:"
@echo " all - all algorithm cores"
@echo " cores - all algorithm cores"
@echo " listings - all algorithm core listings"
@echo " tests - all algorithm test programs"
@echo " stats - all algorithm size statistics"
@echo " blockciphers - all blockcipher cores"
@echo " streamciphers - all streamcipher cores"
@echo " hashes - all hash cores"
@echo " macs - all MAC cores"
@echo " prngs - all PRNG cores"
@echo " all_testrun - testrun all algorithms"
@echo " hash_size - measure size of all hash functions"
@echo " hash_speed - measure performance of all hash functions"
@echo " docu - build doxygen documentation"
@echo " clean - remove a lot of builded 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"
@echo " all - all algorithm cores"
@echo " cores - all algorithm cores"
@echo " listings - all algorithm core listings"
@echo " tests - all algorithm test programs"
@echo " stats - all algorithm size statistics"
@echo " blockciphers - all blockcipher cores"
@echo " streamciphers - all streamcipher cores"
@echo " hashes - all hash cores"
@echo " macs - all MAC cores"
@echo " prngs - all PRNG cores"
@echo " all_testrun - testrun all algorithms"
@echo " hash_size - measure size of all hash functions"
@echo " hash_speed - measure performance of all hash functions"
@echo " blockcipher_size - measure size of all blockciphers"
@echo " blockcipher_speed - measure performance of all blockciphers"
@echo " docu - build doxygen documentation"
@echo " clean - remove a lot of builded 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"
#-------------------------------------------------------------------------------
@ -308,7 +311,7 @@ clean:
.PHONY: depclean
depclean: clean
rm $(DEP_DIR)*.d
rm -f $(DEP_DIR)*.d
#-------------------------------------------------------------------------------
# dependency inclusion

View File

@ -19,7 +19,7 @@
#include <stdint.h>
#include <string.h>
#include "gf256mul.h"
#include "gf256mul/gf256mul.h"
#include "aes.h"
#include "aes_invsbox.h"
#include "aes_dec.h"

View File

@ -28,8 +28,8 @@
#include <stdint.h>
#include <string.h>
#include "aes.h"
#include "gf256mul.h"
#include "aes_sbox.h"
#include "gf256mul/gf256mul.h"
#include "aes/aes_sbox.h"
#include "aes_enc.h"
void aes_shiftcol(void* data, uint8_t shift){

View File

@ -28,7 +28,7 @@
#include <stdint.h>
#include "aes.h"
#include "aes_keyschedule.h"
#include "aes_sbox.h"
#include "aes/aes_sbox.h"
#include <string.h>
static

View File

@ -28,6 +28,6 @@
#define AES_SBOX_H_
#include <stdint.h>
extern uint8_t aes_sbox[];
extern const uint8_t aes_sbox[];
#endif

View File

@ -6,7 +6,6 @@ FLASHCMD = arm-elf-gdb -x gdb-flash #
DEP_DIR = deps/
TEST_DIR = test/
BIN_DIR = bin/
TESTBIN_DIR = test_bin/
TESTSRC_DIR = test_src/
ERASECMD =
TESTPORT = /dev/ttyUSB1

View File

@ -21,7 +21,7 @@
#include <string.h>
#include "bcal-cbc.h"
#include "bcal-basic.h"
#include "memxor.h"
#include "memxor/memxor.h"
uint8_t bcal_cbc_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, bcal_cbc_ctx_t* ctx){
ctx->desc = (bcdesc_t*)desc;

View File

@ -22,7 +22,7 @@
#include <string.h>
#include "bcal-cfb_byte.h"
#include "bcal-basic.h"
#include "memxor.h"
#include "memxor/memxor.h"
uint8_t bcal_cfb_B_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, uint16_t size_b, bcal_cfb_B_ctx_t* ctx){

View File

@ -22,7 +22,7 @@
#include <string.h>
#include "bcal-basic.h"
#include "bcal-cmac.h"
#include "memxor.h"
#include "memxor/memxor.h"
static uint8_t left_shift_be_block(void* block, uint8_t blocksize_B){

View File

@ -22,7 +22,7 @@
#include <string.h>
#include "bcal-basic.h"
#include "bcal-ctr.h"
#include "memxor.h"
#include "memxor/memxor.h"
static void increment_be(void* block, uint8_t size_B){
uint16_t c=1;

View File

@ -24,7 +24,7 @@
#include "bcal-cmac.h"
#include "bcal-ctr.h"
#include "bcal-eax.h"
#include "memxor.h"
#include "memxor/memxor.h"
uint8_t bcal_eax_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, bcal_eax_ctx_t* ctx){
uint8_t r;

View File

@ -21,7 +21,7 @@
#include <string.h>
#include "bcal-ofb.h"
#include "bcal-basic.h"
#include "memxor.h"
#include "memxor/memxor.h"
uint8_t bcal_ofb_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, bcal_ofb_ctx_t* ctx){

52
bcal/bcal_camellia128.c Normal file
View File

@ -0,0 +1,52 @@
/* bcal_camellia128.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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 bcal_camellia128.c
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "blockcipher_descriptor.h"
#include "camellia.h"
#include "keysize_descriptor.h"
const char camellia128_str[] PROGMEM = "Camellia-128";
const uint8_t camellia128_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(128),
KS_TYPE_TERMINATOR };
const bcdesc_t camellia128_desc PROGMEM = {
BCDESC_TYPE_BLOCKCIPHER,
BC_INIT_TYPE_2,
camellia128_str,
sizeof(camellia128_ctx_t),
128,
{(void_fpt)camellia128_init},
{(void_fpt)camellia128_enc},
{(void_fpt)camellia128_dec},
(bc_free_fpt)NULL,
camellia128_keysize_desc
};

33
bcal/bcal_camellia128.h Normal file
View File

@ -0,0 +1,33 @@
/* bcal_camellia128.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 bcal_camellia128.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include "blockcipher_descriptor.h"
#include "camellia.h"
#include "keysize_descriptor.h"
extern const bcdesc_t camellia128_desc;

52
bcal/bcal_cast5.c Normal file
View File

@ -0,0 +1,52 @@
/* bcal_cast5.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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 bcal_cast5.c
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "blockcipher_descriptor.h"
#include "cast5.h"
#include "keysize_descriptor.h"
const char cast5_str[] PROGMEM = "CAST5";
const uint8_t cast5_keysize_desc[] PROGMEM = { KS_TYPE_RANGE, KS_INT(0), KS_INT(128),
KS_TYPE_TERMINATOR };
const bcdesc_t cast5_desc PROGMEM = {
BCDESC_TYPE_BLOCKCIPHER,
BC_INIT_TYPE_2,
cast5_str,
sizeof(cast5_ctx_t),
128,
{(void_fpt)cast5_init},
{(void_fpt)cast5_enc},
{(void_fpt)cast5_dec},
(bc_free_fpt)NULL,
cast5_keysize_desc
};

33
bcal/bcal_cast5.h Normal file
View File

@ -0,0 +1,33 @@
/* bcal_cast5.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 bcal_cast5.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include "blockcipher_descriptor.h"
#include "cast5.h"
#include "keysize_descriptor.h"
extern const bcdesc_t cast5_desc;

52
bcal/bcal_cast6.c Normal file
View File

@ -0,0 +1,52 @@
/* bcal_cast6.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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 bcal_cast6.c
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-04-03
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "blockcipher_descriptor.h"
#include "cast6.h"
#include "keysize_descriptor.h"
const char cast6_str[] PROGMEM = "CAST-256";
const uint8_t cast6_keysize_desc[] PROGMEM = { KS_TYPE_RANGE, KS_INT(0), KS_INT(256),
KS_TYPE_TERMINATOR };
const bcdesc_t cast6_desc PROGMEM = {
BCDESC_TYPE_BLOCKCIPHER,
BC_INIT_TYPE_2,
cast6_str,
sizeof(cast6_ctx_t),
128,
{(void_fpt)cast6_init},
{(void_fpt)cast6_enc},
{(void_fpt)cast6_dec},
(bc_free_fpt)NULL,
cast6_keysize_desc
};

33
bcal/bcal_cast6.h Normal file
View File

@ -0,0 +1,33 @@
/* bcal_cast6.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 bcal_cast6.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-04-03
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include "blockcipher_descriptor.h"
#include "cast6.h"
#include "keysize_descriptor.h"
extern const bcdesc_t cast6_desc;

61
bcal/bcal_des.c Normal file
View File

@ -0,0 +1,61 @@
/* bcal_des.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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 bcal_des.c
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "blockcipher_descriptor.h"
#include "des.h"
#include "keysize_descriptor.h"
const char des_str[] PROGMEM = "DES";
const uint8_t des_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(64),
KS_TYPE_TERMINATOR };
static
void des_dummy_enc(void* block, void* key){
des_enc(block, block, key);
}
static
void des_dummy_dec(void* block, void* key){
des_dec(block, block, key);
}
const bcdesc_t des_desc PROGMEM = {
BCDESC_TYPE_BLOCKCIPHER,
BC_INIT_TYPE_1,
des_str,
8,
128,
{(void_fpt)NULL},
{(void_fpt)des_dummy_enc},
{(void_fpt)des_dummy_dec},
(bc_free_fpt)NULL,
des_keysize_desc
};

View File

@ -1,4 +1,4 @@
/* aes_sbox.h */
/* bcal_des.h */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
@ -17,17 +17,17 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file aes_sbox.h
* \file bcal_des.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2008-12-30
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#ifndef AES_SBOX_H_
#define AES_SBOX_H_
#include <stdint.h>
extern const uint8_t aes_sbox[];
#include <avr/pgmspace.h>
#include "blockcipher_descriptor.h"
#include "des.h"
#include "keysize_descriptor.h"
#endif
extern const bcdesc_t des_desc;

41
bcal/bcal_noekeon.c Normal file
View File

@ -0,0 +1,41 @@
/* bcal_noekeon.c */
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "blockcipher_descriptor.h"
#include "noekeon/noekeon.h"
#include "keysize_descriptor.h"
const char noekeon_direct_str[] PROGMEM = "Noekeon-Direct";
const char noekeon_indirect_str[] PROGMEM = "Noekeon-Indirect";
const uint8_t noekeon_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(128),
KS_TYPE_TERMINATOR };
const bcdesc_t noekeon_direct_desc PROGMEM = {
BCDESC_TYPE_BLOCKCIPHER,
BC_ENC_TYPE_1,
noekeon_direct_str,
16,
128,
{(void_fpt)NULL},
{(void_fpt)noekeon_enc},
{(void_fpt)noekeon_dec},
(bc_free_fpt)NULL,
noekeon_keysize_desc
};
const bcdesc_t noekeon_indirect_desc PROGMEM = {
BCDESC_TYPE_BLOCKCIPHER,
BC_INIT_TYPE_1 | BC_ENC_TYPE_1,
noekeon_indirect_str,
16,
128,
{(void_fpt)noekeon_init},
{(void_fpt)noekeon_enc},
{(void_fpt)noekeon_dec},
(bc_free_fpt)NULL,
noekeon_keysize_desc
};

10
bcal/bcal_noekeon.h Normal file
View File

@ -0,0 +1,10 @@
/* bcal_noekeon.h */
#include <avr/pgmspace.h>
#include "blockcipher_descriptor.h"
#include "noekeon/noekeon.h"
#include "keysize_descriptor.h"
extern const bcdesc_t noekeon_direct_desc;
extern const bcdesc_t noekeon_indirect_desc;

52
bcal/bcal_present.c Normal file
View File

@ -0,0 +1,52 @@
/* bcal_present.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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 bcal_present.c
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "blockcipher_descriptor.h"
#include "present.h"
#include "keysize_descriptor.h"
const char present_str[] PROGMEM = "Present";
const uint8_t present_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(80),
KS_TYPE_TERMINATOR };
const bcdesc_t present_desc PROGMEM = {
BCDESC_TYPE_BLOCKCIPHER,
BC_INIT_TYPE_1,
present_str,
sizeof(present_ctx_t),
64,
{(void_fpt)present_init},
{(void_fpt)present_enc},
{(void_fpt)present_dec},
(bc_free_fpt)NULL,
present_keysize_desc
};

33
bcal/bcal_present.h Normal file
View File

@ -0,0 +1,33 @@
/* bcal_present.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 bcal_present.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include "blockcipher_descriptor.h"
#include "present.h"
#include "keysize_descriptor.h"
extern const bcdesc_t present_desc;

59
bcal/bcal_rc5.c Normal file
View File

@ -0,0 +1,59 @@
/* bcal_rc5.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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 bcal_rc5.c
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "blockcipher_descriptor.h"
#include "rc5.h"
#include "keysize_descriptor.h"
#define RC5_ROUNDS 12
const char rc5_str[] PROGMEM = "RC5";
const uint8_t rc5_keysize_desc[] PROGMEM = { KS_TYPE_RANGE, KS_INT(1), KS_INT(2040),
KS_TYPE_TERMINATOR };
static
void rc5_dummy_init(void* key, uint16_t keysize_b, void* ctx){
rc5_init(key, keysize_b, RC5_ROUNDS, ctx);
}
const bcdesc_t rc5_desc PROGMEM = {
BCDESC_TYPE_BLOCKCIPHER,
BC_INIT_TYPE_2,
rc5_str,
sizeof(rc5_ctx_t),
128,
{(void_fpt)rc5_dummy_init},
{(void_fpt)rc5_enc},
{(void_fpt)rc5_dec},
(bc_free_fpt)rc5_free,
rc5_keysize_desc
};

View File

@ -1,4 +1,4 @@
/* aes_sbox.h */
/* bcal_rc5.h */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
@ -17,17 +17,17 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file aes_sbox.h
* \file bcal_rc5.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2008-12-30
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#ifndef AES_SBOX_H_
#define AES_SBOX_H_
#include <stdint.h>
extern uint8_t aes_sbox[];
#include <avr/pgmspace.h>
#include "blockcipher_descriptor.h"
#include "rc5.h"
#include "keysize_descriptor.h"
#endif
extern const bcdesc_t rc5_desc;

52
bcal/bcal_rc6.c Normal file
View File

@ -0,0 +1,52 @@
/* bcal_rc6.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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 bcal_rc6.c
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "blockcipher_descriptor.h"
#include "rc6.h"
#include "keysize_descriptor.h"
const char rc6_str[] PROGMEM = "RC6";
const uint8_t rc6_keysize_desc[] PROGMEM = { KS_TYPE_RANGE, KS_INT(1), KS_INT(2040),
KS_TYPE_TERMINATOR };
const bcdesc_t rc6_desc PROGMEM = {
BCDESC_TYPE_BLOCKCIPHER,
BC_INIT_TYPE_2,
rc6_str,
sizeof(rc6_ctx_t),
128,
{(void_fpt)rc6_init},
{(void_fpt)rc6_enc},
{(void_fpt)rc6_dec},
(bc_free_fpt)rc6_free,
rc6_keysize_desc
};

View File

@ -1,4 +1,4 @@
/* gf256mul.h */
/* bcal_rc6.h */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
@ -16,22 +16,18 @@
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
*
* \file bcal_rc6.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <stdint.h>
uint8_t gf256mul(uint8_t a, uint8_t b, uint8_t reducer);
#endif /* GF256MUL_H_ */
#include <avr/pgmspace.h>
#include "blockcipher_descriptor.h"
#include "rc6.h"
#include "keysize_descriptor.h"
extern const bcdesc_t rc6_desc;

View File

@ -1,4 +1,4 @@
/* gf256mul.c */
/* bcal_seed.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 Daniel Otte (daniel.otte@rub.de)
@ -16,25 +16,37 @@
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 bcal_seed.c
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "blockcipher_descriptor.h"
#include "seed.h"
#include "keysize_descriptor.h"
const char seed_str[] PROGMEM = "SEED";
const uint8_t seed_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(128),
KS_TYPE_TERMINATOR };
const bcdesc_t seed_desc PROGMEM = {
BCDESC_TYPE_BLOCKCIPHER,
BC_INIT_TYPE_1,
seed_str,
sizeof(seed_ctx_t),
128,
{(void_fpt)seed_init},
{(void_fpt)seed_enc},
{(void_fpt)seed_dec},
(bc_free_fpt)NULL,
seed_keysize_desc
};
#include <stdint.h>
uint8_t gf256mul(uint8_t a, uint8_t b, uint8_t reducer){
uint8_t r=0;
while(a&0xFE){
if(a&1){
r ^= b;
}
a >>= 1;
if(b&0x80){
b <<= 1;
b ^= reducer;
}else{
b <<= 1;
}
}
if(a&1){
r ^= b;
}
return r;
}

33
bcal/bcal_seed.h Normal file
View File

@ -0,0 +1,33 @@
/* bcal_seed.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 bcal_seed.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include "blockcipher_descriptor.h"
#include "seed.h"
#include "keysize_descriptor.h"
extern const bcdesc_t seed_desc;

52
bcal/bcal_serpent.c Normal file
View File

@ -0,0 +1,52 @@
/* bcal_serpent.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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 bcal_serpent.c
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "blockcipher_descriptor.h"
#include "serpent.h"
#include "keysize_descriptor.h"
const char serpent_str[] PROGMEM = "serpent";
const uint8_t serpent_keysize_desc[] PROGMEM = { KS_TYPE_RANGE, KS_INT(1), KS_INT(256),
KS_TYPE_TERMINATOR };
const bcdesc_t serpent_desc PROGMEM = {
BCDESC_TYPE_BLOCKCIPHER,
BC_INIT_TYPE_2,
serpent_str,
sizeof(serpent_ctx_t),
128,
{(void_fpt)serpent_init},
{(void_fpt)serpent_enc},
{(void_fpt)serpent_dec},
(bc_free_fpt)NULL,
serpent_keysize_desc
};

33
bcal/bcal_serpent.h Normal file
View File

@ -0,0 +1,33 @@
/* bcal_serpent.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 bcal_serpent.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include "blockcipher_descriptor.h"
#include "serpent.h"
#include "keysize_descriptor.h"
extern const bcdesc_t serpent_desc;

52
bcal/bcal_skipjack.c Normal file
View File

@ -0,0 +1,52 @@
/* bcal_skipjack.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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 bcal_skipjack.c
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "blockcipher_descriptor.h"
#include "skipjack.h"
#include "keysize_descriptor.h"
const char skipjack_str[] PROGMEM = "Skipjack";
const uint8_t skipjack_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(80),
KS_TYPE_TERMINATOR };
const bcdesc_t skipjack_desc PROGMEM = {
BCDESC_TYPE_BLOCKCIPHER,
BC_INIT_TYPE_1,
skipjack_str,
10,
64,
{(void_fpt)NULL},
{(void_fpt)skipjack_enc},
{(void_fpt)skipjack_dec},
(bc_free_fpt)NULL,
skipjack_keysize_desc
};

33
bcal/bcal_skipjack.h Normal file
View File

@ -0,0 +1,33 @@
/* bcal_skipjack.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 bcal_skipjack.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include "blockcipher_descriptor.h"
#include "skipjack.h"
#include "keysize_descriptor.h"
extern const bcdesc_t skipjack_desc;

62
bcal/bcal_tdes.c Normal file
View File

@ -0,0 +1,62 @@
/* bcal_tdes.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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 bcal_tdes.c
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "blockcipher_descriptor.h"
#include "des.h"
#include "keysize_descriptor.h"
const char tdes_str[] PROGMEM = "TDES";
const uint8_t tdes_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(192),
KS_TYPE_TERMINATOR };
static
void tdes_dummy_enc(void* block, void* key){
tdes_enc(block, block, key);
}
static
void tdes_dummy_dec(void* block, void* key){
tdes_dec(block, block, key);
}
const bcdesc_t tdes_desc PROGMEM = {
BCDESC_TYPE_BLOCKCIPHER,
BC_INIT_TYPE_1,
tdes_str,
24,
64,
{(void_fpt)NULL},
{(void_fpt)tdes_dummy_enc},
{(void_fpt)tdes_dummy_dec},
(bc_free_fpt)NULL,
tdes_keysize_desc
};

33
bcal/bcal_tdes.h Normal file
View File

@ -0,0 +1,33 @@
/* bcal_tdes.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 bcal_tdes.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include "blockcipher_descriptor.h"
#include "des.h"
#include "keysize_descriptor.h"
extern const bcdesc_t tdes_desc;

70
bcal/bcal_tdes2.c Normal file
View File

@ -0,0 +1,70 @@
/* bcal_tdes2.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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 bcal_tdes.c
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2010-02-02
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "blockcipher_descriptor.h"
#include "des.h"
#include "keysize_descriptor.h"
const char tdes2_str[] PROGMEM = "TDES-2";
const uint8_t tdes2_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(128),
KS_TYPE_TERMINATOR };
static
void tdes_dummy_enc(void* block, void* key){
tdes_enc(block, block, key);
}
static
void tdes_dummy_dec(void* block, void* key){
tdes_dec(block, block, key);
}
static
void tdes2_init(void* key, void* ctx){
memcpy(ctx, key, 16);
memcpy((uint8_t*)ctx+16, key, 8);
}
const bcdesc_t tdes2_desc PROGMEM = {
BCDESC_TYPE_BLOCKCIPHER,
BC_INIT_TYPE_1,
tdes2_str,
24,
64,
{(void_fpt)tdes2_init},
{(void_fpt)tdes_dummy_enc},
{(void_fpt)tdes_dummy_dec},
(bc_free_fpt)NULL,
tdes2_keysize_desc
};

38
bcal/bcal_tdes2.h Normal file
View File

@ -0,0 +1,38 @@
/* bcal_tdes2.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 bcal_tdes.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#ifndef BCAL_TDES2_H_
#define BCAL_TDES2_H_
#include <avr/pgmspace.h>
#include "blockcipher_descriptor.h"
#include "des.h"
#include "keysize_descriptor.h"
extern const bcdesc_t tdes2_desc;
#endif /* BCAL_TDES2_H_ */

56
bcal/bcal_threefish1024.c Normal file
View File

@ -0,0 +1,56 @@
/* bcal_threefish1024.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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 bcal_threefish1024.c
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2010-02-20
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "blockcipher_descriptor.h"
#include "threefish.h"
#include "keysize_descriptor.h"
const char threefish1024_str[] PROGMEM = "Threefish-1024";
const uint8_t threefish1024_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(1024),
KS_TYPE_TERMINATOR };
static void threefish1024_dummy_init(void* key, void* ctx){
threefish1024_init(key, NULL, ctx);
}
const bcdesc_t threefish1024_desc PROGMEM = {
BCDESC_TYPE_BLOCKCIPHER,
BC_INIT_TYPE_1,
threefish1024_str,
sizeof(threefish1024_ctx_t),
1024,
{(void_fpt)threefish1024_dummy_init},
{(void_fpt)threefish1024_enc},
{(void_fpt)threefish1024_dec},
(bc_free_fpt)NULL,
threefish1024_keysize_desc
};

33
bcal/bcal_threefish1024.h Normal file
View File

@ -0,0 +1,33 @@
/* bcal_threefis1024.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 bcal_threefish1024.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2010-02-20
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include "blockcipher_descriptor.h"
#include "threefish.h"
#include "keysize_descriptor.h"
extern const bcdesc_t threefish1024_desc;

56
bcal/bcal_threefish256.c Normal file
View File

@ -0,0 +1,56 @@
/* bcal_threefish256.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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 bcal_threefish256.c
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2010-02-20
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "blockcipher_descriptor.h"
#include "threefish.h"
#include "keysize_descriptor.h"
const char threefish256_str[] PROGMEM = "Threefish-256";
const uint8_t threefish256_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(256),
KS_TYPE_TERMINATOR };
static void threefish256_dummy_init(void* key, void* ctx){
threefish256_init(key, NULL, ctx);
}
const bcdesc_t threefish256_desc PROGMEM = {
BCDESC_TYPE_BLOCKCIPHER,
BC_INIT_TYPE_1,
threefish256_str,
sizeof(threefish256_ctx_t),
256,
{(void_fpt)threefish256_dummy_init},
{(void_fpt)threefish256_enc},
{(void_fpt)threefish256_dec},
(bc_free_fpt)NULL,
threefish256_keysize_desc
};

33
bcal/bcal_threefish256.h Normal file
View File

@ -0,0 +1,33 @@
/* bcal_threefis256.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 bcal_threefish256.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2010-02-20
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include "blockcipher_descriptor.h"
#include "threefish.h"
#include "keysize_descriptor.h"
extern const bcdesc_t threefish256_desc;

56
bcal/bcal_threefish512.c Normal file
View File

@ -0,0 +1,56 @@
/* bcal_threefish512.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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 bcal_threefish512.c
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2010-02-20
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "blockcipher_descriptor.h"
#include "threefish.h"
#include "keysize_descriptor.h"
const char threefish512_str[] PROGMEM = "Threefish-512";
const uint8_t threefish512_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(512),
KS_TYPE_TERMINATOR };
static void threefish512_dummy_init(void* key, void* ctx){
threefish512_init(key, NULL, ctx);
}
const bcdesc_t threefish512_desc PROGMEM = {
BCDESC_TYPE_BLOCKCIPHER,
BC_INIT_TYPE_1,
threefish512_str,
sizeof(threefish512_ctx_t),
512,
{(void_fpt)threefish512_dummy_init},
{(void_fpt)threefish512_enc},
{(void_fpt)threefish512_dec},
(bc_free_fpt)NULL,
threefish512_keysize_desc
};

33
bcal/bcal_threefish512.h Normal file
View File

@ -0,0 +1,33 @@
/* bcal_threefis512.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 bcal_threefish512.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2010-02-20
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include "blockcipher_descriptor.h"
#include "threefish.h"
#include "keysize_descriptor.h"
extern const bcdesc_t threefish512_desc;

62
bcal/bcal_xtea.c Normal file
View File

@ -0,0 +1,62 @@
/* bcal_xtea.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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 bcal_xtea.c
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "blockcipher_descriptor.h"
#include "xtea.h"
#include "keysize_descriptor.h"
const char xtea_str[] PROGMEM = "XTEA";
const uint8_t xtea_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(128),
KS_TYPE_TERMINATOR };
static
void xtea_dummy_enc(void* block, void* key){
xtea_enc(block, block, key);
}
static
void xtea_dummy_dec(void* block, void* key){
xtea_dec(block, block, key);
}
const bcdesc_t xtea_desc PROGMEM = {
BCDESC_TYPE_BLOCKCIPHER,
BC_INIT_TYPE_2,
xtea_str,
16,
64,
{(void_fpt)NULL},
{(void_fpt)xtea_dummy_enc},
{(void_fpt)xtea_dummy_dec},
(bc_free_fpt)NULL,
xtea_keysize_desc
};

33
bcal/bcal_xtea.h Normal file
View File

@ -0,0 +1,33 @@
/* bcal_xtea.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 bcal_xtea.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-01-09
* \license GPLv3 or later
*
*/
#include <avr/pgmspace.h>
#include "blockcipher_descriptor.h"
#include "xtea.h"
#include "keysize_descriptor.h"
extern const bcdesc_t xtea_desc;

View File

@ -27,7 +27,7 @@
#include <stdint.h>
#include <string.h>
#include "memxor.h"
#include "memxor/memxor.h"
#include "blake_large.h"
#include "blake_common.h"

View File

@ -27,7 +27,7 @@
#include <stdint.h>
#include <string.h>
#include "memxor.h"
#include "memxor/memxor.h"
#include "blake_small.h"
#include "blake_common.h"

View File

@ -28,7 +28,7 @@
#include <stdint.h>
#include <string.h>
#include "bmw_small.h"
#include "memxor.h"
#include "memxor/memxor.h"
#define SHL32(a,n) ((a)<<(n))
#define SHR32(a,n) ((a)>>(n))

View File

@ -28,7 +28,6 @@
#include <stdint.h>
#include <string.h>
#include "bmw_small.h"
#include "memxor.h"
#define SHL32(a,n) ((a)<<(n))
#define SHR32(a,n) ((a)>>(n))

View File

@ -1,12 +0,0 @@
#include <stdint.h>
#include "memxor.h"
void memxor(void* dest, const void* src, uint16_t n){
while(n--){
*((uint8_t*)dest) ^= *((uint8_t*)src);
dest = (uint8_t*)dest +1;
src = (uint8_t*)src +1;
}
}

View File

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

View File

@ -26,21 +26,22 @@
*/
#include "memxor.h"
#include "memxor/memxor.h"
#include "cubehash.h"
#include <string.h>
#include <stdint.h>
inline
static uint32_t rol32(uint32_t a, uint8_t r){
return (a<<r)|(a>>(32-r));
}
/*
Add x_0jklm into x_1jklm modulo 232 , for each (j, k, l, m).
Add x_0jklm into x_1jklm modulo 2**32 , for each (j, k, l, m).
Rotate x_0jklm upwards by 7 bits, for each (j, k, l, m).
Swap x_00klm with x_01klm , for each (k, l, m).
Xor x_1jklm into x_0jklm , for each (j, k, l, m).
Swap x_1jk0m with x_1jk1m , for each (j, k, m).
Add x_0jklm into x_1jklm modulo 232 , for each (j, k, l, m).
Add x_0jklm into x_1jklm modulo 2**32 , for each (j, k, l, m).
Rotate x_0jklm upwards by 11 bits, for each (j, k, l, m).
Swap x_0j0lm with x_0j1lm , for each (j, l, m).
Xor x_1jklm into x_0jklm , for each (j, k, l, m).
@ -52,8 +53,6 @@ static void cubehash_round(cubehash_ctx_t* ctx){
uint32_t t;
for(i=0; i<16; ++i){
ctx->a[i+16] += ctx->a[i];
}
for(i=0; i<16; ++i){
ctx->a[i] = rol32(ctx->a[i], 7);
}
for(i=0; i<8; ++i){
@ -74,8 +73,6 @@ static void cubehash_round(cubehash_ctx_t* ctx){
}
for(i=0; i<16; ++i){
ctx->a[i+16] += ctx->a[i];
}
for(i=0; i<16; ++i){
ctx->a[i] = rol32(ctx->a[i], 11);
}
for(i=0; i<4; ++i){

View File

@ -1,12 +0,0 @@
#include <stdint.h>
#include "memxor.h"
void memxor(void* dest, const void* src, uint16_t n){
while(n--){
*((uint8_t*)dest) ^= *((uint8_t*)src);
dest = (uint8_t*)dest +1;
src = (uint8_t*)src +1;
}
}

View File

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

View File

@ -19,8 +19,8 @@
#include <stdint.h>
#include "aes_enc_round.h"
#include "gf256mul.h"
#include "aes_sbox.h"
#include "gf256mul/gf256mul.h"
#include "aes/aes_sbox.h"
static
void aes_shiftcol(void* data, uint8_t shift){

View File

@ -1,39 +0,0 @@
/* aes sbox */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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/>.
*/
#include <stdint.h>
const uint8_t aes_sbox[256] = {
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
};

View File

@ -19,8 +19,8 @@
#include "echo.h"
#include "gf256mul.h"
#include "memxor.h"
#include "gf256mul/gf256mul.h"
#include "memxor/memxor.h"
#include "aes_enc_round.h"
#include <stdint.h>
#include <string.h>

View File

@ -1,12 +0,0 @@
#include <stdint.h>
#include "memxor.h"
void memxor(void* dest, const void* src, uint16_t n){
while(n--){
*((uint8_t*)dest) ^= *((uint8_t*)src);
dest = (uint8_t*)dest +1;
src = (uint8_t*)src +1;
}
}

View File

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

View File

@ -1,39 +0,0 @@
/* aes sbox */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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/>.
*/
#include <stdint.h>
const uint8_t aes_sbox[256] = {
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
};

View File

@ -26,9 +26,9 @@
*/
#include "groestl_large.h"
#include "aes_sbox.h"
#include "gf256mul.h"
#include "memxor.h"
#include "aes/aes_sbox.h"
#include "gf256mul/gf256mul.h"
#include "memxor/memxor.h"
#include <stdint.h>
#include <string.h>

View File

@ -26,9 +26,9 @@
*/
#include "groestl_small.h"
#include "aes_sbox.h"
#include "gf256mul.h"
#include "memxor.h"
#include "aes/aes_sbox.h"
#include "gf256mul/gf256mul.h"
#include "memxor/memxor.h"
#include <stdint.h>
#include <string.h>

View File

@ -1,12 +0,0 @@
#include <stdint.h>
#include "memxor.h"
void memxor(void* dest, const void* src, uint16_t n){
while(n--){
*((uint8_t*)dest) ^= *((uint8_t*)src);
dest = (uint8_t*)dest +1;
src = (uint8_t*)src +1;
}
}

View File

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

127
hfal/hfal-hmac.c Normal file
View File

@ -0,0 +1,127 @@
/* hfal-hmac.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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/>.
*/
#include <avr/pgmspace.h>
#include "hashfunction_descriptor.h"
#include "hfal-basic.h"
#include <stdlib.h>
#define IPAD 0x36
#define OPAD 0x5C
uint8_t hfal_hmac_init(const hfdesc_t* hash_descriptor,
hfhmacgen_ctx_t* ctx,
const void* key, uint16_t keylength_b){
uint16_t bs = hfal_hash_getBlocksize();
uint8_t buffer[bs/8];
uint8_t i;
hf_init_fpt init;
hf_nextBlock_fpt nextBlock;
memset(buffer, 0, bs/8);
ctx->desc = hash_descriptor;
ctx->ctx = malloc(pgm_read_word(&(hash_descriptor->ctxsize_B)));
ctx->finctx = malloc(pgm_read_word(&(hash_descriptor->ctxsize_B)));
if(ctx->ctx==NULL && ctx->finctx==NULL)
return 3;
if(ctx->finctx==NULL){
free(ctx->ctx)
return 2;
}
if(ctx->ctx==NULL){
free(ctx->finctx)
return 1;
}
if(keylength_b>bs){
hfal_hash_mem(hash_descriptor, buffer, key, keylength_b);
} else {
memcpy(buffer, key, (keylength_b+7)/8);
}
for(i=0; i<bs/8; ++i){
buffer[i] ^= IPAD;
}
init = pgm_read_word(&(hash_descriptor->init));
nextBlock = pgm_read_word(&(hash_descriptor->nextBlock));
init(ctx->ctx);
init(ctx->finctx);
nextBlock(ctx->ctx, buffer);
for(i=0; i<bs/8; ++i){
buffer[i] ^= IPAD^OPAD;
}
nextBlock(ctx->finctx, buffer);
memset(buffer, 0, bs/8);
}
void hfal_hmac_nextBlock(hfhmacgen_ctx_t* ctx, const void* block){
hf_nextBlock_fpt nextBlock;
nextBlock = pgm_read_word(&(hash_descriptor->nextBlock));
nextBlock(ctx->ctx, block);
}
void hfal_hmac_lastBlock(hfhmacgen_ctx_t* ctx, const void* block, uint16_t length_b){
hf_lastBlock_fpt lastBlock;
hf_ctx2hash_fpt ctx2hash;
uint16_t hs = pgm_read_word(&(hash_descriptor->hashsize_b));
uint8_t buffer[(hs+7)/8];
lastBlock = pgm_read_word(&(hash_descriptor->lastBlock));
ctx2hash = pgm_read_word(&(hash_descriptor->ctx2hash));
lastBlock(ctx->ctx, block, length_b);
ctx2hash(buffer, ctx->ctx);
lastBlock(ctx->finctx, buffer, hs);
}
void hfal_hmac_ctx2mac(void* dest, hfhmacgen_ctx_t* ctx){
hf_ctx2hash_fpt ctx2hash;
ctx2hash = pgm_read_word(&(hash_descriptor->ctx2hash));
ctx2hash(dest, ctx->finctx);
}
void hfal_hmac_free(hfhmacgen_ctx_t* ctx){
hf_free_fpt free_fpt;
free_fpt = pgm_read_word(&(hash_descriptor->free));
if(free_fpt){
free_fpt(ctx->ctx);
free_fpt(ctx->finctx);
}
free(ctx->ctx)
free(ctx->finctx)
}
void hfal_hmac_mem(const hfdesc_t* hash_descriptor, const void* key, uint16_t keylength_b, void* dest, const void* msg, uint32_t length_b){
hfhmacgen_ctx_t ctx;
uint16_t bs = hfal_hash_getBlocksize();
hfal_hmac_init(hash_descriptor, &ctx, key, keylength_b);
while(length_b>bs){
hfal_hmac_nextBlock(&ctx, msg);
msg = msg + bs/8;
length_b-=bs;
}
hfal_hmac_lastBlock(&ctx, msg, length_b);
hfal_hmac_ctx2mac(dest, &ctx);
hfal_free(&ctx);
}
uint16_t hfal_hmac_getBlocksize(const hfdesc_t* hash_descriptor){
return hfal_hash_getBlocksize(hash_descriptor);
}
uint16_t hfal_hmac_getMACsize(const hfdesc_t* hash_descriptor){
return hfal_hash_getHashsize(hash_descriptor);
}

41
hfal/hfal-hmac.h Normal file
View File

@ -0,0 +1,41 @@
/* hfal-hmac.h */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2009 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 HFAL_HMAC_H_
#define HFAL_HMAC_H_
#include <avr/pgmspace.h>
#include "hashfunction_descriptor.h"
typedef struct {
hfdesc_t* desc;
void* ctx;
void* finctx;
} hfhmacgen_ctx_t;
uint8_t hfal_hmac_init(const hfdesc_t* hash_descriptor, hfhmacgen_ctx_t* ctx, const void* key, uint16_t keylength_b);
void hfal_hmac_nextBlock(hfhmacgen_ctx_t* ctx, const void* block);
void hfal_hmac_lastBlock(hfhmacgen_ctx_t* ctx, const void* block, uint16_t length_b);
void hfal_hmac_ctx2mac(void* dest, hfhmacgen_ctx_t* ctx);
void hfal_hmac_free(hfhmacgen_ctx_t* ctx);
void hfal_hmac_mem(const hfdesc_t* hash_descriptor, const void* key, uint16_t keylength_b, void* dest, const void* msg, uint32_t length_b);
uint16_t hfal_hmac_getBlocksize(const hfdesc_t* hash_descriptor);
uint16_t hfal_hmac_getMACsize(const hfdesc_t* hash_descriptor);
#endif /* HFAL_HMAC_H_ */

58
hfal/hfal-nessie.c Normal file
View File

@ -0,0 +1,58 @@
/* hfal-nessie.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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 hfal-nessie.c
* \author Daniel Otte
* \email daniel.otte@rub.de
* \date 2009-05-10
* \license GPLv3 or later
*
*/
#include "nessie_hash_test.h"
#include "hashfunction_descriptor.h"
#include <stdint.h>
void hfal_nessie(const hfdesc_t* hd){
if(hd->type!=HFDESC_TYPE_HASHFUNCTION)
return;
nessie_hash_ctx.hashsize_b = hd->hashsize_b;
nessie_hash_ctx.name = (char*)(hd->name); /* needs a nicer fix */
nessie_hash_ctx.blocksize_B = hd->blocksize_b/8;
nessie_hash_ctx.ctx_size_B = hd->ctxsize_B;
nessie_hash_ctx.hash_init = (nessie_hash_init_fpt)(hd->init);
nessie_hash_ctx.hash_next = (nessie_hash_next_fpt)(hd->nextBlock);
nessie_hash_ctx.hash_last = (nessie_hash_last_fpt)(hd->lastBlock);
nessie_hash_ctx.hash_conv = (nessie_hash_conv_fpt)(hd->ctx2hash);
nessie_hash_run();
}
void hfal_nessie_multiple(const hfdesc_t** hd_list){
const hfdesc_t* hd;
for(;;){
hd = *hd_list;
if(!hd)
return;
hfal_nessie(hd);
hd_list += 1;
}
}

36
hfal/hfal-nessie.h Normal file
View File

@ -0,0 +1,36 @@
/* hfal-nessie.h */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2009 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 hfal-nessie.h
* \author Daniel Otte
* \email daniel.otte@rub.de
* \date 2009-05-10
* \license GPLv3 or later
*
*/
#ifndef HFAL_NESSIE_H_
#define HFAL_NESSIE_H_
#include "hashfunction_descriptor.h"
void hfal_nessie(const hfdesc_t* hd);
void hfal_nessie_multiple(const hfdesc_t** hd_list);
#endif /* HFAL_NESSIE_H_ */

221
hfal/hfal-performance.c Normal file
View File

@ -0,0 +1,221 @@
/* hfal-performance.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 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 hfal-performance.c
* \author Daniel Otte
* \email daniel.otte@rub.de
* \date 2009-05-10
* \license GPLv3 or later
*
*/
#include "hfal-performance.h"
#include "hashfunction_descriptor.h"
/* #include "stack_measuring.h" */
#include "cli.h"
#include "performance_test.h"
#include "string-extras.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#define PATTERN_A 0xAA
#define PATTERN_B 0x55
static
void printvalue(unsigned long v){
char str[20];
int i;
ultoa(v, str, 10);
for(i=0; i<10-strlen(str); ++i){
cli_putc(' ');
}
cli_putstr(str);
}
void hfal_performance(const hfdesc_t* hd){
hfdesc_t hf;
memcpy(&hf, hd, sizeof(hfdesc_t));
uint8_t ctx[hf.ctxsize_B];
uint8_t data[(hf.blocksize_b+7)/8];
uint8_t digest[(hf.hashsize_b+7)/8];
uint64_t t;
uint8_t i;
if(hf.type!=HFDESC_TYPE_HASHFUNCTION)
return;
calibrateTimer();
print_overhead();
cli_putstr("\r\n\r\n === ");
cli_putstr(hf.name);
cli_putstr(" performance === "
"\r\n type: hashfunction"
"\r\n hashsize (bits): ");
printvalue(hf.hashsize_b);
cli_putstr("\r\n ctxsize (bytes): ");
printvalue(hf.ctxsize_B);
cli_putstr("\r\n blocksize (bits): ");
printvalue(hf.blocksize_b);
t=0;
for(i=0; i<32; ++i){
startTimer(0);
START_TIMER;
hf.init(&ctx);
STOP_TIMER;
t += stopTimer();
if(i!=31 && hf.free){
hf.free(&ctx);
}
}
t>>=5;
cli_putstr("\r\n init (cycles): ");
printvalue(t);
t=0;
for(i=0; i<32; ++i){
startTimer(0);
START_TIMER;
hf.nextBlock(&ctx, data);
STOP_TIMER;
t += stopTimer();
}
t>>=5;
cli_putstr("\r\n nextBlock (cycles): ");
printvalue(t);
t=0;
for(i=0; i<32; ++i){
startTimer(0);
START_TIMER;
hf.lastBlock(&ctx, data, 0);
STOP_TIMER;
t += stopTimer();
}
t>>=5;
cli_putstr("\r\n lastBlock (cycles): ");
printvalue(t);
t=0;
for(i=0; i<32; ++i){
startTimer(0);
START_TIMER;
hf.ctx2hash(digest, &ctx);
STOP_TIMER;
t += stopTimer();
}
t>>=5;
cli_putstr("\r\n ctx2hash (cycles): ");
printvalue(t);
if(hf.free){
hf.free(&ctx);
}
}
/*
void hfal_stacksize(const hfdesc_t* hd){
hfdesc_t hf;
stack_measuring_ctx_t smctx;
memcpy(&hf, hd, sizeof(hfdesc_t));
uint8_t ctx[hf.ctxsize_B];
uint8_t data[(hf.blocksize_b+7)/8];
uint8_t digest[(hf.hashsize_b+7)/8];
uint16_t t1, t2;
if(hf.type!=HFDESC_TYPE_HASHFUNCTION)
return;
cli_putstr("\r\n\r\n === ");
cli_putstr_P(hf.name);
cli_putstr(" stack-usage === ");
cli();
stack_measure_init(&smctx, PATTERN_A);
hf.init(&ctx);
t1 = stack_measure_final(&smctx);
stack_measure_init(&smctx, PATTERN_B);
hf.init(&ctx);
t2 = stack_measure_final(&smctx);
sei();
t1 = (t1>t2)?t1:t2;
cli_putstr("\r\n init (bytes): ");
printvalue((unsigned long)t1);
cli();
stack_measure_init(&smctx, PATTERN_A);
hf.nextBlock(&ctx, data);
t1 = stack_measure_final(&smctx);
stack_measure_init(&smctx, PATTERN_B);
hf.nextBlock(&ctx, data);
t2 = stack_measure_final(&smctx);
sei();
t1 = (t1>t2)?t1:t2;
cli_putstr("\r\n nextBlock (bytes): ");
printvalue((unsigned long)t1);
cli();
stack_measure_init(&smctx, PATTERN_A);
hf.lastBlock(&ctx, data, 0);
t1 = stack_measure_final(&smctx);
stack_measure_init(&smctx, PATTERN_B);
hf.lastBlock(&ctx, data, 0);
t2 = stack_measure_final(&smctx);
sei();
t1 = (t1>t2)?t1:t2;
cli_putstr("\r\n lastBlock (bytes): ");
printvalue((unsigned long)t1);
cli();
stack_measure_init(&smctx, PATTERN_A);
hf.ctx2hash(digest, &ctx);
t1 = stack_measure_final(&smctx);
stack_measure_init(&smctx, PATTERN_B);
hf.ctx2hash(digest, &ctx);
t2 = stack_measure_final(&smctx);
sei();
t1 = (t1>t2)?t1:t2;
cli_putstr("\r\n ctx2hash (bytes): ");
printvalue((unsigned long)t1);
if(hf.free){
hf.free(&ctx);
}
}
*/
void hfal_performance_multiple(const hfdesc_t** hd_list){
const hfdesc_t* hd;
for(;;){
hd = *hd_list;
if(!hd){
cli_putstr("\r\n\r\n End of performance figures\r\n");
return;
}
hfal_performance(hd);
// hfal_stacksize(hd);
hd_list += 1;
}
}

35
hfal/hfal-performance.h Normal file
View File

@ -0,0 +1,35 @@
/* hfal-performance.h */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2009 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 hfal-performance.h
* \author Daniel Otte
* \email daniel.otte@rub.de
* \date 2009-05-10
* \license GPLv3 or later
*
*/
#ifndef HFAL_PERFORMANCE_H_
#define HFAL_PERFORMANCE_H_
#include "hashfunction_descriptor.h"
void hfal_performance(const hfdesc_t* hd);
void hfal_performance_multiple(const hfdesc_t** hd_list);
#endif /* HFAL_PERFORMANCE_H_ */

View File

@ -1,4 +1,4 @@
/* gf256mul.c */
/* hfal-test.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 Daniel Otte (daniel.otte@rub.de)
@ -16,25 +16,33 @@
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 hfal-test.c
* \author Daniel Otte
* \email daniel.otte@rub.de
* \date 2009-05-10
* \license GPLv3 or later
*
*/
#include "hfal-basic.h"
#include "hashfunction_descriptor.h"
#include "cli.h"
#include <stdint.h>
uint8_t gf256mul(uint8_t a, uint8_t b, uint8_t reducer){
uint8_t r=0;
while(a&0xFE){
if(a&1){
r ^= b;
}
a >>= 1;
if(b&0x80){
b <<= 1;
b ^= reducer;
}else{
b <<= 1;
}
}
if(a&1){
r ^= b;
}
return r;
void hfal_test(const hfdesc_t* hd, const void* msg, uint32_t length_b){
if(hd->type!=HFDESC_TYPE_HASHFUNCTION)
return;
uint16_t dlen = (hd->hashsize_b+7)/8;
uint8_t digest[dlen];
cli_putstr("\r\n=== ");
cli_putstr(hd->name);
cli_putstr(" ===\r\n message:");
cli_hexdump_block(msg, (length_b+7)/8, 4, 16);
hfal_hash_mem(hd, digest, msg, length_b);
cli_putstr(" \r\n digest:");
cli_hexdump_block(digest, dlen, 4, 16);
cli_putstr("\r\n");
}

36
hfal/hfal-test.h Normal file
View File

@ -0,0 +1,36 @@
/* hfal-test.h */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2009 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 hfal-test.h
* \author Daniel Otte
* \email daniel.otte@rub.de
* \date 2009-05-10
* \license GPLv3 or later
*
*/
#ifndef HFAL_TEST_H_
#define HFAL_TEST_H_
#include "hashfunction_descriptor.h"
#include <stdint.h>
void hfal_test(const hfdesc_t* hd,const void* msg, uint32_t length_b);
#endif /* HFAL_TEST_H_ */

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