Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
0a2ac69250 | |||
599e8019c6 | |||
625f3a5e30 | |||
28d442db03 | |||
2d8b8dc34a | |||
74c2ec2014 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -12,6 +12,8 @@
|
|||||||
*.ilk
|
*.ilk
|
||||||
*.map
|
*.map
|
||||||
*.exp
|
*.exp
|
||||||
|
# Objdump output
|
||||||
|
*.dis
|
||||||
|
|
||||||
# Precompiled Headers
|
# Precompiled Headers
|
||||||
*.gch
|
*.gch
|
||||||
@@ -154,3 +156,5 @@ CTestTestfile.cmake
|
|||||||
.vscode/c_cpp_properties.json
|
.vscode/c_cpp_properties.json
|
||||||
semihosting_test/build/semihosting_test
|
semihosting_test/build/semihosting_test
|
||||||
semihosting_test/build/Makefile
|
semihosting_test/build/Makefile
|
||||||
|
|
||||||
|
.cache
|
@@ -571,33 +571,7 @@ static int ee_vsprintf(char *buf, const char *fmt, va_list args) {
|
|||||||
|
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
|
|
||||||
void uart_send_char(char c) {
|
void uart_send_char(char c) { write(STDOUT_FILENO, &c, 1); }
|
||||||
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
|
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
int ee_printf(const char *fmt, ...) {
|
int ee_printf(const char *fmt, ...) {
|
||||||
char buf[1024], *p;
|
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
|
export ALG ?= ascon
|
||||||
|
|
||||||
|
#hash or aead
|
||||||
export API ?= aead
|
export API ?= aead
|
||||||
export ARCH ?= generic
|
#generic, rv32 or rv64
|
||||||
export IMP ?= nist
|
export ARCH ?= rv32
|
||||||
export ISE ?= xalu
|
#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 :
|
BOARD=iss
|
||||||
@make --directory="${REPO_HOME}/src" build
|
LINK_TARGET=link
|
||||||
sw-run :
|
RISCV_ARCH:=rv32$(ISA)
|
||||||
@make --directory="${REPO_HOME}/src" run
|
ifeq ($(ISA),e)
|
||||||
sw-scan :
|
RISCV_ABI:=ilp32e
|
||||||
@make --directory="${REPO_HOME}/src" scan
|
else
|
||||||
sw-clean :
|
RISCV_ABI:=ilp32
|
||||||
@make --directory="${REPO_HOME}/src" clean
|
endif
|
||||||
|
LDFLAGS += -g -Wl,--wrap=printf
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
compiler := $(shell which riscv64-unknown-elf-gcc)
|
||||||
|
TOOL_DIR=$(dir $(compiler))
|
||||||
|
|
||||||
clean :
|
TRIPLET=riscv64-unknown-elf
|
||||||
@rm --force --recursive ${REPO_HOME}/build/*
|
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
|
# can be found at https://opensource.org/licenses/MIT (or should be included
|
||||||
# as LICENSE.txt within the associated archive or repository).
|
# 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 build-related content for algorithm
|
||||||
include ./${ALG}/Makefile.in
|
include ${REPO_HOME}/src/${ALG}/Makefile.in
|
||||||
|
|
||||||
# include build-related content for architecture
|
# 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
|
# parameterise source code using environment variables
|
||||||
ifeq "${API}" "aead"
|
ifeq "${API}" "aead"
|
||||||
GCC_FLAGS += -DAPI_AEAD
|
GCC_FLAGS += -DAPI_AEAD
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq "${API}" "hash"
|
ifeq "${API}" "hash"
|
||||||
GCC_FLAGS += -DAPI_HASH
|
GCC_FLAGS += -DAPI_HASH
|
||||||
endif
|
endif
|
||||||
@@ -37,9 +27,9 @@ endif
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
ifeq "${IMP}" "nist"
|
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
|
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
|
endif
|
||||||
|
|
||||||
export LWISE_SOURCES += $(wildcard $(addsuffix /*.c, ${LWISE_INCLUDES}))
|
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_SOURCES += $(wildcard $(addsuffix /*.S, ${LWISE_INCLUDES}))
|
||||||
export LWISE_HEADERS += $(wildcard $(addsuffix /*.h, ${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 SOURCES := ${LWISE_SOURCES} ${NIST_SOURCES}
|
||||||
export HEADERS := ${LWISE_HEADERS} ${NIST_HEADERS} ${REPO_HOME}/build/${ALG}/kat_${API}.h
|
export HEADERS := ${LWISE_HEADERS} ${NIST_HEADERS}
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
${REPO_HOME}/build/${ALG} :
|
${REPO_HOME}/build/${ALG} :
|
||||||
@mkdir --parents ${@}
|
@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}
|
${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}
|
${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
|
C_SRCS += $(filter %.c, ${SOURCES})
|
||||||
@${GCC_PREFIX}-objdump --disassemble-all ${<} > ${@}
|
CXX_SRCS += $(filter %.cpp, ${SOURCES})
|
||||||
|
ASM_SRCS += $(filter %.S, ${SOURCES})
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -102,9 +90,6 @@ dump :
|
|||||||
@echo "HEADERS = ${HEADERS}"
|
@echo "HEADERS = ${HEADERS}"
|
||||||
@echo "TARGETS = ${TARGETS}"
|
@echo "TARGETS = ${TARGETS}"
|
||||||
|
|
||||||
build : ${TARGETS}
|
@echo "ASM_SRCS = ${ASM_SRCS}"
|
||||||
|
|
||||||
clean :
|
|
||||||
@rm --force --recursive ${TARGETS}
|
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
@@ -255,39 +255,39 @@ int main( int argc, char* argv[] ) {
|
|||||||
rand_bytes_init();
|
rand_bytes_init();
|
||||||
|
|
||||||
#if defined( API_AEAD ) && !defined( DRIVER_BYPASS_TEST )
|
#if defined( API_AEAD ) && !defined( DRIVER_BYPASS_TEST )
|
||||||
printf( "++ test : encrypt" "\n" );
|
printf( "++ test : encrypt\n" "\n" );
|
||||||
test_encrypt();
|
test_encrypt();
|
||||||
printf( "-- test : encrypt" "\n" );
|
printf( "-- test : encrypt\n" "\n" );
|
||||||
|
|
||||||
printf( "++ test : decrypt" "\n" );
|
printf( "++ test : decrypt\n" "\n" );
|
||||||
test_decrypt();
|
test_decrypt();
|
||||||
printf( "-- test : decrypt" "\n" );
|
printf( "-- test : decrypt\n" "\n" );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined( API_HASH ) && !defined( DRIVER_BYPASS_TEST )
|
#if defined( API_HASH ) && !defined( DRIVER_BYPASS_TEST )
|
||||||
printf( "++ test : hash" "\n" );
|
printf( "++ test : hash\n" "\n" );
|
||||||
test_hash();
|
test_hash();
|
||||||
printf( "-- test : hash" "\n" );
|
printf( "-- test : hash\n" "\n" );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined( API_AEAD ) && !defined( DRIVER_BYPASS_TIME )
|
#if defined( API_AEAD ) && !defined( DRIVER_BYPASS_TIME )
|
||||||
printf( "++ time : encrypt" "\n" );
|
printf( "++ time : encrypt\n" "\n" );
|
||||||
time_encrypt();
|
time_encrypt();
|
||||||
printf( "-- time : encrypt" "\n" );
|
printf( "-- time : encrypt\n" "\n" );
|
||||||
|
|
||||||
printf( "++ time : decrypt" "\n" );
|
printf( "++ time : decrypt\n" "\n" );
|
||||||
time_decrypt();
|
time_decrypt();
|
||||||
printf( "-- time : decrypt" "\n" );
|
printf( "-- time : decrypt\n" "\n" );
|
||||||
|
|
||||||
printf( "++ time : kernel" "\n" );
|
printf( "++ time : kernel\n" "\n" );
|
||||||
time_kernel();
|
time_kernel();
|
||||||
printf( "-- time : kernel" "\n" );
|
printf( "-- time : kernel\n" "\n" );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined( API_HASH ) && !defined( DRIVER_BYPASS_TIME )
|
#if defined( API_HASH ) && !defined( DRIVER_BYPASS_TIME )
|
||||||
printf( "++ time : hash" "\n" );
|
printf( "++ time : hash\n" "\n" );
|
||||||
time_hash();
|
time_hash();
|
||||||
printf( "-- time : hash" "\n" );
|
printf( "-- time : hash\n" "\n" );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rand_bytes_fini();
|
rand_bytes_fini();
|
||||||
|
Reference in New Issue
Block a user