Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
0a2ac69250 | |||
599e8019c6 | |||
625f3a5e30 | |||
28d442db03 | |||
2d8b8dc34a | |||
74c2ec2014 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -12,6 +12,8 @@
|
||||
*.ilk
|
||||
*.map
|
||||
*.exp
|
||||
# Objdump output
|
||||
*.dis
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
@@ -154,3 +156,5 @@ CTestTestfile.cmake
|
||||
.vscode/c_cpp_properties.json
|
||||
semihosting_test/build/semihosting_test
|
||||
semihosting_test/build/Makefile
|
||||
|
||||
.cache
|
@@ -571,33 +571,7 @@ static int ee_vsprintf(char *buf, const char *fmt, va_list args) {
|
||||
|
||||
#include <platform.h>
|
||||
|
||||
void uart_send_char(char c) {
|
||||
write(STDOUT_FILENO, &c, 1); // write or puts ??
|
||||
/*
|
||||
#if defined(BOARD_ehrenberg)
|
||||
while (get_uart_rx_tx_reg_tx_free(uart) == 0)
|
||||
;
|
||||
uart_write(uart, c);
|
||||
if (c == '\n') {
|
||||
while (get_uart_rx_tx_reg_tx_free(uart) == 0)
|
||||
;
|
||||
uart_write(uart, '\r');
|
||||
}
|
||||
#elif defined(BOARD_iss)
|
||||
*((uint32_t *)0xFFFF0000) = c;
|
||||
#else
|
||||
while (UART0_REG(UART_REG_TXFIFO) & 0x80000000)
|
||||
;
|
||||
UART0_REG(UART_REG_TXFIFO) = c;
|
||||
if (c == '\n') {
|
||||
while (UART0_REG(UART_REG_TXFIFO) & 0x80000000)
|
||||
;
|
||||
UART0_REG(UART_REG_TXFIFO) = '\r';
|
||||
}
|
||||
#endif
|
||||
|
||||
*/
|
||||
}
|
||||
void uart_send_char(char c) { write(STDOUT_FILENO, &c, 1); }
|
||||
|
||||
int ee_printf(const char *fmt, ...) {
|
||||
char buf[1024], *p;
|
||||
|
1
lwc/.gitignore
vendored
Normal file
1
lwc/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
build/
|
52
lwc/Makefile
52
lwc/Makefile
@@ -10,27 +10,45 @@ export REPO_HOME = ${PWD}
|
||||
|
||||
export ALG ?= ascon
|
||||
|
||||
#hash or aead
|
||||
export API ?= aead
|
||||
export ARCH ?= generic
|
||||
export IMP ?= nist
|
||||
export ISE ?= xalu
|
||||
#generic, rv32 or rv64
|
||||
export ARCH ?= rv32
|
||||
#nist, rv32 or rv64m if imp is nist does not allow for ASCON_RVXX_TYPE
|
||||
export IMP ?= rv32
|
||||
#rvxx requires a ACSCON_RVXX_TYPEX
|
||||
#export CONF ?= -DASCON_RV32_TYPE1 # -DASCON_RV32_TYPE1 or -DASCON_RV32_TYPE2 (with custom instrs)
|
||||
|
||||
export CONF ?=
|
||||
TARGET = ascon
|
||||
ISA?=gc_zbb_zbkb_zbkx
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
C_SRCS = $(wildcard *.c)
|
||||
HEADERS = $(wildcard *.h)
|
||||
OPT ?= -O0
|
||||
CFLAGS += $(OPT) -g
|
||||
#CFLAGS += -DDRIVER_BYPASS_TEST
|
||||
CFLAGS += -DDRIVER_BYPASS_TIME #Time throws a trap somewhere
|
||||
|
||||
sw-build :
|
||||
@make --directory="${REPO_HOME}/src" build
|
||||
sw-run :
|
||||
@make --directory="${REPO_HOME}/src" run
|
||||
sw-scan :
|
||||
@make --directory="${REPO_HOME}/src" scan
|
||||
sw-clean :
|
||||
@make --directory="${REPO_HOME}/src" clean
|
||||
BOARD=iss
|
||||
LINK_TARGET=link
|
||||
RISCV_ARCH:=rv32$(ISA)
|
||||
ifeq ($(ISA),e)
|
||||
RISCV_ABI:=ilp32e
|
||||
else
|
||||
RISCV_ABI:=ilp32
|
||||
endif
|
||||
LDFLAGS += -g -Wl,--wrap=printf
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
compiler := $(shell which riscv64-unknown-elf-gcc)
|
||||
TOOL_DIR=$(dir $(compiler))
|
||||
|
||||
clean :
|
||||
@rm --force --recursive ${REPO_HOME}/build/*
|
||||
TRIPLET=riscv64-unknown-elf
|
||||
BSP_BASE = ../bare-metal-bsp
|
||||
|
||||
all: ${TARGET}.elf
|
||||
|
||||
include ${REPO_HOME}/src/Makefile
|
||||
CFLAGS += ${GCC_FLAGS}
|
||||
|
||||
include $(BSP_BASE)/env/common-gcc.mk
|
||||
|
||||
# =============================================================================
|
||||
|
@@ -4,27 +4,17 @@
|
||||
# can be found at https://opensource.org/licenses/MIT (or should be included
|
||||
# as LICENSE.txt within the associated archive or repository).
|
||||
|
||||
ifndef REPO_HOME
|
||||
$(error "execute 'source ./bin/conf.sh' to configure environment")
|
||||
endif
|
||||
ifndef REPO_VERSION
|
||||
$(error "execute 'source ./bin/conf.sh' to configure environment")
|
||||
endif
|
||||
|
||||
export API ?= aead
|
||||
|
||||
# =============================================================================
|
||||
|
||||
# include build-related content for algorithm
|
||||
include ./${ALG}/Makefile.in
|
||||
include ${REPO_HOME}/src/${ALG}/Makefile.in
|
||||
|
||||
# include build-related content for architecture
|
||||
include ./share/arch/${ARCH}/Makefile.in
|
||||
#include ${REPO_HOME}/src/share/arch/${ARCH}/Makefile.in
|
||||
|
||||
# parameterise source code using environment variables
|
||||
ifeq "${API}" "aead"
|
||||
GCC_FLAGS += -DAPI_AEAD
|
||||
endif
|
||||
|
||||
ifeq "${API}" "hash"
|
||||
GCC_FLAGS += -DAPI_HASH
|
||||
endif
|
||||
@@ -37,9 +27,9 @@ endif
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
ifeq "${IMP}" "nist"
|
||||
export LWISE_INCLUDES += ${REPO_HOME}/build/${ALG} ./share ./share/nist ./share/arch/${ARCH}
|
||||
export LWISE_INCLUDES += ${REPO_HOME}/build/${ALG} ${REPO_HOME}/src/share ${REPO_HOME}/src/share/nist ${REPO_HOME}/src/share/arch/${ARCH}
|
||||
else
|
||||
export LWISE_INCLUDES += ${REPO_HOME}/build/${ALG} ./share ./share/nist ./share/arch/${ARCH} ./${ALG}/arch/${ARCH} ./${ALG}/imp/${IMP} ./${ALG}/imp/share
|
||||
export LWISE_INCLUDES += ${REPO_HOME}/build/${ALG} ${REPO_HOME}/src/share ${REPO_HOME}/src/share/nist ${REPO_HOME}/src/share/arch/${ARCH} ${REPO_HOME}/src/${ALG}/arch/${ARCH} ${REPO_HOME}/src/${ALG}/imp/${IMP} ${REPO_HOME}/src/${ALG}/imp/share
|
||||
endif
|
||||
|
||||
export LWISE_SOURCES += $(wildcard $(addsuffix /*.c, ${LWISE_INCLUDES}))
|
||||
@@ -48,32 +38,30 @@ export LWISE_SOURCES += $(wildcard $(addsuffix /*.s, ${LWISE_INCLUDES}))
|
||||
export LWISE_SOURCES += $(wildcard $(addsuffix /*.S, ${LWISE_INCLUDES}))
|
||||
export LWISE_HEADERS += $(wildcard $(addsuffix /*.h, ${LWISE_INCLUDES}))
|
||||
|
||||
export INCLUDES := ${LWISE_INCLUDES} ${NIST_INCLUDES}
|
||||
export ALL_INCLUDES := ${LWISE_INCLUDES} ${NIST_INCLUDES} ${REPO_HOME}/build/${ALG}
|
||||
INCLUDES += $(foreach dir,$(ALL_INCLUDES),-I$(dir))
|
||||
|
||||
export SOURCES := ${LWISE_SOURCES} ${NIST_SOURCES} ${REPO_HOME}/build/${ALG}/kat_${API}.c
|
||||
export HEADERS := ${LWISE_HEADERS} ${NIST_HEADERS} ${REPO_HOME}/build/${ALG}/kat_${API}.h
|
||||
|
||||
export TARGETS += ${REPO_HOME}/build/${ALG}
|
||||
export TARGETS += ${REPO_HOME}/build/${ALG}/kat_${API}.h
|
||||
export TARGETS += ${REPO_HOME}/build/${ALG}/kat_${API}.c
|
||||
export TARGETS += ${REPO_HOME}/build/${ALG}/driver-${API}_${ARCH}_${IMP}.elf
|
||||
export TARGETS += ${REPO_HOME}/build/${ALG}/driver-${API}_${ARCH}_${IMP}.asm
|
||||
export SOURCES := ${LWISE_SOURCES} ${NIST_SOURCES}
|
||||
export HEADERS := ${LWISE_HEADERS} ${NIST_HEADERS}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
${REPO_HOME}/build/${ALG} :
|
||||
@mkdir --parents ${@}
|
||||
|
||||
${SOURCES} : ${REPO_HOME}/build/${ALG}/kat_${API}.c ${REPO_HOME}/build/${ALG}/kat_${API}.h
|
||||
|
||||
${REPO_HOME}/build/${ALG}/kat_${API}.h : ${NIST_KAT}
|
||||
@python3 ./share/kat.py --api="${API}" --header < ${<} > ${@}
|
||||
@python3 ${REPO_HOME}/src/share/kat.py --api="${API}" --header < ${<} > ${@}
|
||||
${REPO_HOME}/build/${ALG}/kat_${API}.c : ${NIST_KAT}
|
||||
@python3 ./share/kat.py --api="${API}" --source < ${<} > ${@}
|
||||
@python3 ${REPO_HOME}/src/share/kat.py --api="${API}" --source < ${<} > ${@}
|
||||
|
||||
|
||||
${REPO_HOME}/build/${ALG}/driver-${API}_${ARCH}_${IMP}.elf : ${SOURCES}
|
||||
@${GCC_PREFIX}-gcc ${GCC_FLAGS} ${GCC_PATHS} $(addprefix -I ,${INCLUDES}) -std='gnu99' -O3 -o ${@} $(filter %.c, ${^}) $(filter %.cpp, ${^}) $(filter %.S, ${^}) ${GCC_LIBS}
|
||||
|
||||
${REPO_HOME}/build/${ALG}/driver-${API}_${ARCH}_${IMP}.asm : ${REPO_HOME}/build/${ALG}/driver-${API}_${ARCH}_${IMP}.elf
|
||||
@${GCC_PREFIX}-objdump --disassemble-all ${<} > ${@}
|
||||
C_SRCS += $(filter %.c, ${SOURCES})
|
||||
CXX_SRCS += $(filter %.cpp, ${SOURCES})
|
||||
ASM_SRCS += $(filter %.S, ${SOURCES})
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
@@ -102,9 +90,6 @@ dump :
|
||||
@echo "HEADERS = ${HEADERS}"
|
||||
@echo "TARGETS = ${TARGETS}"
|
||||
|
||||
build : ${TARGETS}
|
||||
|
||||
clean :
|
||||
@rm --force --recursive ${TARGETS}
|
||||
@echo "ASM_SRCS = ${ASM_SRCS}"
|
||||
|
||||
# =============================================================================
|
||||
|
@@ -255,39 +255,39 @@ int main( int argc, char* argv[] ) {
|
||||
rand_bytes_init();
|
||||
|
||||
#if defined( API_AEAD ) && !defined( DRIVER_BYPASS_TEST )
|
||||
printf( "++ test : encrypt" "\n" );
|
||||
printf( "++ test : encrypt\n" "\n" );
|
||||
test_encrypt();
|
||||
printf( "-- test : encrypt" "\n" );
|
||||
printf( "-- test : encrypt\n" "\n" );
|
||||
|
||||
printf( "++ test : decrypt" "\n" );
|
||||
printf( "++ test : decrypt\n" "\n" );
|
||||
test_decrypt();
|
||||
printf( "-- test : decrypt" "\n" );
|
||||
printf( "-- test : decrypt\n" "\n" );
|
||||
#endif
|
||||
|
||||
#if defined( API_HASH ) && !defined( DRIVER_BYPASS_TEST )
|
||||
printf( "++ test : hash" "\n" );
|
||||
printf( "++ test : hash\n" "\n" );
|
||||
test_hash();
|
||||
printf( "-- test : hash" "\n" );
|
||||
printf( "-- test : hash\n" "\n" );
|
||||
#endif
|
||||
|
||||
#if defined( API_AEAD ) && !defined( DRIVER_BYPASS_TIME )
|
||||
printf( "++ time : encrypt" "\n" );
|
||||
printf( "++ time : encrypt\n" "\n" );
|
||||
time_encrypt();
|
||||
printf( "-- time : encrypt" "\n" );
|
||||
printf( "-- time : encrypt\n" "\n" );
|
||||
|
||||
printf( "++ time : decrypt" "\n" );
|
||||
printf( "++ time : decrypt\n" "\n" );
|
||||
time_decrypt();
|
||||
printf( "-- time : decrypt" "\n" );
|
||||
printf( "-- time : decrypt\n" "\n" );
|
||||
|
||||
printf( "++ time : kernel" "\n" );
|
||||
printf( "++ time : kernel\n" "\n" );
|
||||
time_kernel();
|
||||
printf( "-- time : kernel" "\n" );
|
||||
printf( "-- time : kernel\n" "\n" );
|
||||
#endif
|
||||
|
||||
#if defined( API_HASH ) && !defined( DRIVER_BYPASS_TIME )
|
||||
printf( "++ time : hash" "\n" );
|
||||
printf( "++ time : hash\n" "\n" );
|
||||
time_hash();
|
||||
printf( "-- time : hash" "\n" );
|
||||
printf( "-- time : hash\n" "\n" );
|
||||
#endif
|
||||
|
||||
rand_bytes_fini();
|
||||
|
Reference in New Issue
Block a user