--- /dev/null
+TOOLCHAIN = arm-none-eabi-#
+MCU_TARGET = arm7tdmi
+MCU_OPTS = -marm
+OPTIMIZE = -O0 -fomit-frame-pointer
+DEBUG = -gdwarf-2
+WARNING = -pedantic -Wall -Wstrict-prototypes -Werror
+DEFS = -D$(call uc, $(subst -,_,$(MCU_TARGET)))
+FLASHCMD = $(OPENOCD) -f openocd.cfg \
+ -c "init" \
+ -c "halt" \
+ -c "flash write_image erase $(1) 0 bin" \
+ -c "reset run" \
+ -c "shutdown"
+DEP_DIR = deps/#
+TEST_DIR = test/#
+BIN_DIR = bin/#
+TESTSRC_DIR = test_src/#
+ERASECMD =
+TESTPORT = /dev/ttyUSB1
+TESTPORTBAUDR = 115200
+TESTLOG_DIR = testlog/#
+TESTPREFIX = nessie-#
+SPEEDTOOL = host/get_performance.rb
+SPEEDLOG_DIR = speed_log/#
+SPEEDPREFIX =
+SPEEDCMD = performance
+SIZE_DIR = size_log/#
+LIST_DIR = listings/#
+STAT_DIR = stats/#
+AUTOASM_DIR = autoasm/#
+LIB_DIR = lib/#
+LIB_NAME = libcrypto.a
+AUTOASM_OPT = -S
+CSTD = gnu99
+LIBS = c gcc
+
+COMMON_FLAGS = -ffunction-sections -fdata-sections \
+ $(DEBUG) $(WARNING) -std=$(CSTD) $(OPTIMIZE) \
+ -mcpu=$(MCU_TARGET) $(MCU_OPTS) $(DEFS) -MMD
+
+override CFLAGS_A = $(COMMON_FLAGS) \
+ -MF$(DEP_DIR)$(patsubst %.o,%.d,$(notdir $(1)))
+override CFLAGS = $(COMMON_FLAGS) \
+ -MF$(DEP_DIR)$(patsubst %.o,%.d,$(notdir $@))
+
+override LDFLAGS = -g -T lm3s9b90.ld -Wl,--gc-sections \
+ -Wl,--entry=reset_isr \
+ -Wl,-Map,# no space at the end
+
+override ASFLAGS = -mcpu=$(MCU_TARGET)
+
+SIZESTAT_FILE = sizestats.txt
+
+CC = $(TOOLCHAIN)gcc
+OBJCOPY = $(TOOLCHAIN)objcopy
+OBJDUMP = $(TOOLCHAIN)objdump
+SIZE = $(TOOLCHAIN)size
+OPENOCD = openocd
+READELF = readelf
+AR = $(TOOLCHAIN)ar
+CHMOD = chmod
+CHOWN = chown
+CHGRP = chgrp
+RM = rm
+RUBY = ruby
+GET_TEST = host/get_test.rb
+MAKE = make
+MAKE2GRAPH = ~/bin/make2graph.rb
+TWOPI = twopi
memcpy(dest->ctx, src->ctx, dest->desc->ctxsize_B);
dest->finctx = malloc(dest->desc->ctxsize_B);
if(dest->finctx == NULL){
+ free(dest->ctx);
return 1;
}
memcpy(dest->finctx, src->finctx, dest->desc->ctxsize_B);
STREAM_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_DIR := arcfour/
-$(ALGO_NAME)_INCDIR := memxor/ scal/
+$(ALGO_NAME)_INCDIR := memxor/ bcal/ scal/
$(ALGO_NAME)_OBJ := arcfour.o
$(ALGO_NAME)_TESTBIN := main-arcfour-test.o scal_arcfour.o $(CLI_STD) $(SCAL_STD)
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_DIR := grain/
$(ALGO_NAME)_OBJ := grain.o
-$(ALGO_NAME)_INCDIR := memxor/ scal/
+$(ALGO_NAME)_INCDIR := memxor/ bcal/ scal/
$(ALGO_NAME)_TESTBIN := main-grain-test.o $(CLI_STD) $(SCAL_STD) scal_grain.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
$(ALGO_NAME)_DIR := mickey128/
$(ALGO_NAME)_OBJ := mickey128.o
-$(ALGO_NAME)_INCDIR := memxor/ scal/
+$(ALGO_NAME)_INCDIR := memxor/ bcal/ scal/
$(ALGO_NAME)_TESTBIN := main-mickey128-test.o $(CLI_STD) $(SCAL_STD) scal_mickey128.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
AUX += $(ALGO_NAME)
$(ALGO_NAME)_DIR := prf_tls12/
-$(ALGO_NAME)_INCDIR := hmac/ sha512/ sha256/ hfal/
+$(ALGO_NAME)_INCDIR := hmac/ sha2/ hfal/
$(ALGO_NAME)_OBJ := prf_tls12.o
-$(ALGO_NAME)_TESTBIN := main-prf_tls12-test.o $(CLI_STD) hfal_sha512.o hfal_sha256.o $(HFAL_STD) \
- sha256.o sha512.o hfal-hmac.o
+$(ALGO_NAME)_TESTBIN := main-prf_tls12-test.o $(CLI_STD) $(HFAL_STD) sha224.o sha256.o sha384.o sha512.o \
+ sha2_small_common.o sha2_large_common.o hfal_sha224.o hfal_sha256.o hfal_sha384.o hfal_sha512.o hfal-hmac.o
$(ALGO_NAME)_PERFORMANCE_TEST := performance
$(ALGO_NAME)_DIR := rabbit/
$(ALGO_NAME)_OBJ := rabbit_c.o
-$(ALGO_NAME)_INCDIR := memxor/ scal/
+$(ALGO_NAME)_INCDIR := memxor/ bcal/ scal/
$(ALGO_NAME)_TESTBIN := main-rabbit-test.o $(CLI_STD) $(SCAL_STD) scal_rabbit.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
$(ALGO_NAME)_DIR := rabbit/
$(ALGO_NAME)_OBJ := rabbit_c.o
-$(ALGO_NAME)_INCDIR := memxor/ scal/
+$(ALGO_NAME)_INCDIR := memxor/ bcal/ scal/
$(ALGO_NAME)_TESTBIN := main-rabbit-test.o $(CLI_STD) $(SCAL_STD) scal_rabbit.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
$(ALGO_NAME)_DIR := salsa20/
$(ALGO_NAME)_OBJ := salsa20.o
-$(ALGO_NAME)_INCDIR := memxor/ scal/
+$(ALGO_NAME)_INCDIR := memxor/ bcal/ scal/
$(ALGO_NAME)_TESTBIN := main-salsa20-test.o $(CLI_STD) $(SCAL_STD) scal_salsa20.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
$(ALGO_NAME)_DIR := trivium/
$(ALGO_NAME)_OBJ := trivium.o
-$(ALGO_NAME)_INCDIR := memxor/ scal/
+$(ALGO_NAME)_INCDIR := memxor/ bcal/ scal/
$(ALGO_NAME)_TESTBIN := main-trivium-test.o $(CLI_STD) $(SCAL_STD) scal_trivium.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
BASE64 \
BIGINT_C \
BLAKE_C \
- BMW \
+ BMW_C \
CAST5 \
CAST6 \
CSCIPHER_SMALL_C \
MICKEY128 \
NOEKEON_C \
PRESENT \
+ PRF_TLS12 \
RABBIT_C \
RC5 \
RC6 \
SEED_C \
SERPENT_BITSLICE \
SHA1_C \
- SHA256_C \
+ SHA2_C \
SHABAL_C \
SKEIN_C \
TDES \
XTEA_C \
HFAL_HMAC \
BCAL_BASIC \
- SCAL_BASIC
+ SCAL_BASIC \
+ HFAL_ALGOS \
+ BCAL_ALGOS \
+ SCAL_ALGOS
+
+
#define PRF_TLS12_H_
#include <stdint.h>
-#include <crypto/hashfunction_descriptor.h>
-#include <crypto/hfal-basic.h>
-#include <crypto/hfal-hmac.h>
+#include "hashfunction_descriptor.h"
+#include "hfal-basic.h"
+#include "hfal-hmac.h"
typedef struct{
hfhmacgen_ctx_t mainctx;
#define CH(x,y,z) (((x)&(y)) ^ ((~(x))&(z)))
#define MAJ(x,y,z) (((x)&(y)) ^ ((x)&(z)) ^ ((y)&(z)))
-#define SIGMA0(x) (rotr32((x),2) ^ rotr32((x),13) ^ rotl32((x),10))
-#define SIGMA1(x) (rotr32((x),6) ^ rotr32((x),11) ^ rotl32((x),7))
-#define SIGMA_a(x) (rotr32((x),7) ^ rotl32((x),14) ^ ((x)>>3))
+#define SIGMA_0(x) (rotr32((x), 2) ^ rotr32((x),13) ^ rotl32((x),10))
+#define SIGMA_1(x) (rotr32((x), 6) ^ rotr32((x),11) ^ rotl32((x),7))
+#define SIGMA_a(x) (rotr32((x), 7) ^ rotl32((x),14) ^ ((x)>>3))
#define SIGMA_b(x) (rotl32((x),15) ^ rotl32((x),13) ^ ((x)>>10))
const
* block must be, 512, Bit = 64, Byte, long !!!
*/
void sha2_small_common_nextBlock (sha2_small_common_ctx_t *state, const void* block){
- uint32_t w[16], wx; /* this is 256, byte, large, */
+ uint32_t w[16], wx;
uint8_t i;
uint32_t a[8],t1,t2;
memmove(&(w[0]), &(w[1]), 15*4);
w[15] = wx;
}
- t1 = a[7] + SIGMA1(a[4]) + CH(a[4],a[5],a[6]) + k[i] + wx;
- t2 = SIGMA0(a[0]) + MAJ(a[0],a[1],a[2]);
+ t1 = a[7] + SIGMA_1(a[4]) + CH(a[4],a[5],a[6]) + k[i] + wx;
+ t2 = SIGMA_0(a[0]) + MAJ(a[0],a[1],a[2]);
memmove(&(a[1]), &(a[0]), 7*4); /* a[7]=a[6]; a[6]=a[5]; a[5]=a[4]; a[4]=a[3]; a[3]=a[2]; a[2]=a[1]; a[1]=a[0]; */
a[4] += t1;
a[0] = t1 + t2;
* bigint test-suit
*
*/
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include "config.h"
-#include "cli.h"
-#include "dump.h"
-#include "uart_lowlevel.h"
-#include "sysclock.h"
-#include "hw_gptm.h"
+#include "main-test-common.h"
#include "noekeon.h"
#include "noekeon_prng.h"
char* algo_name = "BigInt";
-void uart0_putc(char byte){
- uart_putc(UART_0, byte);
-}
-
-char uart0_getc(void){
- return uart_getc(UART_0);
-}
-
/*****************************************************************************
* additional validation-functions *
*****************************************************************************/
cli_putstr("\r\nenter scale:");
{
char str[8];
- cli_getsn_cecho(str, 7);
+ cli_getsn(str, 7);
scale = atoi(str);
}
/*
};
int main (void){
- sysclk_set_freq(SYS_FREQ);
- sysclk_mosc_verify_enable();
- uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
- gptm_set_timer_32periodic(TIMER0);
-
- cli_rx = uart0_getc;
- cli_tx = uart0_putc;
-
+ main_setup();
for(;;){
- cli_putstr("\r\n\r\nARM-Crypto-Lib VS (");
- cli_putstr(algo_name);
- cli_putstr("; ");
- cli_putstr(__DATE__);
- cli_putc(' ');
- cli_putstr(__TIME__);
- cli_putstr(")\r\nloaded and running\r\n");
+ welcome_msg(algo_name);
cmd_interface(cmdlist);
}
}
void testrun_nessie_groestl(void){
hfal_nessie_multiple(algolist);
}
-void groestl224_test(void* msg, uint32_t length_b){
+void groestl224_test(const void* msg, uint32_t length_b){
hfal_test(&groestl224_desc, msg, length_b);
}
-void groestl256_test(void* msg, uint32_t length_b){
+void groestl256_test(const void* msg, uint32_t length_b){
hfal_test(&groestl256_desc, msg, length_b);
}
-void groestl384_test(void* msg, uint32_t length_b){
+void groestl384_test(const void* msg, uint32_t length_b){
hfal_test(&groestl384_desc, msg, length_b);
}
-void groestl512_test(void* msg, uint32_t length_b){
+void groestl512_test(const void* msg, uint32_t length_b){
hfal_test(&groestl512_desc, msg, length_b);
}
*
*/
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include "config.h"
-#include "cli.h"
-#include "dump.h"
-#include "uart_lowlevel.h"
-#include "sysclock.h"
-#include "hw_gptm.h"
+#include "main-test-common.h"
#include "rc6.h"
#include "nessie_bc_test.h"
#include "bcal-performance.h"
#include "bcal_rc6.h"
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
#define RC6_ROUNDS 20
char* algo_name = "RC6-32/20/16";
-void uart0_putc(char byte){
- uart_putc(UART_0, byte);
-}
-
-char uart0_getc(void){
- return uart_getc(UART_0);
-}
-
const bcdesc_t* algolist[] = {
(bcdesc_t*)&rc6_desc,
NULL
};
int main (void){
- sysclk_set_freq(SYS_FREQ);
- sysclk_mosc_verify_enable();
- uart_init_flow(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE, UART_FLOWCTRL_SOFT);
- gptm_set_timer_32periodic(TIMER0);
+ main_setup();
- cli_rx = (cli_rx_fpt)uart0_getc;
- cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
- cli_putstr("\r\n\r\nARM-Crypto-Lib VS (");
- cli_putstr(algo_name);
- cli_putstr("; ");
- cli_putstr(__DATE__);
- cli_putc(' ');
- cli_putstr(__TIME__);
- cli_putstr(")\r\nloaded and running\r\n");
- cmd_interface(cmdlist);
+ welcome_msg(algo_name);
+ cmd_interface(cmdlist);
}
}
*
*/
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include "config.h"
-#include "cli.h"
-#include "dump.h"
-#include "uart_lowlevel.h"
-#include "sysclock.h"
-#include "hw_gptm.h"
+#include "main-test-common.h"
#include "shavs.h"
#include "nessie_hash_test.h"
#include "performance_test.h"
+#include "hfal-basic.h"
#include "hfal-nessie.h"
#include "hfal-performance.h"
#include "hfal-test.h"
#include "hfal_skein512.h"
#include "hfal_skein1024.h"
-
-void uart0_putc(char byte){
- uart_putc(UART_0, byte);
-}
-
-char uart0_getc(void){
- return uart_getc(UART_0);
-}
-
const char* algo_name = "Skein";
const hfdesc_t* algolist[] = {
};
int main(void) {
- sysclk_set_freq(SYS_FREQ);
- sysclk_mosc_verify_enable();
- uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
- gptm_set_timer_32periodic(TIMER0);
-
- cli_rx = uart0_getc;
- cli_tx = uart0_putc;
-
+ main_setup();
shavs_algolist=(hfdesc_t**)algolist;
shavs_algo=(hfdesc_t*)&skein256_256_desc;
for(;;){
- cli_putstr("\r\n\r\nARM-Crypto-Lib VS (");
- cli_putstr(algo_name);
- cli_putstr("; ");
- cli_putstr(__DATE__);
- cli_putc(' ');
- cli_putstr(__TIME__);
- cli_putstr(")\r\nloaded and running\r\n");
- cmd_interface(cmdlist);
+ welcome_msg(algo_name);
+ cmd_interface(cmdlist);
}
}