This commit is contained in:
Henry Case 2023-02-07 14:52:47 +00:00
parent ef833b8b37
commit e4a57ac77b
7 changed files with 29 additions and 33 deletions

View File

@ -8,10 +8,6 @@ set(CMAKE_VERBOSE_MAKEFILE ON)
set(UPQCL_LIBRARY_VER ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
set(CMAKE_C_STANDARD 99)
if(PLATFORM STREQUAL "stm32disco")
include_directories(${PROJECT_SOURCE_DIR}/platform/stm32disco)
endif()
# Global configuration
string(APPEND CMAKE_C_FLAGS "-Os ")
string(APPEND CMAKE_C_FLAGS "-Wno-ignored-qualifiers ")
@ -35,8 +31,6 @@ set(uEXAMPLE_SRC
${PROJECT_SOURCE_DIR}/src/common/keccakf1600.S
${PROJECT_SOURCE_DIR}/src/common/crypto_hashblocks_sha512_inner32.s
${PROJECT_SOURCE_DIR}/src/common/crypto_hashblocks_sha512.c
${PROJECT_SOURCE_DIR}/src/common/randombytes.c
#${PROJECT_SOURCE_DIR}/src/common/hal-stm32f4.c
${PROJECT_SOURCE_DIR}/src/saber/cbd.c
${PROJECT_SOURCE_DIR}/src/saber/kem.c
${PROJECT_SOURCE_DIR}/src/saber/mul.S
@ -50,23 +44,15 @@ set(uEXAMPLE_SRC
${PROJECT_SOURCE_DIR}/src/saber/verify.c)
add_library(
uexample_obj OBJECT
example STATIC
${uEXAMPLE_SRC})
target_include_directories(
uexample_obj PRIVATE
example PRIVATE
#${PROJECT_SOURCE_DIR}/3rd/libopencm3/include
${PROJECT_SOURCE_DIR}/src/common
${PROJECT_SOURCE_DIR}/src/sabre)
add_executable(
uexample_test
${uEXAMPLE_SRC}
${PROJECT_SOURCE_DIR}/src/test.c
)
target_include_directories(
uexample_test PRIVATE
#${PROJECT_SOURCE_DIR}/3rd/libopencm3/include
${PROJECT_SOURCE_DIR}/src/common
${PROJECT_SOURCE_DIR}/src/saber)
if(PLATFORM STREQUAL "stm32disco")
add_subdirectory(${PROJECT_SOURCE_DIR}/platform/stm32disco)
endif()

View File

@ -9,11 +9,7 @@ enum clock_mode {
CLOCK_BENCHMARK
};
static void hal_setup(const enum clock_mode clock) {
UNUSED(clock);
}
static void hal_send_str(const char* in) {
UNUSED(in);
}
void hal_setup(const enum clock_mode clock);
void hal_send_str(const char* in);
#endif

View File

@ -1,9 +1,26 @@
add_executable(
uexample_test
${PROJECT_SOURCE_DIR}/test/test.c
${PROJECT_SOURCE_DIR}/platform/${PLATFORM}/hal.c
${PROJECT_SOURCE_DIR}/platform/${PLATFORM}/randombytes.c
)
target_include_directories(
uexample_test PRIVATE
#${PROJECT_SOURCE_DIR}/3rd/libopencm3/include
${PROJECT_SOURCE_DIR}/src/common
${PROJECT_SOURCE_DIR}/src/saber
${PROJECT_SOURCE_DIR}/platform
${PROJECT_SOURCE_DIR}/platform/${PLATFORM}
${PROJECT_SOURCE_DIR}/${PLATFORM_INC})
target_link_libraries(
uexample_test PRIVATE
example
--static -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
-T${PROJECT_SOURCE_DIR}/platform/stm32disco/stm32f405x6.ld
-nostartfiles -Wl,--gc-sections
cmsis)
-L${PROJECT_SOURCE_DIR}/3rd/libopencm3/lib -lm -lopencm3_stm32f4)
add_custom_command(
TARGET uexample_test POST_BUILD

View File

@ -1,5 +1,5 @@
#include <stdint.h>
//#include <libopencm3/stm32/rng.h>
#include <libopencm3/stm32/rng.h>
#include "randombytes.h"
//TODO Maybe we do not want to use the hardware RNG for all randomness, but instead only read a seed and then expand that using fips202.
@ -14,23 +14,19 @@ int randombytes(uint8_t *obuf, size_t len)
while (len > 4)
{
/*
random.asint = rng_get_random_blocking();
*obuf++ = random.aschar[0];
*obuf++ = random.aschar[1];
*obuf++ = random.aschar[2];
*obuf++ = random.aschar[3];
len -= 4;
*/
}
if (len > 0)
{
/*
for (random.asint = rng_get_random_blocking(); len > 0; --len)
{
*obuf++ = random.aschar[len - 1];
}
*/
}
return 0;

View File

@ -14,3 +14,4 @@ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(PLATFORM "stm32disco")
set(PLATFORM_INC "3rd/libopencm3/include")

View File

@ -89,7 +89,7 @@ int main(void)
for(i=0;i<10;i++)
hal_send_str("==========================");
test_keys();
hal_send_str("# That's all folks!");
hal_send_str("## That's all folks! #");
while(1);